示例#1
0
 def visit_import(self, node):
     """visit an astng.Import node
     
     resolve module dependencies
     """
     context_file = node.root().file
     for name in node.names:
         relative = is_relative(name[0], context_file)
         self._imported_module(node, name[0], relative)
示例#2
0
 def visit_import(self, node):
     """visit an astng.Import node
     
     resolve module dependencies
     """
     context_file = node.root().file
     for name in node.names:
         relative = is_relative(name[0], context_file)
         self._imported_module(node, name[0], relative)
示例#3
0
 def visit_from(self, node):
     """visit an astng.From node
     
     resolve module dependencies
     """
     basename = node.modname
     context_file = node.root().file
     if context_file is not None:
         relative = is_relative(basename, context_file)
     else:
         relative = False
     for name in node.names:
         if name[0] == '*':
             continue
         # analyze dependancies
         fullname = '%s.%s' % (basename, name[0])
         if fullname.find('.') > -1:
             try:
                 # XXX: don't use get_module_part, missing package precedence
                 fullname = get_module_part(fullname)
             except ImportError:
                 continue
         if fullname != basename:
             self._imported_module(node, fullname, relative)
示例#4
0
 def visit_from(self, node):
     """visit an astng.From node
     
     resolve module dependencies
     """
     basename = node.modname
     context_file = node.root().file
     if context_file is not None:
         relative = is_relative(basename, context_file)
     else:
         relative = False
     for name in node.names:
         if name[0] == '*':
             continue
         # analyze dependancies
         fullname = '%s.%s' % (basename, name[0])
         if fullname.find('.') > -1:
             try:
                 # XXX: don't use get_module_part, missing package precedence
                 fullname = get_module_part(fullname)
             except ImportError:
                 continue
         if fullname != basename:
             self._imported_module(node, fullname, relative)