zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
U
X±d`'ã    @stdZddlZddlZddlZddlZddlZddlZddlZddlZddl    Z    ddl
m Z m Z ddl Z ddlmZddlmZddlmZddlmZdd    lmZmZmZmZej d
¡ZGd d „d ƒZGd d„dƒZdZdZ ej!ddkrîene Z"dd„e #¡DƒZ$e%e$dd„ddZ&iZ'dZ(Gdd„de)ƒZ*dodd„Z+e     ,d¡Z-dd„Z.dd „Z/d!d"„Z0d#d$„Z1d%d&„Z2d'd(„Z3d)d*„Z4iZ5d+d,„Z6d-d.„Z7Gd/d0„d0e d0d1d2d3d4gƒƒZ8Gd5d6„d6ƒZ9Gd7d8„d8e:ƒZ;Gd9d:„d:e9ƒZ<Gd;d<„d<e9ƒZ=Gd=d>„d>e=ƒZ>Gd?d@„d@e=ƒZ?GdAdB„dBe=ƒZ@GdCdD„dDe9ƒZAGdEdF„dFe9ƒZBGdGdH„dHeBƒZCGdIdJ„dJeBƒZDGdKdL„dLeDƒZEGdMdN„dNeBƒZFGdOdP„dPeBƒZGGdQdR„dReBƒZHGdSdT„dTeBƒZIGdUdV„dVeHeIƒZJGdWdX„dXeIƒZKGdYdZ„dZeBƒZLGd[d\„d\eIƒZMGd]d^„d^eBƒZNGd_d`„d`eBƒZOdaaPdbaQdcaRddaSdeaTdfaUdgdh„ZVdidj„ZWej!ddkrJdZ"ndZ"Gdkdl„dlejXƒZYGdmdn„dneƒZZdS)pa
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)Ú ObjectGraph)Ú
GraphErroré)Úutil)Úzipio)ÚBytesIOÚStringIOÚ pathname2urlÚ
_READ_MODEzutf-8c@seZdZdd„ZdS)ÚBUILTIN_MODULEcCsdS©NF©)Úfqnamerrú^d:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\PyInstaller/lib/modulegraph/modulegraph.pyÚ
is_package)szBUILTIN_MODULE.is_packageN)Ú__name__Ú
__module__Ú __qualname__rrrrrr (sr c@seZdZdd„Zdd„ZdS)ÚNAMESPACE_PACKAGEcCs
||_dS©N)Únamespace_dirs)ÚselfrrrrÚ__init__.szNAMESPACE_PACKAGE.__init__cCsdS©NTr)rrrrrr1szNAMESPACE_PACKAGE.is_packageN)rrrrrrrrrr-sréÿÿÿÿécCsi|]\}}}||||f“qSrr)Ú.0ZfiletypeZ    open_modeZimp_typerrrÚ
<dictcomp>`sÿrcCst|ƒSr)Úlen)ÚprrrÚ<lambda>fór"T)ÚkeyÚreverse)ztimport sys, types, os;has_mfs = sys.version_info > (3, 5);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('zOimport sys,types,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('zMimport sys,new,os; p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('zPimport sys, types, os;p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('zsimport sys, types, os;pep420 = sys.version_info > (3, 3);p = os.path.join(sys._getframe(1).f_locals['sitedir'], *('c@s eZdZdS)ÚInvalidRelativeImportErrorN©rrrrrrrr&¦sr&cCslt |¡}t|ƒ}|D]P}| d¡r| d¡ ¡}||krtjj|j    f| 
d¡žŽ}||kr|  |¡q|S)z¶
    Return the __path__ for the python package in *fqname*.
 
    This function uses setuptools metadata to extract information
    about namespace packages from installed eggs.
    znamespace_packages.txtÚ.) Ú pkg_resourcesÚ
WorkingSetÚlistÚ has_metadataÚ get_metadataÚ
splitlinesÚosÚpathÚjoinÚlocationÚsplitÚappend)rÚ    pathnamesr0Ú working_setÚdistÚ
namespacesZnspathrrrÚ_namespace_package_pathªs
 
ÿ r9z ^\s*["']([A-Za-z0-9_]+)["'],?\s*cCs~| d¡r| d¡st|ƒ‚|}|dd…}g}|rvt |¡}|dkrNt|ƒ‚| | d¡¡|t| d¡ƒd…}q0t|ƒS)zœ
    Input is the repr of a tuple of strings, output
    is that tuple.
 
    This only works with a tuple where the members are
    python identifiers.
    ú(ú)rrNr)    Ú
startswithÚendswithÚ
ValueErrorÚ_strsÚmatchr4Úgroupr Útuple)ÚvalueZ
orig_valueÚresultÚmrrrÚ_eval_str_tupleÃs 
rFcCs&t dt|ƒ¡}|dk    r"| d¡S|S)Nz^No module named (\S+)$r)Úrer@ÚstrrA)ÚexcÚdefaultrErrrÚ_path_from_importerrorÝs
rKcCst dt¡t |¡S)z
    Deprecated name
    z'Use zipio.listdir instead of os_listdir)ÚwarningsÚwarnÚDeprecationWarningrÚlistdir)r0rrrÚ
os_listdirçs
þrPcCsNtjdkrt ¡d}n$tjdkr0t ¡d}n t ¡d}t|t |¡ƒS)z+ Convert code object to a .pyc pseudo-file )éés )rQéss)ÚsysÚ version_infoÚimpZ    get_magicr    ÚmarshalÚdumps)ÚcoÚheaderrrrÚ _code_to_fileñs 
 
 r[cCsFt ¡D]8\}}}| |¡rtj |¡dt|ƒ …||fSqdSr)rVÚ get_suffixesr=r/r0Úbasenamer )r0ÚextZreadmodeÚtyprrrÚmoduleInfoForPathüs
