Commit ab2103e9 authored by Stefan Behnel's avatar Stefan Behnel

minor code reformatting

parent 5d23e513
...@@ -80,6 +80,7 @@ def use_utility_code_definitions(scope, target, seen=None): ...@@ -80,6 +80,7 @@ def use_utility_code_definitions(scope, target, seen=None):
elif entry.as_module: elif entry.as_module:
use_utility_code_definitions(entry.as_module, target, seen) use_utility_code_definitions(entry.as_module, target, seen)
def sort_utility_codes(utilcodes): def sort_utility_codes(utilcodes):
ranks = {} ranks = {}
def get_rank(utilcode): def get_rank(utilcode):
...@@ -92,19 +93,23 @@ def sort_utility_codes(utilcodes): ...@@ -92,19 +93,23 @@ def sort_utility_codes(utilcodes):
get_rank(utilcode) get_rank(utilcode)
return [utilcode for utilcode, _ in sorted(ranks.items(), key=lambda kv: kv[1])] return [utilcode for utilcode, _ in sorted(ranks.items(), key=lambda kv: kv[1])]
def normalize_deps(utilcodes): def normalize_deps(utilcodes):
deps = {} deps = {}
for utilcode in utilcodes: for utilcode in utilcodes:
deps[utilcode] = utilcode deps[utilcode] = utilcode
def unify_dep(dep): def unify_dep(dep):
if dep in deps: if dep in deps:
return deps[dep] return deps[dep]
else: else:
deps[dep] = dep deps[dep] = dep
return dep return dep
for utilcode in utilcodes: for utilcode in utilcodes:
utilcode.requires = [unify_dep(dep) for dep in utilcode.requires or ()] utilcode.requires = [unify_dep(dep) for dep in utilcode.requires or ()]
def inject_utility_code_stage_factory(context): def inject_utility_code_stage_factory(context):
def inject_utility_code_stage(module_node): def inject_utility_code_stage(module_node):
module_node.prepare_utility_code() module_node.prepare_utility_code()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment