� K�gA���z�dZgd�ZddlZddlZddlmZmZmZmZm Z m Z m Z m Z m Z mZmZmZmZddlmZddlmZd�Zd �Zd �Zd �Zd(d �Zd)d�Z d*d�Zd�Zd�Zd�Zd�Z d+d�Z!d,d�Z"d,d�Z#e$��Z%e&��Z'd�Z(d-d�Z)d.d�Z*d)d�Z+d�Z,d/d�Z-d0d �Z. d1d!�Z/d2d"�Z0d-d#�Z1d3d$�Z2d/d%�Z3d)d&�Z4d4d'�Z5e+Z6eZ7dS)5a; Extensions to python's 'inspect' module, which can be used to retrieve information from live python objects. The methods defined in this module are augmented to facilitate access to source code of interactively defined functions and classes, as well as provide access to source code for objects defined in a file. )� findsource�getsourcelines� getsource�indent�outdent�_wrap� dumpsource�getname� _namespace� getimport� _importable� importable� isdynamic� isfrommain�N) �getblock�getfile� getmodule� getsourcefile� indentsize� isbuiltin�isclass�iscode�isframe� isfunction�ismethod�ismodule� istraceback)� TokenError�)� IS_IPYTHONc�B�t|��}|r |jdkrdSdS)z%check if object was built in __main__�__main__TF)r�__name__)�obj�modules �[/home/asafur/pinokio/api/open-webui.git/app/env/lib/python3.11/site-packages/dill/source.pyrr#s+�� �s�^�^�F� ��&�/�Z�/�/��t� �5�c�x�t|��}n#t$rd}YnwxYw|dkrt|��rdSdS)z,check if object was built in the interpreterN�<stdin>TF)r� TypeErrorr)r$�files r&rr+sJ���� � ���� �!�!�!�T�d�d�d�!���� �y���Z��_�_���t� �5s �� � c ��� � �ddlm}ddlm}m}m}d�}��dd��d�dd��\}} t d|�d|��t��t����� n#t$r|� YnwxYw|� ��j ||��j c� } �fd �||��� ��D��� � s � | krd Sd St� ��sd S||��� �fd �� d � dzD��� � rt� ��sd S�fd�||��� ��D��� � rt� ��sd S�� d��dk�r|||��� ��vr�|�dd��d�dd��\} } t d| �d| ��t��t����� n#t$r|� YnwxYw|� ��j ||��j c� } t� ��t| ��krd Std�t!� | ��D����� t� ��dkrd Sd St#���sd S� �� d ��� | �| d ��� t%� fd�t'dt� ����D����� t%� fd�t'dt� ����D����� � � ��� � ��krFt)� �����t)� �����krd Sd S)z=check if lambda object 'func' matches raw line of code 'line'r)�code)�freevars� globalvars�varnamesc��dS)N� __this_is_a_big_dummy_function__�r3r'r&�<lambda>z_matchlambda.<locals>.<lambda>8s��7�r'�lambda ������:z : c�:��g|]}��|����Sr3��count��.0�i�lines �r&� <listcomp>z _matchlambda.<locals>.<listcomp>As#��� 7� 7� 7�A�$�*�*�Q�-�-� 7� 7� 7r'TFc�:��g|]}��|����Sr3r9r;s �r&r?z _matchlambda.<locals>.<listcomp>Js#��� -� -� -�A�$�*�*�Q�-�-� -� -� -r'rc�:��g|]}��|����Sr3r9r;s �r&r?z _matchlambda.<locals>.<listcomp>Ls#��� 9� 9� 9�A�$�*�*�Q�-�-� 9� 9� 9r'c3�0K�|]\}}||k� ||fV��dS)Nr3)r<r=�js r&� <genexpr>z_matchlambda.<locals>.<genexpr>Xs.����9�9�%�1�Q�!�q�&�&��1��&�&�&�&�9�9r'c3�r�K�|]1}tjd�|�����V��2dS�z([\W\D\S])(.*)N��re�match�groups)r<r=�_s �r&rDz_matchlambda.<locals>.<genexpr>bs@����� Q� Q�A�R�X�'��1�� .� .� 5� 5� 7� 7� Q� Q� Q� Q� Q� Qr'c3�r�K�|]1}tjd�|�����V��2dSrFrG)r<r=�_fs �r&rDz_matchlambda.<locals>.<genexpr>cs@����� T� T�a�b�h�(�"�Q�%�0�0�7�7�9�9� T� T� T� T� T� Tr')�detectr-r.r/r0�split�eval�globals�locals� Exception�co_code�keys�allr:�len�set�zipr�dict�range�sorted�values)�funcr>�getcoder.r/r0�dummy�lhs�rhsr-�_lhs�_rhsrKrMs ` @@r&� _matchlambdare4s������'�'�'�'�'�'�6�6�6�6�6�6�6�6�6�6� 7� 7�E��j�j��1�%�%�b�)�/�/��Q�7�7�G�C�� � �D�S�S�S���-�w�y�y���� B� B���� ����%�a�a�a������g�a�j�j� �'�'�$�-�-�"7�G�A�t� 7� 7� 7� 7���$���!4�!4�!6�!6� 7� 7� 7�B� �� ��9�9�T�T��u� �r�7�7� �5�5� ��$���B� -� -� -� -��A��r�!�u�� -� -� -�B� �'�#�b�'�'�'�%�%� 9� 9� 9� 9���D�!1�!1�!6�!6�!8�!8� 9� 9� 9�B� �'�#�b�'�'�'�%�%� � � �9����!�!��x�x��~�~�/B�/B�/D�/D�(D�(D��I�I�i��*�*�2�.�4�4�S��;�;� ��T� %���$�$�$�t�t�4�g�i�i����I�I�B�B���$�$�$�u�"�"�"�$�����'�"�+�+�%�w�w�t�}�}�'<���4� �q�6�6�S��Y�Y� � �u�u� �9�9�3�q��;�;�9�9�9� 9� 9�� �q�6�6�Q�;�;�u�u��t� �d� � �)�E�E� ����!�� � �A� ���D��G� � �B� � Q� Q� Q� Q��q��Q����� Q� Q� Q�Q�Q�A� � T� T� T� T�5��3�r�7�7�CS�CS� T� T� T� T� T�B� �����B�G�G�I�I���F�1�8�8�:�:�$6�$6�&������:M�:M�$M�$M��t� �5s$� /A;�; B � B �/H� H�Hc� ��t|��}t|��}n#t$rd}YnwxYw|o |jdko| }t�r |�r t|��}t |��}n�#t$rwt |��rett|j � ����D]8}t|��}|� d��s�'|}t |��}YnwxYw|rtj |��}�n�d�t��jj��}d�|���D��}�n�|r� ddl�d} nQ#t($rDddl} | ���djd} | jdd �d kr| d z } YnwxYw| rt3| �������} �fd �t7d| ��D��}�n t |��s;t t9|����rt|��}t |��}nt|��}t |��}n5#tt:f$r!t|��}t |��}YnwxYw|s(|dd�|d d�zdkrt3d���|r|n|}t||��}|rtj ||j ��}ntj |��}|st3d���t=|��r|dfSdx} x} }d}t?|��r|j} | dkrd} nd} |j }t|��r|j} | dkrd} |}nd} |j!}tE|��r|j#}tI|��r|j%}tM|���rtO|d��st3d���|j(dk}|rtS|��dz }| sd} n |j*dz }d} tWj,| ��} tWj,|��}|dkr�||}| �-|��r_|sng| dkrt]||��rnPnD| |vr@d}t7|dz d d ��D]#}|�-||��r|dz }�#||z }n |dz }|dk��||fS t |��s#t t9|����r|j/}n#t:$rYnwxYwt |��r�|j} tWj,d| zdz��}g}t7tS|��dz d d ��D]a}|�-||��}|rB||ddkr||fcS|�0|�1d��|f���b|r$|�2��||ddfSt3d���t3d���)aReturn the entire source file and starting line number for an object. For interactively-defined objects, the 'file' is the interpreter's history. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of all the lines in the file and the line number indexes a line in that list. An IOError is raised if the source code cannot be retrieved, while a TypeError is raised for objects where the source code is unavailable (e.g. builtins).Nr"z<ipython-input-� c��g|]}|dz��S�rgr3�r<r>s r&r?zfindsource.<locals>.<listcomp>�s��B�B�B�T�T�D�[�B�B�Br'r�r��winz, please install 'pyreadline'c�@��g|]}��|��dz��Sri)�get_history_item)r<r=�readlines �r&r?zfindsource.<locals>.<listcomp>�s,���J�J�J�q��*�*�1�-�-�d�2�J�J�Jr'r6z<>zsource code not availablezcould not extract source code�^(\s*@)�<lambda>z(.*(?<!\w)lambda(:|\s))z ^(\s*def\s)�co_firstlinenoz"could not find function definitionr)z+^(\s*def\s)|(.*(?<!\w)lambda(:|\s))|^(\s*@)z^(\s*)class\s*z\b�czcould not find class definitionzcould not find code object)3rrr*r#r rr�filterr�__dict__r]� startswith� linecache�getlines�join� get_ipython�history_manager�input_hist_parsed� splitlinesrp� ImportError�sys�exc_info�args�platform�IOError�get_current_history_lengthr[�type�AttributeErrorrr�__func__�__code__r�tb_framer�f_coder�hasattr� co_filenamerWrsrH�compilerIre� __class__�append�group�sort)�objectr%r+�is_module_main� sourcefile� object_method�file_candidate�lines�history�errr��lbuf�name�pat1r$�pat2�stdin�lnumr>�hats�_lnum�pat� candidatesr=rIrps @r&rris�����v� � �F�������� �!�!�!�T�d�d�d�!�����K���J�!>�K�t�8�N��6-�n�6-� ��6�?�?�D�&�v�.�.�J�J��� � � ��v��� �%+�J���8N�8N�8P�8P�%Q�%Q���M�%,�]�%;�%;�N�)�4�4�5F�G�G�!� �)�D�!.�}�!=�!=�J���� ���� � C��&�t�,�,�E�E��i�i� � � � =� O�P�P�G�B�B�W�-?�-?�-A�-A�B�B�B�E�E� � -� 7� �O�O�O��C�C��� 7� 7� 7� �J�J�J��,�,�.�.��#�(��+�C��|�B�Q�B��5�(�(��6�6����  7���� � ��#�,�,� ��2�2�4�4��J�J�J�J�E�!�D�M�M�J�J�J��� /��6�?�?� 3�w�t�F�|�|�'<�'<� 3��v����*�6�2�2� � ��v����*�6�2�2� ����>�*� /� /� /��6�?�?�D�&�v�.�.�J�J�J� /����� 7�d�2�A�2�h��b�c�c��2�d�:�:��5�6�6� 6�'�1�z�z�T���6�4�(�(�� � -��&�t�V�_�=�=�E�E��&�t�,�,�E� �7��5�6�6�6�������a�x����D��4�#� �D�����!���� �:� � �&@�t�t�#�d�����&���!���� �:� � �-�D��C�C�#�d�����6���!�����v������� �f�~�~���v�/�0�0� @��>�?�?� ?��"�i�/�� � B��u�:�:��>�D�� N� N����(�1�,�D�A�D��z�$����� �4�(8�(8���Q�h�h���;�D��z�z�$��� ��#�e��:�%�%�#�C��.�.�5��5��t�|�|� ��%*�4��6�"�R�%8�%8�(�(�E�#�z�z�%��,�7�7�(������"'�#�d�{����!�8�D��Q�h�h��d�{�� ��v��� &�7�4��<�<�#8�#8� &��%�F��� ����4�4������v���=�����j�*�T�1�E�9�:�:��� ��s�5�z�z�!�|�B�r�*�*� 7� 7�A��I�I�e�A�h�'�'�E�� 7���8�A�;�#�%�%� �!�8�O�O�O��!�!�5�;�;�q�>�>�1�"5�6�6�6�� � =� �O�O� � � ��*�Q�-��*�*� *��;�<�<� <� �.� /� /�/sW�!� 0�0�A.�.A>C/�.C/�E�A F-�,F-�4A(I�/J�J�2S9�9 T�TFc���t|��\}}t|��r|rt|��}|dur|gdgfn|gSt||��}t ||d���}|r|s|rt|��}|dur|g|gfn|gSd}t j|��}d} t j| ��} d} d} g} g} d�|��}| |k�rj|�|| ��r�| s1t || d���}n#t$r || g}YnwxYwt|| ��|kr| t|��| z z } n_|d�|��vrC| � |��| � | | z ��| t|��| z z } n| dz } d} n�| �|| ��rbt || d���}n#t$r || g}YnwxYwd} |dd�D]}| �|��sn| dz } �| | z } n| dz } d} | |k��j| s|g} |g} |r d�| D��} |dur| | fn| S) a�Return a list of source lines and starting line number for an object. Interactively-defined objects refer to lines in the interpreter's history. If enclosing=True, then also return any enclosing code. If lstrip=True, ensure there is no indentation in the first line of code. If locate=True, then also return the line number for the block of code. DEPRECATED: use 'getsourcelines' instead TrNz#^(\s*def\s)|(.*(?<!\w)lambda(:|\s))rqrkrc�,�g|]}t|����Sr3)�_outdent)r<�blocks r&r?zgetblocks.<locals>.<listcomp>Gs��=�=�=�U��%���=�=�=r') rrr�rrrHr�rzrIrrWr�)r��lstrip� enclosing�locater�r�rr�r�r��skipr>�blocksr��targetr-�_lines r&� getblocksr�s����V�$�$�K�E�4�����=� �*�8�E�?�?�5�!'�4�����!��~�~�e�W�<���d� � $� $�F� �U�4�5�5�\� "� "�E� �@�F�@� �*�8�E�?�?�5�$*�d�N�N���$�� � ���?� 1�D�"�*�T�:J�:J�4� �D�b�j��.�.�t� �D� �D� �F��� �W�W�U�^�^�F� �$�,�,� �:�:�e�D�k� "� "� �� 8�$�U�4�5�5�\�2�2�T�T��!�7�7�7�5��;�-�4�4�4�7�����%��+�&�&��/�/���D� � �D�(�(����2�7�7�4�=�=�(�(�� � �d�#�#�#�� � �T�D�[�)�)�)���D� � �D�(�(����� ���D�D� �Z�Z��d� � $� $� � ��t�u�u��.�.����� 3� 3� 3�u�T�{�m�t�t�t� 3�����D��a�b�b�� � ���z�z�%�(�(�/�%�%��� ��� �D�L�D�D� �1�H�D��D�7 �$�,�,�: �������� �=�=�=�f�=�=�=�v�$��n�n�F�E�?�?�&�8s$�;D�D)�(D)�G0�0H�Hc�N�t|||d���\}}|d|dfS)a�Return a list of source lines and starting line number for an object. Interactively-defined objects refer to lines in the interpreter's history. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a list of the lines corresponding to the object and the line number indicates where in the original source file the first line of code was found. An IOError is raised if the source code cannot be retrieved, while a TypeError is raised for objects where the source code is unavailable (e.g. builtins). If lstrip=True, ensure there is no indentation in the first line of code. If enclosing=True, then also return any enclosing code.T)r�r�r�r6)r�)r�r�r�r-�ns r&rrLs0����v��4�P�P�P�G�D�!� ��8�Q�r�U�?�r'rkc ��t|��}t|��} t||���\}} �n#ttf$r�|s�t |��sV|st |||���cYSt ||���} t|d���} |rd|znd} || krd} | | zd| zzcYS|st |||���cYS|jj } |j } | dvrt |||���cYS| �d | �d | �d | �d �gd } }t|d � | dz����}t||���\}} YnwxYw|s|rt|��}|rfdt|��vr|�d|z��n<t!|d|d���}d�|�d ��D��dd�d } }|�r�|r�d }|D]}|�d��sn|dz }�||� ���d��r.||j kr!|�d |�d|j �d ����nd||vrH|||�d��d ���kr|�d||��||<n�||j kr!|�d |�d|j �d ���n�|rI||d�d��d ���krd|z|dz|d<n:t|d���p|j } || kr|�d |�d| �d ���d�|��S)a+Return the text of the source code for an object. The source code for interactively-defined objects are extracted from the interpreter's history. The argument may be a module, class, method, function, traceback, frame, or code object. The source code is returned as a single string. An IOError is raised if the source code cannot be retrieved, while a TypeError is raised for objects where the source code is unavailable (e.g. builtins). If alias is provided, then add a line of code that renames the object. If lstrip=True, ensure there is no indentation in the first line of code. If enclosing=True, then also return any enclosing code. If force=True, catch (TypeError,IOError) and try to use import hooks. If builtin=True, force an import for any builtins )r�)�builtinT��force�%s = rk�%s ��builtins� __builtin__z = __import__('z', fromlist=['z']).rgrz = �(z%r F)�alias�new�enclosec��g|]}|dz��Srir3rjs r&r?zgetsource.<locals>.<listcomp>�s��C�C�C��4��9�C�C�Cr'Nr6�@rzdef r5�=)�_hascode� _isinstancerr*r�rr r r�r#� __module__rPr�r��reprr�rrOrw�striprz)r�r�r�r�r�r��hascode�instancer�r��_importr��_aliasr%r$r�r>s r&rr^s��$�v���G��6�"�"�H�G�$�V�y�A�A�A� ��t�t�� �w� �G�G�G�� � ��� � � G�� M�I�f�e�W�$M�$M�$M�M�M�M����8�8�8�G��6��.�.�.�D�(-�5�W�u�_�_�2�F���}�}�r�f��6�>�&�4�-�/� /� /� /�� M�I�f�e�W�$M�$M�$M�M�M�M��#�,�D��&�F��3�3�3� ����@�@�@�@�@�@�PT�PT�PT�U[�U[�U[�\`�\`�\`�ae�ae�ae�f�g�ij�t���5��8�?�?�4�%�<�8�8�9�9��,�S�I�F�F�F� ��t�t�t�+G����0� �� �������L� �$�v�,�,� � �� � �V�f�_� =� =� =� =� �v�R�U�E�J�J�J�E�C�C����T�1B�1B�C�C�C�C�R�C�H�!�4�E� �@� � @��D�� � �����s�+�+�2�U�U��� ����T�{�!�!�#�#�.�.�v�6�6� K��F�O�+�+��L�L�L�%�%�%�����!I�J�J�J���e�D�k�)�)��E�$�K�-�-�c�2�2�1�5�;�;�=�=�=�=�/4�u�u�e�D�k�k�"B�E�$�K���F�O�+�+��L�L�L�%�%�%�����!I�J�J�J��� @��E�"�I�O�O�C�0�0��3�9�9�;�;�;�;�!(�5��E�"�I� =�E�"�I���v�T�2�2�2�E�f�o���D�=�=��L�L�L�%�%�%����!>�?�?�?� �7�7�5�>�>�s(�6�7E�/>E�/E�)E�0AE�Ec�F�t|dd��pt|dd��S)z9True if object has an attribute that stores it's __code__r�N� func_code)�getattr�r�s r&r�r��s%�� �6�*�T� *� *� N�g�f�[��.N�.N�Nr'c���t|��st|��st|��rdSt|��st |��st |��rdSt |��s%t t|����jdvrdSd}tt|����� |��sdSt |��r|j dvst|d���dvrdSdS)z>True if object is a class instance type (and is not a builtin)F)�numpyT)z<class z<type 'instance'>r�r�)�array) r�rrrrrrr�r#r�rwr�r )r��_typess r&r�r��s�������7�6�?�?��h�v�.>�.>���u��6����g�f�o�o��������u� �V� � ���4��<�<�!8�!8�!A�Y�!N�!N��t�-�F� ��V� � � � � (� (�� 0� 0���u� �V� � ��� 1�5O� O� O�SZ�[a�im�Sn�Sn�Sn�r{�S{�S{��u� �4r'c��ddl}t|��td��urt|d���}|dkrd}t||��rdndS) z(check if object is in the 'types' modulerNrkTr��ellipsis� EllipsisTypeF)�typesr�r r�)r�r�s r&�_intypesr��s\���L�L�L� �F�|�|�4��8�8�#�#���t�,�,�,�� ����n�V��5�&�)�)� 4�4�4�u�4r'c�:�t|ttf��S)z%check if object is a string-like type)� isinstance�str�bytesr�s r&� _isstringr��s�� �f�s�E�l� +� +�+r'�c��t|��}t|��turd|z}t|��}|�d��}t t |����D],}t||��}||kr�|||z||<�-|d���dkrd|d<d�|��S)z<indent a block of code with whitespace (default is 4 spaces)� rgr6rk)rr��intrOr[rWr�rz)r-�spacesr�nspacesr�r=�_indents r&rr�s��� �� � �F� �F�|�|�s���S��Z�F��� � �G� �J�J�t� � �E��3�u�:�:� � �#�#���U�1�X�&�&�� �G� � �X��%��(�?��a��� �R�y�����B���B��b� � �9�9�U� � �r'Tc���t|d��}|� ||ks|dkr|}t|rt|��nd��D]5}t||��}||kr|}n|}|||d�||<�6|S)zAoutdent lines of code, accounting for docs and line continuationsrNr)rr[rW)r�r�rVrr=r��_spacess r&r�r��s��� ��a�� !� !�F� �~��&���F�Q�J�J��� ��+�3�u�:�:�:�!� ,� ,�&�&���U�1�X�&�&�� �G� � �w�W�W��g���8�G�H�H�%��a��� �Lr'c���t|��}|� ||ks|dkr|}|s ||d�Sd�t|�d��||�����S)zDoutdent a block of code (default is to strip all leading whitespace)Nrrg)r�rV)rrzr�rO)r-r�rVrs r&rr sh�� �� � �F� �~��&���F�Q�J�J��� �$�t�F�G�G�}�$� �9�9�X�d�j�j��.�.�v�3�G�G�G� H� H�Hr'c�B���fd�}�j|_�j|_|S)z, encapsulate a function and it's __import__ c��� tt�d���tt��n%#t$rt d�jz���wxYwt|i|��S)NrK�r�zcannot import name )�exec� getimportable� __globals__� __locals__rSrr#rK)r��kwds�fs �r&r^z_wrap.<locals>.funcss��� B� ��q��,�,�,�k�:� F� F� F� F��� B� B� B��3�a�j�@�A�A� A� B�����$��$���s �*.�"A)r#�__doc__)r�r^s` r&rrs5��� � � � � ��J�D�M��9�D�L� �Kr'c ��d}d}d|z}|tt||dd�����z }|td|z��z }|r|d|zz }||�d|�d �z }|S) z<create a function enclosure around the source of some object�*__this_is_a_big_dummy_enclosing_function__�__this_is_a_stub_variable__z def %s(): T�r�r�r�z return %s r�z(); del rg)rr)r�r�r`�stubr-s r&�_encloser�%s��� 9�E� (�D� �5� �D��F�9�V�4��D�I�I�I� J� J�J�D��F�=�4�'� (� (�(�D� �%�d�g��o�%�d�����u�u�u� -�-�D� �Kr'c���ddlm}t||����}d}|r d}d|z}d}n |}|rd|zn|}|rt|��s ||d|zzz }n>|t |jdd d � ��z }t|j��} ||d |�d | �d �zz }|rad} t| |���} | �d��} | ddzt|��zd� | dd���z}|S)a/'dump to source', where the code includes a pickled object. If new=True and object is a class instance, then create a new instance using the unpacked class source code. If enclose, then create the object inside a function enclosure (thus minimizing any global namespace pollution). r)�dumpsz import dill r�r�Fzdill.loads(%s) rkTr�z dill.loads(z .replace(bz,bytes(__name__,"UTF-8"))) �__this_is_a_big_dummy_object__r�rg�����N) �dillr�r�r�rr�r�r�rOrrz) r�r�r�r�r��pikr-r��pre�modr`s r&rr3sQ�������� �u�u�V�}�}� � �C� �D��1�,����n������� %�0�g��n�n�5�� �Z�k�&�)�)�Z� ��(�3�.�.�.��� � �&�*�"�T��N�N�N�N���6�$�%�%�� ���QT�QT�QT�UX�UX�UX�Y�Y�Y���D�0����e�,�,�,��� � �D�!�!���Q�x��}�v�d�|�|�+�d�i�i��b�c�c� �.C�.C�C�� �Kr'c���|r"d�t|����St|��}|s|sdSt|��S |j}|dkr;t |���dd��d���S|jdvr|dkrd }|S#t$r1|sYdSt|��}|� d ��rYdS|cYSwxYw) zEget the name of the object. for lambdas, get the name of the pointer �.Nrrr�rrr�r�r��<) rzr rr�r#rrOr�r�rw)r$r��fqnr%r�s r&r r Zs�� �,�3�8�8�J�s�O�O�,�,� ,� �s�^�^�F� ���!�T�T��C�y�y����|�� �:� � ��S�>�>�'�'��A�.�.�q�1�7�7�9�9� 9� �?�8� 8� 8��z�!�!�.�4�� �� �����!�T�T�T��C�y�y�� �?�?�3� � � ��4�4�� � � � ���s%� AB%�B%�% C �4$C �C �C c�L� tt|�������d�d���d���d��x}}|�d��}t |��r|St |��p|j}|dvrt|��rdg|gzS||gzS#t$rYnwxYwt|��dvrd gt|��gzSt|j d d ��}t|j ��}||� d��dzd �}n#t$rYnwxYw|�d��}|dvr.|d dkrd|d <t|d ��rd}|g|z}|S)a_namespace(obj); return namespace hierarchy (as a list of names) for the given object. For an instance, find the class hierarchy. For example: >>> from functools import partial >>> p = partial(int, base=2) >>> _namespace(p) ['functools', 'partial'] r�>�"�'rr�r�)�inf�nan�Inf�NaNr�r�N�����r6r�r�) r�rrOr�rr r#r�rSr�r��index� ValueError)r$r%�qualr�s r&r r ss��� ��I�c�N�N�+�+�1�1�3�3�A�6�<�<�S�A�A�G�G��L�L�R�R�SV�W�W�W����z�z�#���� �C�=�=� ��K��s�|�|�+�s�|�� �/� /� /���~�~� 8�w�i�4�&�&8�8��t�f�}��� ����d�d����� �3�x�x�,�,�,��y�C��H�H�:�%�%� �S�]�L�$� 7� 7�F� �s�}� � �D��T�Z�Z��_�_�Q�&�r�)�*���� ����t�t����� �:�:�c�?�?�D� �+�+�+� ��8�z� !� !�n�4��8� �D��H� � �/��v��x�$��� �Ks0�BC �/C �C � C�C�, E � E�Ec��|dvr|dvr tj}n!|dvr|dvr|rd|znd}||krd}|d|zzS|dvr6|dkrd }t|��rd }n|s|rd|znd}||krd}|d|zzS |sd |z}nd |�d |��}|rd|znd}||krd}||z }|rl|�d��sWt |��nG#t $r:|�dd��d}|s�||krt||||��}YnwxYw|S)adhelper to build a likely import string from head and tail of namespace. ('head','tail') are used in the following context: "from head import tail" If verify=True, then test the import string before returning it. If builtin=True, then force an import for builtins where possible. If alias is provided, then rename the object on import. )�Ellipsis�NotImplemented)r�)�Noner�rkr�r�r�r�r�z import %szfrom z import z as %s rgzdill.rrr)rWr�r�rwr�r�rsplit� _getimport)�head�tailr��verifyr�r��_str�_heads r&rr�s��� �-�-�-�$�)�2C�2C��~��� �� � �d�i�/�/�$)�1��5���r�� �D�=�=�2�&��f�t�m�#�#� �)�)�)� �:� � �n�t� �D�>�>� �'�4�4�� �(-�5�W�u�_�_�2�F���}�}�r�f��&�4�-�'� '�� �4� �d�*���4�(,���d�d�3�$�#(� 2�Z�%� � �d�F� ��}�}�t�f��F�N�D��>�d�o�o�g�.�.�>� �$�Z�Z�Z�Z��� >� >� >��K�K��A�&�&�q�)�E�� �%���}�}�!�%��u�f�=�=����  >���� �Ks�.B>�>AD�Dc���|rddlm}||��}|r|n|}t|��}d�|dd���}|d} t |���dd��d�dd��d} d} nL#t $r?|dvrt |��} n(t |���d ��d } YnwxYw| rMt|| |||��S#t$rYn.t$r"|dvr|rd |znd } || krd } | d | zzcYSYnwxYw t|| |||��S#t$r�t$r!|dvr|rd |znd } || krd } | d | zzcYS�wxYw)alget the likely import string for the given object obj is the object to inspect If verify=True, then test the import string before returning it. If builtin=True, then force an import for builtins where possible. If enclosing=True, get the import for the outermost enclosing callable. If alias is provided, then rename the object on import. r)� outermostrNr6rrr�r�rr�rkr�) rNrr rzr�rOrSrr� SyntaxError) r$r�rr�r�r�_objrrrr�r�s r&r r �s���$�%�%�%�%�%�%��y��~�~���#�d�d��� �c�?�?�D� �8�8�D��"��I� � �D� ��8�D�+��C�y�y���s�1�%�%�a�(�.�.�s�1�5�5�a�8������ �+�+�+� �-� -� -���9�9�D�D���9�9�?�?�3�'�'��*�D��� +���� ���t�T�5�&�'�B�B� B��� � � �D�D�� � � ��1�1�1�,1�9��5���r���D�=�=�2�&��f�t�m�+�+�+�+��$�  ���� ��$��e�V�W�=�=�=�� ���� � ���� �-� -� -�(-�5�W�u�_�_�2�F���}�}�r�f��&�4�-�'� '� '� '� � ���s>�AB�AC�C�#C6�6 D-�&D-�,D-�1E�1E9�7E9c�z�|�t|��rdnd}|r& t||||||���S#t$rYnwxYw t|��st |||| |���St ||| |���}t |d���}|st d���|rd|znd } ||krd } || zd |zzS#t$rYnwxYw|s& t||||||���S#t$rYnwxYwt ||���}|r|�d ��rt d���|rd|znd } ||krd } | d |zzS) a\get an import string (or the source code) for the given object This function will attempt to discover the name of the object, or the repr of the object, or the source code for the object. To attempt to force discovery of the source code, use source=True, to attempt to force the use of an import, use source=False; otherwise an import will be sought for objects not defined in __main__. The intent is to build a string that can be imported from a python file. obj is the object to inspect. If alias is provided, then rename the object with the given alias. If source=True, use these options: If enclosing=True, then also return any enclosing code. If force=True, catch (TypeError,IOError) and try to use import hooks. If lstrip=True, ensure there is no indentation in the first line of code. If source=False, use these options: If enclosing=True, get the import for the outermost enclosing callable. If force=True, then don't test the import string before returning it. If builtin=True, then force an import for builtins where possible. NTF)r�r�r�r�)r�rr�r�z!object has no atribute '__name__'r�rkr�r)rrrSr�r r r�rw) r$r��sourcer�r�r�r�r�r�r�s r&r r s���,�~�#�C���3���e�� �� ��S�%�9�#(���J�J�J� J������$�$�������3��� G��S�%�9�.3�)�g�G�G�G� G��C�9�-2��W�F�F�F���s�$�'�'�'��� F� �!D�E�E� E�$)�1��5���r�� �D�=�=�2�&��v�~�f�t�m�+�+�� ����d�d����� �� ��S�%�9�#(���J�J�J� J������$�$����� �#�U� #� #� #�C� �B�#�.�.��%�%�B��@�A�A�A� %� -�W�u�_�_�2�F� ��|�|�b�V� �&�3�,� �s6�.� ;�;�#B5�#AB5�5 C�C�C� C*�)C*c��� �����ddl�ddlm}m}||��}i}t |�����D�]�\�}t |��s�|�����t���}|� ��� d��rt�||���}�n-||��� dt� ��zdzt���z�tt� ����} t� ��\} } � ��fd �| D��} | s>tt�����} t���\} } ���fd �| D��} t| ��st!d ���| d } | �d d��d���d ����t'| �||���}||�<���|s�||���tt�����} | r�|ur$t|d����t|||���}n�t���\} } ��fd�| D��} t| ��st!d ���| d } | �d d��d���d ����t'| �||���}||�<|S)zEget import for closured objects; return a dict of 'name' and 'import'rNr)r.rr��r�r�� .*[\w\s]=\s*�\(c�X��g|]&}t���|v��j�|���$|��'Sr3�r rI)r<r>�enclr�rHs ���r&r?z#_closuredimport.<locals>.<listcomp>TsF���.�.�.�$�7�4�=�=�D�3H�3H�!���#�t�,�,�4I��3H�3H�3Hr'c�X��g|]&}t���|v��j�|���$|��'Sr3r&)r<r>�fobjr�rHs ���r&r?z#_closuredimport.<locals>.<listcomp>ZsI���O�O�O�d� '�� � �� 5� 5�(�"�(�3��:M�:M� 5�"� 5� 5� 5r'zimport could not be foundr6r�Tr�c�~��g|]9}t���|v��jdt���zdz|���7|��:S)r#r$r&)r<r>r�rHs ��r&r?z#_closuredimport.<locals>.<listcomp>jsY���N�N�N�$�7�4�=�=�D�3H�3H�!���/�'�$�-�-�"?��"E�t�L�L�4I��3H�3H�3Hr')rHrNr.r�list�itemsr�poprr�rwr r rrrWr*rOr�r)r^r�r�r.r� free_vars� func_varsr$�srcr�r�rK� candidater'r)r�r�rHs @@@@@r&�_closuredimportr2?sC������� �I�I�I�+�+�+�+�+�+�+�+������I��I�����*�*�+�+�����S��#���(���}�}�T�"�"����o�o�� �:�:�<�<� "� "�3� '� '� F��D��w�?�?�?�C�C��9�T�?�?�D�!�'�$�-�-�/��5�g�d�m�m�C�C��)�D�/�/�*�*�C� ��&�&�G�E�!�.�.�.�.�.�.�%�.�.�.�I�� O��i��o�o�.�.��$�T�*�*���a�O�O�O�O�O�O�e�O�O�O� ��y�>�>� O��3N�)O�)O�#O�!�"� �I��?�?�3�q�)�)�!�,�2�2�4�4�R�8�>�>�@�@�D��S�$�e�W�E�E�E�C�� �$��� ���y������i��o�o�&�&��� F�d�d�l�l��4�t�,�,�,�D��D��w�?�?�?�C�C� ��&�&�G�E�!�N�N�N�N�N�%�N�N�N�I��y�>�>� O��3N�)O�)O�#O�!�"� �I��?�?�3�q�)�)�!�,�2�2�4�4�R�8�>�>�@�@�D��S�$�e�W�E�E�E�C�� �$�� �r'c��ddlm}||��}i}t|�����D]�\}}t |��st |d|���||<�*|�|��}t ||��}|����d��s)t||���}t ||dd���} || f}n(t |dd���} t||d� ��}| |f}|||<��d � |� ����}|st ||ddd� ��} || f}n|d f}||d <|S) zSget source code for closured objects; return a dict of 'name' and 'code blocks'r)r.T)r�r�r�r�F)r�r�)r rk)r�r�r�N) rNr.r+r,rrr-r�rwr rzr]) r^r�r.r.r/r�r$r)r0�orgs r&�_closuredsourcer5ts���!� � � � � ������I��I�����*�*�+�+�����S��#��� �'��4�t�D�D�D�I�d�O� ��}�}�T�"�"����e�$�$���z�z�|�|�&�&�s�+�+� ��T��-�-�-�C��D�%�5��F�F�F�C���*�C�C��D�D��?�?�?�C��T�5��6�6�6�C���*�C�� �$��� �'�'�)�"�"�$�$� %� %�C� ����e�4�5��N�N�N���C�j����D�k���I�d�O� �r'c�t�|�t|��rdnd}n|rt|��rd}dx}} |s� t|��rt||d|���St |||���}t |��dkrt d���t |��dkrt d���t|�����dS#t$r|r�d}YnwxYw t||� ��}t |��dkrt d���d �}||� d����}|r|gng}|���D]$} || ��} | r|� | ���%t |��sd }n1t |��dkr |d}nd � |��}dd lm} | |��}td�|���D����}|rd � |��nd }|s|S|s|S||zS#t$r |r�d}| }YnwxYw�� )a�get an importable string (i.e. source code or the import string) for the given object, including any required objects from the enclosing and global scope This function will attempt to discover the name of the object, or the repr of the object, or the source code for the object. To attempt to force discovery of the source code, use source=True, to attempt to force the use of an import, use source=False; otherwise an import will be sought for objects not defined in __main__. The intent is to build a string that can be imported from a python file. obj is the object to inspect. If alias is provided, then rename the object with the given alias. If builtin=True, then force an import for builtins where possible. NTF�r r�r"rznot implementedrr�c��|dr|drd�|��}n$|dr |d}n|dr |d}nd}|S)z,stitch together the strings in tuple 'block'rr6rgrk)rz)r�s r&�_code_stitcherz"importable.<locals>._code_stitcher�sa����8�!��b� �!�4�9�9�U�3C�3C�5�5��1�X�!�u�Q�x�u�u��2�Y�!��b� ��� �e�� r'rkrg)r/c3�^K�|](\}}t|���t||d���V��)dS)Tr�N)rr)r<r�rs r&rDzimportable.<locals>.<genexpr>�sD����m�m�;�D��]f�gk�]l�]l�m�y��d��6�6�6�m�m�m�m�m�mr')rrr�r r2rW�NotImplementedErrorr+r]rSr5r-r�rzrNr/r,) r$r�r r�� tried_source� tried_importr0r9�_src�xxxr/s r&r r �s���$�~�#�C���3���e��� ��Y�s�^�^����"'�'�L�<�5 �� $� $��s�#�#�R�&�s�E�%��Q�Q�Q�Q�%�c���H�H�H���s�8�8�q�=�=�-�.?�@�@�@��s�8�8�a�<�<�-�.?�@�@�@��C�J�J�L�L�)�)�!�,�,��� $� $� $��&��#� � � � $����& �!�#�U�3�3�3�C��3�x�x�1�}�}�)�*;�<�<�<� � � �"�>�#�'�'�$�-�-�0�0�D�!�)�D�6�6�r�D��z�z�|�|� )� )��$�n�S�)�)���(�� � �C�(�(�(���t�9�9� &�����T���a����1�g����i�i��o�o�� *� *� *� *� *� *��*�S�/�/�C��m�m�#�)�)�+�+�m�m�m�m�m�C�$'�/�$�)�)�C�.�.�.�R�C�� "�s� �� "�s� ���9� ��� � � �� "�U��L��Z�F�F�F� ����e5 s7�!C�A<C�C#�"C#�'D/H �H �H � H5�4H5c�*�t||| |���S)Nr7)r )r$r��byname�explicits r&r�r��s�� �c�%�F� �H� E� E� E�Er'c�(�t|| |���S�N)rr�)r )r$�passiverBs r&� likely_importrF�s�� �S�g�+�� A� A� A�Ar'c�*�t||| |���SrD)r)�first�lastrErBs r&�_likely_importrJ�s�� �e�T�w�;�� J� J� J�Jr')FFF)FF)rkFFFF)r�)NT)rk)rkFT)rkTF)rkTFF)rkNFTTT)rkF)rkNT)FT)8r��__all__rxrH�inspectrrrrrrrrrrrrr�tokenizer�_dillr rrrerr�rrr�r�r�r�rr�rrQr�rRr�rr�rr r rr r r2r5r r�rFrJ� _get_name�getblocks_from_historyr3r'r&�<module>rQs]���� B� B� B������ � � � �,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,�,� ������������������2�2�2�jY0�Y0�Y0�xD9�D9�D9�D9�N����$9>�CH�Y�Y�Y�Y�xO�O�O����(5�5�5�,�,�,� ����< � � � �I�I�I�I��g�i�i� � �V�X�X� � � � � � � � �$�$�$�$�N����2'�'�'�V+�+�+�+�`0�0�0�0�fDH�CG�:�:�:�:�|2�2�2�2�j%�%�%�%�NN �N �N �N �dF�F�F�F�B�B�B�B�K�K�K�K� � �"���r'
Memory