&r`cCst dt¡t||ƒdS)Nz,Use addPackagePath instead of AddPackagePath)rLrMrNÚaddPackagePath)Ú packagenamer0rrrÚAddPackagePaths
þrccCs"t |g¡}| |¡|t|<dSr)Ú_packagePathMapÚgetr4)rbr0Úpathsrrrra
s 
racCst dt¡t||ƒdS)Nz,use replacePackage instead of ReplacePackage)rLrMrNÚreplacePackage©ZoldnameÚnewnamerrrÚReplacePackagesÿrjcCs |t|<dSr)Ú_replacePackageMaprhrrrrgsrgc@seZdZdZdd„ZdS)ÚDependencyInforcCsp|js|js|jr$|js<|js<|js<tddd|jo6|jdSt|jpH|j|jpR|j|jp\|j|jof|jdSdS)NF)Ú conditionalÚfunctionÚ    tryexceptÚfromlist)rmrnrorlrp)rÚotherrrrÚ_merged)s&ÿÿÿ
ü
 
 
 
üzDependencyInfo._mergedN)rrrÚ    __slots__rrrrrrrl%srlrmrnrorpc    @s¾eZdZdZdddddddd    d
g    Zd d „Zd d„Zdd„Zdd„Zdd„Z    dd„Z
dd„Z dd„Z dd„Z dd„Zdd „Zd!d"„Zd#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1S)2ÚNodea
    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_nodecCs@d|_d|_||_||_d|_d|_tƒ|_tƒ|_t    ƒ|_
dS)zÞ
        Initialize this graph node.
 
        Parameters
        ----------
        identifier : str
            Fully-qualified name of this graph node's corresponding module,
            package, or C extension.
        N) rurvrwrxryrzÚsetr{r|Údictr})rrxrrrr¬s z Node.__init__cCs
||jkS)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.
        )r{©rÚ    attr_namerrrÚis_global_attrÂs'zNode.is_global_attrcCs
||jkS)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.
        ©r}©rÚsubmodule_basenamerrrÚ is_submoduleìszNode.is_submodulecCs|j |¡dS)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)r{Úaddr€rrrÚadd_global_attrszNode.add_global_attrcCs|j |j¡dS)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)r{Úupdate)rÚ target_modulerrrÚadd_global_attrs_from_modulesz!Node.add_global_attrs_from_modulecCs||j|<dS)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ƒ)rr…Zsubmodule_noderrrÚ add_submodule(szNode.add_submodulecCs
|j|S)aW
        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„rrrÚ get_submodule;szNode.get_submodulecCs |j |¡S)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`.
        )r}rer„rrrÚget_submodule_or_noneSszNode.get_submodule_or_nonecCs| |¡r|j |¡dS)a
        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‚r{Úremover€rrrÚremove_global_attr_if_foundks
z Node.remove_global_attr_if_foundcCs4zt|dƒ}Wntk
r&tYSXt|j|ƒS©Nrw)ÚgetattrÚAttributeErrorÚNotImplementedÚcmprw©rrqZ
otherIdentrrrÚ__cmp__Œs
 
z Node.__cmp__cCs0zt|dƒ}Wntk
r$YdSX|j|kS)NrwF©r’r“rwr–rrrÚ__eq__”s
z Node.__eq__cCs0zt|dƒ}Wntk
r$YdSX|j|kS)NrwTr˜r–rrrÚ__ne__œs
z Node.__ne__cCs2zt|dƒ}Wntk
r&tYSX|j|kSr‘©r’r“r”rwr–rrrÚ__lt__¤s
 
z Node.__lt__cCs2zt|dƒ}Wntk
r&tYSX|j|kSr‘r›r–rrrÚ__le__¬s
 
z Node.__le__cCs2zt|dƒ}Wntk
r&tYSX|j|kSr‘r›r–rrrÚ__gt__´s
 
z Node.__gt__cCs2zt|dƒ}Wntk
r&tYSX|j|kSr‘r›r–rrrÚ__ge__¼s
 
z Node.__ge__cCs
t|jƒSr)Úhashrw©rrrrÚ__hash__Äsz Node.__hash__cCs|jfSr©rxr¡rrrÚ    infoTupleÇszNode.infoTuplecCsdt|ƒj| ¡fS)Nz%s%r)Útyperr¤r¡rrrÚ__repr__Êsz Node.__repr__N)rrrÚ__doc__rsrr‚r†rˆr‹rŒrrŽrr—r™ršrœrržrŸr¢r¤r¦rrrrrtDs<\÷ *!rtc@seZdZdZdS)ÚAliasa
    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.
    N©rrrr§rrrrr¨Òsr¨cs(eZdZdZ‡fdd„Zdd„Z‡ZS)Ú    AliasNodez’
    Graph node representing the aliasing of an existing source module under a
    non-existent target module name (i.e., the desired alias).
    cs:tt|ƒ |¡dD] }t||ƒrt||t||ƒƒqdS)aD
        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.
        )rxryr{r|r}N)ÚsuperrªrÚhasattrÚsetattrr’)rÚnameÚnoder©Ú    __class__rrræs 
zAliasNode.__init__cCs |j|jfSr)rwrxr¡rrrr¤szAliasNode.infoTuple)rrrr§rr¤Ú __classcell__rrr°rrªàs rªc@s eZdZdS)Ú    BadModuleNr'rrrrr³sr³c@s eZdZdS)ÚExcludedModuleNr'rrrrr´    sr´c@s eZdZdS)Ú MissingModuleNr'rrrrrµ srµcs$eZdZ‡fdd„Zdd„Z‡ZS)ÚInvalidRelativeImportcsD|}| d¡r||7}n |d|7}tt|ƒ |¡||_||_dS)Nr()r=r«r¶rÚ relative_pathÚ    from_name)rr·r¸rxr°rrrs
 
 zInvalidRelativeImport.__init__cCs |j|jfSr)r·r¸r¡rrrr¤szInvalidRelativeImport.infoTuple©rrrrr¤r²rrr°rr¶s
