Skip to content

octoprint.vendor.imp#

This module provides the components needed to build your own import function. Undocumented functions are obsolete.

In most cases it is preferred you consider using the importlib module's functionality over this module.

Taken from CPython 3.7.0 and vendored to still have it when it gets completely removed.

Licensed under the PSF LICENSE AGREEMENT https://docs.python.org/3/license.html

NullImporter #

Null import object.

find_module(fullname) #

Always returns None.

cache_from_source(path, debug_override=None) #

Given the path to a .py file, return the path to its .pyc file.

The .py file does not need to exist; this simply returns the path to the .pyc file calculated as if the .py file were imported.

If debug_override is not None, then it must be a boolean and is used in place of sys.flags.optimize.

If sys.implementation.cache_tag is None then NotImplementedError is raised.

find_module(name, path=None) #

Search for a module.

If path is omitted or None, search for a built-in, frozen or special module and continue search in sys.path. The module name cannot contain '.'; to search for a submodule of a package, pass the submodule name and the package's path.

get_magic() #

Return the magic number for .pyc files.

get_tag() #

Return the magic tag for .pyc files.

init_builtin(name) #

Load and return a built-in module by name, or None is such module doesn't exist

load_compiled(name, pathname, file=None) #

DEPRECATED

load_dynamic(name, path, file=None) #

Load an extension module.

load_module(name, file, filename, details) #

Load a module, given information returned by find_module().

The module name must include the full package name, if any.

new_module(name) #

Create a new module.

The module is not entered into sys.modules.

reload(module) #

Reload the module and return it.

The module must have been successfully imported before.

source_from_cache(path) #

Given the path to a .pyc. file, return the path to its .py file.

The .pyc file does not need to exist; this simply returns the path to the .py file calculated to correspond to the .pyc file. If path does not conform to PEP 3147 format, ValueError will be raised. If sys.implementation.cache_tag is None then NotImplementedError is raised.

Back to top