
    i             	          S r SSKrSSKrSSKrSSKrSSKrSSKJrJrJ	r	  SSK
rSSKrSSKrSSKr\R                   S:  a  SSKJr  OSSKr\R(                  " 5          \R*                  " S\SS9  SSKJr  SS	KJr  SSS5        S
SKJr   " S S5      r " S S5      rSr Sr  \ r!  " S S\"5      r#S r$ " S S\" S/ SQ5      5      r% " S S5      r& " S S\'5      r( " S S\&5      r) " S S\&5      r* " S S \*5      r+ " S! S"\*5      r, " S# S$\*5      r- " S% S&\&5      r. " S' S(\&5      r/ " S) S*\/5      r0 " S+ S,\/5      r1 " S- S.\15      r2 " S/ S0\/5      r3 " S1 S2\/5      r4 " S3 S4\/5      r5 " S5 S6\/5      r6 " S7 S8\5\65      r7 " S9 S:\65      r8 " S; S<\/5      r9 " S= S>\65      r: " S? S@\/5      r; " SA SB\/5      r<SCq=SDq>SEq?SFq@SGqASHqBSI rCSJ rDSr! " SK SL\R                  5      rF " SM SN\5      rGg! , (       d  f       GN{= f)Oa  
Find modules used by a script, using bytecode analysis.

Based on the stdlib modulefinder by Thomas Heller and Just van Rossum,
but uses a graph data structure and 2.3 features

XXX: Verify all calls to _import_hook (and variants) to ensure that
imports are done in the right way.
    N)deque
namedtupledefaultdict)   
   ignorezpkg_resources is deprecated)categorymessage)ObjectGraph)
GraphError   )utilc                       \ rS rSrS rSrg)BUILTIN_MODULE1   c                     gNF )fqnames    TC:\des-py\RoboSAPF\venv\Lib\site-packages\PyInstaller\lib\modulegraph\modulegraph.py
is_packageBUILTIN_MODULE.is_package2   s        r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__r   r   r   r   r   1   s    r   r   c                        \ rS rSrS rS rSrg)NAMESPACE_PACKAGE6   c                     Xl         g Nnamespace_dirs)selfr%   s     r   __init__NAMESPACE_PACKAGE.__init__7   s    ,r   c                     gNTr   )r&   r   s     r   r   NAMESPACE_PACKAGE.is_package:   s    r   r$   N)r   r   r   r   r'   r   r   r   r   r   r    r    6   s    -r   r    c                       \ rS rSrSrg)InvalidRelativeImportError[   r   Nr   r   r   r   r   r   r   r   r.   r.   [       r   r.   c                 n    [         R                  " S[        U 5      5      nUb  UR                  S5      $ U$ )Nz^No module named (\S+)$r   )rematchstrgroup)excdefaultms      r   _path_from_importerrorr:   _   s1     	+SX6A}wwqzNr   c                       \ rS rSrSrS rSrg)DependencyInfom   r   c                     U R                   (       d"  U R                  (       d  U R                  (       a3  UR                   (       dK  UR                  (       d:  UR                  (       d)  [        SSSU R                  =(       a    UR                  S9$ [        U R                   =(       d    UR                   U R                  =(       d    UR                  U R                  =(       d    UR                  U R                  =(       a    UR                  S9$ )NFconditionalfunction	tryexceptfromlist)r@   rA   rB   r<   rC   )r&   others     r   _mergedDependencyInfo._mergedq   s      t~~$$U^^EOO!!95>>	; ; " $ 0 0 EE4E4E!]]<enn"nn?!]]=u~~	? ?r   N)r   r   r   r   	__slots__rE   r   r   r   r   r<   r<   m   s    I?r   r<   r?   c                       \ rS rSrSr/ SQrS rS rS rS r	S r
S	 rS
 rS rS rS rS rS rS rS rS rS rS rS rSrg)Node   a  
Abstract base class (ABC) of all objects added to a `ModuleGraph`.

Attributes
----------
code : codeobject
    Code object of the pure-Python module corresponding to this graph node
    if any _or_ `None` otherwise.
graphident : str
    Synonym of `identifier` required by the `ObjectGraph` superclass of the
    `ModuleGraph` class. For readability, the `identifier` attribute should
    typically be used instead.
filename : str
    Absolute path of this graph node's corresponding module, package, or C
    extension if any _or_ `None` otherwise.
identifier : str
    Fully-qualified name of this graph node's corresponding module,
    package, or C extension.
packagepath : str
    List of the absolute paths of all directories comprising this graph
    node's corresponding package. If this is a:
    * Non-namespace package, this list contains exactly one path.
    * Namespace package, this list contains one or more paths.
_deferred_imports : list
    List of all target modules imported by the source module corresponding
    to this graph node whole importations have been deferred for subsequent
    processing in between calls to the `_ModuleGraph._scan_code()` and
    `_ModuleGraph._process_imports()` methods for this source module _or_
    `None` otherwise. Each element of this list is a 3-tuple
    `(have_star, _safe_import_hook_args, _safe_import_hook_kwargs)`
    collecting the importation of a target module from this source module
    for subsequent processing, where:
    * `have_star` is a boolean `True` only if this is a `from`-style star
      import (e.g., resembling `from {target_module_name} import *`).
    * `_safe_import_hook_args` is a (typically non-empty) sequence of all
      positional arguments to be passed to the `_safe_import_hook()` method
      to add this importation to the graph.
    * `_safe_import_hook_kwargs` is a (typically empty) dictionary of all
      keyword arguments to be passed to the `_safe_import_hook()` method
      to add this importation to the graph.
    Unlike functional languages, Python imposes a maximum depth on the
    interpreter stack (and hence recursion). On breaching this depth,
    Python raises a fatal `RuntimeError` exception. Since `ModuleGraph`
    parses imports recursively rather than iteratively, this depth _was_
    commonly breached before the introduction of this list. Python
    environments installing a large number of modules (e.g., Anaconda) were
    particularly susceptible. Why? Because `ModuleGraph` concurrently
    descended through both the abstract syntax trees (ASTs) of all source
    modules being parsed _and_ the graph of all target modules imported by
    these source modules being built. The stack thus consisted of
    alternating layers of AST and graph traversal. To unwind such
    alternation and effectively halve the stack depth, `ModuleGraph` now
    descends through the abstract syntax tree (AST) of each source module
    being parsed and adds all importations originating within this module
    to this list _before_ descending into the graph of these importations.
    See pyinstaller/pyinstaller/#1289 for further details.
_global_attr_names : set
    Set of the unqualified names of all global attributes (e.g., classes,
    variables) defined in the pure-Python module corresponding to this
    graph node if any _or_ the empty set otherwise. This includes the names
    of all attributes imported via `from`-style star imports from other
    existing modules (e.g., `from {target_module_name} import *`). This
    set is principally used to differentiate the non-ignorable importation
    of non-existent submodules in a package from the ignorable importation
    of existing global attributes defined in that package's pure-Python
    `__init__` submodule in `from`-style imports (e.g., `bar` in
    `from foo import bar`, which may be either a submodule or attribute of
    `foo`), as such imports ambiguously allow both. This set is _not_ used
    to differentiate submodules from attributes in `import`-style imports
    (e.g., `bar` in `import foo.bar`, which _must_ be a submodule of
    `foo`), as such imports unambiguously allow only submodules.
_starimported_ignored_module_names : set
    Set of the fully-qualified names of all existing unparsable modules
    that the existing parsable module corresponding to this graph node
    attempted to perform one or more "star imports" from. If this module
    either does _not_ exist or does but is unparsable, this is the empty
    set. Equivalently, this set contains each fully-qualified name
    `{trg_module_name}` for which:
    * This module contains an import statement of the form
      `from {trg_module_name} import *`.
    * The module whose name is `{trg_module_name}` exists but is _not_
      parsable by `ModuleGraph` (e.g., due to _not_ being pure-Python).
    **This set is currently defined but otherwise ignored.**
_submodule_basename_to_node : dict
    Dictionary mapping from the unqualified name of each submodule
    contained by the parent module corresponding to this graph node to that
    submodule's graph node. If this dictionary is non-empty, this parent
    module is typically but _not_ always a package (e.g., the non-package
    `os` module containing the `os.path` submodule).
)	codefilename
graphident
identifierpackagepath_deferred_imports_global_attr_names"_starimported_ignored_module_names_submodule_basename_to_nodec                     SU l         SU l        Xl        Xl        SU l        SU l        [        5       U l        [        5       U l        [        5       U l
        g)z
Initialize this graph node.

Parameters
----------
identifier : str
    Fully-qualified name of this graph node's corresponding module,
    package, or C extension.
N)rK   rL   rM   rN   rO   rP   setrQ   rR   dictrS   )r&   rN   s     r   r'   Node.__init__   sJ     	$$!%"%%25%/+/6(r   c                     XR                   ;   $ )a  
`True` only if the pure-Python module corresponding to this graph node
defines a global attribute (e.g., class, variable) with the passed
name.

If this module is actually a package, this method instead returns
`True` only if this package's pure-Python `__init__` submodule defines
such a global attribute. In this case, note that this package may still
contain an importable submodule of the same name. Callers should
attempt to import this attribute as a submodule of this package
_before_ assuming this attribute to be an ignorable global. See
"Examples" below for further details.

Parameters
----------
attr_name : str
    Unqualified name of the attribute to be tested.

Returns
----------
bool
    `True` only if this module defines this global attribute.

Examples
----------
Consider a hypothetical module `foo` containing submodules `bar` and
`__init__` where the latter assigns `bar` to be a global variable
(possibly star-exported via the special `__all__` global variable):

>>> # In "foo.__init__":
>>> bar = 3.1415

Python 2 and 3 both permissively permit this. This method returns
`True` in this case (i.e., when called on the `foo` package's graph
node, passed the attribute name `bar`) despite the importability of the
`foo.bar` submodule.
)rQ   r&   	attr_names     r   is_global_attrNode.is_global_attr
  s    N 3333r   c                     XR                   ;   $ )a  
`True` only if the parent module corresponding to this graph node
contains the submodule with the passed name.

If `True`, this parent module is typically but _not_ always a package
(e.g., the non-package `os` module containing the `os.path` submodule).

Parameters
----------
submodule_basename : str
    Unqualified name of the submodule to be tested.

Returns
----------
bool
    `True` only if this parent module contains this submodule.
rS   r&   submodule_basenames     r   is_submoduleNode.is_submodule4  s    & "%E%EEEr   c                 :    U R                   R                  U5        g)a  
Record the global attribute (e.g., class, variable) with the passed
name to be defined by the pure-Python module corresponding to this
graph node.