r¶cs$eZdZ‡fdd„Zdd„Z‡ZS)ÚScriptcstt|ƒ |¡||_dSr)r«rºrrv)rrvr°rrr!szScript.__init__cCs|jfSr)rvr¡rrrr¤%szScript.infoTupler¹rrr°rrº s rºcs&eZdZd‡fdd„    Zdd„Z‡ZS)Ú
BaseModuleNcs tt|ƒ |¡||_||_dSr)r«r»rrvry)rr®rvr0r°rrr*szBaseModule.__init__cCsttd|j|j|jfƒƒSr)rBÚfilterrxrvryr¡rrrr¤/szBaseModule.infoTuple)NNr¹rrr°rr»)sr»c@s eZdZdS)Ú BuiltinModuleNr'rrrrr½3sr½c@s eZdZdS)Ú SourceModuleNr'rrrrr¾7sr¾c@s eZdZdS)ÚInvalidSourceModuleNr'rrrrr¿;sr¿c@s eZdZdS)ÚCompiledModuleNr'rrrrrÀ?srÀc@s eZdZdS)ÚInvalidCompiledModuleNr'rrrrrÁCsrÁc@s eZdZdS)Ú    ExtensionNr'rrrrrÂGsrÂc@seZdZdZdS)ÚPackagez:
    Graph node representing a non-namespace package.
    Nr©rrrrrÃKsrÃc@seZdZdZdS)ÚExtensionPackageza
    Graph node representing a package where the __init__ module is an extension
    module.
    Nr©rrrrrÄRsrÄc@seZdZdZdS)ÚNamespacePackagez6
    Graph node representing a namespace package.
    Nr©rrrrrÅZsrÅc@seZdZdZdS)Ú RuntimeModulea<
    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.
    Nr©rrrrrÆasrÆc@seZdZdZdS)ÚRuntimePackageaQ
    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.
    Nr©rrrrrÇwsrÇcseZdZ‡fdd„Z‡ZS)Ú FlatPackagecs t dt¡ttf|ž|ŽdS©Nz=This class will be removed in a future version of modulegraph©rLrMrNr«rÈ©rÚargsÚkwdsr°rrrs
þzFlatPackage.__init__©rrrrr²rrr°rrȏsrÈcseZdZ‡fdd„Z‡ZS)Ú ArchiveModulecs t dt¡ttf|ž|ŽdSrÉrÊrËr°rrršs
þzArchiveModule.__init__rÎrrr°rrϙsrÏ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>cCsDg}|D](}t|tjƒr&| |j¡q| |¡qdd„|Dƒ}|S)NcSsg|]}|dkr|‘qS)Ú__main__r)rÚrrrrÚ
<listcomp>Ísz_ast_names.<locals>.<listcomp>)Ú
isinstanceÚastÚaliasr4r®)ÚnamesrDÚnmrrrÚ
_ast_namesÅs  rØcs tƒ‰ˆj‰‡‡fdd„|DƒS)z/Remove duplicates from a list, preserving ordercs g|]}|ˆksˆ|ƒs|‘qSrr)rÚx©ÚseenZseen_addrrrÒÖszuniq.<locals>.<listcomp>)r~r‡)ÚseqrrÚrÚuniqÑsrÝc@sÀeZdZdd„Zedd„ƒZedd„ƒZedd„ƒZd    d
„Zd d „Z    d d„Z
dd„Z dd„Z e Z dd„Zdd„Zdd„ZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZeZdS)Ú_VisitorcCs.||_||_t|_dg|_dg|_dg|_dSr)Z_graphÚ_moduleÚDEFAULT_IMPORT_LEVELÚ_levelÚ_in_ifÚ_in_defÚ _in_tryexcept)rÚgraphÚmodulerrrràs z_Visitor.__init__cCs
|jdS©Nr)râr¡rrrÚin_ifèsz_Visitor.in_ifcCs
|jdSrç)rãr¡rrrÚin_defìsz_Visitor.in_defcCs
|jdSrç)rär¡rrrÚ in_tryexceptðsz_Visitor.in_tryexceptc CsŠtjddkr(|dkr(d|pdkr(d|_d}|dk    rRt|ƒ}d|krR| d¡d}|jj |||j||fd    t|j    |j
|j dd
if¡dS) NrrÚ
__future__Úabsolute_importrFÚ*TÚ    edge_attr)rmrornrp) rTrUrárÝrrßrzr4rlrèrêré)rr®rpÚlevelÚ    have_starrrrÚ_collect_importõs(
 üþÿz_Visitor._collect_importcCs$t|jƒD]}| |d|j¡q
dSr)rØrÖrñrá)rr¯r×rrrÚ visit_Import sz_Visitor.visit_ImportcCs4|jdkr|jn|j}| |jp"dt|jƒ|¡dS)NrÚ)rïrárñrærØrÖ)rr¯rïrrrÚvisit_ImportFromsz_Visitor.visit_ImportFromcCs$|j d¡| |¡|j ¡dSr)râr4Ú generic_visitÚpop©rr¯rrrÚvisit_Ifs 
z_Visitor.visit_IfcCs$|j d¡| |¡|j ¡dSr)rãr4rõrör÷rrrÚvisit_FunctionDefs 
z_Visitor.visit_FunctionDefcCs$|j d¡| |¡|j ¡dSr©rär4rõrör÷rrrÚ    visit_Try!s 
z_Visitor.visit_TrycCs$|j d¡| |¡|j ¡dSrrúr÷rrrÚvisit_TryExcept&s 
z_Visitor.visit_TryExceptcCsdSrrr÷rrrÚvisit_Expression+sz_Visitor.visit_ExpressionN) rrrrÚpropertyrèrérêrñròrôrørùZvisit_AsyncFunctionDefrûrürýZ visit_BoolOpZ visit_BinOpZ visit_UnaryOpZ visit_LambdaZ visit_IfExpZ
visit_DictZ    visit_SetZvisit_ListCompZ visit_SetCompZvisit_GeneratorExpZ visit_CompareZ visit_YieldZvisit_YieldFromZ visit_AwaitZ
visit_CallrrrrrÞßsB
 
 
rÞcs|eZdZdZ‡fdd„ZdN‡fdd„    Zd    d
„Zd d „ZdOd d„Zdd„Z    e    Z
dPdd„Z e Z dd„Z dd„Zdd„ZdQ‡fdd„    ZeZdR‡fdd„    ZeZejZdSdd „Zddedfd!d"„Zd#d$„Zefd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Z d1d2„Z!d3d4„Z"edfd5d6„Z#dTd7d8„Z$d9d:„Z%d;d<„Z&d=d>„Z'dUd?d@„Z(dAdB„Z)dVdCdD„Z*dWdFdG„Z+dXdHdI„Z,dJdK„Z-dLdM„Z.‡Z/S)YÚ ModuleGraphzr
    Directed graph whose nodes represent modules and edges represent
    dependencies between these modules.
    cs0| |¡}|dkr,tt|ƒj||f|ž|Ž}|Sr)Ú    find_noder«rÿÚ
