Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
ImportManager Class Reference

doesn't work in JPython... More...

Public Member Functions

def install
 
def uninstall
 
def add_suffix
 
def __init__
 

Data Fields

 previous_importer
 
 namespace
 
 fs_imp
 

Static Public Attributes

 clsFilesystemImporter = None
 PRIVATE METHODS. More...
 

Detailed Description

doesn't work in JPython...

Definition at line 27 of file imputil.py.

Constructor & Destructor Documentation

def __init__ (   self,
  fs_imp = None 
)

Definition at line 61 of file imputil.py.

References ImportManager.clsFilesystemImporter.

61 
62  def __init__(self, fs_imp=None):
63  # we're definitely going to be importing something in the future,
64  # so let's just load the OS-related facilities.
65  if not _os_stat:
66  _os_bootstrap()
67 
68  # This is the Importer that we use for grabbing stuff from the
69  # filesystem. It defines one more method (import_from_dir) for our use.
70  if not fs_imp:
71  cls = self.clsFilesystemImporter or _FilesystemImporter
72  fs_imp = cls()
73  self.fs_imp = fs_imp
74 
75  # Initialize the set of suffixes that we recognize and import.
76  # The default will import dynamic-load modules first, followed by
77  # .py files (or a .py file's cached bytecode)
78  for desc in imp.get_suffixes():
79  if desc[2] == imp.C_EXTENSION:
80  self.add_suffix(desc[0],
81  DynLoadSuffixImporter(desc).import_file)
82  self.add_suffix('.py', py_suffix_importer)

Member Function Documentation

def add_suffix (   self,
  suffix,
  importFunc 
)

Definition at line 50 of file imputil.py.

50 
51  def add_suffix(self, suffix, importFunc):
52  assert callable(importFunc)
53  self.fs_imp.add_suffix(suffix, importFunc)
def install (   self,
  namespace = vars(__builtin__) 
)

Definition at line 30 of file imputil.py.

30 
31  def install(self, namespace=vars(__builtin__)):
32  "Install this ImportManager into the specified namespace."
33 
34  if isinstance(namespace, _ModuleType):
35  namespace = vars(namespace)
36 
37  # Note: we have no notion of "chaining"
38 
39  # Record the previous import hook, then install our own.
40  self.previous_importer = namespace['__import__']
41  self.namespace = namespace
42  namespace['__import__'] = self._import_hook
43 
44  ### fix this
45  #namespace['reload'] = self._reload_hook
def uninstall (   self)

Definition at line 46 of file imputil.py.

References ImportManager.namespace, and ImportManager.previous_importer.

46 
47  def uninstall(self):
48  "Restore the previous import mechanism."
49  self.namespace['__import__'] = self.previous_importer

Field Documentation

clsFilesystemImporter = None
static

PRIVATE METHODS.

Definition at line 59 of file imputil.py.

fs_imp

Definition at line 72 of file imputil.py.

namespace

Definition at line 40 of file imputil.py.

previous_importer

Definition at line 39 of file imputil.py.


The documentation for this class was generated from the following file: