Input Resolver

Functions:

input_resolver_function(input_dict, ...)

Resolve the full input specification against dcf_class.inp.

row_resolver_function(top_key, middle_key, ...)

Resolve a single row in a table using its specification.

table_group_resolver_function(...)

Resolve a group of tables that share a common prefix.

table_resolver_function(top_key, table_dict, ...)

Resolve a single table (top-level key) using its row specifications.

value_resolver_function(top_key, middle_key, ...)

Resolve a single value and validate it against its specification.

value_with_unit_resolver_function(top_key, ...)

Resolve a value that may have an associated unit into a Quantity.

wildcard_row_resolver_function(top_key, ...)

Resolve all rows in a table using a wildcard row specification (going through all rows in dcf_class.inp[top_key]).

pyH2A.Utilities.IO.input_resolver.input_resolver_function(input_dict, dcf_class, plugin_name)[source]

Resolve the full input specification against dcf_class.inp.

This is the top-level entry point used by plugins. It dispatches to table-group resolvers (wildcard top keys) or regular table resolvers, returning a fully resolved dictionary with validated values.

Parameters:
input_dictdict

Plugin input specification. Top-level keys are tables or table groups; middle-level keys are rows; bottom-level keys are value and unit specs.

dcf_classobject

DCF-like object containing inp input data.

plugin_namestr

Name of the plugin used to prefix error messages.

Returns:
input_dict_resolveddict

Fully resolved input dictionary with Quantity objects where appropriate.

pyH2A.Utilities.IO.input_resolver.row_resolver_function(top_key, middle_key, row_dict, dcf_class)[source]

Resolve a single row in a table using its specification.

This function handles optional rows, resolves each bottom-level entry, and marks the row as processed in dcf_class.inp. Decision between resolving values with units or simply values

Parameters:
top_keystr

Table name in dcf_class.inp.

middle_keystr

Row name in the table.

row_dictdict

Row specification dict describing expected values and units.

dcf_classobject

DCF-like object with inp nested dictionaries.

Returns:
resolved_rowdict or None

Resolved row dictionary, or None when the row is optional and missing from dcf_class.inp.

pyH2A.Utilities.IO.input_resolver.table_group_resolver_function(table_group_top_key, table_group_dict, dcf_class)[source]

Resolve a group of tables that share a common prefix.

The wildcard marker in table_group_top_key is removed to form a prefix used to find matching tables in dcf_class.inp.

Parameters:
table_group_top_keystr

Table-group key containing the wildcard marker.

table_group_dictdict

Table specification applied to each matched table.

dcf_classobject

DCF-like object with inp nested dictionaries.

Returns:
resolved_table_groupdict

Mapping of each matched table key to its resolved table data.

pyH2A.Utilities.IO.input_resolver.table_resolver_function(top_key, table_dict, dcf_class)[source]

Resolve a single table (top-level key) using its row specifications. Decision between regular rows and wildcard rows (indicated by WILDCARD_MARKER in middle_key)

Supports optional tables, regular rows, and wildcard rows. Also handles sum tables if specified in table_dict (sum of values across multiple rows, with specifications provided in table_dict under middle key SUM_TABLES_KEY).

Parameters:
top_keystr

Table name in dcf_class.inp.

table_dictdict

Table specification mapping row keys to row specifications.

dcf_classobject

DCF-like object with inp nested dictionaries.

Returns:
resolved_tabledict or None

Resolved table dictionary, or None when the table is optional and missing from dcf_class.inp.

pyH2A.Utilities.IO.input_resolver.value_resolver_function(top_key, middle_key, bottom_key, row_dict, dcf_class, return_specification=True)[source]

Resolve a single value and validate it against its specification.

This runs process_input(), type checks, and optional categorical option checks before returning the raw value or (spec, value).

Parameters:
top_keystr

Table name in dcf_class.inp.

middle_keystr

Row name in dcf_class.inp[top_key].

bottom_keystr

Column key in dcf_class.inp[top_key][middle_key].

row_dictdict

Row specification containing the bottom-level spec.

dcf_classobject

DCF-like object with inp nested dictionaries.

return_specificationbool, default True

When True, return (spec, value). When False, return only value.

Returns:
resulttuple or Any

(specification, retrieved_value) when return_specification is True, otherwise just the retrieved value.

pyH2A.Utilities.IO.input_resolver.value_with_unit_resolver_function(top_key, middle_key, bottom_key_group, row_dict, dcf_class)[source]

Resolve a value that may have an associated unit into a Quantity.

If the retrieved value is already a Quantity, it is validated and returned. If the value is numeric (or nested dict of numerics), it is combined with the unit and converted to Quantity objects. Strings are returned as-is after type validation. Throws error if retrieved value is of unsupported type (not Quantity, numerical or string).

Parameters:
top_keystr

Table name in dcf_class.inp.

middle_keystr

Row name in dcf_class.inp[top_key].

bottom_key_grouplist[str]

A two-element list: [value_key, unit_key].

row_dictdict

Row specification dictionary.

dcf_classobject

DCF-like object with inp nested dictionaries.

Returns:
resolved_valueQuantity, dict, or str

Resolved quantity (or dict of quantities) or a string value.

pyH2A.Utilities.IO.input_resolver.wildcard_row_resolver_function(top_key, row_dict, dcf_class)[source]

Resolve all rows in a table using a wildcard row specification (going through all rows in dcf_class.inp[top_key]).

Parameters:
top_keystr

Table name in dcf_class.inp.

row_dictdict

Row specification applied to every row in the table.

dcf_classobject

DCF-like object with inp nested dictionaries.

Returns:
resolved_rowsdict

Mapping of each row key to its resolved row dictionary.