Skip to content

Getting started with nyaml

nyaml is a Python package that is published on PyPI.

How to Install

The tool is published to PyPI and available for pip install

$ pip install nyaml

To contribute to the tool or to install it in development mode, you should run

$ git clone https://github.com/FAIRmat-NFDI/nyaml.git
$ cd nyaml
$ pip install -e ".[dev]"

There is also a pre-commit hook available which formats the code and checks the linting before actually committing. It can be installed with

$ pre-commit install

How to Use

nyaml works as a command line tool to convert NeXus application definitions or base classes from YAML file format into the nxdl.xml file format and vice-versa. The converter can be called by the command

nyaml2nxdl

Main function that distinguishes the input file format and launches the tools.

Usage:

nyaml2nxdl [OPTIONS] INPUT_FILE

Options:

Name Type Description Default
--output-file text Specify the output file path for the converted file. None
--check-consistency boolean Check whether YAML and NXDL can be recursively converted, ensuring version consistency. False
--do-not-store-nxdl boolean Prevent the input NXDL file from being stored as a comment at the end of the output YAML file. False
--verbose boolean Display keywords and value types in standard output to assist in identifying issues in YAML files. False
--help boolean Show this message and exit. False

Brief interpretation of the command line options:

--output-file: The option defines the output file name (including the file extension), if the option is not specified the converter will define the output file name from the input file. Exemplified for a given input file NXapplication.nxdl.xml (NXapplication.yaml), the resultant file will be NXapplication_parser.yaml (NXapplication.nxdl.xml).

--check-consistency: With the option --check-consistency, nyaml produces the same type of file as the input, e.g. for input NXapplication.nxdl.xml the output file is NXapplication_consistency.nxdl.xml. When converting the nxdl.xml file into YAML it also stores the nxdl.xml file at the end of YAML file with a hash.

--do-not-store-nxdl: The option --do-not-store-nxdl prevents the YAML file from storing the original nxdl.xml text as comment.

--verbose: The verbose option is to identify any issues arising from unexpected conversion or syntax errors that occur while converting the file from one to another.

--help: The help option Show this message and exit.