1
0
mirror of https://github.com/thp/pyotherside.git synced 2025-01-28 23:52:55 +08:00

Fixes PyOtherSideQtRCImporter for submodule imports (#134)

* fixes PyOtherSideQtRCImporter for submodule imports
* adjusts QrRCImporter to use the original check
This commit is contained in:
Alexander Blum 2024-05-31 06:50:10 +00:00 committed by GitHub
parent 4fa3406775
commit 302c111b99
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 @@ class PyOtherSideQtRCLoader(abc.SourceLoader):
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,7 +48,7 @@ class PyOtherSideQtRCLoader(abc.SourceLoader):
class PyOtherSideQtRCImporter(abc.MetaPathFinder):
def find_spec(self, fullname, path, target=None):
if path is None:
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))