From cd81ee7b2dab7b8dbf51762f5f9960357fb59fd4 Mon Sep 17 00:00:00 2001 From: Robert Sachunsky Date: Wed, 5 Oct 2022 18:27:28 +0200 Subject: [PATCH] Processor.module: handle namespace pkg case --- ocrd/ocrd/processor/base.py | 11 ++++++++++- repo/spec | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ocrd/ocrd/processor/base.py b/ocrd/ocrd/processor/base.py index 60e8586ad9..ccc9fe0396 100644 --- a/ocrd/ocrd/processor/base.py +++ b/ocrd/ocrd/processor/base.py @@ -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): diff --git a/repo/spec b/repo/spec index 6a71151d6b..39b20c4ece 160000 --- a/repo/spec +++ b/repo/spec @@ -1 +1 @@ -Subproject commit 6a71151d6bce7a5b7e0d9dfd80c8461b4c8e8657 +Subproject commit 39b20c4eced8417252ea7335e6968c47b325ca59