MCPcopy Create free account
hub / github.com/jasperproject/jasper-client / check_python_import

Function check_python_import

client/diagnose.py:69–89  ·  view source on GitHub ↗

Checks if a python package or module is importable. Arguments: package_or_module -- the package or module name to check Returns: True or False

(package_or_module)

Source from the content-addressed store, hash-verified

67
68
69def check_python_import(package_or_module):
70 """
71 Checks if a python package or module is importable.
72
73 Arguments:
74 package_or_module -- the package or module name to check
75
76 Returns:
77 True or False
78 """
79 logger = logging.getLogger(__name__)
80 logger.debug("Checking python import '%s'...", package_or_module)
81 loader = pkgutil.get_loader(package_or_module)
82 found = loader is not None
83 if found:
84 logger.debug("Python %s '%s' found: %r",
85 "package" if loader.is_package(package_or_module)
86 else "module", package_or_module, loader.get_filename())
87 else:
88 logger.debug("Python import '%s' not found", package_or_module)
89 return found
90
91
92def get_pip_requirements(fname=os.path.join(jasperpath.LIB_PATH,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected