Skip to main content

A Python package that converts ILCD XML formats to their Python equivalents and export the same data back to XML.

Project description

pyilcd

PyPI Status Python Version License

Read the documentation at https://pyilcd.readthedocs.io/ Tests Codecov

pre-commit Black

Installation

You can install pyilcd via [pip] from [PyPI]:

$ pip install pyilcd

Usage

from pyilcd import parse_file_contact_dataset, validate_file_contact_dataset, save_ilcd_file, Defaults

# Override defaults if needed, else skip. Defaults are already set.
Defaults.config_defaults("config.ini")  # Replace with your own config file

# Validate the ContactDataset class against the ContactDataset schema.
validate_file_contact_dataset("data/invalid/sample_contact_invalid.xml")  # Replace with your own XML file
>> data/contact/sample_contact_invalid.xml:17:0:ERROR:SCHEMASV:SCHEMAV_CVC_DATATYPE_VALID_1_2_1: Element '{http://lca.jrc.it/ILCD/Common}class', attribute 'level': 'a' is not a valid value of the atomic type '{http://lca.jrc.it/ILCD/Common}LevelType'. data/contact/sample_contact_invalid.xml:17:0:ERROR:SCHEMASV:SCHEMAV_CVC_IDC: Element '{http://lca.jrc.it/ILCD/Common}class', attribute 'level': Warning: No precomputed value available, the value was either invalid or something strange happened.

# Parse the required XML file to ContactDataset class.
contactDataset = parse_file_contact_dataset("data/contact/sample_contact.xml")  # Replace with your own XML file
contactDataset
>> <Element {http://lca.jrc.it/ILCD/Contact}contactDataSet at 0x1c85f20c780>

## Change whatever attributes you need changing.
dataSetInformation = contactDataset.contactInformation.dataSetInformation
dataSetInformation.UUID
>> 00000000-0000-0000-0000-000000000000
dataSetInformation.UUID = "10000000-0000-0000-0000-000000000000"
dataSetInformation.UUID
>> 10000000-0000-0000-0000-000000000000

## Save final ContactDataset class as an XML file, make sure root directory exists.
save_ilcd_file(contactDataset, "out/sample_contact_new.xml")  # Replace with your own path

Contributing

Contributions are very welcome. To learn more, see the Contributor Guide.

License

Distributed under the terms of the GPL 3.0 license, pyilcd is free and open source software.

Issues

If you encounter any problems, please file an issue along with a detailed description.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyilcd-6.3.0.tar.gz (120.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyilcd-6.3.0-py3-none-any.whl (134.3 kB view details)

Uploaded Python 3

File details

Details for the file pyilcd-6.3.0.tar.gz.

File metadata

  • Download URL: pyilcd-6.3.0.tar.gz
  • Upload date:
  • Size: 120.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyilcd-6.3.0.tar.gz
Algorithm Hash digest
SHA256 b377e7f00ba1da8d069323de320403cdd36ed878b78cfd6604c4f44f6c1f0051
MD5 1ce12b4b1d5d28bd9b267b16d8cbea17
BLAKE2b-256 05c2195cb6b6a41dc538d53c3f235b8a7f3d33fe17c9d8cffdcd9df76c21d447

See more details on using hashes here.

File details

Details for the file pyilcd-6.3.0-py3-none-any.whl.

File metadata

  • Download URL: pyilcd-6.3.0-py3-none-any.whl
  • Upload date:
  • Size: 134.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for pyilcd-6.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a87241f376cf85afdcce5872b8b86e35dddf00ae881f4d5d5ab12aa6c0816ae5
MD5 1e1d9fccad862f2ceec81024edcd5739
BLAKE2b-256 d208241b4784107a759c4a6e30b96179a377827bf2cc66214be0147333b9148b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page