module documentation

Representation of modules.

Class Module Inferred information about a module.
Function get_absolute_name Joins a dotted-name prefix and a relative name.
Function get_all_prefixes Return all the prefixes of a module name.
Function get_module_name Get the module name, or None if we can't determine it.
Function get_package_name Figure out a package name for a module.
Function infer_module Convert a filename to a module relative to pythonpath.
Function path_to_module_name Converts a filename into a dotted module name.
Function strip_init_suffix Undocumented
def get_absolute_name(prefix, relative_name): (source)

Joins a dotted-name prefix and a relative name. Args: prefix: A dotted name, e.g. foo.bar.baz relative_name: A dotted name with possibly some leading dots, e.g. ..x.y Returns: The relative name appended to the prefix, after going up one level for each leading dot. e.g. foo.bar.baz + ..hello.world -> foo.bar.hello.world None if the relative name has too many leading dots.

def get_all_prefixes(module_name): (source)

Return all the prefixes of a module name. e.g. x.y.z => x, x.y, x.y.z Args: module_name: module name Returns: List of prefixes

def get_module_name(filename, pythonpath): (source)

Get the module name, or None if we can't determine it.

def get_package_name(module_name, is_package=False): (source)

Figure out a package name for a module.

def infer_module(filename, pythonpath): (source)

Convert a filename to a module relative to pythonpath. This method tries to deduce the module name from the pythonpath and the filename. This will not always be possible. (It depends on the filename starting with an entry in the pythonpath.) Args: filename: The filename of a Python file. E.g. "foo/bar/baz.py". pythonpath: The path Python uses to search for modules. Returns: A Module object.

def path_to_module_name(filename): (source)

Converts a filename into a dotted module name.

def strip_init_suffix(parts: Sequence[str]): (source)

Undocumented