Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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")
def get_source_file_provenance(self, filename):
return resolve.Direct(filename, "module.name")
def get_source_file_provenance(self, filename):
return resolve.Direct(filename, 'module.name')
def _add_source_file(self, filename):
self.sources.add(filename)
self.provenance[filename] = resolve.Direct(filename)
def get_source_file_provenance(self, filename):
return resolve.Direct(filename)
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)
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