Skip to content

Commit

Permalink
fix filein/fileout in toml conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed Nov 7, 2024
1 parent dffd27c commit 57f0f24
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions flopy/mf6/utils/codegen/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def _load_v1(cls, f, name, **kwargs) -> "Dfn":
flat, meta = Dfn._load_v1_flat(f, **kwargs)
refs = kwargs.pop("refs", dict())
fkeys = dict()
popped = dict()

def _map(spec: Dict[str, Any]) -> Var:
"""
Expand Down Expand Up @@ -336,15 +337,31 @@ def _choices() -> Vars:
}

def _fields() -> Vars:
"""Load a record's children (fields)."""
"""
Load a record's children (fields).
Notes
-----
This includes a hack to handle cases where `filein` or `fileout`
is defined just once in a DFN file, where in the new structured
format it is expected wherever it appears.
"""
names = _type.split()[1:]
return {
v["name"]: _map(v)
for v in flat.values(multi=True)
if v["name"] in names
and v.get("in_record", False)
and not v["type"].startswith("record")
}
fields = dict()
for name in names:
v = popped.get(name, None)
if v:
fields[name] = v
continue
v = flat.get(name, None)
if (
not v
or not v.get("in_record", False)
or v["type"].startswith("record")
):
continue
fields[name] = v
return fields

if _type.startswith("recarray"):
children = _items()
Expand Down

0 comments on commit 57f0f24

Please sign in to comment.