Package epydoc :: Module imports
[show private | hide private]
[frames | no frames]

Module epydoc.imports

Module import support for epydoc.
Classes
_DevNull A "file-like" object that discards anything that is written and always reports end-of-file when read.

Function Summary
list of string find_modules(dirname)
If dirname contains a package, then return the filenames for the package, its modules, and all of its descendant packages and modules.
list of module import_module(name_or_filename)
Return the module with the given module name or filename.
(string, string) _find_module_from_filename(filename)
Break a module/package filename into a base directory and a module name.
  _find_modules(pkg)
Helper function for find_modules.
module _import_module(name)
Return the module with the given name.

Variable Summary
_DevNull _dev_null = <epydoc.imports._DevNull instance at 0x819a0...
SRE_Pattern _VALID_MODULE_NAME = ^[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*$

Function Details

find_modules(dirname)

If dirname contains a package, then return the filenames for the package, its modules, and all of its descendant packages and modules. If dirname does not contain a package, then return an empty list.
Parameters:
dirname - The directory name to search.
           (type=string)
Returns:
The filenames for the package in dirname, its modules, and all of its descendant packages and modules.
           (type=list of string)

import_module(name_or_filename)

Parameters:
name_or_filename - The module name or filename specifying which module to import.
           (type=string)
Returns:
The module with the given module name or filename.
  • If name_or_filename is the name of a module (such as os.path), then return that module.
  • If name_or_filename is the name of a file (such as epytext.py or multiarray.so), then return the module defined by that file.
If name_or_filename names both a file and a module, then import_module will treat it as a file name.
           (type=list of module)
Raises:
ImportError - If there was any problem importing the given object. In particular, an ImportError is raised if the given file does not exist; if the given file name does not name a valid module; or if importing the module causes any exception to be raised.

_find_module_from_filename(filename)

Break a module/package filename into a base directory and a module name. _find_module_from_filename checks directories in the filename to see if they contain "__init__.py" files; if they do, then it assumes that the module is part of a package, and returns the full module name. For example, if filename is "/tmp/epydoc/imports.py", and the file "/tmp/epydoc/__init__.py" exists, then the base directory will be "/tmp/" and the module name will be "epydoc.imports".
Parameters:
filename - The filename that contains the module. filename can be a directory (for a package); a .py file; a .pyc file; a .pyo file; or an .so file.
           (type=string)
Returns:
A pair (basedir, module), where basedir is the base directory from which the module can be imported; and module is the name of the module itself.
           (type=(string, string))

_find_modules(pkg)

Helper function for find_modules.

_import_module(name)

Parameters:
name - The name of the module to import. name is a fully qualified module name, such as os.path.
           (type=string)
Returns:
the module with the given name. import_module makes some attempts to prevent the imported module from modifying sys and __builtins__. In the future, more sandboxing might be added (e.g., using the rexec module).
           (type=module)
Raises:
ImportError - If there was any problem importing the given object. In particular, if importing the module causes any exception to be raised.

Variable Details

_dev_null

Type:
_DevNull
Value:
<epydoc.imports._DevNull instance at 0x819a044>                        

_VALID_MODULE_NAME

Type:
SRE_Pattern
Value:
^[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*$                                        

Generated by Epydoc 2.1 on Sat Mar 20 17:46:16 2004 http://epydoc.sf.net