%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/twisted/persisted/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/twisted/persisted/__pycache__/aot.cpython-312.pyc

�

Ϫ�f�G���dZddlZddlZddlZddlmZddlmZm	Z	ddl
mZddlm
ZGd�d	�ZGd
�de�ZGd�d
e�ZGd�de�ZGd�d�ZGd�d�Ze�Zeeeeeeed�eee�g	ZGd�d�Z Gd�d�Z!Gd�d�Z"Gd�d�Z#d�Z$Gd�de%�Z&ejNd�Z(d �Z)d!�Z*d"�Z+d#�Z,d$�Z-Gd%�d&�Z.d'�Z/d.d(�Z0d)�Z1d*�Z2d+�Z3Gd,�d-�Z4y)/z|
AOT: Abstract Object Trees
The source-code-marshallin'est abstract-object-serializin'est persister
this side of Marmalade!
�N)�crefutil)�log�reflect)�_constructMethod�)�generate_tokensc��eZdZd�Zy)�Namedc��||_y�N��name)�selfrs  �7/usr/lib/python3/dist-packages/twisted/persisted/aot.py�__init__zNamed.__init__"s	����	�N)�__name__�
__module__�__qualname__r�rrr
r
!s��rr
c��eZdZd�Zy)�Classc� �d|jzS)Nz	Class(%r)r
�rs r�	getSourcezClass.getSource's���T�Y�Y�&�&rN�rrrrrrrrr&s��'rrc��eZdZd�Zy)�Functionc� �d|jzS)NzFunction(%r)r
rs rrzFunction.getSource,s����	�	�)�)rNrrrrrr+s��*rrc��eZdZd�Zy)�Modulec� �d|jzS)Nz
Module(%r)r
rs rrzModule.getSource1s���d�i�i�'�'rNrrrrr!r!0s��(rr!c��eZdZd�Zd�Zy)�InstanceMethodc��t|t�s.t|t�st|t�st	d|z��||_||_||_y)Nz$%s isn't an Instance, Ref, or Deref!)�
isinstance�Ref�Instance�Deref�	TypeErrorr�klass�instance)rrr+�insts    rrzInstanceMethod.__init__6sF���t�S�!��$��)��$��&��B�T�I�J�J���	���
���
rc�v�dj|j|jt|j��S)Nz InstanceMethod({!r}, {!r}, 
{}))�formatrr+�prettifyr,rs rrzInstanceMethod.getSourceAs/��3�:�:��I�I��J�J��T�]�]�#�
�	
rN�rrrrrrrrr$r$5s��	�
rr$c��eZdZy)�_NoStateObjN)rrrrrrr3r3Is��rr3c��eZdZefd�Zd�Zy)r(c��t|t�std|z��||_|tur||_d|_y||_d|_y)Nz%s isn't a string!rr)r&�strr*r+�
NoStateObj�state�stateIsDict)r�	className�__stateObj__r8s    rrzInstance.__init__]sJ���)�S�)��0�9�<�=�=���
��z�)�%�D�J� �D���D�J� �D�rc���|jr
|j}nWt|jt�r;t|jjt
�r|jj}nd}|�	d|j�dt|��d�Sd|j�dt|j��d�S#t$rd|j�dt|��d�cYSwxYw)Nz	Instance(�, �))
r9r8r&r'�obj�dictr+�dictToKW�NonFormattableDictr0)r�	stateDicts  rrzInstance.getSourcehs�������
�
�I�
��
�
�C�
(�Z��
�
����-M��
�
���I��I�� �
J�"�4�:�:�.��8�I�3F�2G�q�I�I��4�:�:�.��8�D�J�J�+?�*@��B�B��&�
J�"�4�:�:�.��8�I�3F�2G�q�I�I�
J�s�4B6�6%C�CN)rrrr7rrrrrr(r(\s��/9�	!�
Crr(c�$�eZdZd�Zd�Zd�Zd�Zy)r'c�l�t|�dk(r|d|_|d|_y|sd|_d|_yy)N�rr)�len�refnumr?)r�argss  rrzRef.__init__ys9���t�9��>��q�'�D�K��A�w�D�H���D�K��D�H�rc�`�|jrtd|�d|j����||_y)NzError setting id �, I already have )rH�
ValueError�r�nums  r�setRefz
Ref.setRef�s.���;�;��0���5F�t�{�{�m�T�U�U���rc�`�|jrtd|�d|j����||_y)NzError setting obj rK)r?rL)rr?s  r�setObjz
Ref.setObj�s.���8�8��1�#��6G����z�R�S�S���rc��|j�td��|jr$d|jt|j�fzSt|j�S)Nz7Don't try to display me before setting an object on me!z
Ref(%d, 
%s))r?�RuntimeErrorrHr0rs rrz
Ref.getSource�sQ���8�8���I��
��;�;�$����X�d�h�h�5G�'H�H�H�����!�!rN)rrrrrOrQrrrrr'r'xs����
�
"rr'c��eZdZd�Zd�ZeZy)r)c��||_yr�rHrMs  rrzDeref.__init__�s	����rc� �d|jzS)Nz	Deref(%d)rVrs rrzDeref.getSource�s���T�[�[�(�(rN)rrrrr�__repr__rrrr)r)�s���)��Hrr)c��eZdZd�Zd�Zy)�Copyregc� �||_||_yr)�loadfuncr8)rr\r8s   rrzCopyreg.__init__�s�� ��
���
rc�N�d|j�dt|j��d�S)NzCopyreg(r=r>)r\r0r8rs rrzCopyreg.getSource�s&���$�-�-�*�"�X�d�j�j�-A�,B�!�D�DrNr1rrrrZrZ�s
���ErrZc�0�tdt|�z�S)zDPass me an AO, I'll return a nicely-formatted source representation.zapp = )�	indentifyr0)�aos rrr�s���X����,�-�-rc��eZdZdZy)rBz!A dictionary was not formattable.N)rrr�__doc__rrrrBrB�s��+rrBz[a-zA-Z_][a-zA-Z0-9_]*$c	�R�g}t|j��}|j�|D]g\}}t|t�std|z��tj|�std|z��|jd|�dt|��d���idj|�S)Nz%r ain't a stringz%r ain't an identifier�
�=�,�)�list�items�sortr&r6rB�r�match�appendr0�join)�d�outri�k�vs     rrArA�s���
�C������O�E�	�J�J�L��.���1��!�S�!�$�%8�1�%<�=�=��w�w�q�z�$�%=��%A�B�B��
�
�T�!��A�h�q�k�]�!�,�-�.��7�7�3�<�rc	�"�t|d�r|j�St|�}|tvrt	|�S|t
urxdg}|j
�D]/\}}|jdt|��dt|��d���1|jt|�xrdxsd�dj|�S|turZd	g}|D]}|jd
t|�z��!|jt|�xrdxsd�dj|�S|turZd
g}|D]}|jd
t|�z��!|jt|�xrdxsd�dj|�Std|�d|�d���)Nr�{rdz: rfz
}�}rg�[z
%s,z
]�]�(z
)r>zUnsupported type z when trying to prettify �.)�hasattrr�type�_SIMPLE_BUILTINS�reprr@rirmr0rGrnrh�tupler*)r?�trprqrr�xs      rr0r0�s{���s�K� ��}�}���
��I��� � ���9��
�$�Y��%�C��	�	��
A���1��
�
�T�(�1�+��b��!��
�Q�?�@�
A��J�J�s�3�x�+�G�2�s�3��7�7�3�<��
�$�Y��%�C��
4���
�
�9�x��{�2�3�
4��J�J�s�3�x�+�G�2�s�3��7�7�3�<��
�%�Z��%�C��
4���
�
�9�x��{�2�3�
4��J�J�s�3�x�+�G�2�s�3��7�7�3�<���/��s�2K�C�5�PQ�R�S�Src�<�g}g}d|g}t|j�D]l\}}\}}\}}	}
|dvr|j|�n|dvr|j�|dk(r|jdt|�z��\|j|��ndj	|�S)Nrg)rvrxrt)rwr>ru�z  )�tokenize�poprmrGrn)�srp�stack�l�	tokenType�tokenString�startRow�startColumn�endRow�	endColumn�logicalLines           rr_r_�s���
�C��E�	�Q��A�
�!�%�%��
$�	�����;������/�)��L�L��%�
�O�
+��I�I�K��$���J�J�t�c�%�j�(�)��J�J�{�#�$��7�7�3�<�rc�4�t�j|�S)zG
    Pass me an Abstract Object Tree, and I'll unjelly it for you.
    )�AOTUnjellier�unjelly)�aots r�unjellyFromAOTr�s���>�!�!�#�&�&rc	�
�tttttt
ttd�}t|d�r|j�}n|}t|dd�}t|||�d|vrt|d�Std|z��)z�
    Pass me a string of code or a filename that defines an 'app' variable (in
    terms of Abstract Objects!), and I'll execute it and unjelly the resulting
    AOT for you, returning a newly unpersisted Application object!
    )r(r$rrr!r'r)rZ�readz<source>�exec�appz'%s needs to define an 'app', it didn't!)r(r$rrr!r'r)rZrzr��compile�evalr�rL)�stringOrFile�ns�source�codes    r�unjellyFromSourcer�s����(�������	
�B��|�V�$��"�"�$�����6�:�v�.�D���r�2����{��b��i�(�(��B�\�Q�R�Rrc�:�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
y	)
r�zWI handle the unjellying of an Abstract Object Tree.
    See AOTUnjellier.unjellyAO
    c�.�i|_g|_g|_yr)�
referencesr��afterUnjellyrs rrzAOTUnjellier.__init__/s�������
���rc�T�tj�}|j|d|�|S)zUnjelly a node, later.r)r�_Defer�unjellyInto)r�noderos   r�unjellyLaterzAOTUnjellier.unjellyLater7s%���O�O�������A�t�$��rc��|j|�}|||<t|tj�r|j	||�|S)zvUtility method for unjellying one object into another.
        This automates the handling of backreferences.
        )�	unjellyAOr&r�NotKnown�addDependant)rr?�locr`�os     rr�zAOTUnjellier.unjellyInto=s>��
�N�N�2�����C���a��*�*�+�
�N�N�3��$��rc��t|tj�rdg}|j|d�n|g}|jj||f�y)Nr)r&rr�r�r�rm)r�callable�result�
listResults    r�	callAfterzAOTUnjellier.callAfterGsI���f�h�/�/�0���J����
�A�.� ��J���� � �(�J�!7�8rc�>�|j|j||�y)z�Utility method for unjellying into instances of attributes.

        Use this rather than unjellyAO unless you like surprising bugs!
        Alternatively, you can use unjellyInto on your instance's __dict__.
        N)r��__dict__)rr,�attrNamer`s    r�unjellyAttributezAOTUnjellier.unjellyAttributeOs��	
