Name | tastier JSON |
Version |
0.1.0
JSON |
| download |
home_page | https://github.com/zeionara/tasty |
Summary | A human-readable format for nested data serialization |
upload_time | 2023-01-27 17:04:24 |
maintainer | |
docs_url | None |
author | Zeio Nara |
requires_python | |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Tasty
Tasty - **ta**b **s**eparated **t**ables - a human-readable format for nested data serialization. The module allows to represent lists of objects with variable length in the following format:
```sh
pair triple
one 1 two 2 three two 2 three
three 3 four 4 five
six 6 seven 7 eight
```
Which corresponds to the following data (see `examples/main.py` for more details):
```py
(
(
(
(TastyPair('one', 1), ),
(TastyTriple('two', 2, Quux('three')), TastyTriple('two', 2, Quux('three')))
),
(
(TastyPair('three', 3), ),
(TastyTriple('four', 4, Quux('five')), )
)
),
(
(
(TastyPair('six', 6), ),
(TastyTriple('seven', 7, Quux('eight')), )
),
)
)
```
## Installation
The module doesn't require any additional dependencies. To install from pypi, run the following command:
```sh
pip install tasty
```
## Usage
Default methods for dataset serialization and deserialization are implemented, so the module can be used as follows (see the `main.py` script in the `examples` folder):
```py
from dataclasses import dataclass
from tasty import Corpus, CellComponent, encode, pipe
@dataclass
class TastyPair(CellComponent):
foo: str
bar: int
@property
def serialized(self):
return self._serialize(
self.foo | pipe | encode,
self.bar | pipe | str
)
@dataclass
class Quux:
value: str
@dataclass
class TastyTriple(CellComponent):
baz: str
qux: int
quux: Quux
@property
def serialized(self):
return self._serialize(
self.baz | pipe | encode,
self.qux | pipe | str,
self.quux.value | pipe | encode
)
written_corpus = Corpus(
(
(
(
(TastyPair('one', 1), ),
(TastyTriple('two', 2, Quux('three')), TastyTriple('two', 2, Quux('three')))
),
(
(TastyPair('three', 3), ),
(TastyTriple('four', 4, Quux('five')), )
)
),
(
(
(TastyPair('six', 6), ),
(TastyTriple('seven', 7, Quux('eight')), )
),
)
)
).write('corpus.txt', header = ('pair', 'triple'))
read_corpus = Corpus.read('corpus.txt', parsers = (TastyPair, TastyTriple))
assert read_corpus.data == written_corpus.data
```
Raw data
{
"_id": null,
"home_page": "https://github.com/zeionara/tasty",
"name": "tastier",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "",
"author": "Zeio Nara",
"author_email": "zeionara@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9f/a7/df15808e4d79303d05d405361577d957535e2675f6b83fadcd758d28a947/tastier-0.1.0.tar.gz",
"platform": null,
"description": "# Tasty\n\nTasty - **ta**b **s**eparated **t**ables - a human-readable format for nested data serialization. The module allows to represent lists of objects with variable length in the following format:\n\n```sh\npair\ttriple\none 1\ttwo 2 three two 2 three\nthree 3\tfour 4 five\n\nsix 6\tseven 7 eight\n```\n\nWhich corresponds to the following data (see `examples/main.py` for more details):\n\n```py\n(\n (\n (\n (TastyPair('one', 1), ),\n (TastyTriple('two', 2, Quux('three')), TastyTriple('two', 2, Quux('three')))\n ),\n (\n (TastyPair('three', 3), ),\n (TastyTriple('four', 4, Quux('five')), )\n )\n ),\n (\n (\n (TastyPair('six', 6), ),\n (TastyTriple('seven', 7, Quux('eight')), )\n ),\n )\n)\n```\n\n## Installation\n\nThe module doesn't require any additional dependencies. To install from pypi, run the following command:\n\n```sh\npip install tasty\n```\n\n## Usage\n\nDefault methods for dataset serialization and deserialization are implemented, so the module can be used as follows (see the `main.py` script in the `examples` folder):\n\n```py\nfrom dataclasses import dataclass\nfrom tasty import Corpus, CellComponent, encode, pipe\n\n\n@dataclass\nclass TastyPair(CellComponent):\n foo: str\n bar: int\n\n @property\n def serialized(self):\n return self._serialize(\n self.foo | pipe | encode,\n self.bar | pipe | str\n )\n\n\n@dataclass\nclass Quux:\n value: str\n\n\n@dataclass\nclass TastyTriple(CellComponent):\n baz: str\n qux: int\n quux: Quux\n\n @property\n def serialized(self):\n return self._serialize(\n self.baz | pipe | encode,\n self.qux | pipe | str,\n self.quux.value | pipe | encode\n )\n\n\nwritten_corpus = Corpus(\n (\n (\n (\n (TastyPair('one', 1), ),\n (TastyTriple('two', 2, Quux('three')), TastyTriple('two', 2, Quux('three')))\n ),\n (\n (TastyPair('three', 3), ),\n (TastyTriple('four', 4, Quux('five')), )\n )\n ),\n (\n (\n (TastyPair('six', 6), ),\n (TastyTriple('seven', 7, Quux('eight')), )\n ),\n )\n )\n).write('corpus.txt', header = ('pair', 'triple'))\n\nread_corpus = Corpus.read('corpus.txt', parsers = (TastyPair, TastyTriple))\n\nassert read_corpus.data == written_corpus.data\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "A human-readable format for nested data serialization",
"version": "0.1.0",
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "9fa7df15808e4d79303d05d405361577d957535e2675f6b83fadcd758d28a947",
"md5": "ab813312665108c6d37b1e88e4835276",
"sha256": "fa8ebbd4c165a8c3f00cec81e7d15e4a71feb86e80aa9c243991f314191bcdb0"
},
"downloads": -1,
"filename": "tastier-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "ab813312665108c6d37b1e88e4835276",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 7327,
"upload_time": "2023-01-27T17:04:24",
"upload_time_iso_8601": "2023-01-27T17:04:24.095215Z",
"url": "https://files.pythonhosted.org/packages/9f/a7/df15808e4d79303d05d405361577d957535e2675f6b83fadcd758d28a947/tastier-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-01-27 17:04:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "zeionara",
"github_project": "tasty",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "tastier"
}