Compare commits

..

No commits in common. "2f7711d9894549bc45dff69b5b9812268e160937" and "be491bfdb249fdedb654cf5b0de976e6b7da0785" have entirely different histories.

View file

@ -37,23 +37,16 @@ def get_level(module):
return module.level return module.level
def get_annotators(annotators, module_name, file_name=None): def get_annotators(annotators, module_name):
if file_name is None: annotators[module_name] = []
_module_name = module_name
else:
_module_name = module_name + "." + file_name
full_file_name = f"/{file_name}.py"
annotators[_module_name] = []
for pathobj in importlib.resources.files(module_name).iterdir(): for pathobj in importlib.resources.files(module_name).iterdir():
path = str(pathobj) path = str(pathobj)
if not path.endswith(".py") or path.endswith("__.py"): if not path.endswith(".py") or path.endswith("__.py"):
continue continue
if file_name is not None and not path.endswith(full_file_name):
continue
module = load_modules(module_name, path) module = load_modules(module_name, path)
if "Annotator" not in dir(module): if "Annotator" not in dir(module):
continue continue
annotators[_module_name].append(module.Annotator) annotators[module_name].append(module.Annotator)
class SpaceAnnotator: # pylint: disable=R0903 class SpaceAnnotator: # pylint: disable=R0903
@ -73,7 +66,7 @@ class SpaceAnnotator: # pylint: disable=R0903
get_annotators(ANNOTATORS, extra_annotator) get_annotators(ANNOTATORS, extra_annotator)
for plugin in objectspace.plugins: for plugin in objectspace.plugins:
try: try:
get_annotators(ANNOTATORS, f"rougail.{plugin}", "annotator") get_annotators(ANNOTATORS, f"rougail.{plugin}.annotator")
except ModuleNotFoundError: except ModuleNotFoundError:
pass pass
annotators = ANNOTATORS["rougail.annotator"].copy() annotators = ANNOTATORS["rougail.annotator"].copy()