Skip to content

Commit

Permalink
STYLE: Update processing of *Config.py files
Browse files Browse the repository at this point in the history
Add classes with named elements to make understanding
the complex LazyLoading and template convenience function
building more transparent.
  • Loading branch information
hjmjohnson committed Nov 30, 2020
1 parent ba66340 commit 53e4fe0
Show file tree
Hide file tree
Showing 4 changed files with 223 additions and 140 deletions.
26 changes: 14 additions & 12 deletions Wrapping/Generators/Python/itk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,24 @@ def _initialize_module():
"""
A function to explicitly avoid polluting the global namespace
"""
from .support.itkBase import ITKModuleInfo, ITKTemplateFeatures

def _get_lazy_attributes(local_lazy_attributes, l_module, l_data):
template_feature_tuples = [
(t[0], t[3]) if len(t) > 3 else (t[0], False) for t in l_data["templates"]
]
for (template_name, is_in_library) in template_feature_tuples:
if is_in_library:
def _get_lazy_attributes(local_lazy_attributes, l_module, l_data: ITKModuleInfo):
for template_feature in l_data._template_feature_tuples:
if template_feature._class_in_module:
# insert in front front if in library
local_lazy_attributes.setdefault(template_name, []).insert(0, l_module)
local_lazy_attributes.setdefault(
template_feature._py_class_name, []
).insert(0, l_module)
else:
# append to end
local_lazy_attributes.setdefault(template_name, []).append(l_module)
if "snake_case_functions" in l_data:
for function in l_data["snake_case_functions"]:
# snake case always appended to end
local_lazy_attributes.setdefault(function, []).append(l_module)
local_lazy_attributes.setdefault(
template_feature._py_class_name, []
).append(l_module)

for function in l_data._snake_case_functions:
# snake case always appended to end
local_lazy_attributes.setdefault(function, []).append(l_module)

from .support import itkBase as _itkBase
from .support import itkLazy as _itkLazy
Expand Down
Loading

0 comments on commit 53e4fe0

Please sign in to comment.