Skip to main content
crispum
=======

Cross-language declarative parsing pipeline.

Installation
------------

| Node: ``npm i crispum --save``
| Python: ``pip install crispum``, or if you're clever
``pipenv install crispum``

Usage
-----

Crispum is designed to take in static JSON schema objects and return
back a parser function which will apply all of the transformations
listed in the schema object.

Here is an example of a simple
`obstruction <https://github.com/bendrucker/obstruction>`__ example.

.. code:: json

{
"type": "simple",
"keys": {
"indeed": "awesome"
}
}

This schema would transform the following object...

.. code:: json

{
"awesome": "it works!"
}

into

.. code:: json

{
"indeed": "it works!"
}

The schema may also be an array of instructions, and can apply
instructions to to the whole object or to each element of an array.

.. code:: json

[{
"type": "pluck",
"key": "indeed"
}, {
"type": "array"
}, {
"type": "conditional",
"key": "foo",
"default": {
"type": "filter"
},
"options": {
"bar": {
"type": "pluck",
"key": "nested"
},
"baz": {
"type": "pluck",
"key": "special"
}
}
}, {
"type": "dearray"
}, {
"type": "simple",
"keys": {
"result": "0",
"extra": "1"
}
}]

This results in a complex multistep schema, which when appled to data
like this...

.. code:: json

{
"extra": "oh hey",
"indeed": [{
"foo": "bar",
"nested": "value"
}, {
"foo": "boozle",
"nested": "lost in space"
}, {
"foo": "baz",
"nested": "value",
"special": "so bazzy"
}]
}

results in...

.. code:: json

{
"result": "value",
"extra": "so bazzy"
}

API
===

``crispum(schema)`` -> ``function (data)``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Create a new crispum parser with the options passed. The returned parse
method takes one parameter, which is input data, and returns the
transformed data.

schema
~~~~~~

| *Required*
| Type: ``object`` or ``array``

The schema may either be a single instruction or an array of them. Each
instruction must have a ``type``, and may optionally contain an
``array`` field.

When ``array`` is true, the current data will be reinterpreted as an
array and each instruction will execute on the entries instead of the
list itself.

Available types are...

array
^^^^^

The array instruction tells the crispum pipeline to run all subsequent
instructions as if they had ``array: true`` set. It also can take in an
optional parameters, ``keys``

``keys`` is a list of keys to copy from the data into each element of
the array before continuing on the pipeline

conditional
^^^^^^^^^^^

The conditional instruction looks at the value of a specified key and
then executes a different instruction based on the value found.

- ``key``: They keyname to check the conditional against
- ``default``: The default instruction if the value found is not in the
options list
- ``options``: An associative array of instruction options

dearray
^^^^^^^

Stops an array pipeline and goes back to interpreting the data as a
whole instead of each element.

filter
^^^^^^

This instruction deletes the current data and does ont take any
parameters. This is useful in combination with ``array`` and
``conditional``

simple
^^^^^^

Simple onyl takes 1 other parameter, which is ``keys``. Keys should be a
valid `obstruction
schema <https://github.com/bendrucker/obstruction#schema-definitions>`__.
The result is the same as the output obstruction would generate, except
extra keys not mentioned in the schema are not removed.

pluck
^^^^^

The pluck instruction takes a given key and rebases the dataset onto it.
It takes in two parameters \* ``key``: The keyname to grab and rebase
the current dataset onto \* ``keys``: An array of extra keys to copy
from the parent object into the plucked value

License
=======

MIT


Metadata

Release files for crispum 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for crispum 0.2.0
File Interpreter ABI Platform Actions
crispum-0.2.0-py3-none-any.whl Python 3 none any Details for crispum-0.2.0-py3-none-any.whl
crispum-0.2.0-py2-none-any.whl Python 2 none any Details for crispum-0.2.0-py2-none-any.whl

Total release size: 15.3 kB

Release files / crispum-0.2.0-py3-none-any.whl

Download URL crispum-0.2.0-py3-none-any.whl
Size 7.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
37669caf71bb28de627d10c7495c3ee87fa8c27e9f7bc42736e5826e21d044d0
BLAKE2b-256 checksum
How to use checksums
62adcd321ae4f31ab6624fcebcf9ae74e2c627c6d6a2dea3d708f36f5f54f41d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / crispum-0.2.0-py2-none-any.whl

Download URL crispum-0.2.0-py2-none-any.whl
Size 7.7 kB
Tags Python 2
SHA-256 checksum
How to use checksums
291efbfa26470b01e8b940b0f28ba19db48f3dfb9e111a77e3b11d0ce4f15498
BLAKE2b-256 checksum
How to use checksums
01e7b3a99229fbfe2d1a86df2fd965b8b19bb601169f74b9922c147f48fce926
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for crispum 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page