Browse Source

Compatible module loading for zip modules #234

pull/235/head
Oliverpool 9 years ago
parent
commit
385a49c5f4
  1. 8
      patacrep/files.py

8
patacrep/files.py

@ -8,6 +8,7 @@ import pkgutil
import posixpath
import re
import sys
from zipimport import ZipImportError
from patacrep import utils
from patacrep import __DATADIR__
@ -90,6 +91,13 @@ def iter_modules(path, prefix):
else:
try:
yield module_finder.find_spec(name).loader.load_module()
except AttributeError:
# It is a zipimport.zipimporter object
try:
yield module_finder.load_module(name)
except ZipImportError as error:
LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error)))
continue
except ImportError as error:
LOGGER.debug("[plugins] Could not load module {}: {}".format(name, str(error)))
continue

Loading…
Cancel
Save