If this module is actually a package, this method instead records this
attribute to be defined by this package's pure-Python `__init__`
submodule.

Parameters
----------
attr_name : str
    Unqualified name of the attribute to be added.
N)rQ   addrY   s     r   add_global_attrNode.add_global_attrJ  s      	##I.r   c                 N    U R                   R                  UR                   5        g)a  
Record all global attributes (e.g., classes, variables) defined by the
target module corresponding to the passed graph node to also be defined
by the source module corresponding to this graph node.

If the source module is actually a package, this method instead records
these attributes to be defined by this package's pure-Python `__init__`
submodule.

Parameters
----------
target_module : Node
    Graph node of the target module to import attributes from.
N)rQ   update)r&   target_modules     r   add_global_attrs_from_module!Node.add_global_attrs_from_module]  s      	&&}'G'GHr   c                      X R                   U'   g)a  
Add the submodule with the passed name and previously imported graph
node to the parent module corresponding to this graph node.

This parent module is typically but _not_ always a package (e.g., the
non-package `os` module containing the `os.path` submodule).

Parameters
----------
submodule_basename : str
    Unqualified name of the submodule to add to this parent module.
submodule_node : Node
    Graph node of this submodule.
Nr^   )r&   r`   submodule_nodes      r   add_submoduleNode.add_submodulep  s      @N(();<r   c                      U R                   U   $ )a  
Graph node of the submodule with the passed name in the parent module
corresponding to this graph node.

If this parent module does _not_ contain this submodule, an exception
is raised. Else, this parent module is typically but _not_ always a
package (e.g., the non-package `os` module containing the `os.path`
submodule).

Parameters
----------
module_basename : str
    Unqualified name of the submodule to retrieve.

Returns
----------
Node
    Graph node of this submodule.
r^   r_   s     r   get_submoduleNode.get_submodule  s    * //0BCCr   c                 8    U R                   R                  U5      $ )a  
Graph node of the submodule with the passed unqualified name in the
parent module corresponding to this graph node if this module contains
this submodule _or_ `None`.

This parent module is typically but _not_ always a package (e.g., the
non-package `os` module containing the `os.path` submodule).

Parameters
----------
submodule_basename : str
    Unqualified name of the submodule to retrieve.

Returns
----------
Node
    Graph node of this submodule if this parent module contains this
    submodule _or_ `None`.
)rS   getr_   s     r   get_submodule_or_noneNode.get_submodule_or_none  s    * //334FGGr   c                 h    U R                  U5      (       a  U R                  R                  U5        gg)aj  
Record the global attribute (e.g., class, variable) with the passed
name if previously recorded as defined by the pure-Python module
corresponding to this graph node to be subsequently undefined by the
same module.

If this module is actually a package, this method instead records this
attribute to be undefined by this package's pure-Python `__init__`
submodule.

This method is intended to be called on globals previously defined by
this module that are subsequently undefined via the `del` built-in by
this module, thus "forgetting" or "undoing" these globals.

For safety, there exists no corresponding `remove_global_attr()`
method. While defining this method is trivial, doing so would invite
`KeyError` exceptions on scanning valid Python that lexically deletes a
global in a scope under this module's top level (e.g., in a function)
_before_ defining this global at this top level. Since `ModuleGraph`
cannot and should not (re)implement a full-blown Python interpreter,
ignoring out-of-order deletions is the only sane policy.

Parameters
----------
attr_name : str
    Unqualified name of the attribute to be removed.
N)r[   rQ   removerY   s     r   remove_global_attr_if_found Node.remove_global_attr_if_found  s.    : y))##**95 *r   c                 Z     [        US5      nU R                  U:H  $ ! [         a     gf = f)NrM   FgetattrAttributeErrorrM   r&   rD   
otherIdents      r   __eq__Node.__eq__  s8    	 5J *,,  		    
**c                 Z     [        US5      nU R                  U:g  $ ! [         a     gf = f)NrM   Tr|   r   s      r   __ne__Node.__ne__  s8    	 5J *,,  		r   c                 f     [        US5      nU R                  U:  $ ! [         a	    [        s $ f = fNrM   r}   r~   NotImplementedrM   r   s      r   __lt__Node.__lt__  ;    	" 5J ++  	"!!	"    00c                 f     [        US5      nU R                  U:*  $ ! [         a	    [        s $ f = fr   r   r   s      r   __le__Node.__le__  ;    	" 5J *,,  	"!!	"r   c                 f     [        US5      nU R                  U:  $ ! [         a	    [        s $ f = fr   r   r   s      r   __gt__Node.__gt__  r   r   c                 f     [        US5      nU R                  U:  $ ! [         a	    [        s $ f = fr   r   r   s      r   __ge__Node.__ge__  r   r   c                 ,    [        U R                  5      $ r#   )hashrM   r&   s    r   __hash__Node.__hash__  s    DOO$$r   c                     U R                   4$ r#   )rN   r   s    r   	infoTupleNode.infoTuple  s    !!r   c                 T    [        U 5      R                  < U R                  5       < 3$ r#   )typer   r   r   s    r   __repr__Node.__repr__	  s    d,,dnn.>??r   )	rP   rQ   rR   rS   rK   rL   rM   rN   rO   N)r   r   r   r   __doc__rG   r'   r[   ra   re   rj   rn   rq   ru   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   rI   rI      sr    Yv
I2,'4TF,/&I&N&D0H06@--,-,-%"@r   rI   c                       \ rS rSrSrSrg)Aliasi  a  
Placeholder aliasing an existing source module to a non-existent target
module (i.e., the desired alias).

For obscure reasons, this class subclasses `str`. Each instance of this
class is the fully-qualified name of the existing source module being
aliased. Unlike the related `AliasNode` class, instances of this class are
_not_ actual nodes and hence _not_ added to the graph; they only facilitate
communication between the `ModuleGraph.alias_module()` and
`ModuleGraph.find_node()` methods.
r   Nr   r   r   r   r   r   r   r   r   r   r     s    
r   r   c                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )	AliasNodei  z
Graph node representing the aliasing of an existing source module under a
non-existent target module name (i.e., the desired alias).
c                 N   > [         [        U ]  U5        U R                  U5        g)a  
Initialize this alias.

Parameters
----------
name : str
    Fully-qualified name of the non-existent target module to be
    created (as an alias of the existing source module).
node : Node
    Graph node of the existing source module being aliased. Optional;
    if not provided here, the attributes from referred node should
    be copied later using `copyAttributesFromReferredNode` method.
N)superr   r'   copyAttributesFromReferredNode)r&   namenode	__class__s      r   r'   AliasNode.__init__!  s$     	i'- 	++D1r   c           	      d    S H*  n[        X5      (       d  M  [        X[        X5      5        M,     g)zX
Copy a subset of attributes from referred node (source module) into this target alias.
)rN   rO   rQ   rR   rS   N)hasattrsetattrr}   )r&   r   rZ   s      r   r   (AliasNode.copyAttributesFromReferredNode4  s*    +I t'')AB+r   c                 2    U R                   U R                  4$ r#   )rM   rN   r   s    r   r   AliasNode.infoTupleB  s    11r   r   r#   )
r   r   r   r   r   r'   r   r   r   __classcell__r   s   @r   r   r     s    
2&C2 2r   r   c                       \ rS rSrSrg)	BadModuleiF  r   Nr0   r   r   r   r   r   F  r1   r   r   c                       \ rS rSrSrg)ExcludedModuleiJ  r   Nr0   r   r   r   r   r   J  r1   r   r   c                       \ rS rSrSrg)MissingModuleiN  r   Nr0   r   r   r   r   r   N  r1   r   r   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )InvalidRelativeImportiR  c                    > UnUR                  S5      (       a  X2-  nOUSU-   -  n[        [        U ]  U5        Xl        X l        g )N.)endswithr   r   r'   relative_path	from_name)r&   r   r   rN   r   s       r   r'   InvalidRelativeImport.__init__S  sJ    "
!!#&&#J#	/)J#T3J?*"r   c                 2    U R                   U R                  4$ r#   )r   r   r   s    r   r   InvalidRelativeImport.infoTuple]  s    ""DNN33r   )r   r   r   r   r   r   r'   r   r   r   r   s   @r   r   r   R  s    #4 4r   r   c                   .   ^  \ rS rSrU 4S jrS rSrU =r$ )Scriptia  c                 8   > [         [        U ]  U5        Xl        g r#   )r   r   r'   rL   )r&   rL   r   s     r   r'   Script.__init__b  s    fd$X. r   c                     U R                   4$ r#   rL   r   s    r   r   Script.infoTuplef  s    r   r   r   r   s   @r   r   r   a  s    !   r   r   c                   2   ^  \ rS rSrSU 4S jjrS rSrU =r$ )
BaseModuleij  c                 D   > [         [        U ]  U5        X l        X0l        g r#   )r   r   r'   rL   rO   )r&   r   rL   pathr   s       r   r'   BaseModule.__init__k  s    j$(. r   c                 n    [        [        S U R                  U R                  U R                  45      5      $ r#   )tuplefilterrN   rL   rO   r   s    r   r   BaseModule.infoTuplep  s)    VD4??DMM4CSCS"TUVVr   )rL   rO   )NNr   r   s   @r   r   r   j  s     
W Wr   r   c                       \ rS rSrSrg)BuiltinModuleit  r   Nr0   r   r   r   r   r   t  r1   r   r   c                       \ rS rSrSrg)SourceModuleix  r   Nr0   r   r   r   r   r   x  r1   r   r   c                       \ rS rSrSrg)InvalidSourceModulei|  r   Nr0   r   r   r   r   r   |  r1   r   r   c                       \ rS rSrSrg)CompiledModulei  r   Nr0   r   r   r   r   r     r1   r   r   c                       \ rS rSrSrg)InvalidCompiledModulei  r   Nr0   r   r   r   r   r     r1   r   r   c                       \ rS rSrSrg)	Extensioni  r   Nr0   r   r   r   r   r     r1   r   r   c                       \ rS rSrSrSrg)Packagei  z2
Graph node representing a non-namespace package.
r   Nr   r   r   r   r   r          	r   r   c                       \ rS rSrSrSrg)ExtensionPackagei  zU
Graph node representing a package where the __init__ module is an extension
module.
r   Nr   r   r   r   r   r     s     	r   r   c                       \ rS rSrSrSrg)NamespacePackagei  z.
Graph node representing a namespace package.
r   Nr   r   r   r   r   r     r   r   r   c                       \ rS rSrSrSrg)RuntimeModulei  a  
Graph node representing a non-package Python module dynamically defined at
runtime.

Most modules are statically defined on-disk as standard Python files.
Some modules, however, are dynamically defined in-memory at runtime
(e.g., `gi.repository.Gst`, dynamically defined by the statically
defined `gi.repository.__init__` module).

This node represents such a runtime module. Since this is _not_ a package,
all attempts to import submodules from this module in `from`-style import
statements (e.g., the `queue` submodule in `from six.moves import queue`)
will be silently ignored.

To ensure that the parent package of this module if any is also imported
and added to the graph, this node is typically added to the graph by
calling the `ModuleGraph.add_module()` method.
r   Nr   r   r   r   r   r         $ 	r   r   c                       \ rS rSrSrSrg)RuntimePackagei  a  
Graph node representing a non-namespace Python package dynamically defined
at runtime.

Most packages are statically defined on-disk as standard subdirectories
containing `__init__.py` files. Some packages, however, are dynamically
defined in-memory at runtime (e.g., `six.moves`, dynamically defined by
the statically defined `six` module).

This node represents such a runtime package. All attributes imported from
this package in `from`-style import statements that are submodules of this
package (e.g., the `queue` submodule in `from six.moves import queue`) will
be imported rather than ignored.

To ensure that the parent package of this package if any is also imported
and added to the graph, this node is typically added to the graph by
calling the `ModuleGraph.add_module()` method.
r   Nr   r   r   r   r   r     r   r   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )FlatPackagei  c                 b   > [         R                  " S[        5        [        [        /UQ70 UD6  g Nz=This class will be removed in a future version of modulegraphwarningswarnDeprecationWarningr   r   r&   argskwdsr   s      r   r'   FlatPackage.__init__  )    K	  	k)D)D)r   r   r   r   r   r   r'   r   r   r   s   @r   r   r         * *r   r   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )ArchiveModulei  c                 b   > [         R                  " S[        5        [        [        /UQ70 UD6  g r   r   r   s      r   r'   ArchiveModule.__init__  r   r   r   r   r   s   @r   r  r    r  r   r  a  <!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>%(TITLE)s</title>
    <style>
      .node { padding: 0.5em 0 0.5em; border-top: thin grey dotted; }
      .moduletype { font: smaller italic }
      .node a { text-decoration: none; color: #006699; }
      .node a:visited { text-decoration: none; color: #2f0099; }
    </style>
  </head>
  <body>
    <h1>%(TITLE)s</h1>zB
<div class="node">
  <a name="%(NAME)s"></a>
  %(CONTENT)s
</div>z:<tt>%(NAME)s</tt> <span class="moduletype">%(TYPE)s</span>zp<a target="code" href="%(URL)s" type="text/plain"><tt>%(NAME)s</tt></a>
<span class="moduletype">%(TYPE)s</span>z6  <div class="import">
%(HEAD)s:
  %(LINKS)s
  </div>
z
  </body>
</html>c                     / nU  HP  n[        U[        R                  5      (       a  UR                  UR                  5        M?  UR                  U5        MR     U Vs/ s H  o3S:w  d  M
  UPM     nnU$ s  snf )N__main__)
isinstanceastaliasappendr   )namesresultnmrs       r   
_ast_namesr    sb    Fb#))$$MM"''"MM"	   3A
?aF3M 4s   	A4*A4c                     [        5       nUR                  nU  Vs/ s H  o3U;   a  M
  U" U5      (       a  M  UPM     sn$ s  snf )z/Remove duplicates from a list, preserving order)rU   rd   )seqseenseen_addxs       r   uniqr    s8     5DxxH=s!9AAs===s   	A A A c                       \ rS rSrS r\S 5       r\S 5       r\S 5       rS r	S r
S rS	 rS
 r\rS rS rS r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r\r \rSr!g)_Visitori  c                 b    Xl         X l        [        U l        S/U l        S/U l        S/U l        g r   )_graph_moduleDEFAULT_IMPORT_LEVEL_level_in_if_in_def_in_tryexcept)r&   graphmodules      r   r'   _Visitor.__init__  s/    *gw#Wr   c                      U R                   S   $ Nr,   )r  r   s    r   in_if_Visitor.in_if&  s    {{2r   c                      U R                   S   $ r%  )r  r   s    r   in_def_Visitor.in_def*  s    ||Br   c                      U R                   S   $ r%  )r   r   s    r   in_tryexcept_Visitor.in_tryexcept.  s    !!"%%r   c                    SnUb$  [        U5      nSU;   a  UR                  S5        SnU R                  R                  R	                  UXR                  X#4S[        U R                  U R                  U R                  SS9045        g )NF*T	edge_attr)r@   rB   rA   rC   )	r  rx   r  rP   r  r<   r&  r,  r)  )r&   r   rC   level	have_stars        r   _collect_import_Visitor._collect_import3  s    	H~Hh$ 	 	&&--LL(2>!ZZ,,++	! "#	$r   c                 v    [        UR                  5       H   nU R                  US U R                  5        M"     g r#   )r  r  r3  r  )r&   r   r  s      r   visit_Import_Visitor.visit_ImportG  s+    TZZ(B  T4;;7 )r   c                     UR                   S:w  a  UR                   OU R                  nU R                  UR                  =(       d    S[	        UR
                  5      U5        g )Nr    )r1  r  r3  r"  r  r  )r&   r   r1  s      r   visit_ImportFrom_Visitor.visit_ImportFromK  s?    "jjAo

4;;T[[.B
4::0FNr   c                     U R                   R                  S5        U R                  U5        U R                   R                  5         g r*   )r  r  generic_visitpopr&   r   s     r   visit_If_Visitor.visit_IfO  s0    4 4 r   c                     U R                   R                  S5        U R                  U5        U R                   R                  5         g r*   )r  r  r=  r>  r?  s     r   visit_FunctionDef_Visitor.visit_FunctionDefT  s2    D!4 r   c                     U R                   R                  S5        U R                  U5        U R                   R                  5         g r*   r   r  r=  r>  r?  s     r   	visit_Try_Visitor.visit_Try[  6    !!$'4  r   c                     U R                   R                  S5        U R                  U5        U R                   R                  5         g r*   rF  r?  s     r   visit_TryExcept_Visitor.visit_TryExcept`  rI  r   c                     g r#   r   r?  s     r   visit_Expression_Visitor.visit_Expressione  s     	r   )r  r  r  r   r  r  N)"r   r   r   r   r'   propertyr&  r)  r,  r3  r6  r:  r@  rC  visit_AsyncFunctionDefrG  rK  rN  visit_BoolOpvisit_BinOpvisit_UnaryOpvisit_Lambdavisit_IfExp
visit_Dict	visit_Setvisit_ListCompvisit_SetCompvisit_GeneratorExpvisit_Comparevisit_Yieldvisit_YieldFromvisit_Await
visit_Callr   r   r   r   r  r    s    %       & &$(8O

 /!
!
 $L"K$M#L"K!J I%N$M%N)$M"K&O"K!J"Kr   r  c                   t  ^  \ rS rSrSrU 4S jrS'U 4S jjrS rS(S jrS r	\	r
