Commit 70ffa8d1 authored by Kris Vanneste's avatar Kris Vanneste
Browse files

Catch import errors in get_available_gsims function.

git-svn-id: https://svn.seismo.oma.be/svn/seismo/hazard/rshalib/trunk@8459 40b490c5-b4d9-47cb-8714-9bef99b524d5
parent c38ff00e
......@@ -42,10 +42,14 @@ def get_available_gsims():
for fname in os.listdir(os.path.dirname(__file__)):
if fname.endswith('.py'):
modname, _ext = os.path.splitext(fname)
mod = importlib.import_module('.' + modname, package=__name__)
for cls in mod.__dict__.values():
if inspect.isclass(cls) and issubclass(
cls, GroundShakingIntensityModel) and cls not in (
GroundShakingIntensityModel, GMPE, IPE):
gsims[cls.__name__] = cls
try:
mod = importlib.import_module('.' + modname, package=__name__)
except:
print('Failed importing gsim %s!' % modname)
else:
for cls in mod.__dict__.values():
if inspect.isclass(cls) and issubclass(
cls, GroundShakingIntensityModel) and cls not in (
GroundShakingIntensityModel, GMPE, IPE):
gsims[cls.__name__] = cls
return OrderedDict((k, gsims[k]) for k in sorted(gsims))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment