Skip to content

Commit

Permalink
Processor.module: handle namespace pkg case
Browse files Browse the repository at this point in the history
  • Loading branch information
bertsky committed Oct 5, 2022
1 parent 71d295a commit cd81ee7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
11 changes: 10 additions & 1 deletion ocrd/ocrd/processor/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,16 @@ def module(self):
"""
The top-level module this processor belongs to.
"""
return self.__module__.split('.')[0]
# find shortest prefix path that is not just a namespace package
fqname = ''
for name in self.__module__.split('.'):
if fqname:
fqname += '.'
fqname += name
if sys.modules[fqname].__file__:
return fqname
# fall-back
return self.__module__

@property
def moduledir(self):
Expand Down
2 changes: 1 addition & 1 deletion repo/spec

0 comments on commit cd81ee7

Please sign in to comment.