Metadata-Version: 2.4
Name: nemtus-catparser
Version: 3.2.0
Summary: Symbol Catbuffer Parser
License: MIT
License-File: LICENSE
Keywords: symbol,catbuffer,catparser,parser,catbuffer-parser
Author: Symbol Contributors
Author-email: contributors@symbol.dev
Maintainer: Symbol Contributors
Maintainer-email: contributors@symbol.dev
Requires-Python: >=3.10,<4.0
Classifier: License :: OSI Approved :: MIT License
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
Project-URL: Repository, https://github.com/nemtus/symbol/tree/dev/catbuffer/parser
Description-Content-Type: text/markdown

<!-- nemtus-mirror-notice -->
> **Note (nemtus mirror):** This package is a content mirror of the catbuffer
> parser from [`symbol/symbol`](https://github.com/symbol/symbol)
> (`catbuffer/parser`, upstream PyPI name `catparser`). nemtus republishes it on
> PyPI as [`nemtus-catparser`](https://pypi.org/project/nemtus-catparser/); the
> only change from upstream is the published distribution name. The import module
> name is unchanged — you still `import catparser`. For the canonical project, see
> [symbol/symbol](https://github.com/symbol/symbol).
<!-- /nemtus-mirror-notice -->

# catbuffer-parser

[![Build Status](https://api.travis-ci.com/symbol/catbuffer-parser.svg?branch=main)](https://travis-ci.com/symbol/catbuffer-parser)

This project is the reference parser implementation for the CATS (Compact Affinitized Transfer Schema) DSL that is used by the Symbol blockchain. The parser converts a CATS file or files into an AST that can be used by a generator to produce serialization and deserialization code for defined objects.

- A reference to the DSL format can be found [here](docs/cats_dsl.md).
- For a sampling of real world schemas, those used by the Symbol blockchain can be found [here](https://github.com/symbol/catbuffer-schemas).

## Requirements

* Python >= 3.7

## Installation

```bash
git clone https://github.com/symbol/catbuffer-parser
pip3 install -r requirements.txt
pip3 install -r lint_requirements.txt # optional
```

## Usage

```
usage: python -m catparser [-h] -s SCHEMA -i INCLUDE [-o OUTPUT]

CATS code generator

optional arguments:
  -h, --help            show this help message and exit
  -s SCHEMA, --schema SCHEMA
                        input CATS file
  -i INCLUDE, --include INCLUDE
                        schema root directory
  -o OUTPUT, --output OUTPUT
                        yaml output file
  -g GENERATOR, --generator GENERATOR
                        generator class to use to produce output files (defaults to YAML output)
  -q, --quiet           do not print type descriptors to console
```

## Examples

``catparser`` can be used on its own to parse input files, check their validity and optionally output a YAML file containing the parsed type descriptors:

```bash
# parse but don't output anything
python3 -m catparser --schema ../schemas/symbol/transfer/transfer.cats --include ../schemas/symbol --quiet

# parse and output the AST
python3 -m catparser --schema ../schemas/symbol/transfer/transfer.cats --include ../schemas/symbol

# parse and generate code using the specified generator (`generator.Generator`)
python3 -m catparser --schema ../schemas/symbol/transfer/transfer.cats --include ../schemas/symbol --generator generator.Generator
```

