geolib.models.dseries_parser¶
Functions
|
Gets the type wrapped by a collection of a given class. |
|
Returns the unformatted key and formatted value for a given line. |
|
Returns the property value representation in the dseries files assuming is delimited by either ':' or '='. |
|
|
|
|
|
Reads a property containing a collection of values represented as a list of strings. |
|
Separates by space and tabulator. |
|
Classes
|
Creates a DSeriesStructure that can parse fields like this: |
|
|
|
|
|
|
|
Class to parse older DSerie formats in a generic way. |
|
|
Specialization of DSeriesInlineProperties, use this class when the properties in the text are the same as in the concrete class definition: . |
|
|
Generates a structure where the properties are assumed to be in the same order as define in the concrete implementation. |
|
DSerie structure that prevents its field from being parsed further. |
|
|
|
|
|
|
|
|
Specialization of DSeriesInlineMappedProperties, use this class when the properties in the text are the same as in the concrete class definition except for "name", which has not been declared as a key in the input text: . |
|
|
- class geolib.models.dseries_parser.DSerieListGroupNextStructure(*args)¶
Creates a DSeriesStructure that can parse fields like this:
[NUMBER OF STRUCTURES] 2 ——- [STRUCTURE VALUE] 42 [END STRUCTURE VALUE] [NEXT NUMBER OF STRUCTURES] [STRUCTURE VALUE] 24 [END STRUCTURE VALUE] [END NUMBER OF STRUCTURES]
into:
- wrapper = [
“2
]
Note the “NEXT NUMBER OF STRUCTURES” element that makes this different from a normal ListGroup structure. The extra strings at the beginning of the first element should be ignored by the child parser.
- abstract property group_delimiter: str¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSerieListStructure(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- classmethod parse_text_lines(lines)¶
- Parameters:
lines (
List
[List
[str
]])
- class geolib.models.dseries_parser.DSerieMatrixStructure(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSerieOldTableStructure(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSerieParser(filename=None)¶
Class to parse older DSerie formats in a generic way.
- Parameters:
filename (
Path
)
- abstract property dserie_structure: BaseModelStructure¶
- parse(filename)¶
- Parameters:
filename (
Path
)- Return type:
- static parse_group(text_lines, loose_properties=False, unique_keys=False)¶
- Parses a text with headers such as [GROUP] and [END OF GROUP] and
yields each property of the group as a Tuple[property name, value]. Because it is an iterable it may contain repeated elements. Delegating responsibility on what to do with such elements to the caller.
Example:
[GROUP A] data more_data [END OF GROUP A]
into:
- (
“group_a”: “data
- more_data”
)
- Args:
text_lines (str): List of fields. loose_properties (bool, optional): Properties without a key are yielded. unique_keys (bool, optional): Whether elements can be repeated or not.
- Raises:
Exception: [description]
- Returns:
Iterable[Tuple[str, str]]: Parsed collection of property values, can include repe.
- Yields:
Iterator[Iterable[Tuple[str, str]]]: Parsed Tuple[Property name, value]
- Parameters:
text_lines (
str
)loose_properties (
bool
)unique_keys (
bool
)
- Return type:
Iterable
[Tuple
[str
,str
]]
- static parse_group_as_dict(text_lines)¶
- Parses a text with headers such as
[GROUP] and [END OF GROUP] into a dict.
- Arguments:
text {str} – List of fields
- Returns:
dict – Parsed dictionary.
Can parse the following:
[GROUP A] data more_data [END OF GROUP A]
into:
- {
“group_a”: “data
- more_data”
}
- Parameters:
text_lines (
str
)- Return type:
Dict
[str
,str
]
- static parse_list_group(text, exceptions=['vertical', 'soil', 'residual_settlements'], skipped_keys=[])¶
Method to parse several groups in a sli/sld file that can include repeated groups.
Includes an exception to always parse a group as a list. Can parse the following:
[GROUP A] data [END OF GROUP A] [GROUP B] [GROUP B1] data [END OF GROUP B1] [END OF GROUP B] [GROUP B] data [END OF GROUP B]
into
- {
“group_a”: “data
- “
- “group_b: [
“[GROUP B1]
data [END OF GROUP B1]”,
“data”
}
- Parameters:
text (
str
)- Return type:
Dict
[str
,Union
[List
[str
],str
]]
- abstract property suffix_list: List[str]¶
- class geolib.models.dseries_parser.DSerieVersion(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesInlineMappedProperties(*args)¶
Specialization of DSeriesInlineProperties, use this class when the properties in the text are the same as in the concrete class definition: .. rubric:: Example
- Given class my_structure(DSeriesInlineMappedProeprties):
property_dummy_int: int property_dummy_str: str
- and text, text_to_parse:
[STRUCTURE] property dummy int = 42 some unit/scale [PROPERTY DUMMY STR] It also works with mixed groups. [END OF PROPERTY DUMMY STR] [END OF STRUCTURE]
When ms = my_structure.parse_text(text_to_parse) Then:
ms.property_dummy_int = 42 ms.proeprty_dummy_str = “It also works with mixed groups.”
- classmethod get_property_key_value(text, expected_property)¶
Gets both property key and value from the text line.
- Parameters:
text (str) – Text containing key and value.
expected_property (str) – The expected property if there was no key.
- Returns:
Parsed key and value.
- Return type:
Tuple[str, str]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesInlineProperties(*args)¶
Generates a structure where the properties are assumed to be in the same order as define in the concrete implementation. Hence, only the read value field is relevant here. Use when properties are in order. .. rubric:: Example
- Given class my_structure(DSeriesInlineProperties):
property_one: int
- and text, text_to_parse:
[InlineStructure] dummy_text: 42 some unit/and scale [END OF InlineStructure]
When ms = my_structure.parse_text(text) Then:
parsed_structure.property_one = 42
- Returns:
Parsed structure.
- Return type:
- classmethod get_properties_in_text(text)¶
- Parameters:
text (
str
)
- classmethod get_property_key_value(text, expected_property)¶
Gets the property key and value for a given text line. It allows concrete classes to override it and either use the expected property name or another value.
- Parameters:
text (str) – Text line to parse.
expected_property (str) – The expected property key if parsing the structure properties in order.
- Returns:
Property name and property value text.
- Return type:
Tuple[str, str]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesInlineReversedProperties(*args)¶
- classmethod get_property_key_value(text, expected_property)¶
Returns the value content for a line of format: value : key || value = key
- Parameters:
text (str) – Text line with value-key
expected_property (
str
)
- Returns:
Filtered value.
- Return type:
str
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesMatrixTreeStructureCollection(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- classmethod parse_collection_type(collecion_type, lines)¶
- Parameters:
collecion_type (
Type
)lines (
list
)
- Return type:
Tuple
[DSeriesStructure
,int
]
- class geolib.models.dseries_parser.DSeriesNoParseSubStructure(*args)¶
DSerie structure that prevents its field from being parsed further.
- static is_parseable()¶
- Return type:
bool
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesRepeatedGroupedProperties(*args)¶
- classmethod get_inline_properties(inline_properties)¶
Processes all unmapped properties and returns them in a dictionary. This method can be replaced in concrete implementations of this class. :type inline_properties:
List
[str
] :param inline_properties: List of property values which key was not found. :type inline_properties: List[str]- Returns:
Returns a dictionary of inline properties.
- Return type:
Dict[str, str]
- classmethod get_validated_mappings(generated_dict)¶
Validates the input dictionary mapping within this class properties. Allows for extension on lower classes.
- Parameters:
generated_dict (Dict[str, str]) – [description]
- Returns:
Validated dictionary.
- Return type:
Dict[str, str]
- classmethod group_value_is_list(group_key)¶
Returns whether a group key should be parsed as list or flat value. Allows inherited classes to override its behavior.
- Parameters:
group_key (str) – Property name.
- Returns:
Whether the key represents a list of values or not.
- Return type:
bool
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesRepeatedGroupsWithInlineMappedProperties(*args)¶
- classmethod get_inline_properties(inline_properties)¶
Processes all unmapped properties and returns them in a dictionary. This method can be replaced in concrete implementations of this class. Follows a philosophy of FIFO for repeated keys. :type inline_properties:
List
[str
] :param inline_properties: List of property values which key was not found. :type inline_properties: List[str]- Returns:
Resulting inline mapped properties.
- Return type:
Dict[str, str]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesStructure(*args)¶
- dict(*args, **kwargs)¶
- classmethod get_structure_required_fields()¶
Allows concrete classes to filter out fields that would normally be parsed.
- Returns:
List of Tuples[FieldName, FieldType]
- Return type:
List[Tuple[str, Type]]
- static is_parseable()¶
- Return type:
bool
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesStructureCollection(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesTableStructure(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- classmethod validate_number_of_rows(lines)¶
Validates whether the number of lines matched the expected rows to be read.
- Parameters:
lines (List[List[str]]) – Lines representing rows of data.
- Raises:
ParserError – When the expectations are not met.
- class geolib.models.dseries_parser.DSeriesTreeStructure(*args)¶
- classmethod get_next_property_text_lines(text_lines)¶
Allows inherited classes to override the text lines that are fed into other structures contained in a list property.
- Parameters:
text_lines (list) – List containing other lists or flat text to be parsed.
- Returns:
Filtered list of text to be parsed into a property.
- Return type:
list
- classmethod get_tree_structure_read_lines(parsed_tuple)¶
Allows inherited classes to override how many lines have been actually been read for a given parsed structure based on the cls being instantiated.
- Parameters:
parsed_tuple (Tuple[DSeriesStructure, int]) – Tuple of parsed structure and read lines for it.
- Returns:
Resulting tuple with real number of parsed lines.
- Return type:
Tuple[DSeriesStructure, int]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- classmethod parse_text_lines(text_lines)¶
Parses a list of strings into the properties of a structure. .. rubric:: Example
- [ [“1”, “Property value”],
[“2”, “Values in Property”], [“4”, “2”]]
- Parameters:
text_lines (List[List[str]]) – List of properties as strings.
- Raises:
ValueError – When the number of values for a property does not match its definition.
ValueError – When the number of properties does not match the text definition.
- Returns:
Structure with parsed properties. int: Index of last line being read as part of current structure.
- Return type:
- class geolib.models.dseries_parser.DSeriesTreeStructureCollection(*args)¶
- classmethod get_number_of_structures(lines)¶
Provides an overridable method that retrieves the number of structures contained in the tree collection.
- Parameters:
lines (List[List[str]]) – Tree collection lines.
- Returns:
Number of structures expected.
- Return type:
int
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- classmethod parse_collection_type(collecion_type, lines)¶
- Parameters:
collecion_type (
Type
)lines (
list
)
- Return type:
Tuple
[DSeriesStructure
,int
]
- classmethod parse_text_lines(lines)¶
- Parameters:
lines (
List
[str
])- Return type:
Tuple
[DSeriesStructure
,int
]
- class geolib.models.dseries_parser.DSeriesTreeStructurePropertiesInGroups(*args)¶
- classmethod get_next_property_text_lines(text_lines)¶
Retrieves the first element of a list of Tuples[PropertyTextValue, PropertyName] and splits it into further parseable lines.
- Parameters:
text_lines (list) – list of Tuples[PropertyTextValue, PropertyName].
- Returns:
List of lines representing a property value (another structure).
- Return type:
list
- classmethod get_tree_structure_read_lines(parsed_tuple)¶
Allows inherited classes to override how many lines have been actually been read for a given parsed structure based on the cls being instantiated.
- Parameters:
parsed_tuple (Tuple[DSeriesStructure, int]) – Tuple of parsed structure and read lines for it.
- Returns:
Resulting tuple with real number of parsed lines.
- Return type:
Tuple[DSeriesStructure, int]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesUnmappedNameProperties(*args)¶
Specialization of DSeriesInlineMappedProperties, use this class when the properties in the text are the same as in the concrete class definition except for “name”, which has not been declared as a key in the input text: .. rubric:: Example
- Given class my_structure(DSeriesInlineMappedProeprties):
name: str property_dummy_int: 42
- and text, text_to_parse:
[STRUCTURE] This is a name property dummy int = 42 some unit/scale [END OF STRUCTURE]
When ms = my_structure.parse_text(text_to_parse) Then:
ms.name: “This is a name” ms.property_dummy_int = 42
- classmethod get_property_key_value(text, expected_property)¶
Gets both property key and value from the text line.
- Parameters:
text (str) – Text containing key and value.
expected_property (str) – The expected property if there was no key.
- Returns:
Parsed key and value.
- Return type:
Tuple[str, str]
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- class geolib.models.dseries_parser.DSeriesWrappedTableStructure(*args)¶
- model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}¶
A dictionary of computed field names and their corresponding ComputedFieldInfo objects.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': True, 'extra': 'forbid', 'validate_assignment': True, 'validate_default': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- model_fields: ClassVar[dict[str, FieldInfo]] = {}¶
Metadata about the fields defined on the model, mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
This replaces Model.__fields__ from Pydantic V1.
- classmethod validate_number_of_rows(lines)¶
These sort of tables do not contain information of the number of rows contained in the file. Therefore they are not validated.
- Parameters:
lines (List[str]) – Parsed rows.
- geolib.models.dseries_parser.get_field_collection_type(class_type, field_idx)¶
Gets the type wrapped by a collection of a given class. .. rubric:: Example
- DummyClass:
dummycollection: List[SubDummyClass]
get_field_collection_type(DummyClass, 0) -> SubDummyClass
- Parameters:
class_type (Type) – Class containing a collection field.
field_idx (int) – Position of the collection field in the class.
- Returns:
The class for the items in the collection.
- Return type:
Type
- geolib.models.dseries_parser.get_line_property_key_value(text, reversed_key)¶
Returns the unformatted key and formatted value for a given line. .. rubric:: Examples
reversed_key = False key= value 123 -> key, value reversed_key = True value 123= key asdf -> key, value
- Parameters:
text (str) – Text from where to extract key and value.
reversed_key (bool) – Whether the key comes before or after the value.
- Returns:
Unformatted key and formatted value.
- Return type:
Tuple[str, str]
- geolib.models.dseries_parser.get_line_property_value(text, reversed_key)¶
Returns the property value representation in the dseries files assuming is delimited by either ‘:’ or ‘=’. .. rubric:: Examples
- Given (reversed_key = True):
4.2 : property_value 4.2 = property_value
- Given (reversed_key = False):
property_value : 4.2 property_value = 4.2
- Returns:
4.2
- Parameters:
text (str) – Unformatted line of text.
reversed_key (bool) – How the key needs to be extracted.
- Returns:
First field containing value.
- Return type:
str
- geolib.models.dseries_parser.is_structure_collection(field)¶
- Parameters:
field (
Type
)- Return type:
bool
- geolib.models.dseries_parser.make_key(key)¶
- Parameters:
key (
str
)- Return type:
str
- geolib.models.dseries_parser.read_property_as_list(field_name, field, text_lines)¶
Reads a property containing a collection of values represented as a list of strings.
- Parameters:
field_name (str) – Name of the field to parse.
field (Type) – Type to parse the values to.
text_lines (list) – List of list of strings containing values.
- Raises:
ValueError – If the values given don’t match the defined expectations.
- Returns:
Returns generated DSeriesStructures and lines read.
- Return type:
Tuple[List[DSeriesStructure], int]
- geolib.models.dseries_parser.split_line_elements(text)¶
Separates by space and tabulator.
- Parameters:
text (str) – Text to break into separate fields.
- Returns:
List of formatted values.
- Return type:
List[str]
- geolib.models.dseries_parser.strip_line_first_element(text)¶
- Parameters:
text (
str
)