Ë
    \;jÄ  ã                   ól   — d Z ddlZddlZddlZ	 ddlmZ  G d„ de«      Z	 e	«       Z
y# e$ r eZY Œw xY w)zÔ
Part of the astor library for Python AST manipulation.

License: 3-clause BSD

Copyright (c) 2012-2015 Patrick Maupin
Copyright (c) 2013-2015 Berker Peksag

Functions that interact with the filesystem go here.

é    N)Úopenc                   óP   — e Zd ZdZedd„«       Zed„ «       Zed„ «       Zdd„Zd„ Z	y)	Ú	CodeToAstaw  Given a module, or a function that was compiled as part
    of a module, re-compile the module into an AST and extract
    the sub-AST for the function.  Allow caching to reduce
    number of compiles.

    Also contains static helper utility functions to
    look for python files, to parse python files, and to extract
    the file/line information from a code object.
    Nc              #   óþ   K  — t         j                  j                  | «      s!t         j                  j                  | «      –— t        j                  | «      D ]!  \  }}}|�||v rŒd„ |D «       D ]  }||f–— Œ
 Œ# y­w)zâReturn all the python files in a source tree

        Ignores any path that contains the ignore string

        This is not used by other class methods, but is
        designed to be used in code that uses this class.
        Nc              3   óD   K  — | ]  }|j                  d «      sŒ|–— Œ y­w)ú.pyN)Úendswith)Ú.0Úxs     úXG:\00. PROJECTS\API\Inventory\templateJSON\kerjaOCR\Lib\site-packages\astor/file_util.pyÚ	<genexpr>z*CodeToAst.find_py_files.<locals>.<genexpr>3   s   è ø€ ÐA¡V ¨q¯z©z¸%Õ/@œ!¡Vùs   ‚ ™ )ÚosÚpathÚisdirÚsplitÚwalk)ÚsrctreeÚignoreÚsrcpathÚ_ÚfnamesÚfnames         r   Úfind_py_fileszCodeToAst.find_py_files#   so   è ø€ ô �w‰w�}‰}˜WÔ%Ü—'‘'—-‘- Ó(Ò(Ü"$§'¡'¨'Ö"2ÑˆG�Q˜àÐ! f°Ñ&7ØÙA¡VÖA�Ø˜u�nÓ$ñ Bñ	 #3ùs   ‚A;A=c                 ó¦  — 	 t        | «      5 }|j                  «       }ddd«       j                  dd«      j                  dd«      }|j                  d«      s|dz  }t        j                  || ¬«      S # 1 sw Y   ŒXxY w# t        $ rF | dk7  r‚ t        j                  j                  d«       t        j                  j                  «       }Y Œ©w xY w)zËParse a python file into an AST.

        This is a very thin wrapper around ast.parse

            TODO: Handle encodings other than the default for Python 2
                        (issue #26)
        NÚstdinz
Reading from stdin:

z
Ú
Ú)Úfilename)ÚfopenÚreadÚIOErrorÚsysÚstdoutÚwriter   Úreplacer	   ÚastÚparse)r   ÚfÚfstrs      r   Ú
parse_filezCodeToAst.parse_file6   s©   € ð	$Ü�u” Ø—v‘v“x�÷ ð �|‰|˜F DÓ)×1Ñ1°$¸Ó=ˆØ�}‰}˜TÔ"Ø�D‰LˆDÜ�y‰y˜¨Ô.Ð.÷ �ûäò 	$Ø˜ÒØÜ�J‰J×ÑÐ8Ô9Ü—9‘9—>‘>Ó#ŠDð		$ús(   ‚B �A5žB Á5A>Á:B ÂACÃCc                 ó˜   — t        | dd«      }d}|€$| j                  }|j                  }|j                  }|j	                  dd«      }||fS )zÎReturns the file and line number of a code object.

            If the code object has a __file__ attribute (e.g. if
            it is a module), then the returned line number will
            be 0
        Ú__file__Nr   z.pycr   )ÚgetattrÚ__code__Úco_filenameÚco_firstlinenor%   )Úcodeobjr   ÚlinenumÚ	func_codes       r   Úget_file_infozCodeToAst.get_file_infoL   sW   € ô ˜ ¨TÓ2ˆØˆØˆ=Ø×(Ñ(ˆIØ×)Ñ)ˆEØ×.Ñ.ˆGØ—‘˜f eÓ,ˆØ�gˆ~Ðó    c                 ó   — |xs i | _         y ©N)Úcache)Úselfr8   s     r   Ú__init__zCodeToAst.__init__]   s   € Ø’[˜bˆ�
r5   c                 ó$  — | j                   }| j                  |«      }|j                  |«      }|�|S |d   }| j                  |«      x||df<   }|j                  D ].  }t        |t        j                  «      sŒ||||j                  f<   Œ0 ||   S )Nr   )	r8   r4   Úgetr*   ÚbodyÚ
isinstancer&   ÚFunctionDefÚlineno)r9   r1   r8   ÚkeyÚresultr   Úmod_astÚobjs           r   Ú__call__zCodeToAst.__call__`   s–   € Ø—
‘
ˆØ× Ñ  Ó)ˆØ—‘˜3“ˆØÐØˆMØ�A‘ˆØ&*§o¡o°eÓ&<Ð<ˆˆu�aˆjÑ˜GØ—<”<ˆCÜ˜c¤3§?¡?Ô3ØØ),ˆE�5˜#Ÿ*™*Ð%Ò&ð  ð �S‰zÐr5   r7   )
Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústaticmethodr   r*   r4   r:   rE   © r5   r   r   r      sM   „ ñð ò%ó ð%ð$ ñ/ó ð/ð* ñó ðó !ór5   r   )rI   r&   r"   r   Útokenizer   r   ÚImportErrorÚobjectr   Úcode_to_astrK   r5   r   Ú<module>rP      sL   ðñ
ó Û 
Û 	ðÝ&ô
T�ô Tñn ‹k�øðw ò Ø‚Eðús   �) ©3²3