remove old hacks; ansible_collections is available at time of invoker but not later

pull/715/head
Steven Robertson 6 years ago
parent 1ef96b5827
commit 376d8d0fab

@ -554,6 +554,9 @@ def invoke(invocation):
)) ))
invocation.module_path = mitogen.core.to_text(path) invocation.module_path = mitogen.core.to_text(path)
#jjj
# if 'ansible_collections' in invocation.module_path:
# import epdb; epdb.set_trace()
if invocation.module_path not in _planner_by_path: if invocation.module_path not in _planner_by_path:
_planner_by_path[invocation.module_path] = _get_planner( _planner_by_path[invocation.module_path] = _get_planner(
invocation.module_name, invocation.module_name,

@ -159,21 +159,21 @@ def get_child_modules(path, fullname):
# ISSUE: not everything is being loaded via sys.modules in ansible when it comes to collections # ISSUE: not everything is being loaded via sys.modules in ansible when it comes to collections
# only `action` and `modules` show up in sys.modules[fullname] # only `action` and `modules` show up in sys.modules[fullname]
# but sometimes you want things like `module_utils` # but sometimes you want things like `module_utils`
if fullname.startswith("ansible_collections"): # if fullname.startswith("ansible_collections"):
submodules = [] # submodules = []
# import epdb; epdb.set_trace() # # import epdb; epdb.set_trace()
# sys.modules[fullname].__path__ # # sys.modules[fullname].__path__
# for each in dir(sys.modules[fullname]): # # for each in dir(sys.modules[fullname]):
# # if not each.startswith("__"):
# # submodules.append(to_text(each))
# for each in os.listdir(sys.modules[fullname].__path__[0]):
# if not each.startswith("__"): # if not each.startswith("__"):
# submodules.append(to_text(each)) # submodules.append(to_text(each))
for each in os.listdir(sys.modules[fullname].__path__[0]): # # jjj
if not each.startswith("__"): # # hack: insert submodule on the path so it can be loaded
submodules.append(to_text(each)) # # sys.path.insert(0, each)
# jjj # return submodules
# hack: insert submodule on the path so it can be loaded # else:
# sys.path.insert(0, each)
return submodules
else:
it = pkgutil.iter_modules([os.path.dirname(path)]) it = pkgutil.iter_modules([os.path.dirname(path)])
return [to_text(name) for _, name, _ in it] return [to_text(name) for _, name, _ in it]
@ -589,11 +589,11 @@ class SysModulesMethod(FinderMethod):
# TODO: move to ansible_mitogen somehow if possible # TODO: move to ansible_mitogen somehow if possible
# ansible names the fake __file__ for collections `__synthetic__` with no extension # ansible names the fake __file__ for collections `__synthetic__` with no extension
if fullname.startswith("ansible_collections"): # if fullname.startswith("ansible_collections"):
print(fullname) # print(fullname)
module.__file__ = module.__file__ + ".py" # module.__file__ = module.__file__ + ".py"
# import epdb; epdb.set_trace() # # import epdb; epdb.set_trace()
# jjj # # jjj
path = _py_filename(getattr(module, '__file__', '')) path = _py_filename(getattr(module, '__file__', ''))
if not path: if not path:
return return
@ -711,12 +711,12 @@ class ParentEnumerationMethod(FinderMethod):
TODO: can the __init__ stuff be moved to ansible_mitogen somewhere, really want it to be there instead TODO: can the __init__ stuff be moved to ansible_mitogen somewhere, really want it to be there instead
""" """
# jjj # jjj
for path in search_path: # for path in search_path:
if "collections/ansible_collections" in path: # if "collections/ansible_collections" in path:
init_file = os.path.join(path, modname, "__init__.py") # init_file = os.path.join(path, modname, "__init__.py")
if not os.path.isfile(init_file): # if not os.path.isfile(init_file):
with open(init_file, "w") as f: # with open(init_file, "w") as f:
pass # pass
try: try:
#fp, path, (suffix, _, kind) = imp.find_module(modname, search_path) #fp, path, (suffix, _, kind) = imp.find_module(modname, search_path)

Loading…
Cancel
Save