S)S	 jr\rS
 rS rS rS*U 4S jjr\rS)U 4S jjr\r\R*                  rS(S jrSS\S4S jrS r\4S jrS rS rS rS rS r S r!S r"\S4S jr# S(S jr$S r%S r&S r'S(S jr(S  r)S(S! jr*S+S" jr+S,S# jr,S$ r-S% r.S&r/U =r0$ )-ModuleGraphi  zf
Directed graph whose nodes represent modules and edges represent
dependencies between these modules.
c                 `   > U R                  U5      nUc  [        [        U ]  " X/UQ70 UD6nU$ r#   )	find_noder   rb  
createNode)r&   clsr   r   kwr9   r   s         r   re  ModuleGraph.createNode  s6    NN4 9k43CKKKAr   Nc                   > [         [        U ]  XVS9  Uc  [        R                  nXl        0 U l        U R
                  R                  [        U5      5        U H  nS U R
                  U'   M     X0l        0 U l	        0 U l
        g )N)r!  debug)r   rb  r'   sysr   	lazynodesrh   rV   replace_paths_package_path_map_legacy_ns_packages)	r&   r   excludesrm  impliesr!  rj  r9   r   s	           r   r'   ModuleGraph.__init__  sw    k4))C<88D	d7m,A $DNN1 * "$ $& r   c                    [        S 5      n[        R                  " 5        H  nUR                  S5      nUc  M  UR	                  5       n[        US5      nUc  M:  U HY  n[        R                  R                  " [        UR                  5      /UR                  S5      Q76 nX   R                  U5        M[     M     UR                  5        VVs0 s H  u  pWU[        U5      _M     snnU l        gs  snnf )z
Resolve extra package `__path__` entries for legacy setuptools-based
namespace packages, by reading `namespace_packages.txt` from dist
metadata.
c                      [        5       $ r#   )rU   r   r   r   <lambda><ModuleGraph.scan_legacy_namespace_packages.<locals>.<lambda>  s    r   znamespace_packages.txtN_pathr   )r   importlib_metadatadistributions	read_text
splitlinesr}   osr   joinr5   parentsplitrd   itemslistro  )r&   legacy_ns_packagesdistns_packages	dist_pathpackage_namer   pathss           r   scan_legacy_namespace_packages*ModuleGraph.scan_legacy_namespace_packages  s     )7&446D..)ABK"%002Kg.I  +ww||	(()!'', #044T: !, 7& (:'?'?'A$
'A# $u+%'A$
  $
s   C4c                     [        U[        5      (       a  U R                  XU5        g[        U[        5      (       a  [	        U5      eU R                  X!S5      nU H  nU R                  XU5        M     g)a  
Create a reference from the passed source node to the passed other node,
implying the former to depend upon the latter.

While the source node _must_ be an existing graph node, the target node
may be either an existing graph node _or_ a fully-qualified module name.
In the latter case, the module with that name and all parent packages of
that module will be imported _without_ raising exceptions and for each
newly imported module or package:

* A new graph node will be created for that module or package.
* A reference from the passed source node to that module or package will
  be created.

This method allows dependencies between Python objects _not_ importable
with standard techniques (e.g., module aliases, C extensions).

Parameters
----------
node : str
    Graph node for this reference's source module or package.
other : {Node, str}
    Either a graph node _or_ fully-qualified name for this reference's
    target module or package.
N)r  rI   _updateReferencer   
ValueError_safe_import_hook)r&   r   rD   	edge_dataotherss        r   implyNodeReferenceModuleGraph.implyNodeReference  se    6 eT""!!$y9%'' ''++E>F%%d9=  r   c                 N    U R                  U5      nU R                  U5      u  p4U$ )z\
Yield all nodes that `fromnode` dependes on (that is,
all modules that `fromnode` imports.
)rd  	get_edges)r&   fromnoder   	out_edges_s        r   outgoingModuleGraph.outgoing  s(     ~~h'~~d+	r   c              #      #    U R                  U5      nU R                  U5      u  pEU(       aB  U H;  n[        U[        5      (       a  U R	                  US5       H  nUv   M	     M7  Uv   M=     g U H  nUv   M	     g 7fr   )rd  r  r  r   incoming)r&   tonodecollapse_missing_modulesr   r  in_edgesns          r   r  ModuleGraph.incoming  so     ~~f%nnT*#a//!]]1e4 5 G   s   A<A>c                     U R                  U5      nU R                  U5      nU R                  R                  X5      SL$ )z=Return True iff there is an edge from 'fromnode' to 'tonode' N)rd  r!  edge_by_node)r&   r  r  s      r   hasEdgeModuleGraph.hasEdge  s8    >>(+'zz&&x8DDr   c                    U R                  U5      nU R                  5        GH%  nUR                  R                  UR                  S-   5      (       d  M3  U R	                  U5      u  pEU H\  nUR                  R                  UR                  S-   5      (       a  M2  U R                  X&5      (       a  MJ  U R                  X&S5        M^     U H\  nUR                  R                  UR                  S-   5      (       a  M2  U R                  Xb5      (       a  MJ  U R                  XbS5        M^     U R                  R                  U5        GM(     g)z
Create edges to/from `packagenode` based on the edges to/from all
submodules of that package _and_ then hide the graph nodes
corresponding to those submodules.
r   zpkg-internal-importz
pkg-importN)	rd  nodesrN   
startswithr  r  r  r!  	hide_node)r&   packagenodepkgr  iter_outiter_incrD   s          r   foldReferencesModuleGraph.foldReferences  s    nn[)A<<**3>>C+?@@!%!2H!##..s~~/CDD||C//))#6KL " "##..s~~/CDD||E//))%lC " JJ  #+ r   c                 4    U R                  X5      n[	        U[
        5      (       a  [	        U[
        5      (       d  U R                  XU5        g U R                  XUR                  U5      5        g ! [        [        4 a    U R                  XU5      s $ f = fr#   )edgeDataKeyErrorr   add_edger  r<   updateEdgeDatarE   )r&   r  r  r  eds        r   r  ModuleGraph._updateReference0  s    	>x0B 2~..:i3X3X)<"**Y2GH *% 	>==9==	>s   A2 2"BBc                 (   > [         [        U ]  XUS9$ )z,
Create a reference from fromnode to tonode
r  )r   rb  createReference)r&   r  r  r  r   s       r   r  ModuleGraph.add_edge;  s     [$7T]7^^r   c                   > [         [        U ]  U5      nUb  U$ XR                  ;   a  U R                  R	                  U5      nUc  U R                  [        U5      nU$ [        U[        5      (       a[  U R                  [        U5      nU R                  USS5      R	                  5       nUR                  U5        U R                  XV5        U$ U R                  USS5      R	                  5       nU H  nU R                  XW5        M     U$ g)ao  
Graph node uniquely identified by the passed fully-qualified module
name if this module has been added to the graph _or_ `None` otherwise.

If (in order):

. A namespace package with this identifier exists _and_ the passed
  `create_nspkg` parameter is `True`, this package will be
  instantiated and returned.
. A lazy node with this identifier and:
  * No dependencies exists, this node will be instantiated and
    returned.
  * Dependencies exists, this node and all transitive dependencies of
    this node be instantiated and this node returned.
. A non-lazy node with this identifier exists, this node will be
  returned as is.

Parameters
----------
name : str
    Fully-qualified name of the module whose graph node is to be found.
create_nspkg : bool
    Ignored.

Returns
----------
Node
    Graph node of this module if added to the graph _or_ `None`
    otherwise.
N)r   rb  findNoderl  r>  re  r   r  r   r   r  r   r  )	r&   r   create_nspkgdatadepsr9   rD   depr   s	           r   rd  ModuleGraph.find_nodeC  s   @ [$06K>>!>>%%d+D|OOND92 H1 D%(( OOIt4 ..tT4@DDF
 007''1 H	 **4t<@@BC++A3   Hr   c                    U R                  SSU5        [        R                  R                  U5      nU R	                  U5      nUb  U$ [        US5       nUR                  5       nSSS5        [        R                  R                  W5      n[        XQS[        R                  S5      n[        XaSSS5      nU R                  [        U5      nU R                  X#S5        U R!                  X7U5      nU R#                  U5        Xsl        U R&                  (       a   U R)                  UR$                  5      Ul        U$ ! , (       d  f       N= f)z|
Create a node by path (not module name).  It is expected to be a Python
source file, and will be scanned for dependencies.
   
run_scriptNrbexecTr   )msgr|  r   realpathrd  openread	importlibr   decode_sourcecompiler	  PyCF_ONLY_ASTre  r   r  
_scan_code_process_importsrK   rm  _replace_paths_in_code)	r&   pathnamecallerr9   fpcontentsco_astcor  s	            r   
add_scriptModuleGraph.add_script  s   
 	L(+77##H-NN8$=H(D!RwwyH ">>//9VS5F5FMVvq$7OOFH-f.OOA6*a 008AF "!s   D;;
E	c                    U R                  SSXX$5        U R                  U5      nU R                  XaU5      u  pqU R                  SSXq5        UnU(       a  UR	                  S5      n	U	S:  a  [        U5      n	USU	 XS-   S pUR                  < SU
< 3nU R                  XU5      nUc*  U R                  SS	U5        [        S
[        U5      -   5      eU(       a  M  U R                  SSU5        UnU/nU(       aK  [        U[        [        45      (       a0  U R                  X5       H  nX;  d  M
  UR                  U5        M     U H  nU R!                  X,US9  M     U$ )aC  
Import the module with the passed name, all parent packages of this
module, _and_ all submodules and attributes in this module with the
passed names from the previously imported caller module signified by
the passed graph node.

Unlike most import methods (e.g., `_safe_import_hook()`), this method
is designed to be publicly called by both external and internal
callers and hence is public.

Parameters
----------
target_module_partname : str
    Partially-qualified name of the target module to be imported. See
    `_safe_import_hook()` for further details.
source_module : Node
    Graph node for the previously imported **source module** (i.e.,
    module containing the `import` statement triggering the call to
    this method) _or_ `None` if this module is to be imported in a
    "disconnected" manner. **Passing `None` is _not_ recommended.**
    Doing so produces a disconnected graph in which the graph node
    created for the module to be imported will be disconnected and
    hence unreachable from all other nodes -- which frequently causes
    subtle issues in external callers (namely PyInstaller, which
    silently ignores unreachable nodes).
target_attr_names : list
    List of the unqualified names of all submodules and attributes to
    be imported from the module to be imported if this is a "from"-
    style import (e.g., `[encode_base64, encode_noop]` for the import
    `from email.encoders import encode_base64, encode_noop`) _or_
    `None` otherwise.
level : int
    Whether to perform an absolute or relative import. See
    `_safe_import_hook()` for further details.

Returns
----------
list
    List of the graph nodes created for all modules explicitly imported
    by this call, including the passed module and all submodules listed
    in `target_attr_names` _but_ excluding all parent packages
    implicitly imported by this call. If `target_attr_names` is `None`
    or the empty list, this is guaranteed to be a list of one element:
    the graph node created for the passed module.

Raises
----------
ImportError
    If the target module to be imported is unimportable.
r   _import_hook   	load_tailr   r   Nr   "raise ImportError: No module namedNo module named zload_tail ->r  )r  _determine_parent_find_head_packagemsginfindlenrN   _safe_import_modulemsgoutImportErrorreprr  r   r   %_import_importable_package_submodulesr  r  )r&   target_module_partnamesource_moduletarget_attr_namesr1  r0  source_packagetarget_package	submoduleiheadmnameri   target_modulestarget_submodules                  r   import_hookModuleGraph.import_hook  s   t 	N$:=`//>151H1HE2;. 	

1k>J"	$&++C0A1u./+A,+aCD1 )(33T:E00iHI  ACUK!"4tE{"BCC %$ 	A~y1!' M-4i,@"B "B$($N$N%2 #9"))*:;%2 ,M!!	 " C , r   c                 H   U R                  SSU5        SnU(       ar  UR                  n[        U[        5      (       a  UnONSU;   a&  USUR	                  S5       nU R                  U5      nO"UR                  (       a  U R                  U5      nU R                  SSU5        U$ )z*
Determine the package containing a node.
r  determine_parentNr   zdetermine_parent ->)r  rN   r  r   rfindrd  rO   r  )r&   r  r~  pnames       r   r  ModuleGraph._determine_parent  s     	

