pipeline.src.parsers.utils

Functions

remove_namespace(tag)

Removes xmlns from tag string.

get_root_tag(xml_element)

try_float(s)

try_int(s)

get_first_child(xml_element[, assert_child_single])

tagged_children(el)

make_datetime(→ datetime.datetime)

Takes date a "2020-12-24" string and, optionnally, a time "16:49" or "16:49:10"

serialize_datetime(→ str)

Serialize a datetime object

Module Contents

pipeline.src.parsers.utils.remove_namespace(tag: str)[source]

Removes xmlns from tag string.

>>> remove_namespace("{http://ec.europa.eu/fisheries/schema/ers/v3}OPS")
"OPS"
pipeline.src.parsers.utils.get_root_tag(xml_element)[source]
pipeline.src.parsers.utils.try_float(s: str)[source]
pipeline.src.parsers.utils.try_int(s: str)[source]
pipeline.src.parsers.utils.get_first_child(xml_element, assert_child_single=True)[source]
pipeline.src.parsers.utils.tagged_children(el)[source]
pipeline.src.parsers.utils.make_datetime(date: str, time: str | None = None) datetime.datetime[source]

Takes date a “2020-12-24” string and, optionnally, a time “16:49” or “16:49:10” string. Returns a datetime object

pipeline.src.parsers.utils.serialize_datetime(dt: datetime.datetime | None = None) str[source]

Serialize a datetime object

Parameters:

dt (Optional[datetime])

Returns:

Serialized datetime in ISO format.

Return type:

str