How to use the importlab.resolve.Direct function in importlab

To help you get started, we’ve selected a few importlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github google / importlab / tests / test_resolve.py View on Github external
def testResolveRelativeSymbol(self):
        # importing the Symbol object from baz/__init__.py while in baz/f.py
        parent = resolve.Direct("baz/f.py", "baz.f")
        imp = parsepy.ImportStatement(".Symbol", is_from=True)
        r = resolve.Resolver(self.path, parent)
        f = r.resolve_import(imp)
        self.assertTrue(isinstance(f, resolve.Local))
        self.assertEqual(f.path, "baz/__init__.py")
        self.assertEqual(f.module_name, "baz")
github google / importlab / tests / test_graph.py View on Github external
def get_source_file_provenance(self, filename):
        return resolve.Direct(filename, "module.name")
github google / importlab / tests / test_graph.py View on Github external
def get_source_file_provenance(self, filename):
        return resolve.Direct(filename, 'module.name')
github google / importlab / importlab / graph.py View on Github external
def _add_source_file(self, filename):
        self.sources.add(filename)
        self.provenance[filename] = resolve.Direct(filename)
github google / importlab / importlab / graph.py View on Github external
def get_source_file_provenance(self, filename):
        return resolve.Direct(filename)
github google / importlab / importlab / resolve.py View on Github external
def __init__(self, path, module_name=''):
        # We do not necessarily have a module name for a directly added file.
        super(Direct, self).__init__(path, module_name)
github google / importlab / importlab / output.py View on Github external
def format_file_node(import_graph, node, indent):
    """Prettyprint nodes based on their provenance."""
    f = import_graph.provenance[node]
    if isinstance(f, resolve.Direct):
        out = '+ ' + f.short_path
    elif isinstance(f, resolve.Local):
        out = '  ' + f.short_path
    elif isinstance(f, resolve.System):
        out = ':: ' + f.short_path
    elif isinstance(f, resolve.Builtin):
        out = '(%s)' % f.module_name
    else:
        out = '%r' % node
    return '  '*indent + out