createNode)rÚclsr®rÌÚkwrEr°rrrLs
zModuleGraph.createNodeNrrcsjtt|ƒj||d|dkr"tj}||_i|_|j t|ƒ¡|D]}d|j|<qB||_|     ¡t
|_ dS)N)råÚdebug) r«rÿrrTr0Ú    lazynodesr‰rÚ replace_pathsÚset_setuptools_nspackagesrdÚ_package_path_map)rr0ZexcludesrZimpliesrårrEr°rrrVs zModuleGraph.__init__cCs| ¡|_dSr)Ú_calc_setuptools_nspackagesÚ
nspackagesr¡rrrrgsz%ModuleGraph.set_setuptools_nspackagesc CsÄi}zddlm}Wn@tk
rTzddlm}Wntk
rNtj}YnXYnXtjdd…dkrxddl}|j    j
}|j D]>}t  |¡}t ||ƒr~zt |¡}Wntjk
rÀYq~YnX|D]ö}| d¡rÆttj  ||¡tƒÎ}|D]Â}    tD]¸}
|     |
¡röz t|
ƒd} |     d| ¡d} Wntk
r>YqöYnXt|    | | …ƒ} d | ¡}tj j|f| žŽ}tj  tj  |d    ¡¡r†qö||kr || |¡n
|g||<qîqöqîW5QRXqÆq~|S)
Nr)Ú ImpImporterr)rQrQz
-nspkg.pthr;rr(z __init__.py)Úpkgutilr Ú ImportErrorZ_pkgutilr)Z
ImpWrapperrTrUZimportlib.machineryÚ    machineryÚ
FileFinderr0Ú get_importerrÓr/rOÚerrorr=Úopenr1r Ú_SETUPTOOLS_NAMESPACEPKG_PTHsr<r Úindexr>rFÚexistsr4)rZpkgmapr Ú    importlibÚentryÚimporterZldirÚfnÚfpÚlnÚpfxÚstartÚstopÚpkgrxÚsubdirrrrr    ksN  
 
 
 
 
 
 
 
 
z'ModuleGraph._calc_setuptools_nspackagescCsVt|tƒr| |||¡n8t|tƒr,t|ƒ‚| ||d¡}|D]}| |||¡q>dS)aU
        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ÓrtÚ_updateReferencerBr>Ú_safe_import_hook)rr¯rqÚ    edge_dataZothersrrrÚimplyNodeReferenceªs
 
zModuleGraph.implyNodeReferencecCs| |¡}| |¡\}}|S)zt
        Yield all nodes that `fromnode` dependes on (that is,
        all modules that `fromnode` imports.
        )rÚ    get_edges)rÚfromnoder¯Z    out_edgesÚ_rrrÚoutgoingÎs
zModuleGraph.outgoingTccsf| |¡}| |¡\}}|rR|D].}t|tƒrH| |d¡D]
}|Vq:q |Vq n|D]
}|VqVdSr)rr%rÓrµÚincoming)rÚtonodeZcollapse_missing_modulesr¯r'Zin_edgesÚnrrrr)Ús
 
 
 
zModuleGraph.incomingcCs&| |¡}| |¡}|j ||¡dk    S)z> Return True iff there is an edge from 'fromnode' to 'tonode' N)rråZ edge_by_node)rr&r*rrrÚhasEdgeís
 
zModuleGraph.hasEdgecCsº| |¡}| ¡D]¢}|j |jd¡s*q| |¡\}}|D]2}|j |jd¡rTq<| ||¡s<| ||d¡q<|D]2}|j |jd¡rŒqt| ||¡st| ||d¡qt|j |¡qdS)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(zpkg-internal-importz
pkg-importN)    rÚnodesrxr<r%r,r!råZ    hide_node)rZ packagenoderr+Ziter_outZiter_incrqrrrÚfoldReferencesôs 
   zModuleGraph.foldReferencesc    Cstz| ||¡}Wn&ttfk
r6| |||¡YSXt|tƒrLt|tƒs\| |||¡n| ||| |¡¡dSr)ZedgeDataÚKeyErrorrÚadd_edgerÓrlZupdateEdgeDatarr)rr&r*r#Zedrrrr!szModuleGraph._updateReferenceÚdirectcstt|ƒj|||dS)z<
        Create a reference from fromnode to tonode
        ©r#)r«rÿÚcreateReference)rr&r*r#r°rrr0$szModuleGraph.add_edgec    s
tt|ƒ |¡}|dk    r|S||jkr¬|j |¡}|dkrH| t|¡}n`t|tƒr€|     |dd¡ ¡}| t
||¡}|  ||¡n(|     |dd¡ ¡}|D]}|  ||¡q–|S||j kr|r|j  |¡}| t |¡}d|_t|||jƒ|_|j|j |g¡|_|SdS)aX
        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
            Whether or not to implicitly instantiate namespace packages. If
            `True` _and_ this name is that of a previously registered namespace
            package (i.e., in `self.nspackages`) not already added to the
            graph, this package will be added to the graph. Defaults to `True`.
 
        Returns
        ----------
        Node
            Graph node of this module if added to the graph _or_ `None`
            otherwise.
        Nú-)r«rÿÚfindNoderrörr´rÓr¨r"rªr$r
rÅrvr9r0ryrre)    rr®Z create_nspkgÚdataÚdepsrErqÚdepr5r°rrr,s.#
 
  zModuleGraph.find_nodec
    Cs2| dd|¡tj |¡}| |¡}|dk    r0|Stjddkrœt|dƒ}t     |¡}W5QRXt|t
|d}|  ¡d}W5QRX|  t ¡r¾|dd…}n"t|t
ƒ}|  ¡d}W5QRXt||d    tjd
ƒ}t||d    dd
ƒ}| t|¡}| ||d¡| |||¡}    | |    ¡||_|jr.| |j¡|_|S) z”
        Create a node by path (not module name).  It is expected to be a Python
        source file, and will be scanned for dependencies.
        rÚ
run_scriptNrÚrb©ÚencodingÚ
rÚexecT)Úmsgr/r0ÚrealpathrrTrUrrÚguess_encodingr Úreadr<ÚBOMÚcompilerÔÚ PyCF_ONLY_ASTrrºr!Ú
_scan_codeÚ_process_importsrurÚ_replace_paths_in_code)
rÚpathnameÚcallerrErr<ÚcontentsÚco_astrYr+rrrÚ
add_scriptzs0 
 
 
zModuleGraph.add_scriptcCs:| dd||||¡| |¡}| |||¡\}}| dd||¡|}|rÄ| d¡}    |    dkrbt|ƒ}    |d|    …||    dd…}
}d    |j|
f} | |
| |¡}|dkrD| dd
| ¡t    d t
| ƒƒ‚qD| dd |¡|} | g} |rt | t t fƒr| | |¡D]}|| krþ|  |¡qþ| D]} |j|| |d q| S)a«    
        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.
        rQZ _import_hookrSZ    load_tailr(rNrz%s.%sú"raise ImportError: No module namedúNo module named z load_tail ->r2)r?Ú_determine_parentÚ_find_head_packageÚmsginÚfindr rxÚ_safe_import_moduleÚmsgoutr ÚreprrÓrÃrªÚ%_import_importable_package_submodulesr4r!)rÚtarget_module_partnameÚ source_moduleÚtarget_attr_namesrïrîÚsource_packageÚtarget_packageÚ    submoduleÚiÚheadZmnamerŠÚtarget_modulesÚtarget_submodulerrrÚ import_hook¤sT:
ÿ
ÿÿ
ÿÿ
ÿ
zModuleGraph.import_hookcCst| dd|¡d}|rb|j}t|tƒr,|}n6d|krR|d| d¡…}| |¡}n|jrb| |¡}| dd|¡|S)z:
        Determine the package containing a node.
        rSZdetermine_parentNr(zdetermine_parent ->)rRrxrÓrÃÚrfindrryrU)rrJÚparentZpnamerrrrPs
 
zModuleGraph._determine_parentc Cs¼| dd|||¡d|kr,| dd¡\}}n|}d}|tkrV|rP|jd|}n|}nì|tkrh|}d}nÚ|dkrŽ| dd¡td    |||fƒ‚t|dƒD]Š}d|jkrÆ| dd¡td    |||fƒ‚|j dd¡d
}|     |¡}    |    dkr
| dd¡td    |||fƒ‚|    |k    s t
|    |fƒ‚|    }qš|r<|jd|}n|j}|  |||¡}
|
dkrz|dk    rz|}d}|  |||¡}
|
dk    rž|  dd |
|f¡|
|fS|  dd |¡t d |ƒ‚dS)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.
        rSZfind_head_packager(rróNrz"Relative import outside of packagezARelative import outside of package (name=%r, parent=%r, level=%r)rzfind_head_package ->rNrO)rRr3Ú!ABSOLUTE_OR_RELATIVE_IMPORT_LEVELrxÚABSOLUTE_IMPORT_LEVELr?r&ÚrangeÚrsplitrÚAssertionErrorrTrUr ) rr[rXrïZtarget_module_headnameZtarget_module_tailnameZtarget_package_namer^Zp_fqdnZ
new_parentr\rrrrQ/sŒ(
ÿ ÿÿ
 ÿÿ
 
 ÿÿ ÿ ÿÿ ÿ
zModuleGraph._find_head_packageccs¼t|ƒ}| dd||¡d|kr:| | |¡¡| d¡|D]l}| |¡}|dkr¤|jd|}| |||¡}|dkr¤| |¡r˜|     dd|j|¡q>n t
d|ƒ‚|Vq>| dd¡dS)    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.
        rSrWríNr(zD_import_importable_package_submodules: ignoring from-imported globalrOz(_import_importable_package_submodules ->) r~rRr‰Ú_find_all_submodulesrrŽrxrTr‚r?r )rÚpackageZ
attr_namesrr]Zsubmodule_namerrrrWºs*-
 
ÿ?
 z1ModuleGraph._import_importable_package_submodulesc
csŠ|js
dS|jD]t}zt |¡}Wn,tjtfk
rN| dd|¡YqYnXdd„|DƒD]$}|dkrlq^|ddkr^|dVq^qdS)Nrzcan't list directorycss|]}t|ƒVqdSr)r`)rr!rrrÚ    <genexpr>_sz3ModuleGraph._find_all_submodules.<locals>.<genexpr>rr)ryrrOr/rÚIOErrorr?)rrEr0rÖÚinforrrrjSs
 
 z ModuleGraph._find_all_submodulescCs| dd||f¡t|tƒs.tdt|ƒƒ‚t|tƒsHtdt|ƒƒ‚| |¡}|dk    r~t|tƒrn|j|ks~td||fƒ‚t|ƒ|j    |<dS)a¹
        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).
        rQzalias_module "%s" -> "%s"z"%s" not a module name.Nz,Target module "%s" already imported as "%s".)
r?rÓrHrirrªrxr>r¨r)rZsrc_module_nameZtrg_module_nameZ
trg_modulerrrÚ alias_modulefs 
ÿþÿÿzModuleGraph.alias_modulecCsš| dd|¡| |j¡}|dkr.| |¡n||ksFtd||fƒ‚|j d¡\}}}|r–| |¡}|dkr~| dd|¡n| ||¡| ||¡dS)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.
        rQÚ
add_moduleNzNew module %r != previous %r.r(rSzadd_module parent not found:)r?rrxZaddNoderiÚ
rpartitionr0rŒ)rræZ module_addedÚ parent_namer'Zmodule_basenamerdrrrrp‹s  
 zModuleGraph.add_modulecCs|j |g¡}| |¡dS)ax
        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)rÚ
