a `Å]_Ñ ã@sddlZddd„ZdS)éNÚÚ ImmutableFc sêtˆtƒrˆ dd¡ ¡‰‡fdd„}d}tjdkr@dj|d�}d  d d „ˆDƒ¡}d j||rfd |nd|ƒ||d�}|r‚t|ƒddl m }t |dd�}zt ||ƒWn8t yà} z t | jd|ƒ| ‚WYd} ~ n d} ~ 00||S)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_ ú,ú cs(dd„ˆDƒ}|r$djd |¡d�SdS)NcSsg|]}| d¡rd|‘qS)Ú_ú'%s')Úendswith)Ú.0Úf©r ú;/usr/lib64/python3.9/site-packages/pyrsistent/_immutable.pyÚ 5óz9immutable..frozen_member_test..zÆ frozen_fields = fields_to_modify & set([{frozen_members}]) if frozen_fields: raise AttributeError('Cannot set frozen members %s' % ', '.join(frozen_fields)) ú, ©Zfrozen_membersr)ÚformatÚjoinr©Úmembersr r Úfrozen_member_test4s üz%immutable..frozen_member_testr)ééz, verbose={verbose})Úverbosercss|]}d|VqdS)rNr )r Úmr r r Ú Drzimmutable..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_membersZ member_setrÚverbose_stringÚ class_namer)Ú namedtupleZpyrsistent_immutable)rÚ__name__z: N)Ú isinstanceÚstrÚreplaceÚsplitÚsysÚ version_inforrÚprintÚ collectionsrÚdictÚexecÚ SyntaxErrorÚmessage) rÚnamerrrrÚtemplaterÚ namespaceÚer rr Ú immutables.-    ê  *r0)rrF)r$r0r r r r Ús