1(&1%%E&'**/u{{3/0.## .A,f5r   c           
         U R                  SSXU5        SU;   a  UR                  SS5      u  pEOUnSnU[        :X  a  U(       a  UR                  S-   U-   nGO!UnGOU[        :X  a  UnSnGOUc*  U R                  SS5        [        S	U< S
U< SU< S35      e[        US-
  5       H  nSUR                  ;  a*  U R                  SS5        [        S	U< S
U< SU< S35      eUR                  R                  SS5      S   nU R                  U5      n	U	c*  U R                  SS5        [        S	U< S
U< SU< S35      eXLd   X45       eU	nM     U(       a  UR                  S-   U-   nOUR                  nU R                  XFU5      n
U
c#  Ub   U[        ::  a  UnSnU R                  XFU5      n
U
b  U R                  SSX45        X4$ U R                  SSU5        [        SU-   5      e)a.  
Import the target package providing the target module with the passed
name to be subsequently imported from the previously imported source
package corresponding to the passed graph node.

Parameters
----------
source_package : Package
    Graph node for the previously imported **source package** (i.e.,
    package containing the module containing the `import` statement
    triggering the call to this method) _or_ `None` if this module is
    to be imported in a "disconnected" manner. **Passing `None` is
    _not_ recommended.** See the `_import_hook()` method for further
    details.
target_module_partname : str
    Partially-qualified name of the target module to be imported. See
    `_safe_import_hook()` for further details.
level : int
    Whether to perform absolute or relative imports. See the
    `_safe_import_hook()` method for further details.

Returns
----------
(target_package, target_module_tailname)
    2-tuple describing the imported target package, where:
    * `target_package` is the graph node created for this package.
    * `target_module_tailname` is the unqualified name of the target
      module to be subsequently imported (e.g., `text` when passed a
      `target_module_partname` of `email.mime.text`).

Raises
----------
ImportError
    If the package to be imported is unimportable.
r  find_head_packager   r   r9  Nr  z"Relative import outside of packagez)Relative import outside of package (name=z	, parent=, level=)r   zfind_head_package ->r  r  )r  r  !ABSOLUTE_OR_RELATIVE_IMPORT_LEVELrN   ABSOLUTE_IMPORT_LEVELr  r.   rangersplitrd  r  r  r  )r&   r  r  r1  target_module_headnametarget_module_tailnametarget_package_namer  p_fqdn
new_parentr  s              r   r  ModuleGraph._find_head_package8  sV   P 	

1)>SXY ((&,,S!4 ;"$: &<"%'" 55&4&?&?#&EH^&^#&<#++"8 "N %@A0.GH H 519%n777HHQ DE42NEKL L (2299#qA!D!^^F3
%HHQ DE42NEKL L "7 0:0 07!+% &( &"--36LL $ '5&?&?# 11"I !n&@UNcEc"8!N "55&^MN %KK1N3[\!99 	A;=PQ,/BBCCr   c              #     #    [        U5      nU R                  SSX5        SU;   a1  UR                  U R                  U5      5        UR	                  S5        U H  nUR                  U5      nUck  UR                  S-   U-   nU R                  X5U5      nUcD  UR                  U5      (       a   U R                  SSUR                  U5        Mt  [        SU-   5      eUv   M     U R                  SS5        g7f)	a  
Generator importing and yielding each importable submodule (of the
previously imported package corresponding to the passed graph node)
whose unqualified name is in the passed list.

Elements of this list that are _not_ importable submodules of this
package are either:

* Ignorable attributes (e.g., classes, globals) defined at the top
  level of this package's `__init__` submodule, which will be ignored.
* Else, unignorable unimportable submodules, in which case an
  exception is raised.

Parameters
----------
package : Package
    Graph node of the previously imported package containing the
    modules to be imported and yielded.

attr_names : list
    List of the unqualified names of all attributes of this package to
    attempt to import as submodules. This list will be internally
    converted into a set, safely ignoring any duplicates in this list
    (e.g., reducing the "from"-style import
    `from foo import bar, car, far, bar, car, far` to merely
    `from foo import bar, car, far`).

Yields
----------
Node
    Graph node created for the currently imported submodule.

Raises
----------
ImportError
    If any attribute whose name is in `attr_names` is neither:
    * An importable submodule of this package.
    * An ignorable global attribute (e.g., class, variable) defined at
      the top level of this package's `__init__` submodule.
    In this case, this attribute _must_ be an unimportable submodule of
    this package.
r  r  r/  Nr   zD_import_importable_package_submodules: ignoring from-imported globalr  z(_import_importable_package_submodules ->)rU   r  rh   _find_all_submodulesrx   ru   rN   r  r[   r  r  )r&   package
attr_namesrZ   r  submodule_names         r   r  1ModuleGraph._import_importable_package_submodules  s    Z _


1=wS
 *d77@Ac"
 $I
  55i@I  !(!3!3c!9I!E !44w8	 $~ --i88$jlsl~l~  AJ  K  **<~*MNN Ou $x 	

1@As   C5C7c              #     #    UR                   (       d  g UR                    H  n [        R                  " U5      nU Hz  n[        R                  R                  5        HG  nUR                  U5      (       d  M  [        R                  R                  U5      S [        U5      *  n  O   Mn  US:w  d  Mv  Uv   M|     M     g ! [        R                  [        4 a    U R                  SSU5         M  f = f7f)Nr  zcan't list directoryr'   )rO   r|  listdirerrorIOErrorr  r  	machineryall_suffixesr   r   basenamer  )r&   r9   r   r  r   suffixs         r   r	   ModuleGraph._find_all_submodules[  s     }} MMD

4( '11>>@F}}V,,!ww//5mF|D A
 :%J  " HHg& 2D9s3   "C4C :C496C43C4 -C1-C40C11C4c                    U R                  SSU< SU< S35        [        U[        5      (       d   S[        U5      -  5       e[        U[        5      (       d   S[        U5      -  5       eU R                  U5      nUb9  [        U[        5      (       a  UR
                  U:X  d  [        SU< SU< S	35      e[        U5      U R                  U'   g)
aI  
Alias the source module to the target module with the passed names.

This method ensures that the next call to findNode() given the target
module name will resolve this alias. This includes importing and adding
a graph node for the source module if needed as well as adding a
reference from the target to source module.

Parameters
----------
src_module_name : str
    Fully-qualified name of the existing **source module** (i.e., the
    module being aliased).
trg_module_name : str
    Fully-qualified name of the non-existent **target module** (i.e.,
    the alias to be created).
r   zalias_module "z" -> ""z"%s" not a module name.NzTarget module "z" already imported as "z".)	r  r  r5   rd  r   rN   r  r   rl  )r&   src_module_nametrg_module_name
trg_modules       r   alias_moduleModuleGraph.alias_moduler  s    $ 	?OTU/3//a1JSQ`Ma1aa//3//a1JSQ`Ma1aa/ ^^O4
!j),,  O3#Z12 2
 +0*@'r   c                    U R                  SSU5        U R                  UR                  5      nUc  U R                  U5        OX:X  d   SU< SU< S35       eUR                  R	                  S5      u  p4nU(       aK  U R                  U5      nUc  U R                  SSU5        gU R                  X5        UR                  XQ5        gg)	a:  
Add the passed module node to the graph if not already added.

If that module has a parent module or package with a previously added
node, this method also adds a reference from this module node to its
parent node and adds this module node to its parent node's namespace.

This high-level method wraps the low-level `addNode()` method, but is
typically _only_ called by graph hooks adding runtime module nodes. For
all other node types, the `import_module()` method should be called.

Parameters
----------
module : BaseModule
    Graph node of the module to be added.
r   
add_moduleNzNew module z != previous r   r  zadd_module parent not found:)r  rd  rN   addNode
rpartitionr  rn   )r&   r"  module_addedparent_namer  module_basenamer~  s          r   r  ModuleGraph.add_module  s    " 	L&) ~~f&7&78LL )cfVb+cc) +1*;*;*F*Fs*K'^^K0F~:KHf-$$_= r   c                 ^    U R                   R                  U/ 5      nUR                  U5        g)a  
Modulegraph does a good job at simulating Python's, but it can not
handle packagepath '__path__' modifications packages make at runtime.

Therefore there is a mechanism whereby you can register extra paths
in this map for a package, and it will be honored.

NOTE: This method has to be called before a package is resolved by
      modulegraph.

Parameters
----------
module : str
    Fully-qualified module name.
directory : str
    Absolute or relative path of the directory to append to the
    '__path__' attribute.
N)rn  
setdefaultr  )r&   r  	directoryr  s       r   append_package_pathModuleGraph.append_package_path  s(    ( &&11,CYr   c                    U R                  SSXU5        U R                  U5      nUc  SnUb-  UR                  b  UR                  nOU R                  SS5        g U R	                  XU5      u  pgU R                  X&U5      u  pIU	b~   [        U	[        R                  5      (       a  U	n
[        XSSS5      n	OSn
U R                  XIU
5      nU R                  U5        U R                  (       a  U R                  U	5      n	Xl        Ub@  U R#                  SSUSU5        U R)                  XC[+        SSSSS9S9  UR-                  X5        U R                  SSU5        U$ ! [
         a  nU R                  SSU-  5         SnAgSnAff = f! [          a-    U R#                  S	S
U5        [$        nU R'                  X5      n Nf = f)a  
Create a new graph node for the module with the passed name under the
parent package signified by the passed graph node _without_ raising
`ImportError` exceptions.

If this module has already been imported, this module's existing graph
node will be returned; else if this module is importable, a new graph
node will be added for this module and returned; else this module is
unimportable, in which case `None` will be returned. Like the
`_safe_import_hook()` method, this method does _not_ raise
`ImportError` exceptions when this module is unimportable.

Parameters
----------
module_partname : str
    Unqualified name of the module to be imported (e.g., `text`).
module_name : str
    Fully-qualified name of this module (e.g., `email.mime.text`).
parent_module : Package
    Graph node of the previously imported parent module containing this
    submodule _or_ `None` if this is a top-level module (i.e.,
    `module_name` contains no `.` delimiters). This parent module is
    typically but _not_ always a package (e.g., the `os.path` submodule
    contained by the `os` module).

Returns
----------
Node
    Graph node created for this module _or_ `None` if this module is
    unimportable.
r   safe_import_moduleNz>safe_import_module -> None (parent_parent.packagepath is None)zsafe_import_module -> None (%r)r  r   Tr   z#safe_import_module: SyntaxError in r  z#safe_import_module create referencez->F)r@   rC   rA   rB   r  zsafe_import_module ->)r  rd  rO   r  _find_moduler  _load_moduler  r	  ASTr  r  r  rm  r  rK   SyntaxErrorr  r   re  r  r<   rn   )r&   module_partnamemodule_nameparent_moduler"  search_dirsr  loaderr7   r  r  r  rf  s                r   r  ModuleGraph._safe_import_module  s   B 	

1*O-X ,> K ( !,,8"/";";K KK#cd#'#4#4#-$A   ,,[FKLV~?!"cgg..!#$Vvq$G!%F;A))!,))!88<"$K $HHQ=vt][ !! %""#	2 "  ''@ 	A.7W  A@3FG$ # ?HH@( .C!__S>F?s+   E A=F	 
F'FF	4G ?G c           	         SSK Jn  U R                  SSXUR                  R                  5        UR                  S5      S   nUR                  U5      (       GaJ  [        U[        5      (       a2  U R                  [        U5      nSUl        UR                  S S  Ul        OU R                  R                  U/ 5      n[        X45      (       a  U R                  [         U5      nOU R                  ["        U5      nX&l        [$        R&                  R)                  U5      R+                  S5      (       d   e[$        R&                  R-                  U5      /U-   Ul        UR                  U R.                  R                  U/ 5      -   Ul        [        U[        5      (       a  US 4$ S nU[0        L a  [2        n	O|[        X45      (       a  [4        n	S	 n
U
" U5      nOZ UR7                  U5      nUb$   [E        XS[F        RH                  S5      n[J        n	O! URQ                  U5      nUb  [R        O[T        n	U R                  X5      nX&l        U RW                  SSU5        Xh4$ ! [8        [:        4 az  n[        U[:        5      (       a   [        UR<                  [8        5      (       d  e U R?                  SS
U SU S35        URA                  U5      nURC                  U5      n S nANS nAff = f! [:         a    S n[L        n	 N[N         a$  n[L        n	U R?                  SSUU5         S nANS nAff = f! [N         a$  nU R?                  SSX.5        [T        n	 S nAGN'S nAff = f)Nr   )ExtensionFileLoaderr  load_moduler   r,   -z	__init__.c                 "   [         R                  R                  U 5      n[         R                  R                  U 5      R	                  S5      S   nS H  n[         R                  R                  XU-   5      n[         R                  R                  U5      (       d  MK   [        US5       nUR                  5       nS S S 5        [        WUS[        R                  S5      nUs  $    g ! , (       d  f       N2= f! [         a  n S nAM  S nAff = f)Nr   r   >   .py.pyir  r  T)r|  r   dirnamer  r  r}  isfiler  r  r  r	  r  	Exception)	extension_filenamer   r  extsrc_filenamer  srcr  es	            r   _co_from_accompanying_source>ModuleGraph._load_module.<locals>._co_from_accompanying_sourcek  s    ww'9:77++,>?EEcJ1M*C#%77<<n#EL77>>,77 !,5"$'')C 6$S,@Q@QSWX!	 + 65 % s*   C9+C(<&C9(
C6	2C99
D	Dz)load_module: failed to obtain source for z: z&! Falling back to reading as raw data!r  Tz load_module: InvalidSourceModulez4load_module: InvalidCompiledModule, Cannot load codezload_module ->),importlib._bootstrap_externalr8  r  r   r   r!  r   r  r    re  r   rL   r%   rO   ro  rt   r   r   r|  r   r  r  r>  rn  r   r   r   
get_sourceUnicodeDecodeErrorr0  __context__r  get_filenameget_datar  r	  r  r   r   r@  get_coder   r   r  )r&   r   r  r5  r8  partnamer9   ns_pkgpathsr  rf  rF  rD  rE  r   r7   s                  r   r.  ModuleGraph._load_module:  s   E

1mV##,,	.$$S)"-X&&&"344OO$4f= 
 & 5 5a 8 #66::62Ff::(8&AA8A%
 ww''1<<[IIII!#!: ;k I MMD,B,B,F,F- AM !-..4y ^#C44C" .h7B,''1> 	" 8I8I4PB&C02B-/^> 5  OOC(
A'+wq '4 ,& a--%amm5GHHG$:Rs +%% & **84ood+9,D # .B-C  "-CHHQ BH " "" ! 0HHQ !019@/C0sO   I ."K,  L0 K)/A0K$$K),L- 	L-	L((L-0
M:MMc                 (	  ^ ^^^^ T R                  SSTTTT5        UUUU4S jnU 4S jnSnSn	 T R                  TTSTUS9n[        U5      S:X  d   SR                  U5      5       eUS   n[        U[        5      (       aB  U	c?  U" 5       (       a3  U" T5      (       a&  T R                  U5        T R!                  TTSSUS9nU$ [        U["        5      (       a  UR%                  SS9nT(       Ga  [        U[&        [(        45      (       Ga  T GH  nUR+                  U5      (       a>  UR-                  U5      nUb*  UU;  a"  T R                  TUUS9  UR                  U5        MX  UR.                  S
-   U-   nT R1                  U5      nUc   T R                  TTU/TUS9  T R1                  U5      nUcY  UR3                  U5      (       d!   SR                  UUR.                  5      5       eT R                  SSSUR.                  U5        GM   U	(       aS  T R1                  U5      (       a  T R                  SSU< SU< S35        O!T R                  SS U< S!U< 35        UUl        UR5                  UU5        Uc  GMr  T R                  UUUS9  T R                  TUUS9  UU;  d  GM  UR                  U5        GM     U$ ! [         al    T R                  SSTTT5        / n
T=(       d    S	 HA  nT R	                  [
        S
T-  T-   U5      nT R                  TXS9  U
R                  U5        MC     U
s $ [         Ga  nU" 5       (       a  T R                  SST< ST< ST< S35        U" T5      n	U	(       an  T/mSmSmT R                  SST< ST< ST< S35         T R                  TTSTUS9nO3! [         a&  nT R                  SS[        U5      5         SnAOSnAff = fUcO  T R                  SS[        W5      5        T R	                  [        [        UT5      5      nT R                  TXS9  U/n SnAGNSnAff = f! [         a=  nT R                  SS[        U5      5        T R	                  [        U5      n SnAGN$SnAff = f)"a  
Import the module with the passed name and all parent packages of this
module from the previously imported caller module signified by the
passed graph node _without_ raising `ImportError` exceptions.

This method wraps the lowel-level `_import_hook()` method. On catching
an `ImportError` exception raised by that method, this method creates
and adds a `MissingNode` instance describing the unimportable module to
the graph instead.

Parameters
----------
target_module_partname : str
    Partially-qualified name of the module to be imported. If `level`
    is:
    * `ABSOLUTE_OR_RELATIVE_IMPORT_LEVEL` (e.g., the Python 2 default)
      or a positive integer (e.g., an explicit relative import), the
      fully-qualified name of this module is the concatenation of the
      fully-qualified name of the caller module's package and this
      parameter.
    * `ABSOLUTE_IMPORT_LEVEL` (e.g., the Python 3 default), this name
      is already fully-qualified.
    * A non-negative integer (e.g., `1`), this name is typically the
      empty string. In this case, this is a "from"-style relative
      import (e.g., "from . import bar") and the fully-qualified name
      of this module is dynamically resolved by import machinery.
source_module : Node
    Graph node for the previously imported **caller module** (i.e.,
    module containing the `import` statement triggering the call to
    this method) _or_ `None` if this module is to be imported in a
    "disconnected" manner. **Passing `None` is _not_ recommended.**
    Doing so produces a disconnected graph in which the graph node
    created for the module to be imported will be disconnected and
    hence unreachable from all other nodes -- which frequently causes
    subtle issues in external callers (e.g., PyInstaller, which
    silently ignores unreachable nodes).
target_attr_names : list
    List of the unqualified names of all submodules and attributes to
    be imported via a `from`-style import statement from this target
    module if any (e.g., the list `[encode_base64, encode_noop]` for
    the import `from email.encoders import encode_base64, encode_noop`)
    _or_ `None` otherwise. Ignored unless `source_module` is the graph
    node of a package (i.e., is an instance of the `Package` class).
    Why? Because:
    * Consistency. The `_import_importable_package_submodules()`
      method accepts a similar list applicable only to packages.
    * Efficiency. Unlike packages, modules cannot physically contain
      submodules. Hence, any target module imported via a `from`-style
      import statement as an attribute from another target parent
      module must itself have been imported in that target parent
      module. The import statement responsible for that import must
      already have been previously parsed by `ModuleGraph`, in which
      case that target module will already be frozen by PyInstaller.
      These imports are safely ignorable here.
level : int
    Whether to perform an absolute or relative import. This parameter
    corresponds exactly to the parameter of the same name accepted by
    the `__import__()` built-in: "The default is -1 which indicates
    both absolute and relative imports will be attempted. 0 means only
    perform absolute imports. Positive values for level indicate the
    number of parent directories to search relative to the directory of
    the module calling `__import__()`." Defaults to -1 under Python 2
    and 0 under Python 3. Since this default depends on the major
    version of the current Python interpreter, depending on this
    default can result in unpredictable and non-portable behaviour.
    Callers are strongly recommended to explicitly pass this parameter
    rather than implicitly accept this default.

Returns
----------
list
    List of the graph nodes created for all modules explicitly imported
    by this call, including the passed module and all submodules listed
    in `target_attr_names` _but_ excluding all parent packages
    implicitly imported by this call. If `target_attr_names` is either
    `None` or the empty list, this is guaranteed to be a list of one
    element: the graph node created for the passed module. As above,
    `MissingNode` instances are created for all unimportable modules.
r   r  c                     > TS L=(       aW    TS L =(       aL    T [         :H  =(       a<    [        T5      [        L =(       a$    TSTR                  R	                  S5      S   -   :H  $ )Nr  r   r  )r  r   r   rN   r!  )r1  r  r  r  s   r   is_swig_candidate8ModuleGraph._safe_import_hook.<locals>.is_swig_candidate  sr    !- H%-H22H '<7H +M44??DQGGH	Ir   c                 .  > [        U R                  S5       nUR                  5       nS S S 5        [        R                  R                  W5      nU(       a  UR                  5       S   OSnTR                  SSU-  5        SU;   $ ! , (       d  f       Nc= f)Nr  r   r9     z%SWIG wrapper candidate first line: %rzautomatically generated by SWIG)r  rL   r  r  r   r  r{  r  )r  r  r  
first_liner&   s       r   is_swig_wrapper6ModuleGraph._safe_import_hook.<locals>.is_swig_wrapper  sx    m,,d3r779 4 ~~33H=H5=,,.q12JHHQ?:NO4
BB 43s   B
BN)r  r1  r0  r  zInvalid relative importr/  r   r  r  zSWIG import candidate (name=z	, caller=r  r  r9  r   zSWIG import (caller=z, fromlist=zSWIG ImportError:zImportError:z@Expected import_hook() toreturn only one module but received: {}r   T)rC   z!No global named {} in {}.__init__z#ignoring imported non-module globalzSWIG import error: z
 basename z already existszSWIG import renamed from z to )r  r  r.   r  re  r   r  r  r  r5   r   r:   r  formatr  
removeNoder  r<   _replacer   r   ra   rq   rN   rd  r[   rn   )r&   r  r  r  r1  r0  rT  rY  r  is_swig_importr  subr9   r  ri   target_submodule_partnamer  target_submodule_names   `````             r   r  ModuleGraph._safe_import_hook  sg   d 	')?Pachi	I 	I	C  
 Z	1!--&"&ey . JNx >"a' 	N66<f^6L	N'
 'q)m]33%*;*=*=}--$ OOM*!33&"&a9 4 FN
 "!i00!**D*9I M-4i,@"B "B .?) !--.GHH'4'B'B1(3$
 (3 ,>A 11 - 0*3 2 5 +112BC  ",,s25NN & $(>>2G#H  $+KB( ((2M/H.I"'&/	 ) 1 ,0>>:O+P(
 ,3#0#?#? 9$; $; ? C J J$=$1$<$<!>? $; !HHQ(;=bdqd|d|  X  Y$ *  $~~.GHH $$% )>(A%C!D !%$%(=(A%C!D %> !1 ; ++-/?A#/))%'79 * N))%'79 * N (~=&--.>?C .?H e * 		KK4e.0ACF(/C/OO$9$'%K2H$H#O%%mQ%La 	 0
 M J	1D !"".uFG "1!?! *@(@%-/*EHHQ -/@%IJC)-)9)92M.2"'&/	 *: *1
 ' C$7SBBC %NCH5 !%!*30FG!I %%!= & G #0UJ	1l ' BNCH=+/??)+@,B(Bso   K A>Q
8Q
!Q
A3Q8
QA Q#N76Q7
O'O"Q"O''AQQ

R2RRc                     / Ul         Ub#  U R                  X5        U R                  XSS9  U$ U R                  XSS9  U$ )a  
Parse and add all import statements from the passed code object of the
passed source module to this graph, recursively.

**This method is at the root of all `ModuleGraph` recursion.**
Recursion begins here and ends when all import statements in all code
objects of all modules transitively imported by the source module
passed to the first call to this method have been added to the graph.
Specifically, this method:

1. If the passed `module_code_object_ast` parameter is non-`None`,
   parses all import statements from this object.
2. Else, parses all import statements from the passed
   `module_code_object` parameter.
1. For each such import statement:
   1. Adds to this `ModuleGraph` instance:
      1. Nodes for all target modules of these imports.
      1. Directed edges from this source module to these target
         modules.
   2. Recursively calls this method with these target modules.

Parameters
----------
module : Node
    Graph node of the module to be parsed.
module_code_object : PyCodeObject
    Code object providing this module's disassembled Python bytecode.
    Ignored unless `module_code_object_ast` is `None`.
module_code_object_ast : optional[ast.AST]
    Optional abstract syntax tree (AST) of this module if any or `None`
    otherwise. Defaults to `None`, in which case the passed
    `module_code_object` is parsed instead.
Returns
----------
module : Node
    Graph node of the module to be parsed.
F)is_scanning_importsT)rP   	_scan_ast_scan_bytecode)r&   r"  module_code_objectmodule_code_object_asts       r   r  ModuleGraph._scan_codeI	  se    Z $& 
 "-NN6:    G     F r   c                 <    [        X5      nUR                  U5        g)a9  
Parse and add all import statements from the passed abstract syntax
tree (AST) of the passed source module to this graph, non-recursively.

Parameters
----------
module : Node
    Graph node of the module to be parsed.
module_code_object_ast : ast.AST
    Abstract syntax tree (AST) of this module to be parsed.
N)r  visit)r&   r"  rh  visitors       r   re  ModuleGraph._scan_ast	  s     4(,-r   c                 `   SnSn[        SS9n[        R                  " U5       GH  nU(       d  M  UR                  S:X  a  U(       d  M&  [        R
                  S:  a+  US   R                  S;   d   eUS   R                  S	;   d   eO*US   R                  S
:X  d   eUS   R                  S
:X  d   eUS   R                  nUS   R                  nUb  [        U5      [        L d   eUR                  nSn	Ub$  [        U5      nSU;   a  UR                  S5        Sn	UR                  R                  U	XXT40 45        O[UR                  S;   a  UR                  n
UR                  U
5        O-UR                  S;   a  UR                  n
UR                  U
5        UR                  U5        GM     g)a4  
Parse and add all import statements from the passed code object of the
passed source module to this graph, non-recursively.

This method parses all reasonably parsable operations (i.e., operations
that are both syntactically and semantically parsable _without_
requiring Turing-complete interpretation) directly or indirectly
involving module importation from this code object. This includes:

* `IMPORT_NAME`, denoting an import statement. Ignored unless
  the passed `is_scanning_imports` parameter is `True`.
* `STORE_NAME` and `STORE_GLOBAL`, denoting the
  declaration of a global attribute (e.g., class, variable) in this
  module. This method stores each such declaration for subsequent
  lookup. While global attributes are usually irrelevant to import
  parsing, they remain the only means of distinguishing erroneous
  non-ignorable attempts to import non-existent submodules of a package
  from successful ignorable attempts to import existing global
  attributes of a package's `__init__` submodule (e.g., the `bar` in
  `from foo import bar`, which is either a non-ignorable submodule of
  `foo` or an ignorable global attribute of `foo.__init__`).
* `DELETE_NAME` and `DELETE_GLOBAL`, denoting the
  undeclaration of a previously declared global attribute in this
  module.

Since `ModuleGraph` is _not_ intended to replicate the behaviour of a
full-featured Turing-complete Python interpreter, this method ignores
operations that are _not_ reasonably parsable from this code object --
even those directly or indirectly involving module importation. This
includes:

* `STORE_ATTR(namei)`, implementing `TOS.name = TOS1`. If `TOS` is the
  name of a target module currently imported into the namespace of the
  passed source module, this opcode would ideally be parsed to add that
  global attribute to that target module. Since this addition only
  conditionally occurs on the importation of this source module and
  execution of the code branch in this module performing this addition,
  however, that global _cannot_ be unconditionally added to that target
  module. In short, only Turing-complete behaviour suffices.
* `DELETE_ATTR(namei)`, implementing `del TOS.name`. If `TOS` is the
  name of a target module currently imported into the namespace of the
  passed source module, this opcode would ideally be parsed to remove
  that global attribute from that target module. Again, however, only
  Turing-complete behaviour suffices.

Parameters
----------
module : Node
    Graph node of the module to be parsed.
module_code_object : PyCodeObject
    Code object of the module to be parsed.
is_scanning_imports : bool
    `True` only if this method is parsing import statements from
    `IMPORT_NAME` opcodes. If `False`, no import statements will be
    parsed. This parameter is typically:
    * `True` when parsing this module's code object for such imports.
    * `False` when parsing this module's abstract syntax tree (AST)
      (rather than code object) for such imports. In this case, that
      parsing will have already parsed import statements, which this
      parsing must avoid repeating.
Nr  )maxlenIMPORT_NAME)r      >   
LOAD_CONSTLOAD_SMALL_INTLOAD_CONST_IMMORTALr,   >   rs  ru  rs  Fr/  T)
STORE_NAMESTORE_GLOBAL)DELETE_NAMEDELETE_GLOBAL)r   r   iterate_instructionsopnamerk  version_infoargvalr   r   r  rx   rP   r  re   ry   )r&   r"  rg  rd  r1  rC   
prev_instsinstr  r2  r   s              r   rf  ModuleGraph._scan_bytecode	  s   ~  !_
--.@AD {{m+ + ##w.%b>004kkkk%b>004YYYY%b>00L@@@%b>00L@@@"2--%b>00'4>U+BBB)-& "	'#H~Hh ,$(	 ((//+XE1   >> {{&&t, @@
 {{2248d#i Br   c                 ~   UR                   (       d  gUR                    H  u  p#nU R                  " U0 UD6nU(       d  M!  US   nU(       d  M/  UR                  U5        UR                  R	                  UR                  5        UR
                  b  Mt  US   nUR                  R                  U5        M     SUl         g)ab  
Graph all target modules whose importations were previously parsed from
the passed source module by a prior call to the `_scan_code()` method
and methods call by that method (e.g., `_scan_ast()`,
`_scan_bytecode()`, `_scan_bytecode_stores()`).

Parameters
----------
source_module : Node
    Graph node of the source module to graph target imports for.
Nr   )rP   r  rj   rR   rh   rK   rd   )r&   r  r2  import_infokwargsr  ri   target_module_names           r   r  ModuleGraph._process_imports@
  s     .. /<.M.M*IF "33[KFKN! *1-M y ::=I@@GG!DDF
 !%%-)4Q&!DDHH*,O /NV +/'r   c                    Ub  UR                   S-   U-   nOUnU R                  U5      nUb  U R                  SSU5        [        U5      eUc(  U[        R
                  ;   a  S[        4$ U R                  nU R                  XAU5      $ )a=  
3-tuple describing the physical location of the module with the passed
name if this module is physically findable _or_ raise `ImportError`.

This high-level method wraps the low-level `modulegraph.find_module()`
function with additional support for graph-based module caching.

Parameters
----------
name : str
    Fully-qualified name of the Python module to be found.
path : list
    List of the absolute paths of all directories to search for this
    module _or_ `None` if the default path list `self.path` is to be
    searched.
parent : Node
    Package containing this module if this module is a submodule of a
    package _or_ `None` if this is a top-level module.

Returns
----------
(filename, loader)
    See `modulegraph._find_module()` for details.

Raises
----------
ImportError
    If this module is _not_ found.
Nr   r   zfind_module: already included?)	rN   rd  r  r  rk  builtin_module_namesr   r   _find_module_path)r&   r   r   r~  fullnamer   s         r   r-  ModuleGraph._find_module
  s    > ((3.5HH~~h'HHQ8$?d##<s///n--99D%%hd;;r   c                    U R                  SSX5        Sn/ n U GH[  n[        R                  " U5      nUc  M  [        US5      (       aG  SnUR	                  U5      n	U	b0  U	R
                  nUR                  U	R                  =(       d    / 5        Om[        US5      (       a%  UR                  U5      u  pUR                  U
5        O7[        US5      (       a  UR                  U5      nO[        SU< SU< S	35      eUc  M  Sn[        US
5      (       a  UR                  U5      nO2[        US5      (       a  UR                  nO[        SU< SU< S35      eUc  U R                  SSU5        GMY  X4n  O   U(       a  US   [        U5      4nU R!                  SSU5        Uc  [        S[%        U5      -   5      eU$ ! [         a  nU R!                  SSU5         SnANQSnAf["         a  nU R!                  SSU5        e SnAff = f)a  
3-tuple describing the physical location of the module with the passed
name if this module is physically findable _or_ raise `ImportError`.

This low-level function is a variant on the standard `imp.find_module()`
function with additional support for:

* Multiple search paths. The passed list of absolute paths will be
  iteratively searched for the first directory containing a file
  corresponding to this module.
* Compressed (e.g., zipped) packages.

For efficiency, the higher level `ModuleGraph._find_module()` method
wraps this function with support for module caching.

Parameters
----------
module_name : str
    Fully-qualified name of the module to be found.
search_dirs : list
    List of the absolute paths of all directories to search for this
    module (in order). Searching will halt at the first directory
    containing this module.

Returns
----------
(filename, loader)
    2-tuple describing the physical location of this module, where:
    * `filename` is the absolute path of this file.
    * `loader` is the import loader.
      In case of a namespace package, this is a NAMESPACE_PACKAGE
      instance

Raises
----------
ImportError
    If this module is _not_ found.
r  z_find_module_path <-N	find_specfind_loaderfind_modulezModule z
 importer z loader unobtainablerL  r   z loader z path unobtainablez _find_module_path path not foundr   r   z"_find_module_path -> unicode errorz_find_module_path -> exceptionz_find_module_path ->r  )r  pkgutilget_importerr   r  r5  extendsubmodule_search_locationsr  r  r  rL  r   r  r    rJ  r  r@  r  )r&   r  r2  r4  	path_datar%   
search_dirimporterr5  specloader_namespace_dirsr  r7   s                r   r  ModuleGraph._find_module_path
  s-   N 	

1,hD 	 Q	)
"//
; # 8[11!F#--k:D'!%&--d.M.M.SQST X}554<4H4H#5%1F"))*?@ X}55%11+>F &GRT\]_ _ >  
 6>22%22;?HVV,,%{{H &CNPVWY Y
 #HHQ BHM &.	I *N "!/!2!2>!B!DI 	A-y9043DDEE " 	FKK?EE  	KK;SA	s*   EG 9G 
H	G##H	0HH	c           	      (   Uc  [         R                  n/ n/ nU R                  5        Hg  n[        R                  R                  UR                  5      n[        U[        5      (       a  UR                  XT45        MU  UR                  XT45        Mi     UR                  5         UR                  5         U VVs/ s H  u  pgUPM	     nnnUR                  U5        UnSSR                  U5      -   n	[        [        SU	0-  US9  S n
U GHr  u  pWSn[        U[        5      (       a  [         USS.-  nO[        U["        5      (       a  [         US	UR$                  -  S.-  nOR[&        R(                  R+                  UR$                  =(       d    S5      n[,        X\UR.                  R0                  S
.-  n[3        XR5                  U5      5      u  pU(       aE  / nU H  nUR                  SU< SU< S35        M     SR                  U5      nU[6        SUS.-  -  nU(       aE  / nU H  nUR                  SU< SU< S35        M     SR                  U5      nU[6        SUS.-  -  n[        [8        X[S.-  US9  GMu     [        [:        US9  g s  snnf )Nz modulegraph cross reference for z, TITLE)filec                     U  Vs/ s H4  o(       d  M  [         R                  R                  UR                  5      PM6     nnUR	                  5         U$ s  snf r#   )r|  r   r  rM   sort)modsmodlsts      r   sorted_namelist0ModuleGraph.create_xref.<locals>.sorted_namelistS  sB    ?CKts3277##CNN3tCKHHJJ Ls
   
A-Ar9  z<i>(builtin module)</i>)NAMETYPEz<tt>%s</tt>)r  URLr  z  <a href="#z">z</a>
z	 &#8226; imports)HEADLINKSzimported by)r  CONTENT)rk  stdout
iter_graphr|  r   r  rM   r  r   r  r  r  r}  printheaderr   contplr   rL   urllibrequestpathname2urlcontpl_linkedr   r   mapr  r  entryfooter)r&   outscriptsr  r  r   snr9   scriptnamestitler  contenturlouteincelinksr  s                    r   create_xrefModuleGraph.create_xref>  s@   ;**C??$C77##CNN3D#v&&{+TK( % 			'./webrw/t2TYY{5KKf''c2	 GDG!]++ D,E$G GAy)) D,9AJJ,F$H H nn11!**2BC'434;;3G3G+I I_nnQ.?@JDALL1a!HI 
 $((/7i%%HHHALL1a!HI 
 $((/7me%LLL%4<<3G? @ 	f3W 0s   8Jc              #     ^ ^!^"#    [        [        U R                  R                  U R                  R	                  U 5      5      5      nU R                  R
                  m![        5       n[        5       n0 n0 n0 n[        5       n	[        U5      nS n
S m"SU< S3v   [        SSS9nSm UR                  5        H  nS	T U-  < S
3v   M     U HZ  u  pnn[        USS 5      X}'   [        U[        5      (       d  M-  XUR                  '   [        U/5      X'   UR                  U5        M\     U H  u  pnnU!4S jU 5        H  nUR                  U5        M     SU< SSR!                  U
" XUU5      R                  5        Vs/ s H  nT U-  PM
     sn5      < S3v   UR#                  U5      nUc  [        5       =nX'   X}   nUc  M  UR#                  US UR%                  S5       5      nUc  M  UR                  U5        M     / n0 nU H  n/ UU'   M
     U(       Ga>  UR'                  5       u  nnnnUU4U	;   a  M'  U	R                  UU45        UU   nUU   U-  nU(       d\  U(       aU  [)        U5      n[+        U5      S:w  d	  US   U:w  a2  UR                  UUUUS   45        UR                  USUS   U45        M  U(       av  UR-                  5       nUU:X  a  UR                  UUUU45        O_UU:X  a  UU   R                  USUU45        O@UR                  UUUU45        UR                  UUUU45        OUR                  UUUU45        U(       a  GM>  U U"4S jnUR                  5        H3  u  nnSU< S3v   SUU   < S3v   U" US5       H  nUv   M	     Sv   M5     U" US	5       H  nUv   M	     Sv   g s  snf 7f)Nc                     [        U[        5      (       d  S[        U 5      0$ S[        U5      R                  -   n[        UR                  5       S S S5       H  u  pVUSXV4-  -  nM     USS.$ )Nlabelz<f0> r   z
| <f%d> %srecord)r  shape)r  rI   r5   r   r   	enumerater   )r   r  r  r  sr  vs          r   nodevisitor0ModuleGraph.itergraphreport.<locals>.nodevisitor  sq    dD))T++ $t*---A!$.."22A"6:\QF** ;22r   c                 .    US:X  a  SS0$ US:X  a  SS0$ 0 $ )Norphanstyledashedpkgrefdottedr   )edger  r  tails       r   edgevisitor0ModuleGraph.itergraphreport.<locals>.edgevisitor  s/     x**!**Ir   zdigraph z {
charset="UTF-8";
LRtrue)rankdirconcentratez%s="%s"	z;
rM   c              3   4   >#    U  H  nT" U5      v   M     g 7fr#   r   ).0rE  describe_edges     r   	<genexpr>.ModuleGraph.itergraphreport.<locals>.<genexpr>  s     <8aq))8s   z	"z" [,z];
r   r   r   r  r,   c              3      >#    US-   nU  HJ  u  p4pVT
" X4XV5      nUUUSR                  UR                  5        Vs/ s H  nT	U-  PM
     sn5      4-  v   ML     g s  snf 7f)Nz"%s" -> "%s" [%s];
r  )r}  r  )edgestabsedgestrr  r  r  r  attribsitemcpattr  s            r   do_graph-ModuleGraph.itergraphreport.<locals>.do_graph  so     33G,1(T%d$=HHIut|IJ!   -2
 Js   7AA	Az	subgraph "cluster_z" {
z			label="z";
z		z	}
z}
)r  r  r!  describe_nodeiterdfsr  r   rU   rV   r  r}   r  r   rM   rd   r  r}  rt   r  popleftsortedr  r>  )#r&   r   flatpackagesr  r  packagenodespackageidentsnodetoident
inpackages	mainedgesr  attrr  r   r  r  r  r  insideidentpkgnoder!  	subgraphskeyr  r  tailpkgscommonusepkgsr  gr  r  r  r  s#                                   @@@r   itergraphreportModuleGraph.itergraphreporty  s    S114::3E3Ed3KLM

00u
E	 L)	3	 59::Df5JJLD$t|-- ! 16,T8 'lD AK$((15doo.#&v;
   & 16 16,T8<8<T" =
 Hh?EEGG (,UT\G    ^^D)F~,/E1)%E}#''.?u{{3/?(@AG"

7#- 160 	CIcN   %*]]_"D$dt*MM4,'!$'H%0Fh *w<1$
d(:LL$dGAJ!?@LL$'"+t!DE6>LL$dD!9:V^f%,,dHdD-IJLL$fd!;<LL$fd!;< dD$561 e4		 ")HAu3466)4Q99eV, -M * %&AG ' Is(   C1O
:BO
OAO
1E*O
A,O
c                 f    Uc  [         R                  nUR                  U R                  US95        g )N)r  )rk  r  
writelinesr  )r&   fileobjr  s      r   graphreportModuleGraph.graphreport  s,    ?jjG4//\/JKr   c           	         [        5         [        SS-  5        [        SS-  5        [        U R                  5       S S9 H  n[        U[        5      (       aA  [        [        U5      R                  <S SUR                  <S SUR                  < 35        MY  [        [        U5      R                  <S SUR                  <S SUR                  =(       d    S	< 35        M     g
)zPrint a report to stdout, listing the found modules with their
paths, as well as modules that are missing, or seem to be missing.
z%-15s %-25s %s)ClassNameFile)z---------r	  c                     U R                   $ r#   )rM   )r  s    r   ru  $ModuleGraph.report.<locals>.<lambda>  s    r   )r  15 25r9  N)
r  r  r  r  r   r   r   rM   rN   rL   )r&   r9   s     r   reportModuleGraph.report  s     	!::;!::;)/EFA!Y''$q'*:*:ALL!,,WX$q'*:*:ALL!**JZXZJZ[\	 Gr   c                 L   [         R                  R                  UR                  5      =p#U R                   Hm  u  pE[         R                  R                  US5      n[         R                  R                  US5      nUR                  U5      (       d  M]  XS[        U5      S  -   n  O   U$ [        UR                  5      n[        [        U5      5       H6  n[        Xg   [        U5      5      (       d  M!  U R                  Xg   5      Xg'   M8     UR                  [        U5      US9$ )Nr9  )	co_constsco_filename)r|  r   normpathr  rm  r}  r  r  r  r  r   r  r   r  replacer   )r&   r  new_filenameoriginal_filenamefr  constsr  s           r   r  "ModuleGraph._replace_paths_in_code
  s    +-77+;+;BNN+KK&&DAQ#AQ#A ++A.. SVW#== ' Ibll#s6{#A&)T"X.. 77	B	 $ zzE&M|zLLr   )ro  rn  rl  r   rm  )Nr   r   r   Nr   r#   )T)direct)Gr   )Nr   )1r   r   r   r   r   re  r'   r  r  r  getReferencesr  getReferersr  r  r  r  r  rd  r  r   flattenr  r  r  r  r  r  r  r	  r  r  r)  r  r.  r  r  re  rf  r  r-  r  r  r  r  r  r  r   r   r   s   @r   rb  rb    s$   &&
<">H M" KE$J	I_ OEN H$$JF "nb< #	DTVBr."AJ#>L 0cJ~D #dLf  $	?B.4Y$x=/@0<fHV9 v}~L
]M Mr   rb  )Hr   r	  r|  r  rk  r3   collectionsr   r   r   urllib.requestr  r   importlib.utilr  importlib.machineryr|  importlib.metadatametadatarx  catch_warningsfilterwarningsUserWarningaltgraph.ObjectGraphr   altgraphr   r9  r   r   r    r  r  r  r  r.   r:   r<   rI   r5   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r  r  r  r  r  r  NodeVisitorr  rb  r   r   r   <module>r,     sX    	  
 	 6 6     w3
 -
 1#   
  %' !   - 	+ 	?j!1JL ?>~@ ~@BC (2 (2V	 		Y 		I 	4Y 4 T  W W	J 		: 		, 		Z 		J 		
 		j 		y' 		w 		J 	,	W 	0** **J *
	

 
J,

	>  _#s _#D\"M+ \"Mu s   G00
G?