Skip to content

Commit e963225

Browse files
authored
Allow multiple properties in pvmap for headers (datacommonsorg#1479)
* Allow numeric values for properties with multiple values * Ignore differ output if differ not run * fix typo * Allow #Header to have multiple properties * allow empty values for header props * lint
1 parent 6ecb47f commit e963225

3 files changed

Lines changed: 31 additions & 25 deletions

File tree

tools/statvar_importer/property_value_mapper.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def load_pvs_from_file(self, filename: str, namespace: str = 'GLOBAL'):
188188
#pvs[prop] = value
189189
normalize = True
190190
if '#' in prop or '=' in value:
191-
# Value is a formula. e value as a string.
191+
# Value is a formula. Set value as a string.
192192
normalize = False
193193
pv_utils.add_key_value(prop,
194194
value,
@@ -219,12 +219,12 @@ def load_pvs_dict(self, pv_map_input: dict, namespace: str = 'GLOBAL'):
219219
pvs_input = {namespace: pvs_input}
220220
for p, v in pvs_input.items():
221221
num_keys_added += 1
222-
pv_utils.add_key_value(
223-
p,
224-
v,
225-
pvs_dict,
226-
self._config.get('multi_value_properties', {}),
227-
)
222+
pv_utils.add_key_value(p,
223+
v,
224+
pvs_dict,
225+
self._config.get(
226+
'multi_value_properties', {}),
227+
normalize=False)
228228
# Track the max number of words in any of the keys.
229229
# This is used when splitting input-string for lookups.
230230
num_words_key = len(pv_utils.get_words(key, word_delimiter))

tools/statvar_importer/property_value_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ def get_value_as_list(value: str) -> Union[str, list]:
134134
def pvs_update(new_pvs: dict, pvs: dict, multi_value_keys: set = {}) -> dict:
135135
"""Add the key:value pairs from the new_pvs into the pvs dictionary."""
136136
for prop, value in new_pvs.items():
137-
add_key_value(prop, value, pvs, multi_value_keys)
137+
add_key_value(prop,
138+
value,
139+
pvs,
140+
multi_value_keys=multi_value_keys,
141+
normalize=False)
138142
return pvs
139143

140144

tools/statvar_importer/stat_var_processor.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1675,8 +1675,10 @@ def resolve_value_references(self,
16751675
prop,
16761676
value,
16771677
pvs,
1678-
self._config.get('multi_value_properties', {}),
1678+
multi_value_keys=self._config.get(
1679+
'multi_value_properties', {}),
16791680
overwrite=False,
1681+
normalize=False,
16801682
)
16811683
logging.level_debug() and logging.log(
16821684
2, f'Adding {value} for {prop}:{pvs.get(prop)}')
@@ -1936,10 +1938,10 @@ def process_row_header_pvs(
19361938
for prop in col_header_props:
19371939
# Use any property=value in the header tag or
19381940
# get the value from the column PVs
1939-
value = col_pvs.get(prop, '')
1941+
value = col_pvs.get(prop, None)
19401942
if '=' in prop:
19411943
prop, value = prop.split('=', 1)
1942-
if value:
1944+
if value is not None:
19431945
col_header_pvs[prop] = value
19441946
if col_header_pvs:
19451947
col_headers[col_index] = col_header_pvs
@@ -2083,22 +2085,22 @@ def process_row(self, row: list, row_index: int):
20832085
if (value is not None and
20842086
prop not in self._internal_reference_keys and
20852087
not self.get_reference_names(value)):
2086-
pv_utils.add_key_value(prop,
2087-
value,
2088-
row_pvs,
2089-
self._config.get(
2090-
'multi_value_properties',
2091-
{}),
2092-
normalize=False)
2088+
pv_utils.add_key_value(
2089+
prop,
2090+
value,
2091+
row_pvs,
2092+
multi_value_keys=self._config.get(
2093+
'multi_value_properties', {}),
2094+
normalize=False)
20932095
for prop, value in row_col_pvs.get(col_index, {}).items():
20942096
if value is not None and prop not in self._internal_reference_keys:
2095-
pv_utils.add_key_value(prop,
2096-
value,
2097-
row_pvs,
2098-
self._config.get(
2099-
'multi_value_properties',
2100-
{}),
2101-
normalize=False)
2097+
pv_utils.add_key_value(
2098+
prop,
2099+
value,
2100+
row_pvs,
2101+
multi_value_keys=self._config.get(
2102+
'multi_value_properties', {}),
2103+
normalize=False)
21022104
if config_flags.get_value_type(row_pvs.get('#IgnoreRow'), False):
21032105
logging.level_debug() and logging.log(
21042106
2, f'Ignoring row: {row} in {self._file_context}')

0 commit comments

Comments
 (0)