setdefaultr4)rÚ package_nameÚ    directoryrfrrrÚappend_package_path±szModuleGraph.append_package_pathc
Cs¦| dd|||¡| |¡}|dkrPd}|dk    rT|jdk    rD|j}n| dd¡dSz| |||¡\}}Wn8tk
r¢}z| dd|¡WY¢dSd}~XYnX| |||¡\}}    |    dk    rPzZt|    tj    ƒrä|    }
t
|
|dddƒ}    nd}
|  ||    |
¡} |  | ¡|j r| |    ¡}    |    |_Wn4tk
rN| d    d
|¡t} | | |¡}YnX|dk    r”| d d |d |¡|j||tdddddd| ||¡| dd|¡|S)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.
        rQZsafe_import_moduleNz>safe_import_module -> None (parent_parent.packagepath is None)zsafe_import_module -> None (%r)r>rTrz#safe_import_module: SyntaxError in rSz#safe_import_module create referencez->F)rmrprnror2zsafe_import_module ->)rRrryrUÚ _find_moduler Ú _load_modulerÓrÔÚASTrDrFrGrrHruÚ SyntaxErrorr?r¿rr!rlrŒ) rZmodule_partnameÚ module_nameÚ parent_moduleræÚ search_dirsrIÚloaderrIrYrLr+rrrrrTÉsj!
 
 
 ÿ 
 
 
 
ÿ
üÿ     zModuleGraph._safe_import_modulec Csôddlm}| dd|||jj¡| d¡d}| |¡r&t|tƒ}|rZ|j    dd…}ng}t
  |¡}|rp|}t ||pzg|j ƒ}    |    sŠ|r¨|r¨| t|¡}
d|
_|    |
_nTt||ƒrÀ| t|¡}
n | t|¡}
||
_tj  |¡ d¡sèt‚tj  |¡g|    |
_|
j|j  |g¡|
_t|
tƒr&|
dfSd} |tkr<t} nt||ƒrPt} n|z| |¡} Wnrttfk
rÐ}zNt|tƒr’t|j tƒs’‚| !dd    |›d
|›d ¡| "|¡}| #|¡} W5d}~XYnX| dk    rrz>t$| |d t%j&d ƒ} t'} t(j)dd…dkrt$| dd dd ƒWnTtk
r8d} t*} Yn8t+k
rn}zt*} | !dd||¡W5d}~XYnXnZz | ,|¡} | dk    rŒt-nt.} Wn8t+k
rÊ}z| !dd||¡t.} W5d}~XYnX| | |¡}
||
_| /dd|
¡|
| fS)Nr)ÚExtensionFileLoaderrÚ load_moduler(rr4z    __init__.z)load_module: failed to obtain source for z: z&! Falling back to reading as raw data!r>T)rQéz load_module: InvalidSourceModulez4load_module: InvalidCompiledModule, Cannot load codezload_module ->)0Zimportlib._bootstrap_externalrrRr±rrqrrÓrrrkrer9r0rrÅrvryrÄrÃr/r]r<riÚdirnamerr r½rÂÚ
get_sourceÚUnicodeDecodeErrorrzÚ __context__r?Ú get_filenameÚget_datarDrÔrEr¾rTrUr¿Ú    ExceptionÚget_coderÀrÁrU)rrrIr~rZpartnameZis_nspkgÚpkgpathriZ
ns_pkgpathrErYrÚsrcÚer0rIrrrrx.sž  ÿ 
 
ÿ  
 
ÿ 
 
 
 ÿ
ÿ
ÿÿ zModuleGraph._load_modulec sˆ ddˆˆˆˆ¡‡‡‡‡fdd„}‡fdd„}d}d}    zˆjˆˆdˆ|d}Wnrtk
rÀˆ d    d
ˆˆˆ¡g}
ˆp€d D]4} ˆ td ˆˆ| ¡} ˆjˆ| |d |
 | ¡q‚|
YStk
rÆ} zè|ƒrrˆ ddˆˆˆf¡|ˆƒ}    |    rrˆg‰d‰d‰ˆ d    dˆˆˆf¡zˆjˆˆdˆ|d}Wn6tk
rp} zˆ d    dt    | ƒ¡W5d} ~ XYnX|dkr¶ˆ d    dt    | ƒ¡ˆ t
t | ˆƒ¡}ˆjˆ||d |g}W5d} ~ XYnXt |ƒdksät d |¡ƒ‚|d}t|t
ƒr6|    dkr6|ƒr6|ˆƒr6ˆ |¡ˆjˆˆdd|d}|St|tƒrN|jdd}ˆrt|ttfƒrˆD]¦}| |¡r¶| |¡}|dk    r¶||krhˆjˆ||d | |¡qh|jd |}ˆ |¡}|dkrÄz¨ˆjˆˆ|gˆ|dˆ |¡}|dkr<| |¡s"t d ||j¡ƒ‚ˆ ddd|j|¡Wqh|    r~ˆ |¡rdˆ d    d||f¡nˆ dd||f¡||_WnBtk
rÂ} z"ˆ d    dt    | ƒ¡ˆ t
|¡}W5d} ~ XYnX| ||¡|dk    rhˆj|||d ˆjˆ||d ||krh| |¡qh|S)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.
        rQr"csJˆdk    oHˆdkoHˆtkoHtˆƒtkoHˆdˆj d¡dkoHtjddkS)Nr'r(rrrQ)rfr¥r¾rxrqrTrUr)rïrYrZrXrrÚis_swig_candidateõsÿþ
ýÿü úz8ModuleGraph._safe_import_hook.<locals>.is_swig_candidatec    s^t|jdƒ}t |¡}W5QRXt|jt|d}| ¡}W5QRXˆ dd|¡d|kS)Nr:r;rz%SWIG wrapper candidate first line: %rzautomatically generated by SWIG)rrvrrAr Úreadliner?)rYZsource_module_filer<Ú
first_liner¡rrÚis_swig_wrapperþsz6ModuleGraph._safe_import_hook.<locals>.is_swig_wrapperN)rZrïrîrzInvalid relative importrír(r2rSz4SWIG import candidate (name=%r, caller=%r, level=%r)rórz.SWIG import (caller=%r, fromlist=%r, level=%r)zSWIG ImportError:z ImportError:z@Expected import_hook() toreturn only one module but received: {}rT)rpz!No global named {} in {}.__init__z#ignoring imported non-module globalz0SWIG import error: %r basename %r already existsz!SWIG import renamed from %r to %r)r?rbr&rUrr¶r!r4r rHrµrKr riÚformatrÓZ
removeNoder"rlÚ_replacerÃrªr†rrxrr‚rŒ)rrXrYrZrïrîrrr`Zis_swig_importrDÚsubrEr?rŠZtarget_submodule_partnameraZtarget_submodule_namer)rïrrYrZrXrr"¡sbR     þ 
ÿ 
ÿ "ÿþÿÿü
$
þÿÿÿ ÿÿþ
þ  
ÿ
 ÿ
 
