Package: openepd
Python Library to work with OpenEPD formatThis library is a Python library to work with OpenEPD format.About OpenEPDopenEPDis an open data format for passing digital
third-party verified Environmental Product Declarations (EPDs) among Program Operators, EPD Databases,
Life Cycle Analysis tools, design tools, reporting, and procurement.Unlike print or PDF EPDs, openEPD provides a shared and precise format to express and refer to EPDs in ways that
modern databases can use. openEPD can be used alongside a printable document, or can generate printable EPDs.Unlike existing formats such as ILCD+EPD, it enforces a key set of guarantees for interoperable data processing,including uniqueness of organizations/plants, precise PCR references, and dated version control.The openEPD format isextensible. Standard extensions exist for concrete products, and for
documenting supply-chain specific data.Read More about OpenEPD format here.Usage❗ ATTENTION: Pick the right version. The cornerstone of this library models package representing openEPD models.
Models are defined with Pydantic library which is a dependency for openepd package. If you use Pydantic in your project
carefully pick the version:Use version below1.0.0if your project uses Pydantic version below2.0.0Use version1.0.0or higher if your project uses Pydantic version2.0.0or aboveModelsThe library provides the Pydantic models for all the OpenEPD entities. The models are available in theopenepd.modelsmodule. For mode details on the usage please refer to Pydantic documentation.BundleBundle is a format which allows to bundle multiple openEPD objects together (it might be EPDs, PCRs, Orgs + any
other files which might be related to mentioned objects like pdf version of EPD, logo of the PCR company, etc).Bundle consists of root-level and dependent objects. Dependents are objects which are referenced by root-level objects
or related to the root-level objects. For example, EPD is a root-level object, PDF version of this EPD is a dependent,
translated version of the same EPD is dependent as well.The following example illustrates reading of the bundle file containing PCR and some of the related objects:fromopenepd.bundle.readerimportDefaultBundleReaderfromopenepd.bundle.modelimportAssetType,RelTypewithDefaultBundleReader("test-bundle.epb")asreader:# You could either file path or file-like objectpcr=reader.get_first_root_asset(AssetType.Pcr)# Get FIRST available root level PCR object. We consider that# there is only one PCR in the bundle# Read relative PDF file of the found PCR. `related_pdf` is a reference to the PDF file containing metadata onlyrelated_pdf=reader.get_first_relative_asset(pcr,RelType.Pdf)# We have to read the file content separatelywithreader.read_blob_asset(related_pdf)asf:pass# Do something with the file content hereThe next example illustrates the writing of the bundle file:fromopenepd.bundle.writerimportDefaultBundleWriterfromopenepd.bundle.modelimportRelTypefromopenepd.model.pcrimportPcrpcr_obj=Pcr(...)# Let's assume we already have PCR objectwithDefaultBundleWriter("my-bundle.epb")aswriter,open("test-pcr.pdf","rb")aspcr_pdf_file:# Add our PCR to the bundle. We do not specify any extra information, however you might what to add language# and a file name to make it look nicer in the bundle. If omitted the name will be generated automatically.pcr_asset=writer.write_object_asset(pcr_obj)# Now add related PDF document. We have to specify the content type, related (parent) object and the# type of relation. Again, optionally you might want to specify the language and file name.writer.write_blob_asset(pcr_pdf_file,"application/pdf",pcr_asset,RelType.Pdf)CreditsThis library has been written and maintained byC-Change Labs.LicenseThis library is licensed underApache 2. This means you are free to use it in commercial projects.