Metadata-Version: 2.4
Name: dcc-json-toolkit
Version: 1.2.2
Summary: Converter to extract data out of DCC (.xml) files, exporting it as a python dict or a .json file.
Author-email: Jaime Gonzalez Gomez <jaime.gonzalez-gomez@ptb.de>
License-Expression: LGPL-2.1-or-later
Project-URL: Repository, https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dcc-2-json-conv
Project-URL: Documentation, https://gitlab-pages.ptb.de/dcc-2-json-conv-19ba77/
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: xmlschema
Requires-Dist: requests
Requires-Dist: platformdirs
Provides-Extra: content
Requires-Dist: xmltodict>=1.0; extra == "content"
Requires-Dist: dsiUnits>=3.1.0; extra == "content"
Provides-Extra: full
Requires-Dist: dcc-json-toolkit[content]; extra == "full"
Dynamic: license-file

# Dcc-Json Toolkit

![pipeline status](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dcc-json-toolkit/badges/main/pipeline.svg)
![coverage](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dcc-json-toolkit/badges/main/coverage.svg)
[![Docs](https://img.shields.io/badge/ReadTheDocs_(click_me)-blue?logo=readthedocs)](https://gitlab-pages.ptb.de/dcc-2-json-conv-19ba77/)
[![PyPI Version](https://img.shields.io/pypi/v/dcc-json-toolkit?logo=python&logoColor=white&label=PyPI)](https://pypi.org/project/dcc-json-toolkit/)

The tool offers a set of tools for both users and developers for the [_Digital Calibration Certificate_ (DCC)](https://wiki.dcc.ptb.de/) files.
The functionality of the tool allows:

- Caching locally any released `dcc.xsd` file, together with all its required imports.
- Validation of any DCC file, printing all the possible issues it has.
- Bidirectional conversion XML-JSON for DCC files.

## Setup

### Python Environment

The package is installable via **pip**:
```bash
pip install dcc-json-toolkit
```

The **basic installation** allows working directly with any DCC Schema.
There are also some additional requirements for those interested:

- `pip install dcc-json-toolkit[content]` to allow validating the contents.

Alternatively, all additional requirements can be installed with the following command:
```bash
pip install dcc-json-toolkit[full]
```

> [!Note]
> This method is recommended for any Linux system or to integrate the tool at any development.

### Windows executable

The executable file provides access to all the [commandline tools](#commandline-tools) without the need of extra installation.
This option is recommended for those users that do not require Python.

To obtain the executable, access the GitLab [Project Releases page](https://gitlab1.ptb.de/digitaldynamicmeasurement/dcc-and-dsi/dcc-2-json-conv/-/releases), then download the file under the **Packages** section for the desired release.

```
==================================================
                DccJsonToolkit
==================================================

Write the name of the tool you want to use (followed by its arguments):
   1. dcc-validate : Validate existing DCC files.
   2. dcc-cache : Manage the local cache.
   3. dcc2json : Exports a DCC (.xml) file into a JSON file.
   4. json2dcc : Creates a DCC file from JSON data.

If you don't know what the tool does, write '-h' after its name. For example, 'dcc-validate -h'. Then press ENTER.
```

> [!Warning]
> The executable works only on Windows OS.

## Usage

### Commandline Tools

- **DCC-JSON file conversion**: Use either `dcc2json` or `json2dcc`.
- **DCC file validation**: Use `dcc-validate` to display all errors of a DCC file or to compare it with a different XSD version. The comparison is quite helpful to control the upgrade of any DCC to the next released XSD version.
- **Cache Manager**: Use `dcc-cache` to control cached versions and see the absolute path for every cache.

Read more about the [CLI tools](https://gitlab-pages.ptb.de/dcc-2-json-conv-19ba77/cli/).

## Developer Tools

If you plan to integrate some of the functionality onto your own code, all functionalities can be recreated with the use of `DccSchema`.

```python
from dcc_json_toolkit import DccSchema

schema = DccSchema("3.3.0")
dcc_as_dict = schema.to_dict("./path/to/dcc.xml")
```

Read the [complete official documentation](https://gitlab-pages.ptb.de/dcc-2-json-conv-19ba77/).
