Beispiel #1
0
 def astng_from_module_name(self, modname, context_file=None):
     """given a module name, return the astng object"""
     old_cwd = os.getcwd()
     if context_file:
         os.chdir(dirname(context_file))
     try:
         filepath = self.file_from_module_name(modname, context_file)
         if filepath is None or not is_python_source(filepath):
             try:
                 module = load_module_from_name(modname)
             except ImportError, ex:
                 msg = 'Unable to load module %s (%s)' % (modname, ex)
                 raise ASTNGBuildingException(msg)
             return self.astng_from_module(module, modname)
         return self.astng_from_file(filepath, modname, fallback=False)
Beispiel #2
0
 def astng_from_module_name(self, modname, context_file=None):
     """given a module name, return the astng object"""
     old_cwd = os.getcwd()
     if context_file:
         os.chdir(dirname(context_file))
     try:
         filepath = self.file_from_module_name(modname, context_file)
         if filepath is None or not is_python_source(filepath):
             try:
                 module = load_module_from_name(modname)
             except ImportError, ex:
                 msg = 'Unable to load module %s (%s)' % (modname, ex)
                 raise ASTNGBuildingException(msg)
             return self.astng_from_module(module, modname)
         return self.astng_from_file(filepath, modname, fallback=False)
Beispiel #3
0
 def callnew(*args, **kwargs):
     message = "object %s has been moved to module %s" % (objname, modpath)
     warn(message, DeprecationWarning, stacklevel=2)
     m = load_module_from_name(modpath)
     return getattr(m, objname)(*args, **kwargs)
 def callnew(*args, **kwargs):
     message = "object %s has been moved to module %s" % (objname, modpath)
     warn(message, DeprecationWarning, stacklevel=2)
     m = load_module_from_name(modpath)
     return getattr(m, objname)(*args, **kwargs)