98100abde55f1fb0ab455f95b9259c3adcdbab2c,PyInstaller/building/imphook.py,ImportHook,_process_excludedimports,#ImportHook#Any#,267
Before Change
not_allowed_references = set(self._module.excludedimports)
// Remove references between module nodes, as if they are not imported from "name"
for item in not_allowed_references:
try:
excluded_node = mod_graph.findNode(item)
if excluded_node is not None:
logger.info("Excluding import "%s"" % item)
safe_to_remove = self._remove_module_references(excluded_node, mod_graph,
mod_filter=not_allowed_references)
// If no other modules reference the excluded_node then it is safe to remove
// all references to excluded_node and its all submodules.
// NOTE: Removing references from graph will keep some dead branches that
// are not reachable from the top-level script. But import hoosks
// for modules in dead branches will get processed!
// TODO Find out a way to remove unreachable branches in the graph. - Create a new graph object that will be constructed just from the top-level script?
if safe_to_remove:
submodule_list = set()
// First find submodules.
for subnode in mod_graph.nodes():
if subnode.identifier.startswith(excluded_node.identifier + "."):
submodule_list.add(subnode)
// Then remove references to those submodules.
for mod in submodule_list:
mod_referers = mod_graph.getReferers(mod)
for mod_ref in mod_referers:
mod_graph.removeReference(mod_ref, mod)
logger.warn(" Removing import "%s"" % mod.identifier)
mod_graph.removeNode(mod)
// Remove the parent node itself.
logger.warn(" Removing import "%s"" % item)
mod_graph.removeNode(excluded_node)
else:
logger.info("Excluded import "%s" not found" % item)
except ImportError:
// excludedimport could not be found.
// modulegraph raises ImporError when a module is not found.
logger.info("Excluded import "%s" not found" % item)
def _process_datas(self, mod_graph):
"datas" is a list of globs of files or
directories to bundle as datafiles. For each
After Change
logger.info("Import to be excluded not found: %r", item)
continue
logger.info("Excluding import %r", item)
targets_to_remove.extend(find_all_package_nodes(item))
// Remove references between module nodes, as though they would
// not be imported from "name".
for src in hooked_mods:
In pattern: SUPERPATTERN
Frequency: 4
Non-data size: 4
Instances Project Name: pyinstaller/pyinstaller
Commit Name: 98100abde55f1fb0ab455f95b9259c3adcdbab2c
Time: 2015-10-19
Author: h.goebel@crazy-compilers.com
File Name: PyInstaller/building/imphook.py
Class Name: ImportHook
Method Name: _process_excludedimports
Project Name: sahana/eden
Commit Name: af96485679049ebacca8877c9ca4b444ae6aed12
Time: 2020-04-13
Author: dominic@nursix.org
File Name: modules/s3db/hms.py
Class Name:
Method Name: hms_hospital_rheader
Project Name: deepgram/kur
Commit Name: f9e27737834aa42092518755743a26a4785e198c
Time: 2017-01-31
Author: ajsyp@syptech.net
File Name: kur/providers/batch_provider.py
Class Name: BatchProvider
Method Name: __iter__
Project Name: pyinstaller/pyinstaller
Commit Name: 22c60de32fd53c362ccdba52c6ee648e4ad6ae6c
Time: 2017-08-11
Author: xoviat@users.noreply.github.com
File Name: PyInstaller/depend/utils.py
Class Name:
Method Name: __recursivly_scan_code_objects_for_ctypes