コード例 #1
0
ファイル: builder.py プロジェクト: RamchandraApte/astroid
 def module_build(self, module, modname=None):
     """Build an astroid from a living module instance."""
     node = None
     path = getattr(module, '__file__', None)
     if path is not None:
         path_, ext = os.path.splitext(modutils._path_from_filename(path))
         if ext in ('.py', '.pyc', '.pyo') and os.path.exists(path_ + '.py'):
             node = self.file_build(path_ + '.py', modname)
     if node is None:
         # this is a built-in module
         # get a partial representation by introspection
         node = self.inspect_build(module, modname=modname, path=path)
         if self._apply_transforms:
             # We have to handle transformation by ourselves since the
             # rebuilder isn't called for builtin nodes
             node = self._manager.visit_transforms(node)
     return node
コード例 #2
0
def _get_file_from_object(obj):
    return modutils._path_from_filename(obj.__file__)
コード例 #3
0
def _get_file_from_object(obj):
    return modutils._path_from_filename(obj.__file__)