module — Utilities for module control

Last Version:0.2.1

This module provides utilities for module control, such as getting module object, name, version, copyright, documentation, list of presented classes (without imported or built-in classes), file, directory, etc.

module.get_name(module_name=None, default=None)

Return module name. If the __name__ attribute does not exist, default is returned. By default default is None. If module_name was not provided, the caller’s module will be used.

module.get_dir(module_name=None)

Return path to directory from where script with module was invoked. If module_name was not provided, the caller’s module will be used.

module.get_file(module_name=None, file_name=None)

Return the name of the (text or binary) file in which the module module_name was defined. If module_name does not provided the caller’s module will be used.

This function allows to find files next to module file. For example, the path to the setup.py from a given distribution package can be obtained as follows: module.get_file(__name__, 'setup.py').

module.get_classes(module_name=None)

Return all the classes of a module module_name in a list of (name, value) pairs. The list does not include imported or built-in classes. If module was not provided, the caller’s module will be used.

module.get_object(module_name=None)

Return module object of a module module_name. If module_name was not provided the caller’s module will be used.

module.get_version(module_name=None, default=None)

Return module version. If the __version__ attribute does not exist, default is returned. If module_name was not provided, the caller’s module will be used.

module.set_version(value, module_name=None)

Set module version. If module_name does not provided the caller’s module will be used.

Return a string containing the copyright pertaining to the module module_name. If the __copyright__ attribute does not exist, default is returned. If module_name was not provided, the caller’s module will be used.

Set module copyright. If module_name does not provided the caller’s module will be used.

module.get_doc(module_name=None, default=None)

Return the documentation string for a module module_name. If module_name was not provided, the caller’s module will be used.

class module.ModuleError

The base class for the exceptions related to module.

Authors

Alexander Sviridenko <oleks.sviridenko at gmail.com>

Table Of Contents

This Page