Skip to content

Commit

Permalink
MNT: Move to exec_module instead of load_module (#1369)
Browse files Browse the repository at this point in the history
* move to exec_module instead of load_module

* add check for colormap in config
  • Loading branch information
mgrover1 authored Jan 5, 2023
1 parent 61fe772 commit 0714f46
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pyart/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,14 @@ def load_config(filename=None):
global _DEFAULT_FIELD_LIMITS

try:
from importlib.machinery import SourceFileLoader
from importlib.util import module_from_spec, spec_from_file_location

spec = spec_from_file_location("metadata_config", filename)
# assert spec is not None
cfile = module_from_spec(spec)
# assert spec.loader is not None
spec.loader.exec_module(cfile)

cfile = SourceFileLoader("metadata_config", filename).load_module()
except ImportError:
import imp

Expand All @@ -72,8 +77,13 @@ def load_config(filename=None):
_FIELD_MAPPINGS = cfile.FIELD_MAPPINGS
_FILL_VALUE = cfile.FILL_VALUE
_DEFAULT_FIELD_NAMES = cfile.DEFAULT_FIELD_NAMES
_DEFAULT_FIELD_COLORMAP = cfile.DEFAULT_FIELD_COLORMAP
_DEFAULT_FIELD_LIMITS = cfile.DEFAULT_FIELD_LIMITS

# These last two are optional
try:
_DEFAULT_FIELD_COLORMAP = cfile.DEFAULT_FIELD_COLORMAP
_DEFAULT_FIELD_LIMITS = cfile.DEFAULT_FIELD_LIMITS
except:
pass
return


Expand Down

0 comments on commit 0714f46

Please sign in to comment.