odsbox.model_suggestions¶
Classes¶
Provides fuzzy-match suggestions for ODS model names. |
Module Contents¶
- class odsbox.model_suggestions.ModelSuggestions[source]¶
Provides fuzzy-match suggestions for ODS model names.
Used to generate helpful error messages when an entity, attribute, relation, or enum value name is not found in the ODS application model. All methods return a suggestion string (e.g. “ Did you mean ‘AoMeasurement’?”) or an empty string if no close match is found.
- static get(lower_case_dict, str_val)[source]¶
Return a suggestion string from a lowercase-keyed lookup dict.
- Parameters:
lower_case_dict (dict[str, Any]) – Mapping of lowercase name → canonical name.
str_val (str) – The name that was not found, to find a suggestion for.
- Returns:
A suggestion string like “ Did you mean ‘Name’?”, or “” if no close match is found.
- Return type:
str
- static get_enum(enumeration, str_val)[source]¶
Return a suggestion for an enum item name.
- Parameters:
enumeration (odsbox.proto.ods_pb2.Model.Enumeration) – The ODS model enumeration to search.
str_val (str) – The enum item name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str
- static get_attribute(entity, attribute_or_relation_name)[source]¶
Return a suggestion for an attribute or relation name (application or base name).
- Parameters:
entity (odsbox.proto.ods_pb2.Model.Entity) – The ODS model entity to search within.
attribute_or_relation_name (str) – The name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str
- static get_attribute_by_base_name(entity, attribute_or_relation_name)[source]¶
Return a suggestion for an attribute or relation base name only.
- Parameters:
entity (odsbox.proto.ods_pb2.Model.Entity) – The ODS model entity to search within.
attribute_or_relation_name (str) – The base name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str
- static get_relation(entity, relation_name)[source]¶
Return a suggestion for a relation name (application or base name).
- Parameters:
entity (odsbox.proto.ods_pb2.Model.Entity) – The ODS model entity to search within.
relation_name (str) – The relation name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str
- static get_relation_by_base_name(entity, relation_name)[source]¶
Return a suggestion for a relation base name only.
- Parameters:
entity (odsbox.proto.ods_pb2.Model.Entity) – The ODS model entity to search within.
relation_name (str) – The relation base name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str
- static get_entity(model, entity_name)[source]¶
Return a suggestion for an entity name (application or base name).
- Parameters:
model (odsbox.proto.ods_pb2.Model) – The ODS application model to search within.
entity_name (str) – The entity name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str
- static get_entity_by_base_name(model, entity_name)[source]¶
Return a suggestion for an entity base name only.
- Parameters:
model (odsbox.proto.ods_pb2.Model) – The ODS application model to search within.
entity_name (str) – The entity base name that was not found.
- Returns:
A suggestion string, or “” if no close match is found.
- Return type:
str