From d91142c3db648ed1d51088cded2edec87a15119b Mon Sep 17 00:00:00 2001 From: travis Date: Thu, 8 Feb 2024 12:16:45 -0800 Subject: [PATCH] update entity_instance.py --- .../instance_validator/validate/entity_instance.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tools/validators/instance_validator/validate/entity_instance.py b/tools/validators/instance_validator/validate/entity_instance.py index e15f6cbe85..3b5693a79c 100644 --- a/tools/validators/instance_validator/validate/entity_instance.py +++ b/tools/validators/instance_validator/validate/entity_instance.py @@ -487,16 +487,16 @@ def _IsAllMissingFields(self, entity: EntityInstance) -> bool: return True return False - def _ValidateEnumerations(self, entity_translation: Dict[str, Any]) -> bool: + def _ValidateEnumerations(self, entity: EntityInstance) -> bool: """Validate that a translation is properly enumerated. Args: - entity_translation: Dictionary of written field names to - FieldTranslation instances. + entity: Instance of EntityInstance. Returns: """ + entity_translation = entity.translation enumeration_map = {} is_valid = True for written_field_name in entity_translation: @@ -520,8 +520,9 @@ def _ValidateEnumerations(self, entity_translation: Dict[str, Any]) -> bool: enumeration_map[base_field_name] = [1, 0] for base_field_mapping, enum_list in enumeration_map.items(): if enum_list[0] > enum_list[1] and enum_list != [1, 0]: - print(f'[ERROR]\t field name {base_field_name} is enumerated and ' - 'un-enumerated in the same translation block.') + print(f'[ERROR]\t {entity.guid}: {entity.code} has field name' + f' {base_field_name} which is enumerated and ' + 'not enumerated in the same translation block.') is_valid = False return is_valid @@ -554,7 +555,7 @@ def _ValidateTranslation( if self._IsAllMissingFields(entity): return False - is_valid = self._ValidateEnumerations(entity.translation) + is_valid = self._ValidateEnumerations(entity) # Check that defined fields are in the type for as_written_field_name, ft in entity.translation.items(): qualified_field_name = _GetAllowedField(