+
    Dfj1                       a  R t*0 t R t^ RIt^ RIt^ RIt^ RIt^ RIt^ RIH	t
 ^ RIHt ^ RIHtHt ^ RIHt / t] ^ k ]P&                  tR tR tR t]P                  ! ]P0                  ]4       R	 tR
 t]P                  ! ]P6                  ]4       R tR t]P                  ! ]P<                  ]4       R tR t R t!R t" ! R R4      t#/ s$] ^k / s%R t&R t'R t( ! R R4      t)R# )z(
Different styles of persisted objects.
N)StringIO)Dict)logreflect)_PYPYc                h    \         V P                  V P                  V P                  P                  33# )z3support function for copy_reg to pickle method refs)unpickleMethod__name____self__	__class__)methods   &:/usr/lib/python3/dist-packages/twisted/persisted/styles.pypickleMethodr      s-     		&//6??+D+DE     c                    \        W4      pV# )a  
Retrieve the function object implementing a method name given the class
it's on and a method name.

@param classObject: A class to retrieve the method's function from.
@type classObject: L{type}

@param methodName: The name of the method whose function to retrieve.
@type methodName: native L{str}

@return: the function object corresponding to the given method name.
@rtype: L{types.FunctionType}
)getattr)classObject
methodNamemethodObjects   && r   _methodFunctionr   "   s     ;3Lr   c                (   Vf   \        W 4      #  \        W 4      pRp\        P                  ! W1.VO5!  pV#   \         dO    \
        P                  ! RT RT4       Tf   Q R4       hTP                  TJ d   h \        YTP                  4      u # i ; i)a3  
Support function for copy_reg to unpickle method refs.

@param im_name: The name of the method.
@type im_name: native L{str}

@param im_self: The instance that the method was present on.
@type im_self: L{object}

@param im_class: The class where the method was declared.
@type im_class: L{type} or L{None}
Methodznot on classz'No recourse: no instance to guess from. )	r   r   types
MethodTypeAttributeErrorr   msgr   r   )im_nameim_selfim_classmethodFunction
maybeClassbounds   &&&   r   r   r   4   s     x))(; 
  F:F  C'>8<"M$MM" (g0A0ABBCs   8 ABBc                    V P                   R8X  d   \        RV  24      h\        \        RP	                  V P
                  V P                  .4      .4      3# )aw  
Reduce, in the sense of L{pickle}'s C{object.__reduce__} special method, a
function object into its constituent parts.

@param f: The function to reduce.
@type f: L{types.FunctionType}

@return: a 2-tuple of a reference to L{_unpickleFunction} and a tuple of
    its arguments, a 1-tuple of the function's fully qualified name.
@rtype: 2-tuple of C{callable, native string}
z<lambda>zCannot pickle lambda function: .)r	   _UniversalPicklingError_unpickleFunctiontuplejoin
__module____qualname__)fs   &r   _pickleFunctionr,   W   sL     	zzZ%(Gs&KLLuchhann/M&N%OPQQr   c                    ^ RI Hp V! V 4      # )a  
Convert a function name into a function by importing it.

This is a synonym for L{twisted.python.reflect.namedAny}, but imported
locally to avoid circular imports, and also to provide a persistent name
that can be stored (and deprecated) independently of C{namedAny}.

@param fullyQualifiedName: The fully qualified name of a function.
@type fullyQualifiedName: native C{str}

@return: A function object imported from the given location.
@rtype: L{types.FunctionType}
)namedAny)twisted.python.reflectr.   )fullyQualifiedNamer.   s   & r   r&   r&   h   s     0&''r   c                (    \         V P                  33# )z3support function for copy_reg to pickle module refs)unpickleModuler	   )modules   &r   pickleModuler4   ~   s    FOO---r   c                    V \         9   dA   \        P                  ! RV ,          4       \         V ,          p \        P                  ! V 4       \        V / / R4      # )z5support function for copy_reg to unpickle module refszModule has moved: %sx)
oldModulesr   r   
__import__)names   &r   r2   r2      sB    z&-.$dBC((r   c                P     \         V P                  4       V P                  4       33# )z
Reduce the given cStringO.

This is only called on Python 2, because the cStringIO module only exists
on Python 2.

@param stringo: The string output to pickle.
@type stringo: C{cStringIO.OutputType}
)unpickleStringOgetvaluetell)stringos   &r   pickleStringOr?      s'     CW--/@@@r   c                ^    \        4       pVP                  V 4       VP                  V4       V# )a  
Convert the output of L{pickleStringO} into an appropriate type for the
current python version.  This may be called on Python 3 and will convert a
cStringIO into an L{io.StringIO}.

