0x1949 Team - FAZEMRX - MANAGER
Edit File: _immutable.cpython-310.pyc
o ���a� � @ s d dl Z ddd�ZdS )� N� � ImmutableFc s� t � t�r � �dd��� � � fdd�}d}tjdk r dj|d�}d �d d� � D ��}dj||r3d | nd|� ||d�}|rAt|� ddl m } t|dd�}z t||� W || S t yn } zt t| �d | �| �d} ~ ww )a� Produces a class that either can be used standalone or as a base class for persistent classes. This is a thin wrapper around a named tuple. Constructing a type and using it to instantiate objects: >>> Point = immutable('x, y', name='Point') >>> p = Point(1, 2) >>> p2 = p.set(x=3) >>> p Point(x=1, y=2) >>> p2 Point(x=3, y=2) Inheriting from a constructed type. In this case no type name needs to be supplied: >>> class PositivePoint(immutable('x, y')): ... __slots__ = tuple() ... def __new__(cls, x, y): ... if x > 0 and y > 0: ... return super(PositivePoint, cls).__new__(cls, x, y) ... raise Exception('Coordinates must be positive!') ... >>> p = PositivePoint(1, 2) >>> p.set(x=3) PositivePoint(x=3, y=2) >>> p.set(y=-3) Traceback (most recent call last): Exception: Coordinates must be positive! The persistent class also supports the notion of frozen members. The value of a frozen member cannot be updated. For example it could be used to implement an ID that should remain the same over time. A frozen member is denoted by a trailing underscore. >>> Point = immutable('x, y, id_', name='Point') >>> p = Point(1, 2, id_=17) >>> p.set(x=3) Point(x=3, y=2, id_=17) >>> p.set(id_=18) Traceback (most recent call last): AttributeError: Cannot set frozen members id_ �,� c s( dd� � D �} | rdj d�| �d�S dS )Nc S s g | ]}|� d �rd| �qS )�_�'%s')�endswith)�.0�f� r �7/usr/lib/python3/dist-packages/pyrsistent/_immutable.py� <listcomp>5 s z9immutable.<locals>.frozen_member_test.<locals>.<listcomp>z� frozen_fields = fields_to_modify & set([{frozen_members}]) if frozen_fields: raise AttributeError('Cannot set frozen members %s' % ', '.join(frozen_fields)) �, ��frozen_membersr )�format�joinr ��membersr r �frozen_member_test4 s �z%immutable.<locals>.frozen_member_testr )� � z, verbose={verbose})�verboser c s s � | ]}d | V qdS )r Nr )r �mr r r � <genexpr>D s � zimmutable.<locals>.<genexpr>a� class {class_name}(namedtuple('ImmutableBase', [{quoted_members}]{verbose_string})): __slots__ = tuple() def __repr__(self): return super({class_name}, self).__repr__().replace('ImmutableBase', self.__class__.__name__) def set(self, **kwargs): if not kwargs: return self fields_to_modify = set(kwargs.keys()) if not fields_to_modify <= {member_set}: raise AttributeError("'%s' is not a member" % ', '.join(fields_to_modify - {member_set})) {frozen_member_test} return self.__class__.__new__(self.__class__, *map(kwargs.pop, [{quoted_members}], self)) z set([%s])zset())�quoted_members� member_setr �verbose_string� class_namer )� namedtuple�pyrsistent_immutable)r �__name__z: N)� isinstance�str�replace�split�sys�version_infor r �print�collectionsr �dict�exec�SyntaxError) r �namer r r r �templater � namespace�er r r � immutable s2 - ����r1 )r r F)r&