Пример #1
0
 def load_module(self, fullname):
     module = ImpLoader.load_module(self, fullname)
     if hasattr(module, '__api__'):
         sys.modules[fullname] = _RamModule(module, module.__api__())
     else:
         sys.modules[fullname] = module
     return sys.modules[fullname]
Пример #2
0
 def find_module(self, fullname, path=None):
     try:
         real_path = self.mapping[fullname]
         return ImpLoader(fullname, None, real_path,
                          ('', '', imp.PKG_DIRECTORY))
     except KeyError:
         return None
Пример #3
0
 def load_module(self, fullname):
     module = ImpLoader.load_module(self, fullname)
     if not isinstance(module, UnitLibModule):
         if not IsSame(self.fullname):
             config = ram.query(self.fullname)
         else:
             config = None
         module = UnitLibModule(module, config)
     if not hasattr(module, '__path__'):
         setattr(module, '__path__', [])
     sys.modules[fullname] = module
     return module
Пример #4
0
 def find_module(self, fullname, path=None):
     # Note: we ignore 'path' argument since it is only used via
     # meta_path
     subname = fullname.split(".")[-1]
     if subname != fullname and self.path is None:
         return None
     if self.path is None:
         path = None
     else:
         path = [os.path.realpath(self.path)]
     try:
         file, filename, etc = imp.find_module(subname, path)
     except ImportError:
         return None
     return ImpLoader(fullname, file, filename, etc)
Пример #5
0
 def find_module(self, fullname, path=None):
     # this duplicates most of ImpImporter.find_module
     subname = fullname.split(".")[-1]
     if subname != fullname and self.path is None:
         return None
     if self.path is None:
         path = None
     else:
         path = [os.path.realpath(self.path)]
     try:
         file, filename, etc = imp.find_module(subname, path)
     except ImportError:
         return None
     if file and etc[2] == imp.PY_SOURCE:
         outfilename = maybe_2to3(filename, modname=fullname)
         if outfilename != filename:
             file.close()
             filename = outfilename
             file = open(filename, 'rb')
     return ImpLoader(fullname, file, filename, etc)
Пример #6
0
 def __init__(self, fullname, file, filename, etc):
     object.__init__(self)
     ImpLoader.__init__(self, fullname, file, filename, etc)
Пример #7
0
 def __init__(self, module):
     name = module.__name__
     path = os.path.dirname(module.__file__)
     description = ('', '', imp.PKG_DIRECTORY)
     ImpLoader.__init__(self, name, None, path, description)
Пример #8
0
 def __init__(self, module):
     name = module.__name__
     path = os.path.dirname(module.__file__)
     description = ("", "", imp.PKG_DIRECTORY)
     ImpLoader.__init__(self, name, None, path, description)