Aas-package3-python is a library for reading and writing packaged file format of an Asset Administration Shell (AAS) in Python.
The library is thoroughly tested and meant to be used in production.
The library is written in pure Python with no external dependencies beyond the standard library. Python 3.10 or later is required.
The documentation is available at https://eclipse-aascw.github.io/aas-package3-python/.
Here are short snippets to demonstrate how you can use the library.
To create and write to a package:
import aas_package3
# General packaging handler to be shared across the program
packaging = aas_package3.Packaging()
spec_content = b'{"assetAdministrationShells": []}'
thumbnail_content = b"..." # PNG bytes
supplementary_content = b"..." # PDF bytes
# Create a package
with packaging.create("some-file.aasx") as pkg:
spec = pkg.make_spec(
pkg.put_part(
"/aasx/some-company/data.json", "application/json", spec_content
)
)
pkg.set_thumbnail(
pkg.put_part("/some-thumbnail.png", "image/png", thumbnail_content)
)
pkg.relate_supplementary_to_spec(
pkg.put_part(
"/aasx-suppl/some-company/some-manual.pdf",
"application/pdf",
supplementary_content,
),
spec,
)
# The changes are written when the with-block finishes without an exception.To read from the package:
import aas_package3
# General packaging handler to be shared across the program
packaging = aas_package3.Packaging()
# Read from the package
with packaging.open_read("some-file.aasx") as pkg:
# Read the specs
specs_by_content_type = pkg.specs_by_content_type()
for spec in specs_by_content_type.get("application/json", []):
spec_content = spec.read_all_bytes()
# Do something with the spec content
# Read the thumbnail
thumbnail = pkg.thumbnail()
if thumbnail is not None:
thumbnail_content = thumbnail.read_all_bytes()
# Do something with the thumbnail content
# Read a supplementary file
supplementary_content = pkg.must_part(
"/aasx-suppl/some-company/some-manual.pdf"
).read_all_bytes()Please see the full documentation at https://eclipse-aascw.github.io/aas-package3-python/ for more details.
The library is available on PyPI at https://pypi.org/project/aas-package3/:
pip3 install aas-package3
The name of the library indicates the supported version of the Asset Administration Shell (AAS).
In case of aas-package3-python, this means that Version 3 of the Asset Administration Shell (AAS) is supported.
We follow Semantic Versioning to version the library. The version X.Y.Z indicates:
- X is the major version (backward-incompatible),
- Y is the minor version (backward-compatible), and
- Z is the patch version (backward-compatible bug fix).
Feature requests or bug reports are always very, very welcome!
Please see quickly if the issue does not already exist in the issue section and, if not, create a new issue.
See CONTRIBUTING.rst for how to set up the development environment and run the checks.