@param val: The content of the file.
@type val: L{bytes}

@param sek: The seek position of the file.
@type sek: L{int}

@return: a file-like object which you can write bytes to.
@rtype: C{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
)
_cStringIOwriteseekvalsekr6   s   && r   r;   r;      s&     	AGGCLFF3KHr   c                N    \         V P                  4       V P                  4       33# )a1  
Reduce the given cStringI.

This is only called on Python 2, because the cStringIO module only exists
on Python 2.

@param stringi: The string input to pickle.
@type stringi: C{cStringIO.InputType}

@return: a 2-tuple of (C{unpickleStringI}, (bytes, pointer))
@rtype: 2-tuple of (function, (bytes, int))
)unpickleStringIr<   r=   )stringis   &r   pickleStringIrJ      s#     W--/@@@r   c                >    \        V 4      pVP                  V4       V# )a  
Convert the output of L{pickleStringI} into an appropriate type for the
current Python version.

This may be called on Python 3 and will convert a cStringIO into an
L{io.StringIO}.

@param val: The content of the file.
@type val: L{bytes}

@param sek: The seek position of the file.
@type sek: L{int}

@return: a file-like object which you can read bytes from.
@rtype: C{cStringIO.OutputType} on Python 2, L{io.StringIO} on Python 3.
)rA   rC   rD   s   && r   rH   rH      s    " 	3AFF3KHr   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )	Ephemeralz\
This type of object is never persisted; if possible, even references to it
are eliminated.
c                    \         R3# )z]
Serialize any subclass of L{Ephemeral} in a way which replaces it with
L{Ephemeral} itself.
r   )rM   )selfs   &r   
__reduce__Ephemeral.__reduce__   s    
 2r   c                    \         P                  ! R V ,          4       \        '       gI   ^ RIp\	        VRR4      '       d2   VP                  V 4       F  p\         P                  ! RV 24       K  	  R# )z!WARNING: serializing ephemeral %sNget_referrersz referred to by )r   r   r   gcr   rS   )rO   rT   rs   &  r   __getstate__Ephemeral.__getstate__   sW    3d:;ur?D11))$/AGG.qc23 0r   c                j    \         P                  ! R V P                  ,          4       \        V n        R# )z#WARNING: unserializing ephemeral %sN)r   r   r   rM   rO   states   &&r   __setstate__Ephemeral.__setstate__   s    5FG"r   )r   N)
r	   r)   r*   __firstlineno____doc__rP   rV   r[   __static_attributes____classdictcell____classdict__s   @r   rM   rM      s     
# #r   rM   c                  l    \        \        P                  4       4       F  p \        V 4       K  	  / s/ sR # N)listversionedsToUpgradevaluesrequireUpgradeupgraded)	versioneds    r   	doUpgraderk      s.    -4467	y! 8Hr   c                    \        V 4      pV\        9   d)   V\        9  d   ^\        V&   V P                  4        V # R# R# )z?Require that a Versioned instance be upgraded completely first.N)idrf   ri   versionUpgrade)objobjIDs   & r   rh   rh      s=    sGE##X(=
 )>#r   c                    V \         .p\        P                  ! V 4       F4  pW!9  g   K  \        V\         4      '       g   K#  VP	                  V4       K6  	  VR,          # )z
Get all of the parent classes of C{c}, not including C{c} itself, which are
strict subclasses of L{Versioned}.

@param c: a class
@returns: list of classes
:   NN)	Versionedinspectgetmro
issubclassappend)clbs   &  r   _aybabtur{   	  sG     
IA^^A:*Q	22HHQK  R5Lr   c                   B   a  ] tR tRt o Rt^ tRtR tR	R ltR t	Rt
V tR# )
rs   i  az  
This type of object is persisted with versioning information.