ý
 ÿ
 
ü
 
ÿþþ     þÿþþþÿÿÿ
ÿÿ
zModuleGraph._safe_import_hookcCs@g|_|dk    r,| ||¡|j||ddn|j||dd|S)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.
        NF)Úis_scanning_importsT)rzÚ    _scan_astÚ_scan_bytecode)rræÚmodule_code_objectÚmodule_code_object_astrrrrF6
s3 ÿÿzModuleGraph._scan_codecCst||ƒ}| |¡dS)a
        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)rrær˜Zvisitorrrrr•}
s
zModuleGraph._scan_astc Csd}d}tdd}t |¡D]ø}|s&q|jdkrÒ|s6q|djdksHt‚|djdksZt‚|dj}|dj}|dks†t|ƒtks†t‚|j}d}    |dk    r¶t|ƒ}d    |kr¶|     d    ¡d
}    |j
  |    ||||fif¡n8|jd krî|j}
|  |
¡n|jd kr
|j}
|  |
¡|  |¡qdS) aì
        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éþÿÿÿÚ
LOAD_CONSTrFríT)Ú
STORE_NAMEÚ STORE_GLOBAL)Ú DELETE_NAMEÚ DELETE_GLOBAL)rrZiterate_instructionsÚopnameriÚargvalr¥rBrÝrrzr4rˆr) rrær—r”rïrpZ
prev_instsÚinstrXrðr®rrrr–—
sB?
 
 
 
 
 
ý
 
zModuleGraph._scan_bytecodecCsz|js
dS|jD]^\}}}|j||Ž}|s,q|d}|r| |¡|j |j¡|jdkr|d}|j |¡qd|_dS)aª
        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)rzr"r‹r|r‰rur‡)rrYrðZ import_infoÚkwargsr`rŠZtarget_module_namerrrrG+ s$ 
ÿ
ÿzModuleGraph._process_importscCsr|dk    r|jd|}n|}| |¡}|dk    rD| dd|¡t|ƒ‚|dkrd|tjkr^dtfS|j}| |||¡S)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(rQzfind_module: already included?)    rxrr?r rTÚbuiltin_module_namesr r0Ú_find_module_path)rr®r0rdÚfullnamer¯rrrrwk s
 
zModuleGraph._find_modulec
Cs˜| dd||¡d}g}zî|D]Î}t |¡}|dkr6qt|dƒrZ| |¡\}}    | |    ¡n&t|dƒrp| |¡}ntd||fƒ‚|dkrŠqd}
t|dƒr¤| |¡}
n"t|dƒr¶|j    }
ntd    ||fƒ‚|
dkrÞ| 
dd
|
¡q|
|f}qq|r|d t |ƒf}Wndt k
r8} z|  d d | ¡W5d} ~ XYn4tk
rj} z|  dd| ¡‚W5d} ~ XYnX|  dd|¡|dkr”tdt|ƒƒ‚|S)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.
        rSz_find_module_path <-NÚ find_loaderÚ find_modulez)Module %r importer %r loader unobtainabler†r0z%Module %r loader %r path unobtainablez _find_module_path path not foundrrz"_find_module_path -> unicode errorz_find_module_path -> exceptionz_find_module_path ->rO)rRr rr¬r©Úextendrªr r†r0r?rr„rUrˆrV) rr¨r{r}Z    path_datarZ
search_dirrr~Zloader_namespace_dirsrIrIrrrr§ž s\'
 
ÿ 
 
ÿ
 
 
ÿÿ
zModuleGraph._find_module_pathcCsä|dkrtj}g}g}| ¡D]:}tj |j¡}t|tƒrJ|     ||f¡q|     ||f¡q| 
¡| 
¡dd„|Dƒ}|  |¡|}dd  |¡}t td|i|ddd„}|D]\}}    d    }
t|    tƒrÜt|d
d œ}
nDt|    tƒrüt|d |    jd œ}
n$t|    jpd    ƒ} t|| |    jjd œ}
t|| |    ¡ƒ\} } | rxg}| D]}|     d||f¡qBd  |¡}|
td|dœ7}
| r¼g}| D]}|     d||f¡q†d  |¡}|
td|dœ7}
t t||
dœ|dq´t t|ddS)NcSsg|] \}}|‘qSrr)rZsnrErrrrÒ. sz+ModuleGraph.create_xref.<locals>.<listcomp>z modulegraph cross reference for z, ZTITLE)ÚfilecSsdd„|Dƒ}| ¡|S)NcSsg|]}|rtj |j¡‘qSr)r/r0r]rx)rÚmodrrrrÒ6 szDModuleGraph.create_xref.<locals>.sorted_namelist.<locals>.<listcomp>)Úsort)ÚmodsÚlstrrrÚsorted_namelist5 sz0ModuleGraph.create_xref.<locals>.sorted_namelistróz<i>(builtin module)</i>)ÚNAMEÚTYPEz <tt>%s</tt>)r²ÚURLr³z  <a href="#%s">%s</a>
z     &#8226; Úimports)ÚHEADZLINKSz imported by)r²ZCONTENT)rTÚstdoutÚ
iter_graphr/r0r]rxrÓrºr4r®r«r1ÚprintrZr½ÚcontplrÂrvr Ú contpl_linkedr±rÚmapr%rµrÚfooter)rÚoutÚscriptsr¯r­r®Ú scriptnamesÚtitler±rEÚcontentÚurlZouteZinceÚlinksr+rrrÚ create_xref  s\ 
 
 
ÿ
 
ÿ
ÿ
 
