Back to index

python3.2  3.2.2
Namespaces | Functions | Variables
importlib Namespace Reference

Namespaces

namespace  _bootstrap
namespace  abc
namespace  machinery
namespace  test
namespace  util

Functions

def _case_ok
def _w_long
def _r_long
def import_module

Variables

list __all__ = ['__import__', 'import_module']

Detailed Description

A pure Python implementation of import.

References on import:

* Language reference
      http://docs.python.org/ref/import.html
* __import__ function
      http://docs.python.org/lib/built-in-funcs.html
* Packages
      http://www.python.org/doc/essays/packages.html
* PEP 235: Import on Case-Insensitive Platforms
      http://www.python.org/dev/peps/pep-0235
* PEP 275: Import Modules from Zip Archives
      http://www.python.org/dev/peps/pep-0273
* PEP 302: New Import Hooks
      http://www.python.org/dev/peps/pep-0302/
* PEP 328: Imports: Multi-line and Absolute/Relative
      http://www.python.org/dev/peps/pep-0328

Function Documentation

def importlib._case_ok (   directory,
  check 
) [private]
Check if the directory contains something matching 'check'.

No check is done if the file/directory exists or not.

Definition at line 31 of file __init__.py.

00031 
00032 def _case_ok(directory, check):
00033     """Check if the directory contains something matching 'check'.
00034 
00035     No check is done if the file/directory exists or not.
00036 
00037     """
00038     if 'PYTHONCASEOK' in os.environ:
00039         return True
00040     elif check in os.listdir(directory if directory else os.getcwd()):
00041         return True
00042     return False
00043 

Here is the caller graph for this function:

def importlib._r_long (   int_bytes) [private]
Convert 4 bytes in little-endian to an integer.

XXX Temporary until marshal's long function are exposed.

Definition at line 59 of file __init__.py.

00059 
00060 def _r_long(int_bytes):
00061     """Convert 4 bytes in little-endian to an integer.
00062 
00063     XXX Temporary until marshal's long function are exposed.
00064 
00065     """
00066     x = int_bytes[0]
00067     x |= int_bytes[1] << 8
00068     x |= int_bytes[2] << 16
00069     x |= int_bytes[3] << 24
00070     return x
00071 
00072 
00073 # Required built-in modules.
00074 try:
    import posix as _os

Here is the caller graph for this function:

def importlib._w_long (   x) [private]
Convert a 32-bit integer to little-endian.

XXX Temporary until marshal's long functions are exposed.

Definition at line 44 of file __init__.py.

00044 
00045 def _w_long(x):
00046     """Convert a 32-bit integer to little-endian.
00047 
00048     XXX Temporary until marshal's long functions are exposed.
00049 
00050     """
00051     x = int(x)
00052     int_bytes = []
00053     int_bytes.append(x & 0xFF)
00054     int_bytes.append((x >> 8) & 0xFF)
00055     int_bytes.append((x >> 16) & 0xFF)
00056     int_bytes.append((x >> 24) & 0xFF)
00057     return bytearray(int_bytes)
00058 

Here is the caller graph for this function:

def importlib.import_module (   name,
  package = None 
)
Import a module.

The 'package' argument is required when performing a relative import. It
specifies the package to use as the anchor point from which to resolve the
relative import to an absolute import.

Definition at line 108 of file __init__.py.

00108 
00109 def import_module(name, package=None):
00110     """Import a module.
00111 
00112     The 'package' argument is required when performing a relative import. It
00113     specifies the package to use as the anchor point from which to resolve the
00114     relative import to an absolute import.
00115 
00116     """
00117     level = 0
00118     if name.startswith('.'):
00119         if not package:
00120             raise TypeError("relative imports require the 'package' argument")
00121         for character in name:
00122             if character != '.':
00123                 break
00124             level += 1
00125     return _bootstrap._gcd_import(name[level:], package, level)

Here is the caller graph for this function:


Variable Documentation

list importlib.__all__ = ['__import__', 'import_module']

Definition at line 21 of file __init__.py.