ezgpx.parsers package

Submodules

ezgpx.parsers.fit_parser module

This module contains the FitParser class.

class ezgpx.parsers.fit_parser.FitParser(source: str | Path | IO[str] | IO[bytes] | bytes)[source]

Bases: Parser

Fit file parser.

parse() dict[source]

Parse Fit file.

dict: Gpx, precisions and time_format.

Example: >>> # TODO

ezgpx.parsers.gpx_parser module

This module contains the GPXParser class.

class ezgpx.parsers.gpx_parser.GPXParser(source: str | Path | IO[str] | IO[bytes] | bytes, xml_schemas: bool = True, xml_extensions_schemas: bool = False)[source]

Bases: XMLParser

GPX file parser.

parse() dict[source]

Parse GPX file.

Returns:

dict: Gpx instance, precisions and time format.

ezgpx.parsers.kml_parser module

This module contains the KMLParser class.

class ezgpx.parsers.kml_parser.KMLParser(source: str | Path | IO[str] | IO[bytes] | bytes, xml_schemas: bool = True, xml_extensions_schemas: bool = False)[source]

Bases: XMLParser

KML file parser.

add_properties()[source]

Add missing properties (properties that do not exist in KML/KMZ files but mandatory in GPX files).

find_precisions()[source]

Find decimal precision of any type of value in a KML file (latitude, elevation…).

parse() dict[source]

Parse KML file.

Returns:

dict: Gpx, precisions and time_format.

Example: >>> # TODO

parse_document(document) list[dict] | None[source]

Parse Document element from KML file.

Args:

document (ET.Element): Parsed Document element.

Returns:
list[dict] | None: Informations related to Placemark

elements contained in the Document element.

parse_placemark(placemark) dict | None[source]

Parse Placemark element from KML file.

Args:
placemark (ET.Element): Parsed Placemark

element.

Returns:
dict | None: Informations contained in the Placemark

element (the name of the Placemark (str) and the contents of the LineString (list[str])).

parse_root_document()[source]

Parse Document elements from KML file.

ezgpx.parsers.parser module

This module contains the Parser class.

class ezgpx.parsers.parser.Parser(source: str | Path | IO[str] | IO[bytes] | bytes)[source]

Bases: object

File parser.

ezgpx.parsers.xml_parser module

This module contains the XMLParser class.

class ezgpx.parsers.xml_parser.XMLParser(source: str | Path | IO[str] | IO[bytes] | bytes, xml_schema: bool = True, xml_extensions_schemas: bool = False)[source]

Bases: Parser

XML file parser.

find_float(element: Element, sub_element: str) float | None[source]

Find float point value from sub-element.

Args:

element (ET.Element): Parsed element from GPX file. sub_element (str): Sub-element name.

Returns:

float | None: Floating point value from sub-element.

find_int(element: Element, sub_element: str) int | None[source]

Find integer value from sub-element.

Args:

element (ET.Element): Parsed element from GPX file. sub_element (str): Sub-element name.

Returns:

int | None: Integer value from sub-element.

find_sub_element(element: Element, sub_element: str) Element | None[source]

Find sub-element.

Args:

element (ET.Element): Parsed element from GPX file. sub_element (str): Sub-element name.

Returns:

ET.Element | None: Sub-element.

find_text(element: Element, sub_element: str) str | None[source]

Find text from sub-element.

Args:

element (ET.Element): Parsed element from GPX file. sub_element (str): Sub-element name.

Returns:

str | None: Text from sub-element.

find_time(element: Element, sub_element: str) datetime | None[source]

Find time value from sub-element.

Args:

element (ET.Element): Parsed element from GPX file. sub_element (str): Sub-element name.

Returns:

datetime | None: Floating point value from sub-element.

xml_schemas()[source]

Check XML schemas during parsing.

Module contents