zModuleGraph.create_xrefÚGc  #sttt|jj|j |¡ƒƒ}|jj‰tƒ}tƒ}i}i}i}tƒ}    t|ƒ}dd„}
dd„‰d|fVtddd} d    ‰|      ¡D]} d
ˆ| fVq||D]H\} }}}t
|d dƒ|| <t |t ƒr–| ||j <t| gƒ|| <| | ¡q–|D]À\} }}}‡fd d „|DƒD]}| |¡qd| d ‡fdd„|
| |||ƒ     ¡Dƒ¡fV| | ¡}|dkrftƒ}|| <|| }|dkrzqä| |d| d¡…¡}|dk    rä| |¡qäg}i}|D]}g||<q²|rö| ¡\}}}}||f|    krêqÂ|     ||f¡||}|||@}|sl|rlt|ƒ}t|ƒdks<|d|krl| ||||df¡| |d|d|f¡qÂ|rà| ¡}||kr˜| ||||f¡nF||krº|| |d||f¡n$| ||||f¡| ||||f¡n| ||||f¡q‡‡fdd„}|     ¡D]D\}}d|fVd||fV||dƒD] }|Vq:dVq ||dƒD] }|Vq\dVdS)NcSs^t|tƒsdt|ƒiSdt|ƒj}t| ¡dd…dƒD]\}}|d||f7}q:|ddœS)NÚlabelz<f0> rz
| <f%d> %sÚrecord)rÇÚshape)rÓrtrHr¥rÚ    enumerater¤)r¯r6r(r)Úsr^ÚvrrrÚ nodevisitori s 
 z0ModuleGraph.itergraphreport.<locals>.nodevisitorcSs$|dkrddiS|dkr ddiSiS)NZorphanÚstyleZdashedÚpkgrefZdottedr)Úedger6r_ÚtailrrrÚ edgevisitort s
z0ModuleGraph.itergraphreport.<locals>.edgevisitorzdigraph %s {
charset="UTF-8";
ZLRÚtrue)ZrankdirZ concentratez%s="%s"z    %s;
rxc3s|]}ˆ|ƒVqdSrr)rrŒ)Ú describe_edgerrrlŽ sz.ModuleGraph.itergraphreport.<locals>.<genexpr>z     "%s" [%s];
ú,csg|] }ˆ|‘qSrr©rÚitem©ÚcpattrrrҔ sz/ModuleGraph.itergraphreport.<locals>.<listcomp>r(rrrÏrc    3sT|d}|D]B\}}}}ˆ||||ƒ}|||d ‡fdd„| ¡Dƒ¡fVq dS)Nz"%s" -> "%s" [%s];
rÕcsg|] }ˆ|‘qSrrrÖrØrrrÒË szAModuleGraph.itergraphreport.<locals>.do_graph.<locals>.<listcomp>)r1Úitems)ÚedgesÚtabsZedgestrrÐr6r_rÑZattribs)rÙrÒrrÚdo_graphà sýz-ModuleGraph.itergraphreport.<locals>.do_graphz    subgraph "cluster_%s" {
z        label="%s";
z        z    }
ú    z}
)r+r¼råZ describe_nodeZiterdfsrÔrr~rrÚr’rÓrÃrxr‡r4r1rercÚpopleftÚsortedr rö) rr®Ú flatpackagesr-rÛZ packagenodesZ packageidentsZ nodetoidentZ
inpackagesZ    mainedgesrÍÚattrr×r¯r6r(r)rÐZinsideÚidentZpkgnoderåZ    subgraphsr$r_rÑZtailpkgsÚcommonZusepkgsrÝÚgrËr)rÙrÔrÒrÚitergraphreport[ s˜        
 
 þþ
 
 
 
 
 
 
 
zModuleGraph.itergraphreportcCs$|dkrtj}| |j|d¡dS)N)rá)rTr·Ú
writelinesræ)rÚfileobjrárrrÚ graphreportÚ szModuleGraph.graphreportcCs\tƒtddƒtddƒt| ¡dd„dD]$}tdt|ƒj|j|jpNdfƒq2dS)    z’Print 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)ZClassÚNameÚFile)z-----ú----rìcSs|jSrr£)r+rrrr"æ r#z$ModuleGraph.report.<locals>.<lambda>)r$róN)r¹ràr¸r¥rrxrv)rrErrrÚreportß s
  zModuleGraph.reportc    CsXtj |j¡}}|jD]F\}}tj |d¡}tj |d¡}| |¡r||t|ƒd…}qdq|St|j    ƒ}t
t|ƒƒD](}t ||t |ƒƒrz|  ||¡||<qzt |ƒ}t|dƒrÈ|jt|ƒ|dSt|dƒr||j|j|j|j|j|jt|ƒ|j|j||j|j|j|j|jƒS||j|j|j|j|jt|ƒ|j|j||j|j|j|j|jƒSdS)NróÚreplace)Ú    co_constsÚ co_filenameÚco_kwonlyargcount)r/r0Únormpathrðrr1r<r r+rïrgrÓr¥rHr¬rîrBÚ co_argcountrñÚ
co_nlocalsÚ co_stacksizeÚco_flagsÚco_codeÚco_namesÚ co_varnamesÚco_nameÚco_firstlinenoÚ    co_lnotabÚ co_freevarsÚ co_cellvars)    rrYZ new_filenameZoriginal_filenameÚfrÑZconstsr^Z    code_funcrrrrHé sf
 
 
 
ÿ ûûz"ModuleGraph._replace_paths_in_code)NrrrNr)N)T)r1)T)N)N)N)N)rÆr)Nr)0rrrr§rrrr    r$r(Z getReferencesr)Z getReferersr,r.r!r0r3rr5rÚflattenr¸rMràrbrPrQrWrjrorprvrTrxr"rFr•r–rGrwr§rÅrærérírHr²rrr°rrÿEsp
?
$
 
% K
-ú
qü
 %&euþ
ü
G@
3
;

 
rÿ)N)[r§r)rÔÚcodecsrVrWr/r rTrGÚ collectionsrrrLZaltgraph.ObjectGraphrZaltgraphrrórrÚ_compatr    r
r r ÚBOM_UTF8ÚdecoderCr rrerfrUràr\Z _IMPORTABLE_FILETYPE_TO_METADATAràZ_IMPORTABLE_FILETYPE_EXTSrdrr r&r9rDr?rFrKrPr[r`rcrarkrjrgrlrtrHr¨rªr³r´rµr¶rºr»r½r¾r¿rÀrÁrÂrÃrÄrÅrÆrÇrÈrÏrZrrºr»rµr½rØrÝZ NodeVisitorrÞrÿrrrrÚ<module>s®             þþÿ'
 
 
 
 
ÿ%    
 
     f