Skip to main content

A standalone JSON Schema based validator for XDI files used to save XAS data aiming to be fully compliant with the XDI/1.0 specification..

Project description

License: MIT PyPI - Version Building and testing

XDI-Validator

What is it?

XDI-Validator is a standalone JSON Schema based validator for XDI files. XDI (*.xdi) is a format used to save XAS data. This validator aim to be fully compliant with the XDI/1.0 specification, as detailed in the documents XAS Data Interchange Format Draft Specification, version 1.0 and Dictionary of XAS Data Interchange Metadata.

Usage

As simple as it gets :

# import the functionality from the module
from xdi_validator import validate, XDIEndOfHeaderMissingError

# open the xdi file
with open('filename.xdi', 'r') as xdi_document:
    
    # Validate the file. If there is no end-of-header token
    # an exception is raised
    try:
        xdi_errors, xdi_dict = validate(xdi_document)
    except XDIEndOfHeaderMissingError as ex:
        print(ex.message)
        
    # check if there are errors
    if xdi_errors:
        print('XDI is invalid!')
        print(xdi_errors)
    else:
        print('XDI is valid!')
        print(xdi_dict)
    

Basically, the method xdi_validator.validate() the *.xdi file-like object and will return a dictionary with the found errors per each field, and a representation of the contents of the *.xdi as a dictionary. The dictionary of errors is organized in the following way. The keys are the path (Namespace.tag) of the invalid field, and the corresponding value is the list of errors.

Note: Sure, users can also to use the library for parsing and converting XDI files into json representation.

How to install?

XDI-Validator is available in PyPI. The project page is https://pypi.org/project/xdi-validator/. To install XDI-Validator on your development environment, just issue the command:

 pip install xdi-validator

To build and install from the source code do:

  1. Clone the repository: git clone https://github.com/AAAlvesJr/XDI-Validator.git
  2. Go the project directory: cd XDI-Validator
  3. Build the package: python3 -m build
  4. Install the wheel: pip install dist/xdi_validator-{VERSION}-py3-none-any.whl

where VERSION is the package version.

Source code

Access to the source code is granted via the project GitHub repository at the url https://github.com/AAAlvesJr/XDI-Validator.

Dependencies

XDI-Validator's only external dependency is jsonschema package.

How to contribute

Please, submit a pull request. PR adding new features should implement the correspondind unit test. Aside that, please, feel free to open issues for bugs and features requests.

License

XDI-Validator is available under the MIT license. See the LICENSE file for more info.

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

xdi_validator-1.2.0.tar.gz (24.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xdi_validator-1.2.0-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file xdi_validator-1.2.0.tar.gz.

File metadata

  • Download URL: xdi_validator-1.2.0.tar.gz
  • Upload date:
  • Size: 24.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xdi_validator-1.2.0.tar.gz
Algorithm Hash digest
SHA256 5c2a92018a22f52b0d3d88a4c361f1bc09f19297ab519b7c32872c77d37ab077
MD5 1365e81a8b8e1177fbf0441482fae8d9
BLAKE2b-256 59b9850ff0ae6141515c2e0d2a060f825674bfdfe57cdb2d66eaf9fb8d77893c

See more details on using hashes here.

File details

Details for the file xdi_validator-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: xdi_validator-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for xdi_validator-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 001ece63136c7275b4e466738c7d8866e0b07aaba538ea6cddd0b4102fe92ebb
MD5 9e4e4c5a4aa52678dcdbdf582f624612
BLAKE2b-256 96baff9b088b7ad672a43b84bb27f62dbee8fdf5829b74ad7cb50d146d55c3d2

See more details on using hashes here.

Supported by

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