Skip to content

Commit 595cf9b

Browse files
committed
Fixed formatting
1 parent ec9042a commit 595cf9b

2 files changed

Lines changed: 16 additions & 8 deletions

File tree

hed/schema/schema_io/json2schema.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ def _get_header_attributes(self, json_data):
7575
@staticmethod
7676
def _convert_to_internal_format(value):
7777
"""Convert JSON values to internal schema format.
78-
78+
7979
Multi-value attributes are stored as arrays in JSON but as comma-separated strings internally.
80-
80+
8181
Parameters:
8282
value: The value to convert (could be array, string, bool, etc.)
83-
83+
8484
Returns:
8585
The converted value
8686
"""
@@ -311,7 +311,9 @@ def _create_unit_class_entry(self, class_name, class_data):
311311

312312
# Add default units
313313
if json_constants.DEFAULT_UNITS_KEY in class_data:
314-
entry._set_attribute_value(HedKey.DefaultUnits, self._convert_to_internal_format(class_data[json_constants.DEFAULT_UNITS_KEY]))
314+
entry._set_attribute_value(
315+
HedKey.DefaultUnits, self._convert_to_internal_format(class_data[json_constants.DEFAULT_UNITS_KEY])
316+
)
315317

316318
# Add any other attributes (exclude unit data if present)
317319
unit_names_set = set(class_data.get(json_constants.UNITS_LIST_KEY, []))

hed/schema/schema_io/schema2json.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,14 +358,14 @@ def get_list_value(attr_key):
358358
# Helper to check if attribute is explicitly set (not inherited)
359359
def has_explicit_attribute(attr_key):
360360
return attr_key in tag_entry.attributes
361-
361+
362362
# Helper to get boolean attribute value (preserving string "True"/"true" if present)
363363
def get_bool_attribute(attr_key):
364364
if attr_key not in tag_entry.attributes:
365365
return False
366366
value = tag_entry.attributes[attr_key]
367367
# If it's stored as string "True" or "true", keep it as string for XML compatibility
368-
if isinstance(value, str) and value.lower() in ('true', 'false'):
368+
if isinstance(value, str) and value.lower() in ("true", "false"):
369369
return value
370370
# Otherwise return as boolean
371371
return bool(value)
@@ -471,7 +471,7 @@ def get_list_value(attr_key):
471471
if placeholder_entry.has_attribute(HedKey.TakesValue):
472472
value = placeholder_entry.attributes[HedKey.TakesValue]
473473
# If it's stored as string "True" or "true", keep it as string for XML compatibility
474-
if isinstance(value, str) and value.lower() in ('true', 'false'):
474+
if isinstance(value, str) and value.lower() in ("true", "false"):
475475
placeholder_attrs["takesValue"] = value
476476
else:
477477
placeholder_attrs["takesValue"] = True
@@ -626,7 +626,13 @@ def _add_unit_modifier_data(self, entry, entry_data):
626626
entry_data["SIUnitSymbolModifier"] = si_symbol
627627

628628
# Add any other attributes that aren't in the known list
629-
known_modifier_attrs = {HedKey.ConversionFactor, HedKey.SIUnitModifier, HedKey.SIUnitSymbolModifier, HedKey.HedID, HedKey.InLibrary}
629+
known_modifier_attrs = {
630+
HedKey.ConversionFactor,
631+
HedKey.SIUnitModifier,
632+
HedKey.SIUnitSymbolModifier,
633+
HedKey.HedID,
634+
HedKey.InLibrary,
635+
}
630636
for attr_name, attr_value in entry.attributes.items():
631637
if attr_name not in known_modifier_attrs and not self._attribute_disallowed(attr_name):
632638
# Convert comma-separated strings to lists for multi-value attributes

0 commit comments

Comments
 (0)