██████╗ ██╗ ██████╗██╗ ██╗██╗ ███████╗
██╔══██╗██║██╔════╝██║ ██╔╝██║ ██╔════╝
██████╔╝██║██║ █████╔╝ ██║ █████╗
██╔══██╗██║██║ ██╔═██╗ ██║ ██╔══╝
██║ ██║██║╚██████╗██║ ██╗███████╗███████╗
╚═╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═╝╚══════╝╚══════╝
by Zipfian Science
rickle
is a versatile Python library and command-line tool that offers a wide range of functionalities for working with YAML and JSON data. Here's a brief summary of its key features:
-
Serialization:
rickle
allows you to easily serialize Python objects to YAML format. This is particularly useful for converting Python data structures into a human-readable and easily shareable format. -
Schema Validation: It provides the capability to validate YAML and JSON data against predefined schemas. This ensures that your data adheres to a specific structure or format, helping to maintain data consistency.
-
Schema Generation: You can generate schema definitions from existing YAML (or JSON) files. This is helpful when you want to formalize the structure of your data or for documentation purposes.
-
Conversion between YAML and JSON:
rickle
offers seamless conversion between YAML and JSON formats. This facilitates data interchange between systems that use different serialization formats. -
Simple Web Server: One unique feature of
rickle
is its ability to create a basic web server from a YAML file. This means you can define endpoints, routes, and data sources purely by writing it as a YAML file, making it easy to prototype web services without extensive coding, or to create mock REST APIs.
In summary, rickle
is a powerful utility for working with YAML and JSON data in Python.
It simplifies tasks like serialization, schema validation, schema generation, format conversion,
and even enables quick web server prototyping using YAML configuration files.
This tool is valuable for developers and data engineers working
with structured data in a flexible and efficient manner.
For usage examples see examples page. Documentation can be found here.
First install the tool (Python version >= 3.7):
$ pip install rickled
Optionally the twisted web server can be installed alongside for the serve
functionality.
$ pip install rickled[twisted]
Furthermore, if SSL support is needed:
$ pip install rickled[twisted,pyopenssl]
Check if the installation succeeded:
$ rickle --help
Two main schema tools exist, the check
and the gen
tools.
For checking the schema of input files, the check
tool is used.
$ rickle schema check --help
$ rickle schema check -i test.yaml -c schema.yaml
Schema files can be generated from YAML files with the gen
tool.
$ rickle schema gen --help
$ rickle schema gen -i test.yaml
This will generate a schema file called test.schema.yaml
.
rickle
can also be used for bulk conversion from YAML to JSON or the other way around.
$ rickle conv --help
To convert input files (or directories):
$ rickle conv -i test.yaml -o test.json
For each input file the output file can be defined and the path suffix is used to infer the desired output type.
Alternatively the type can be specified with the -t
flag.
A nifty little use of this Python tool is the ability to host a webserver, using a YAML file.
$ rickle serve --help
$ rickle serve -f basic_example.yaml
This will start listening on http://localhost:8080, for requests using GET
.
As this is an open source project, forks and PRs are welcome! Please review some of the practices stated in CONTRIBUTIONS.md.
© Zipfian Science 2020 - 2024