MCPcopy
hub / github.com/pyinstaller/pyinstaller / find_node

Method find_node

PyInstaller/lib/modulegraph/modulegraph.py:1099–1168  ·  view source on GitHub ↗

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`

(self, name, create_nspkg=True)

Source from the content-addressed store, hash-verified

1097 createReference = add_edge
1098
1099 def find_node(self, name, create_nspkg=True):
1100 """
1101 Graph node uniquely identified by the passed fully-qualified module
1102 name if this module has been added to the graph _or_ `None` otherwise.
1103
1104 If (in order):
1105
1106 . A namespace package with this identifier exists _and_ the passed
1107 `create_nspkg` parameter is `True`, this package will be
1108 instantiated and returned.
1109 . A lazy node with this identifier and:
1110 * No dependencies exists, this node will be instantiated and
1111 returned.
1112 * Dependencies exists, this node and all transitive dependencies of
1113 this node be instantiated and this node returned.
1114 . A non-lazy node with this identifier exists, this node will be
1115 returned as is.
1116
1117 Parameters
1118 ----------
1119 name : str
1120 Fully-qualified name of the module whose graph node is to be found.
1121 create_nspkg : bool
1122 Ignored.
1123
1124 Returns
1125 ----------
1126 Node
1127 Graph node of this module if added to the graph _or_ `None`
1128 otherwise.
1129 """
1130
1131 data = super(ModuleGraph, self).findNode(name)
1132
1133 if data is not None:
1134 return data
1135
1136 if name in self.lazynodes:
1137 deps = self.lazynodes.pop(name)
1138
1139 if deps is None:
1140 # excluded module
1141 m = self.createNode(ExcludedModule, name)
1142 elif isinstance(deps, Alias):
1143 # NOTE: the AliasNode must be created and added to graph
1144 # before trying to create the referred node; that might
1145 # (due to recursive import analysis) lead to another
1146 # attempt to resolve the aliased node (and if there is
1147 # a real node that we are trying to shadow with the alias,
1148 # that will end up added to the graph and prevent the
1149 # alias node from being added).
1150 m = self.createNode(AliasNode, name)
1151
1152 # Create the referred node.
1153 other = self._safe_import_hook(deps, None, None).pop()
1154
1155 # Copy attributes; this used to be done by AliasNode
1156 # constructor, back when referred node was created before

Calls 5

createNodeMethod · 0.95
_safe_import_hookMethod · 0.95
implyNodeReferenceMethod · 0.95
popMethod · 0.80