I have a single class attribute, the int persistenceVersion.  After I am
unserialized (and styles.doUpgrade() is called), self.upgradeToVersionX()
will be called for each version upgrade I must undergo.

For example, if I serialize an instance of a Foo(Versioned) at version 4
and then unserialize it when the code is at version 9, the calls::

  self.upgradeToVersion5()
  self.upgradeToVersion6()
  self.upgradeToVersion7()
  self.upgradeToVersion8()
  self.upgradeToVersion9()

will be made.  If any of these methods are undefined, a warning message
will be printed.
c                6    V \         \        V 4      &   Wn        R # rd   )rf   rm   __dict__rY   s   &&r   r[   Versioned.__setstate__3  s    (,BtH%r   Nc                   \         P                   ! T;'       g    V P                  4      p\        V P                  4      pVP	                  4        VP                  V P                  4       V Fj  pRVP                  9   d   VP                   F  pWR9   g   K  W% K  	  RVP                  9   g   KD  VP                  V\        P                  ! V4       R2&   Kl  	  V# )z8Get state, adding a version number to it on its way out.persistenceForgetspersistenceVersionz.persistenceVersion)
copyr~   r{   r   reverserw   r   r   r   qual)rO   dictdctbasesbaseslots   &&    r   rV   Versioned.__getstate__7  s    ii--.(T^^$D#t}}4 33D{I 4 $t}}4 ++ ||D)**=>  
r   c                   \        V P                  4      pVP                  4        VP                  V P                  4       RV P                  9   d   V P                  R,          pV P                  R ^ pRpV F7  pRVP                  9  d   K  VP
                  V8  g   K)  TpVP
                  pK9  	  V'       d+   VV P                  R\        P                  ! V4      ,          &   V EFg  p\        VP                  9  d   RVP                  9  d   K,  VP
                  pR\        P                  ! V4      ,          pV P                  P                  V4      ;'       g    ^ pV'       d   V P                  V W8:  g   Q R4       hW8  g   K  V^,           pVP                  P                  RV,          R4      p	V	'       dl   \        P                  ! R\        P                  ! V4      : R\        P                  ! V P                  4      : R\        V 4      : R	V: 24       V	! V 4       K  \        P                  ! R
P                  WX4      4       K  	  R# )z (internal) Do a version upgrade.r   Nz%s.persistenceVersionz"Sorry, can't go backwards in time.zupgradeToVersion%sz
Upgrading z (of z @ z) to version z(Warning: cannot upgrade {} to version {})r{   r   r   rw   r~   r   r   r   rs   	__bases__getr   r   rm   format)
rO   r   pverhighestVersionhighestBaser   currentVerspverNamepersistVersr   s
   &         r   rn   Versioned.versionUpgradeH  s   ( 	T^^$4==0 ==!56D23NK't}}<**^;"&K%)%<%<N    +gll;.GG D /(=11K.d1CCH--++H5::KMM(+-S/SS-+)Ao**+?++MtTGG $LL.#LL8tH' 4LGGBII 9 r   )r~   r   rd   )r	   r)   r*   r]   r^   r   r   r[   rV   rn   r_   r`   ra   s   @r   rs   rs     s,     ( "? ?r   rs   c                    V ^8  d   Qh/ ^ \         9   d%   \        \        \        P                  3,          ;R&   ^\         9   d   \        \
        R3,          ;R&   # )rr   r7   rs   rf   )__conditional_annotations__r   strr   
ModuleTypeint)r   s   "r   __annotate__r      sL       - ,De&&&' ,^ 1 0T#{*+ 0_r   )+r   r^   r   copyregcopy_regrt   pickler   ior   rA   typingr   twisted.pythonr   r   twisted.python.compatr   r7   PicklingErrorr%   r   r   r   r   r,   r&   FunctionTyper4   r2   r   r?   r;   rJ   rH   rM   rf   ri   rk   rh   r{   rs   r   )r   s   @r   <module>r      s   
      %  ' '*,
 , !.. $@ 	  , /R"(& 	""O 4.
) 	  , /A*A ,# #8 /1  0$l lr   