Skip to main content

A toolkit for reading and writing ILCD format and it's derivatives

Project description

ILCD Lib


Python library providing parsing capabilities for ILCD XML files.

Installation

Install the library from PyPi. The following command will install the library with all optional dependencies:

pip install "ilcdlib[lxml,cli]"

If you don't need CLI tool, you can omit cli extra. The following extras are available:

  • lxml - install lxml library for faster XML parsing
  • cli - install CLI tool so it could be used from command line via ilcdtool command.

Usage

❗ ATTENTION: Pick the right version. There are 2 versions of the library available:

  • Use version below 2.0.0 if your project uses Pydantic version below 2.0.0
  • Use version 2.x.x or higher if your project uses Pydantic version 2.0.0 or above

Branch 1.x.x is not maintained anymore, so if you don't use pydantic 2.x.x should be your choice.

CLI

At the moment the primary function of the CLI tool is to convert ILCD XML files to openEPD (json) format.

Here is a simple example of how to use it to convert ILCD archive to openEPD format:

ilcdtool --debug convert-epd -i ilcd+epd -o openEPD "<path/to/archive.zip>"

It is also possible to point the tool to the http endpoint instead. At the moment Soda4Lca web UI and api endpoints are supported.

ilcdtool convert-epd -i ilcd+epd -o openEPD "https://oekobaudat.de/OEKOBAU.DAT/datasetdetail/process.xhtml?uuid=ee8863aa-7276-4896-b07a-713937a3134d&version=00.00.018&stock=OBD_2021_II&lang=en"

Another important feature is the ability to specify a dialect. Dialect is a set of rules that define how the handle provider specific data. It is useful for the cases when provider does not follow the standard or standard is not strict enough the provider has a multiple options how to persist the data.

convert-epd -i ilcd+epd -o openEPD -d environdec https://data.environdec.com/showProcess.xhtml?uuid=bfeb8678-b3cb-4a5b-b8cb-2512b551ad17&version=01.00.001&stock=Environdata

CLI tool provides comprehensive help for each of the supported commands. Use ilcdtool --help to get the list of the supported commands and a set of global parameters. And use ilcdtool <command> --help to get help for the specific command.

Use in Python code

There are 3 primary concepts in the library:

  1. Medium is a way how application reads ILCD XML data. It could be a zip file, some http API or anything else.
  2. IlcdXmlReader is a class that reads ILCD XML data from the medium and provides a set of methods to access the data.
  3. Dialects are just a subclasses of corresponding readers which override data extraction logic for some of the fields.

So very basic usage of the library would look like this:

from ilcdlib.epd.reader import IlcdEpdReader
from ilcdlib.medium.archive import ZipIlcdReader

lang = ["en", None] # Means "en" or any available language

# Create a medium capable to read data from the zip archive
zip_reader = ZipIlcdReader("<path/to/archive.zip>")
# Create a reader that will read data from the given medium and passing the target object to read 
# (identified by id and version)
epd_reader = IlcdEpdReader(
    "2eb43850-0ab2-4068-afe5-218d69a096f8",
    "00.01.000",
    zip_reader,
)

print(epd_reader.get_product_name(lang))    # Extract product name
print(epd_reader.get_declared_unit())       # Extract declared unit  

# Convert to openEPD format
print(epd_reader.to_openepd_epd(lang).json(indent=2))

For Library Maintainers

Maintainer's Guide is available here.

Credits

This library has been written and maintained by C-Change Labs.

License

This library is licensed under Apache 2. This means you are free to use it in commercial projects.

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

ilcdlib-4.0.0.tar.gz (205.0 kB view details)

Uploaded Source

Built Distribution

ilcdlib-4.0.0-py3-none-any.whl (242.8 kB view details)

Uploaded Python 3

File details

Details for the file ilcdlib-4.0.0.tar.gz.

File metadata

  • Download URL: ilcdlib-4.0.0.tar.gz
  • Upload date:
  • Size: 205.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.9 Linux/6.5.0-1017-azure

File hashes

Hashes for ilcdlib-4.0.0.tar.gz
Algorithm Hash digest
SHA256 19913c900b47c2e34425565d029c35ac104e4fd390d8ab3d747ecd24a968f765
MD5 2068489f6005cb71af52b20579d45726
BLAKE2b-256 88b57e6a98c6cdd5f56a3253a0e7b492cff3881da6a0b3645c552517cedff53e

See more details on using hashes here.

File details

Details for the file ilcdlib-4.0.0-py3-none-any.whl.

File metadata

  • Download URL: ilcdlib-4.0.0-py3-none-any.whl
  • Upload date:
  • Size: 242.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.9 Linux/6.5.0-1017-azure

File hashes

Hashes for ilcdlib-4.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ee32fbbb420614e93a89eb778b7150435520d2b5beb598b22d0ad5e991c97f85
MD5 4169e3857e238d2c26328de285158d83
BLAKE2b-256 55b81926a4015b3cedecfd6b48d8a79afc46c2a33410e4e0be319f260c587896

See more details on using hashes here.

Supported by

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