def print_impacting_modules(single_node=None, json_out=None):
"""
For each module, print a list of modules that the module is depending on,
i.e. modules whose change can potentially impact the module. The function
shows all levels of dependency, not just the immediately imported
modules. If the json_out argument is not None, then the output will be
recorded there instead of on stdout.
:return:
"""
if json_out is None:
print('\n===Impacting Modules===')
else:
json_out['impacting_modules'] = {}
for node_name in G.nodes_iter():
if single_node and (node_name!=single_node):
continue
descendants = nx.descendants(G, node_name)
if json_out is None:
print(augment_format_string(node_name, '\n%s:') % node_name)
else:
json_out['impacting_modules'][node_name] = []
for d in descendants:
if json_out is None:
print(augment_format_string(d, ' %s') % d)
else:
json_out['impacting_modules'][node_name].append(d)
评论列表
文章目录