Skip to content

Commit

Permalink
Update variable handling (stop using reserved keyword)
Browse files Browse the repository at this point in the history
  • Loading branch information
devsjc committed Oct 6, 2023
1 parent 65f7395 commit e85be37
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions nwp/assets/ecmwf/mars.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,19 @@


@contextlib.contextmanager
def modify_env(vars: dict[str, str]):
def modify_env(newvars: dict[str, str]):
"""Temporarily modify the environment."""
oldvars = os.environ.copy()
for var in vars:
newval = vars[var]
os.environ[var] = newval
oldvars: dict[str, str] = os.environ.copy()
for key in newvars:
os.environ[key] = newvars[key]
try:
yield
finally:
for var in vars:
if var in oldvars:
os.environ[var] = oldvars[var]
for key in newvars:
if key in oldvars:
os.environ[key] = oldvars[key]
else:
del os.environ[var]
del os.environ[key]

class NWPConsumerConfig(Config):
"""Configuration for the NWP consumer."""
Expand Down

0 comments on commit e85be37

Please sign in to comment.