Skip to content

Fix CAS RegEx and add local xml.xsd #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
5eb4bfe
fix CAS RegEx & add local xml.xsd for batch performance
linancn May 6, 2024
a8701f2
Merge branch 'brightway-lca:main' into main
linancn Aug 27, 2024
ffda9ff
chore: Update ILCD schemas to latest version
linancn Aug 27, 2024
0aafc3e
Update ILCD schemas to include Model Dataset schema
linancn Aug 27, 2024
f37a054
chore: Update Python version to 3.11 in workflow file
linancn Aug 27, 2024
3b17145
chore: Update pyilcd package to version 7.0.2 and rename it to pyeilcd
linancn Aug 27, 2024
23dcb52
chore: Update package name from pyeilcd to pyilcd
linancn Aug 27, 2024
6bcdb64
chore: Update package name from pyilcd to pyeilcd
linancn Aug 27, 2024
d833cf7
chore: Bump pyeilcd package version to 7.0.5
linancn Aug 27, 2024
38e556c
chore: Update MANIFEST.in to include pyeilcd schemas
linancn Aug 27, 2024
f2b37a8
chore: Update pyeilcd package version to 7.0.7 and remove unused imports
linancn Aug 28, 2024
1a37d63
chore: Bump pyeilcd package version to 7.0.8
linancn Aug 28, 2024
138ae4b
chore: Update pyeilcd package version to 7.0.9
linancn Aug 28, 2024
9e0fbb9
chore: Bump pyeilcd package version to 7.0.10
linancn Aug 28, 2024
f69b68d
chore: Add required version attribute to ILCD_LifeCycleModelDataSet s…
Zhangsi2 Dec 16, 2024
b53559a
Merge pull request #1 from Zhangsi2/main
linancn Dec 16, 2024
26882db
chore: Update version to 7.0.12 and add tagging instructions in README
linancn Dec 16, 2024
4b1e730
chore: Update LICENSE and README files for pyeilcd package, add Chine…
Zhangsi2 Mar 10, 2025
57c0830
Merge pull request #2 from Zhangsi2/main
linancn Mar 10, 2025
1fe30e5
chore: Bump version to 7.0.13
linancn Mar 10, 2025
6235397
fix: Correct link to Chinese documentation in README
Zhangsi2 Mar 10, 2025
5ab44d3
Merge pull request #3 from Zhangsi2/main
linancn Mar 10, 2025
93251d0
chore: Bump version to 7.0.14
linancn Mar 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions .github/workflows/python-package-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.11"
- name: Install pypa/build
run: >-
python -m
Expand All @@ -29,12 +29,7 @@ jobs:
build
--outdir dist/
.
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
Expand Down
116 changes: 0 additions & 116 deletions CONTRIBUTING.md

This file was deleted.

