Skip to content

Commit

Permalink
Merge pull request #16 from wpbonelli/cleanup
Browse files Browse the repository at this point in the history
cleanup block.py
  • Loading branch information
wpbonelli authored Jul 26, 2024
2 parents a2392ce + 2954dba commit aad8a54
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions flopy4/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@
from flopy4.utils import find_upper, strip


def get_keystrings(members, name):
return [
m for m in members.values() if isinstance(m, MFKeystring) and name in m
]


def get_param(members, name, block):
ks = [m for m in members.values() if isinstance(m, MFKeystring)]
if len(ks) == 1:
param = ks[0]
else:
param = next(iter(get_keystrings(members, name)), None)
if param is None:
param = members.get(name)
if param is not None:
param.name = name
else:
if param is None:
raise ValueError(f"Invalid parameter: {name.upper()}")
param.name = name
param.block = block
return param

Expand Down

0 comments on commit aad8a54

Please sign in to comment.