Compare commits
No commits in common. "2f7711d9894549bc45dff69b5b9812268e160937" and "be491bfdb249fdedb654cf5b0de976e6b7da0785" have entirely different histories.
2f7711d989
...
be491bfdb2
1 changed files with 4 additions and 11 deletions
|
|
@ -37,23 +37,16 @@ def get_level(module):
|
|||
return module.level
|
||||
|
||||
|
||||
def get_annotators(annotators, module_name, file_name=None):
|
||||
if file_name is None:
|
||||
_module_name = module_name
|
||||
else:
|
||||
_module_name = module_name + "." + file_name
|
||||
full_file_name = f"/{file_name}.py"
|
||||
annotators[_module_name] = []
|
||||
def get_annotators(annotators, module_name):
|
||||
annotators[module_name] = []
|
||||
for pathobj in importlib.resources.files(module_name).iterdir():
|
||||
path = str(pathobj)
|
||||
if not path.endswith(".py") or path.endswith("__.py"):
|
||||
continue
|
||||
if file_name is not None and not path.endswith(full_file_name):
|
||||
continue
|
||||
module = load_modules(module_name, path)
|
||||
if "Annotator" not in dir(module):
|
||||
continue
|
||||
annotators[_module_name].append(module.Annotator)
|
||||
annotators[module_name].append(module.Annotator)
|
||||
|
||||
|
||||
class SpaceAnnotator: # pylint: disable=R0903
|
||||
|
|
@ -73,7 +66,7 @@ class SpaceAnnotator: # pylint: disable=R0903
|
|||
get_annotators(ANNOTATORS, extra_annotator)
|
||||
for plugin in objectspace.plugins:
|
||||
try:
|
||||
get_annotators(ANNOTATORS, f"rougail.{plugin}", "annotator")
|
||||
get_annotators(ANNOTATORS, f"rougail.{plugin}.annotator")
|
||||
except ModuleNotFoundError:
|
||||
pass
|
||||
annotators = ANNOTATORS["rougail.annotator"].copy()
|
||||
|
|
|
|||
Loading…
Reference in a new issue