3 changes: 2 additions & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
pyilcd
pyeilcd
Copyright (C) 2023 Mina Sami
Copyright (C) 2025 Nan LI

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
include pyilcd/schemas/*.xsd
include pyeilcd/schemas/*.xsd
95 changes: 43 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,71 @@
# pyilcd
# pyeilcd User Guide

[![PyPI](https://img.shields.io/pypi/v/pyilcd.svg)][pypi status]
[![Status](https://img.shields.io/pypi/status/pyilcd.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/pyilcd)][pypi status]
[![License](https://img.shields.io/pypi/l/pyilcd)][license]
[![PyPI](https://img.shields.io/pypi/v/pyeilcd.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/pyeilcd)][pypi status]

[![Read the documentation at https://pyilcd.readthedocs.io/](https://img.shields.io/readthedocs/pyilcd/latest.svg?label=Read%20the%20Docs)][read the docs]
[![Tests](https://github.com/sami-m-g/pyilcd/actions/workflows/python-test.yml/badge.svg)][tests]
[![Codecov](https://codecov.io/gh/sami-m-g/pyilcd/branch/main/graph/badge.svg)][codecov]
[pypi status]: https://pypi.org/project/pyeilcd/

[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)][pre-commit]
[![Black](https://img.shields.io/badge/code%20style-black-000000.svg)][black]
[English](https://github.com/linancn/pyilcd/blob/main/README.md) | [中文](https://github.com/linancn/pyilcd/blob/main/README_CN.md)

[pypi status]: https://pypi.org/project/pyilcd/
[read the docs]: https://pyilcd.readthedocs.io/
[tests]: https://github.com/sami-m-g/pyilcd/actions?workflow=Tests
[codecov]: https://app.codecov.io/gh/sami-m-g/pyilcd
[pre-commit]: https://github.com/pre-commit/pre-commit
[black]: https://github.com/psf/black
**Note:** This package supports Python versions 3.8 to 3.12 only.

## Installation
## 1. Introduction

You can install _pyilcd_ via [pip] from [PyPI]:
pyeilcd is a Python package that provides a simple interface to validate extended-ILCD (eILCD) XML files against the ILCD schemas. It is built on top of the [pyilcd](https://github.com/brightway-lca/pyilcd) library.

---

## 2. pyeilcd Usage

### (1) Installation Instructions

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

```console
$ pip install pyilcd
$ pip install pyeilcd
```
### (2) Functionalities

pyeilcd offers the following key functionalities:

- Performs schema validation on eILCD XML files.

## Usage
- Supports multiple ILCD standard-compliant dataset types (e.g., ContactDataset, ProcessDataset, etc.).

- ​Leverages core validation capabilities from [pyilcd](https://github.com/brightway-lca/pyilcd).

### (3) Usage Examples

```python
from pyilcd import parse_file_contact_dataset, validate_file_contact_dataset, save_ilcd_file, Defaults
from pyeilcd import validate_file_contact_dataset, 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
## 3. Automatic Building and Publishing (CI/CD)

Contributions are very welcome.
To learn more, see the [Contributor Guide][Contributor Guide].
This project supports automatic building and publishing. When you push a git tag named with the v<version> format to the repository, it will trigger the workflow automatically. For example:

## License
```bash
#list existing tags
git tag
#creat a new tag
git tag v7.0.12
#push this tag to origin
git push origin v7.0.12

Distributed under the terms of the [GPL 3.0 license][License],
_pyilcd_ is free and open source software.

## Issues
```

If you encounter any problems,
please [file an issue][Issue Tracker] along with a detailed description.
## 4. License

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

<!-- github-only -->

[command-line reference]: https://pyilcd.readthedocs.io/en/latest/usage.html
[License]: https://github.com/sami-m-g/pyilcd/blob/main/LICENSE
[Contributor Guide]: https://github.com/sami-m-g/pyilcd/blob/main/CONTRIBUTING.md
[Issue Tracker]: https://github.com/sami-m-g/pyilcd/issues
[pip]: https://pip.pypa.io/en/stable/
[PyPI]: https://pypi.org/project/pyeilcd/
70 changes: 70 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# pyeilcd 使用说明

[![PyPI](https://img.shields.io/pypi/v/pyeilcd.svg)][pypi status]
[![Python Version](https://img.shields.io/pypi/pyversions/pyeilcd)][pypi status]

[pypi status]: https://pypi.org/project/pyeilcd/

[English](https://github.com/linancn/pyilcd/blob/main/README.md) | [中文](https://github.com/linancn/pyilcd/blob/main/README_CN.md)

**注意:** 本工具包仅支持 Python 3.8 至 3.12 版本。

## 1. 介绍

pyeilcd 是一个用于校验扩展ILCD(eILCD)XML数据文件的Python包,它基于 [pyilcd](https://github.com/brightway-lca/pyilcd) 库构建。

---

## 2. pyeilcd 使用方法

### (1) 安装说明

您可以通过 [pip] 从 [PyPI] 安装 _pyeilcd_:

```console
$ pip install pyeilcd
```

### (2) 功能

pyeilcd 主要提供以下功能:

- 根据ILCD Schema对eILCD XML文件进行格式和内容的规范性检查。

- 兼容ILCD标准定义的数据集类型,包括但不限于:ContactDataset、ProcessDataset 等。

- 底层验证逻辑基于 [pyilcd](https://github.com/brightway-lca/pyilcd) 库实现。

### (3) 使用示例

```python
from pyeilcd import validate_file_contact_dataset, Defaults

# 如有需要,可以覆盖默认设置,否则跳过。默认设置已预先配置。
Defaults.config_defaults("config.ini") # 替换为您自己的配置文件

# 根据 ContactDataset schema验证 ContactDataset 类。
validate_file_contact_dataset("data/invalid/sample_contact_invalid.xml") # 替换为您自己的 XML 文件
>> 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.
```

## 3. 自动构建构建并发布(CI/CD)

本项目支持自动构建和发布,当您向 git 仓库推送以 `v版本号` 命名的 tag 时,会自动触发。例如:

```bash
# 列出已有的 tag
git tag
# 创建新 tag(例如版本 v7.0.12)
git tag v7.0.12
# 将新创建的 tag 推送到远程仓库,触发自动构建和发布
git push origin v7.0.12
```

## 4. 许可证

_pyeilcd_ 依据 GPL 3.0 协议发布,属于免费开源软件。


[pip]: https://pip.pypa.io/en/stable/
[PyPI]: https://pypi.org/project/pyeilcd/
26 changes: 26 additions & 0 deletions pyeilcd/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"""pyeilcd."""

from .config import Defaults
from .core import (
validate_file_contact_dataset,
validate_file_flow_dataset,
validate_file_flow_property_dataset,
validate_file_model_dataset,
validate_file_process_dataset,
validate_file_source_dataset,
validate_file_unit_group_dataset,
)

__version__ = "7.0.14"

__all__ = (
"__version__",
"Defaults",
"validate_file_contact_dataset",
"validate_file_flow_dataset",
"validate_file_flow_property_dataset",
"validate_file_process_dataset",
"validate_file_source_dataset",
"validate_file_model_dataset",
"validate_file_unit_group_dataset",
)
3 changes: 3 additions & 0 deletions pyilcd/config.py → pyeilcd/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class Defaults:
SCHEMA_SOURCE_DATASET: ClassVar[str] = os.path.join(
SCHEMA_DIR, "ILCD_SourceDataSet.xsd"
)
SCHEMA_MODEL_DATASET: ClassVar[str] = os.path.join(
SCHEMA_DIR, "ILCD_LifeCycleModelDataSet.xsd"
)

DYNAMIC_DEFAULTS: ClassVar[
Dict[str, Dict[str, Callable[[etree.ElementBase], str]]]
Expand Down
Loading