From 47cd4bec6a7333f3d330f504dd5d4ed3205bdbbb Mon Sep 17 00:00:00 2001 From: Alexander Blum Date: Thu, 2 May 2024 01:49:54 +0200 Subject: [PATCH 1/2] fixes PyOtherSideQtRCImporter for submodule imports --- src/qrc_importer.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/qrc_importer.py b/src/qrc_importer.py index af51a98..8f98b3f 100644 --- a/src/qrc_importer.py +++ b/src/qrc_importer.py @@ -31,7 +31,7 @@ def get_filename(fullname): for candidate in ("{}/{}.py", "{}/{}/__init__.py"): filename = candidate.format(import_path, basename) - if pyotherside.qrc_is_file(filename[len("qrc:") :]): + if pyotherside.qrc_is_file(filename[len("qrc:"):]): return filename @@ -40,7 +40,7 @@ def __init__(self, filepath): self.filepath = filepath def get_data(self, path): - return pyotherside.qrc_get_file_contents(self.filepath[len("qrc:") :]) + return pyotherside.qrc_get_file_contents(self.filepath[len("qrc:"):]) def get_filename(self, fullname): return get_filename(fullname) @@ -48,10 +48,9 @@ def get_filename(self, fullname): class PyOtherSideQtRCImporter(abc.MetaPathFinder): def find_spec(self, fullname, path, target=None): - if path is None: - fname = get_filename(fullname) - if fname: - return spec_from_loader(fullname, PyOtherSideQtRCLoader(fname)) + fname = get_filename(fullname) + if fname: + return spec_from_loader(fullname, PyOtherSideQtRCLoader(fname)) return None From 596655cdcb05e0db50fc396fa30bdb55d7e8d092 Mon Sep 17 00:00:00 2001 From: Alexander Blum Date: Thu, 2 May 2024 12:41:31 +0200 Subject: [PATCH 2/2] adjusts QrRCImporter to use the original check --- src/qrc_importer.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/qrc_importer.py b/src/qrc_importer.py index 8f98b3f..83eb015 100644 --- a/src/qrc_importer.py +++ b/src/qrc_importer.py @@ -48,9 +48,10 @@ def get_filename(self, fullname): class PyOtherSideQtRCImporter(abc.MetaPathFinder): def find_spec(self, fullname, path, target=None): - fname = get_filename(fullname) - if fname: - return spec_from_loader(fullname, PyOtherSideQtRCLoader(fname)) + if path is None or all(x.startswith('qrc:') for x in path): + fname = get_filename(fullname) + if fname: + return spec_from_loader(fullname, PyOtherSideQtRCLoader(fname)) return None