����*�*�H�b�9rc	�	�|jj|�t|�}|tvr|S|tur;g}|D]2}|jd�|j|t
|�dz
|��4|S|turpg}t}|D][}|jd�t|j|t
|�dz
|�tj�s�Ltj}�]||�S|turWi}|j�D]@\}}tj|�}	|j|	d|�|j|	d|��B|S|j}
|
t urt#j$|j&�S|
t(t*fvst-|
t�rt#j.|j&�S|
t0ur�|j&}t#j.|j2�}|j5|j6�}
||j8vrL|
�t;||�St|
tj�rtj<||
|�St?|||
�StAd��|
tBur�t#j.|j2�}|j5|jD�}|jG|�}tI|d�r|jK|jL|�|St|t�r	||_|S|jO�|_|S|
tPur�|j5|jR�}|jT}|jVjY|�}|�||jV|<|St|tj�r"|j[|�||jV|<|S|�	|St]d|�d|�d|�d���|
t^urQ|jT}|jVjY|�}|�&tj`|�}||jV|<|S|S|
tburMt#j.|jd�}|jg|jD�jid	�|�}|StAd
|z��)zaUnjelly an Abstract Object and everything it contains.
        I return the real object.
        Nrrzinstance method changed�__setstate__z&Multiple references with the same ID: r=�!c��||�Srr)r��_ls  r�<lambda>z(AOTUnjellier.unjellyAO.<locals>.<lambda>�s
��r�6�{�rzUnsupported AOT type: %s)5r�rmr{r|rhr�rGr~r&rr��_Tupler@ri�_DictKeyAndValue�	__class__r!r�namedModulerrr�
issubclass�namedObjectr$r+r�r,r��getattr�_InstanceMethodrr*r(r8�__new__rzr�r��__getstate__r'r?rHr��get�resolveDependantsrLr)�_DereferencerZr\r��addCallback)rr`rr�r��tuple_rorqrr�kvd�c�im_name�im_class�im_selfr+r8r-r��refkey�refrN�derr\s                       rr�zAOTUnjellier.unjellyAOXs��	
�
�
���"����H��� � ��I�
�$�Y��A��
3�������� � ��C��F�Q�J��2�
3��H�
�%�Z��A��F��
-��������d�.�.�q�#�a�&�1�*�a�@�(�BS�BS�T�%�_�_�F�
-��!�9��
�$�Y��A����
�
,���1��/�/��2��� � ��a��+�� � ��a��+�
,��H����A��F�{��*�*�2�7�7�3�3��u�h�'�'�:�a��+>��*�*�2�7�7�3�3��n�$��'�'��"�.�.�r�x�x�8���.�.����5���h�/�/�/���&�x��9�9�#�G�X�->�->�?�'�7�7���(�S�S�/��'�7�K�K�#�$=�>�>��h���+�+�B�H�H�5�����r�x�x�0���}�}�U�+���5�.�1��N�N�4�#4�#4�e�<�
��	 ��t�,�$)�D�M���%*�$6�$6�$8�D�M����c���N�N�2�6�6�*�������o�o�)�)�&�1���;�./�D�O�O�F�+��� ��X�%6�%6�7��)�)�!�,�./�D�O�O�F�+����^����	%����,����e���i�i���o�o�)�)�#�.���;�"�/�/��4�C�+.�D�O�O�C�(��J��
��g��"�.�.�r�{�{�;���%�%�b�h�h�/�;�;�2�H������ :�Q� >�?�?rc	�6�	dg}|j|d|�|jD]\}}||d��|dS#t$rStjd�tjdjt
t|j����wxYw)Nr�+Error jellying object! Stacktrace follows::�
)	r�r��
BaseExceptionr�msgrn�mapr}r�)rr`r��funcrrs     rr�zAOTUnjellier.unjelly�s���		���A����Q��2�&��,�,�
���a��Q�q�T�
�
��Q�4�K���	��G�G�A�B��G�G�D�I�I�c�$��
�
�3�4�5��	�s
�9<�ABN)rrrrbrr�r�r�r�r�r�rrrr�r�*s-������9�:�f@�P
rr�c�4�t�j|�S)z-Convert an object to an Abstract Object Tree.)�
AOTJellier�jelly)r?s r�
jellyToAOTr��s���<���c�"�"rc��t|�}|r*|jt|�jd��yt|�S)z�
    Pass me an object and, optionally, a file object.
    I'll convert the object to an AOT either return it (if no file was
    specified) or write it to the file.
    zutf-8N)r��writer�encode)r?�filer�s   r�
jellyToSourcer��s5���S�/�C���
�
�9�S�>�(�(��1�2���~�rc�.�|jjS)z�
    Get the associated class of the given method object.

    @param methodObject: a bound method
    @type methodObject: L{types.MethodType}

    @return: a class
    @rtype: L{type}
    )�__self__r���methodObjects r�_classOfMethodr��s��� � �*�*�*rc��|jS)z�
    Get the associated function of the given method object.

    @param methodObject: a bound method
    @type methodObject: L{types.MethodType}

    @return: the function implementing C{methodObject}
    @rtype: L{types.FunctionType}
    )�__func__r�s r�
_funcOfMethodr������ � � rc��|jS)z�
    Get the object that a bound method is bound to.

    @param methodObject: a bound method
    @type methodObject: L{types.MethodType}

    @return: the C{self} passed to C{methodObject}
    @rtype: L{object}
    )r�r�s r�
_selfOfMethodr��r�rc�$�eZdZd�Zd�Zd�Zd�Zy)r�c�.�i|_d|_g|_y)Nr)�prepared�_ref_idr�rs rrzAOTJellier.__init__
s����
������
rc�4�||jt|�<y)zaI prepare an object for later referencing, by storing its id()
        and its _AORef in a cache.N)r��id)r�aoref�objects   r�
prepareForRefzAOTJellier.prepareForRefs��%*��
�
�b��j�!rc	�&����t��}�jjt���|tvr���n@t|tj�rVtt��jtjt����jt������n�t|tj �rt#�j���n�t|t�r t%tj�����no|tj&ur t)tj*�����n=t-���j.vrw�j.t-��}|j0r|j0}t7|�S�j2dz�_�j2}|j5|�t7|�St9�����fd�}�j;���|t<ur0�j?�D�cgc]}�j|���c}��nT|t@ur0�j?tAtC�j�����n|tDurOi}�jG�D](\}}	�j|	�|�j|�<�*�j?|�n�|tHjJvrYtIjJ|��\}
}�j?tMtj*|
��j|���nZtO�d�r|�jQ��n7tO�d�r|�jR�ntUd|jz���jd=�Scc}w)z+I turn an object into an AOT and return it.rc����jttj�j��j|���yr)rQr(r�qualr��	jellyToAO)r8r?�retvalrs ���r�
_stateFromz(AOTJellier.jellyToAO.<locals>._stateFromLs/����
�
��W�\�\�#�-�-�8�$�.�.��:O�P�rr�r�zUnsupported type: %s���)+r{r�rmr}r|r��types�
MethodTyper$r�rrr�r�r�r��
ModuleTyper!r�FunctionTyper�fullFuncNamer�r�rHr�rOr)r'r�rhrQr~r�r@ri�copy_reg�dispatch_tablerZrzr�r�r*)
rr?�objType�oldRef�keyr�r�rorqrr�unpickleFuncr8r�s
``          @rr�zAOTJellier.jellyToAOs�����s�)���
�
���$�s�)�$��&�&��F�
���!1�!1�
2�$��c�"�+�+����^�C�0�1����}�S�1�2��F����!1�!1�
2��C�L�L�)�F�
���
&��7�<�<��,�-�F�
��*�*�
*��g�2�2�3�7�8�F��#�w�$�-�-�'����r�#�w�/���=�=� �-�-�C��S�z�!�$(�<�<�!�#3�D�L��,�,�C��M�M�#�&��S�z�!��U�F�
�

���v�s�+��$���
�
�#�>�Q�t�~�~�a�0�>�?��E�!��
�
�e�C�����$<�=�>��D�����I�I�K�=�D�A�q�+/�>�>�!�+<�A�d�n�n�Q�'�(�=��
�
�a� ��H�3�3�3�&.�&=�&=�g�&F�s�&K�#��e��
�
��G�0�0��>����u�@U�V����n�-��3�+�+�-�.���j�)��3�<�<�(�� 6��9I�9I� I�J�J��J�J�r�N��
��5?s�
Nc���	|j|�}|S#t$rEtjd�tjdj	|j
���wxYw)Nr�r�)r�r�rr�rnr�)rr?r`s   rr�zAOTJellier.jellypsR��	�����$�B��I���	��G�G�A�B��G�G�D�I�I�d�j�j�)�*��	�s
��AA#N)rrrrr�r�r�rrrr�r�s���*�
V�prr�r)5rb�copyregr�rer��twisted.persistedr�twisted.pythonrr�twisted.python.compatr�	_tokenizerr�r
rrr!r$r3r7�bool�bytesr6�int�float�complexr{�slice�Ellipsisr|r(r'r)rZr�	ExceptionrBr�rkrAr0r_r�r�r�r�r�r�r�r�r�rrr�<module>rs9����	��&�'�2�3���
'�E�'�
*�u�*�
(�U�(�

�
�(	�	��]�
�	�	���	����J�	���N�
��C�C�8"�"�<��E�E�.�
,��,��B�J�J�(�)��
�T�D�6'�S�>`�`�P#�
�
+�
!�
!�k�kr

Zerion Mini Shell 1.0