Welcome to Isogeo - XML Toolbelt’s documentation!

Author:Isogeo
Source code:https://github.com/isogeo/xml-toolbelt-py/
Issues:https://github.com/isogeo/xml-toolbelt-py/issues

Indices and tables

Package modules

isogeo_xml_toolbelt

isogeo_xml_toolbelt package

This package is used to handle geographic metadata asstored as XML in ISO 19139 and 19110.

Subpackages
isogeo_xml_toolbelt.enums package
isogeo_xml_toolbelt.models package
Submodules
isogeo_xml_toolbelt.models.xml_19139_fields module

Isogeo XML Fixer - Metadata

Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x

class isogeo_xml_toolbelt.models.xml_19139_fields.Contact(contact, namespaces)[source]

Bases: object

Contact in metadata XML 19139

Parameters:
  • contact (lxml.etree._ElementTree) – Element {http://www.isotc211.org/2005/gmd}CI_ResponsibleParty
  • namespaces (dict) – XML namespaces like lxml.etree.getroot().nsmap
asDict() → dict[source]

Return contact as a structured dictionary key: value.

isogeo_xml_toolbelt.readers package
Submodules
isogeo_xml_toolbelt.readers.reader_iso19110 module

Isogeo XML Fixer - Metadata

Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x

class isogeo_xml_toolbelt.readers.reader_iso19110.MetadataIso19110(xml: pathlib.Path)[source]

Bases: object

Object representation of a metadata stored into XML respecting ISO 19110.

asDict()[source]

Return the metadata object as a dict.

isogeo_xml_toolbelt.readers.reader_iso19139 module

Isogeo XML Fixer - Metadata

Purpose: Read a metadata stored into XML ISO 19139 as an object Authors: First work by GeoBretagne on mdchecker - updated by Isogeo Python: 3.6.x

class isogeo_xml_toolbelt.readers.reader_iso19139.MetadataIso19139(xml: pathlib.Path)[source]

Bases: object

Object representation of a metadata stored into XML respecting ISO 19139.

asDict() → dict[source]

Retrun object as a structured dictionary key: value.

get_md_contacts() → dict[source]
get_md_keywords() → list[source]
isogeo_xml_toolbelt.reporters package
Submodules
isogeo_xml_toolbelt.reporters.csv_reporter module

Sample module to manage CSV reporting

class isogeo_xml_toolbelt.reporters.csv_reporter.CsvReporter(csvpath: pathlib.Path = PosixPath('report.csv'), headers: list = ['header1', 'header2'], extrahead: str = 'ignore')[source]

Bases: object

Produce CSV report. Inherits from standard ‘csv.DictWriter’ lib.

See:
add_multiple(in_data: list)[source]

Add a set of rows to the CSV from the input list of data dictionaries.

Parameters:in_data (list) – list of dictionaries of data to be added. Expected structure: [{header1: valueA}, {header2: valueB}]
add_unique(in_data: dict)[source]

Add a single row to the CSV from the input data dictionary

Parameters:in_data (dict) – Dictionary of data to be added. Expected structure: {header: value}
write_headers()[source]

Write headers to the CSV.

isogeo_xml_toolbelt.utils package
Submodules
isogeo_xml_toolbelt.utils.xml_utils module

Isogeo XML Fixer - Metadata

Purpose: Read a metadata stored into XML ISO 19110 as an object Authors: Isogeo, inspired by the work did by GeoBretagne on mdchecker Python: 3.6.x

class isogeo_xml_toolbelt.utils.xml_utils.XmlUtils[source]

Bases: object

Common methods used to parse XML files.

parse_string_for_max_date(dates_as_str: str)[source]

Parse string with multiple dates to extract the most recent one. Used to get the latest modification date.

Parameters:dates_as_str (str) – string containing dates
xmlGetTextNodes(doc: lxml.etree._ElementTree, xpath: str, namespaces: dict)[source]

Shorthand to retrieve serialized text nodes matching a specific xpath.

Parameters:
  • doc (lxml.etree._ElementTree) – XML element to parse
  • xpath (str) – Xpath to reach
  • namespaces (dict) – XML namespaces like lxml.etree.getroot().nsmap
xmlGetTextTag(doc: lxml.etree._ElementTree, xpath: str, namespaces: dict, key: str)[source]

Function to get information in tag when information isn’t in nodes matching a specific xpath.

Parameters:
  • doc (lxml.etree._ElementTree) – XML element to parse
  • xpath (str) – Xpath to reach
  • namespaces (dict) – XML namespaces like ‘lxml.etree.getroot().nsmap’

:param key : XML key to find like ‘codeListValue’

Submodules
isogeo_xml_toolbelt.md_xml_fixer module
class isogeo_xml_toolbelt.md_xml_fixer.MetadataXML19139Fixer[source]

Bases: object

ISO 19139 XML fixer.

add_ds_creation_date()[source]

Add metadata creation date into metadata XML.

Under /MD_Metadata/identificationInfo/MD_DataIdentification/citation/CI_Citation/date <date>

<CI_Date>
<date>
<gco:Date>2010-07-07Z</gco:Date>

</date> <dateType>

<CI_DateTypeCode codeList=”http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode” codeListValue=”creation”>creation</CI_DateTypeCode>

</dateType>

</CI_Date>

</date>

add_md_character_set()[source]

Add metadata creation date into metadata XML.

Under /MD_Metadata/characterSet AND /MD_Metadata/identificationInfo/MD_DataIdentification/characterSet <characterSet>

<MD_CharacterSetCode codeList=”http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#MD_CharacterSetCode” codeListValue=”utf8”>utf-8</MD_CharacterSetCode>

</characterSet>

add_namespaces()[source]

Add ISO19139 namespaces.

check_folders()[source]

Check prerequisites.

fix_cgus()[source]

Add dataset usage conditions and limitations into metadata XML.

Under /MD_Metadata/identificationInfo/MD_DataIdentification/resourceConstraints

<resourceConstraints>
<MD_Constraints>
<useLimitation>
<gmx:Anchor xl:href=”http://www.etalab.gouv.fr/licence-ouverte-open-licence” xl:title=”Licence ouverte ETALAB 1.0” />

</useLimitation> <useLimitation>

<gco:CharacterString>Conditions sur [geopaysdebrest.fr &gt; Usage des données](https://geo.pays-de-brest.fr/usages/Pages/default.aspx).</gco:CharacterString>

</useLimitation>

</MD_Constraints>

</resourceConstraints> <resourceConstraints>

<MD_LegalConstraints>
<useLimitation>
<gco:CharacterString>Pas de restriction d’accès public selon INSPIRE</gco:CharacterString>

</useLimitation> <useLimitation>

<gco:CharacterString>Conditions sur [geopaysdebrest.fr &gt; Usage des données](https://geo.pays-de-brest.fr/usages/Pages/default.aspx).</gco:CharacterString>

</useLimitation> <accessConstraints>

<MD_RestrictionCode codeList=”http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode” codeListValue=”license”>license</MD_RestrictionCode>

</accessConstraints>

</MD_LegalConstraints>

</resourceConstraints>

fix_srs()[source]

Fix Spatial Reference System.

Under /MD_Metadata/referenceSystemInfo/MD_ReferenceSystem/referenceSystemIdentifier/RS_Identifier <referenceSystemInfo>

<MD_ReferenceSystem>
<referenceSystemIdentifier>
<RS_Identifier>
<code>
<gco:CharacterString>urn:ogc:def:crs:EPSG:2154</gco:CharacterString>

</code>

</RS_Identifier>

</referenceSystemIdentifier>

</MD_ReferenceSystem>

</referenceSystemInfo>

get_md_ci_citation()[source]

Get CI_Citation level items.

get_md_data_identification()[source]

Get Character_set level items.

get_rs_constraints()[source]

Get resourceConstraints level items.

get_rs_identifier()[source]

Get RS_Identifier level items.

prettify(elem)[source]

Return a pretty-printed XML string for the Element.

isogeo_xml_toolbelt.switch_from_geosource module