From a74eb54976a8b8c4c38ebd097b623c353171fe17 Mon Sep 17 00:00:00 2001 From: IanCa Date: Wed, 20 Mar 2024 13:35:03 -0500 Subject: [PATCH] Add doc strings back --- hed/schema/schema_attribute_validators.py | 110 +++++++++++++++++++--- 1 file changed, 99 insertions(+), 11 deletions(-) diff --git a/hed/schema/schema_attribute_validators.py b/hed/schema/schema_attribute_validators.py index 4237b6b6..a48c4de0 100644 --- a/hed/schema/schema_attribute_validators.py +++ b/hed/schema/schema_attribute_validators.py @@ -20,7 +20,15 @@ def tag_is_placeholder_check(hed_schema, tag_entry, attribute_name): - """Check if comma separated list has valid HedTags.""" + """Check if comma separated list has valid HedTags. + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] if not tag_entry.name.endswith("/#"): issues += ErrorHandler.format_error(SchemaWarnings.SCHEMA_NON_PLACEHOLDER_HAS_CLASS, tag_entry.name, @@ -30,7 +38,15 @@ def tag_is_placeholder_check(hed_schema, tag_entry, attribute_name): def attribute_is_deprecated(hed_schema, tag_entry, attribute_name): - """ Check if the attribute is deprecated. does not check value.""" + """ Check if the attribute is deprecated. does not check value. + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] # Attributes has to check properties section_key = HedSectionKey.Attributes @@ -50,7 +66,15 @@ def attribute_is_deprecated(hed_schema, tag_entry, attribute_name): # todo: This needs to be refactored, these next several functions are near identical def tag_exists_check(hed_schema, tag_entry, attribute_name): - """Check if the list of possible tags exists in the schema.""" + """Check if the list of possible tags exists in the schema. + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] possible_tags = tag_entry.attributes.get(attribute_name, "") split_tags = possible_tags.split(",") @@ -72,7 +96,15 @@ def tag_exists_check(hed_schema, tag_entry, attribute_name): def unit_class_exists(hed_schema, tag_entry, attribute_name): - """Check if comma separated list is valid unit classes.""" + """Check if comma separated list is valid unit classes. + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] possible_unit_classes = tag_entry.attributes.get(attribute_name, "") split_tags = possible_unit_classes.split(",") @@ -94,7 +126,15 @@ def unit_class_exists(hed_schema, tag_entry, attribute_name): def value_class_exists(hed_schema, tag_entry, attribute_name): - """Check if comma separated list is valid value classes.""" + """Check if comma separated list is valid value classes. + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] possible_value_classes = tag_entry.attributes.get(attribute_name, "") split_tags = possible_value_classes.split(",") @@ -117,7 +157,15 @@ def value_class_exists(hed_schema, tag_entry, attribute_name): def unit_exists(hed_schema, tag_entry, attribute_name): - """Check the given unit is valid, and not deprecated.""" + """Check the given unit is valid, and not deprecated. + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] unit = tag_entry.attributes.get(attribute_name, "") unit_entry = tag_entry.get_derivative_unit_entry(unit) @@ -137,7 +185,15 @@ def unit_exists(hed_schema, tag_entry, attribute_name): # This is effectively unused and can never fail - The schema would catch these errors and refuse to load def tag_exists_base_schema_check(hed_schema, tag_entry, attribute_name): - """Check if the single tag is a partnered schema tag""" + """Check if the single tag is a partnered schema tag + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] rooted_tag = tag_entry.attributes.get(attribute_name, "") if rooted_tag and rooted_tag not in hed_schema.tags: @@ -150,7 +206,15 @@ def tag_exists_base_schema_check(hed_schema, tag_entry, attribute_name): def tag_is_deprecated_check(hed_schema, tag_entry, attribute_name): - """ Check if the element has a valid deprecatedFrom attribute, and that any children have it""" + """ Check if the element has a valid deprecatedFrom attribute, and that any children have it + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] deprecated_version = tag_entry.attributes.get(attribute_name, "") library_name = tag_entry.has_attribute(HedKey.InLibrary, return_value=True) @@ -177,7 +241,15 @@ def tag_is_deprecated_check(hed_schema, tag_entry, attribute_name): def conversion_factor(hed_schema, tag_entry, attribute_name): - """Check if the conversion_factor on is valid""" + """Check if the conversion_factor on is valid + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] cf = tag_entry.attributes.get(attribute_name, "1.0") try: @@ -193,7 +265,15 @@ def conversion_factor(hed_schema, tag_entry, attribute_name): def allowed_characters_check(hed_schema, tag_entry, attribute_name): - """ Check allowed character has a valid value""" + """ Check allowed character has a valid value + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] allowed_strings = character_types @@ -208,7 +288,15 @@ def allowed_characters_check(hed_schema, tag_entry, attribute_name): def in_library_check(hed_schema, tag_entry, attribute_name): - """Check if the library attribute is a valid schema name""" + """Check if the library attribute is a valid schema name + + Parameters: + hed_schema (HedSchema): The schema to use for validation + tag_entry (HedSchemaEntry): The schema entry for this tag. + attribute_name (str): The name of this attribute + Returns: + issues(list): A list of issues from validating this attribute. + """ issues = [] library = tag_entry.attributes.get(attribute_name, "")