modvis: Color by package (actually os.path.dirname)

This commit is contained in:
Juha Jeronen
2019-10-31 11:03:17 +02:00
parent 3431c25147
commit 6f0ccdca92

View File

@@ -100,12 +100,12 @@ class ImportVisitor(ast.NodeVisitor):
# TODO: then we could create nodes also for the modules listed in the *values* of self.modules.
for m in self.modules:
ns, mod = split_module_name(m)
fn = self.filenames[m]
package = os.path.dirname(self.filenames[m])
# print("{}: ns={}, mod={}, fn={}".format(m, ns, mod, fn))
n = pyan.node.Node(namespace=ns,
name=mod,
ast_node=None,
filename=fn,
filename=package, # HACK: visualizing at module level, so color by package.
flavor=pyan.node.Flavor.MODULE)
n.defined = True
# Pyan's analyzer.py allows several nodes to share the same short name,