Skip to content

Commit

Permalink
fix(dfn): include missing attributes (#176)
Browse files Browse the repository at this point in the history
Only explicitly acknowledged variable attributes were parsed, we need them all
  • Loading branch information
wpbonelli authored Jan 25, 2025
1 parent 6957554 commit d9a4212
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions modflow_devtools/dfn.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,22 @@ def _load_variable(var: dict[str, Any]) -> Var:
for a separate context will be given a reference to it.
"""

var = var.copy()

# parse booleans from strings. everything else can
# stay a string except default values, which we'll
# try to parse as arbitrary literals below, and at
# some point types, once we introduce type hinting
var = {k: _try_parse_bool(v) for k, v in var.items()}

_name = var["name"]
_type = var.get("type", None)
shape = var.get("shape", None)
_name = var.pop("name")
_type = var.pop("type", None)
shape = var.pop("shape", None)
shape = None if shape == "" else shape
block = var.get("block", None)
default = var.get("default", None)
block = var.pop("block", None)
default = var.pop("default", None)
default = _try_literal_eval(default) if _type != "string" else default
description = var.get("description", "")
description = var.pop("description", "")
ref = refs.get(_name, None)

# if var is a foreign key, register it
Expand Down Expand Up @@ -288,6 +290,7 @@ def _items() -> Vars:
description=description.replace(
"is the list of", "is the record of"
),
**var,
)
}
else:
Expand All @@ -312,6 +315,7 @@ def _items() -> Vars:
description=description.replace(
"is the list of", f"is the {child_type} of"
),
**var,
)
}

Expand Down Expand Up @@ -345,6 +349,7 @@ def _fields() -> Vars:
block=block,
description=description,
default=default,
**var,
)

if _type.startswith("recarray"):
Expand Down Expand Up @@ -385,6 +390,7 @@ def _fields() -> Vars:
),
default=None,
subpackage=ref,
**var,
)

return var_
Expand Down

0 comments on commit d9a4212

Please sign in to comment.