Skip to content

Commit 35e625a

Browse files
committed
COMP: Remove difficult to debug use of global variable
This is a first step in a larger refactoring to help keep the global namespace clean.
1 parent 3f0994e commit 35e625a

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

Wrapping/Generators/Python/itk/__init__.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
thisModule = sys.modules[__name__]
3030

3131

32-
def _GetLazyAttributes(local_lazy_attributes):
33-
templateNames = [t[0] for t in data["templates"]]
34-
isInLibrary = [t[3] for t in data["templates"] if len(t) > 3]
35-
local_attributes = dict([(n, module) for n in templateNames])
32+
def _GetLazyAttributes(local_lazy_attributes, l_module, l_data):
33+
templateNames = [t[0] for t in l_data["templates"]]
34+
isInLibrary = [t[3] for t in l_data["templates"] if len(t) > 3]
35+
local_attributes = dict([(n, l_module) for n in templateNames])
3636
attributesInModule = dict(
3737
[(n, belongs) for n, belongs in zip(templateNames, isInLibrary)]
3838
)
@@ -42,10 +42,10 @@ def _GetLazyAttributes(local_lazy_attributes):
4242
local_lazy_attributes.setdefault(kk, []).insert(0, vv)
4343
else:
4444
local_lazy_attributes.setdefault(kk, []).append(vv)
45-
if "snake_case_functions" in data:
46-
for function in data["snake_case_functions"]:
47-
local_lazy_attributes.setdefault(function, []).append(module)
48-
45+
if "snake_case_functions" in l_data:
46+
for function in l_data["snake_case_functions"]:
47+
local_lazy_attributes.setdefault(function, []).append(l_module)
48+
return l_module, l_data
4949

5050
if itkConfig.LazyLoading:
5151
# If we are loading lazily (on-demand), make a dict mapping the available
@@ -56,7 +56,7 @@ def _GetLazyAttributes(local_lazy_attributes):
5656
# file.
5757
lazyAttributes = {}
5858
for module, data in itkBase.module_data.items():
59-
_GetLazyAttributes(lazyAttributes)
59+
module, data = _GetLazyAttributes(lazyAttributes, module, data)
6060

6161
if isinstance(thisModule, itkLazy.LazyITKModule):
6262
# Handle reload case where we've already done this once.
@@ -84,7 +84,7 @@ def _GetLazyAttributes(local_lazy_attributes):
8484
# Populate itk.ITKModuleName
8585
for module, data in itkBase.module_data.items():
8686
attributes = {}
87-
_GetLazyAttributes(attributes)
87+
module, data = _GetLazyAttributes(attributes, module, data)
8888
itkModule = itkLazy.LazyITKModule(module, attributes)
8989
setattr(thisModule, module, itkModule)
9090

0 commit comments

Comments
 (0)