databrief


Namedatabrief JSON
Version 0.0.0 PyPI version JSON
download
home_pagehttps://github.com/blueskysolarracing/databrief
SummaryA python library for serializing dataclasses to bytes and back.
upload_time2024-12-01 20:06:14
maintainerNone
docs_urlNone
authorBlue Sky Solar Racing
requires_python>=3.13
licenseMIT
keywords dataclass serialization
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Databrief

`databrief` is a Python library for serializing dataclasses to bytes and deserializing bytes back to dataclasses.

## Features

- Compact serialization
- Supports `int`, `float`, and `bool` field types

## Installation

```sh
pip install databrief
````

## Usage

### Dumping a Dataclass to Bytes

To serialize a dataclass instance to bytes, use the `dump` function:

```python
from databrief.databrief import dump
from dataclasses import dataclass

@dataclass
class TestData:
    a: int
    b: float
    c: bool

data = TestData(a=42, b=3.14, c=True)
serialized = dump(data)
print(serialized)
```

### Loading Bytes to a Dataclass

To deserialize bytes back to a dataclass instance, use the `load` function:

```python
from databrief.databrief import load

deserialized = load(serialized, TestData)
print(deserialized)
```

## Example

Here is a complete example:

```python
from dataclasses import dataclass
from databrief.databrief import dump, load

@dataclass
class Example:
    a: int
    b: float
    c: bool
    d: bool
    e: bool
    f: bool
    g: bool
    h: bool
    i: bool
    j: bool
    k: bool
    l: float
    m: int
    n: int
    o: bool

example = Example(1, 2.0, True, False, True, False, True, False, True, True, False, 87543653.35197087, 1351346, -46583278, True)
serialized = dump(example)
deserialized = load(serialized, Example)
print(deserialized)
```

## Contributing

Contributions are welcome! Please read our Contributing Guide for more information.

## License

Databrief is distributed under the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/blueskysolarracing/databrief",
    "name": "databrief",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.13",
    "maintainer_email": null,
    "keywords": "dataclass, serialization",
    "author": "Blue Sky Solar Racing",
    "author_email": "blueskysolar@studentorg.utoronto.ca",
    "download_url": "https://files.pythonhosted.org/packages/1a/3d/1151b3c79c65919b55eb16a6bbc9b8a876bac6a441d554b9b511556ac412/databrief-0.0.0.tar.gz",
    "platform": null,
    "description": "# Databrief\n\n`databrief` is a Python library for serializing dataclasses to bytes and deserializing bytes back to dataclasses.\n\n## Features\n\n- Compact serialization\n- Supports `int`, `float`, and `bool` field types\n\n## Installation\n\n```sh\npip install databrief\n````\n\n## Usage\n\n### Dumping a Dataclass to Bytes\n\nTo serialize a dataclass instance to bytes, use the `dump` function:\n\n```python\nfrom databrief.databrief import dump\nfrom dataclasses import dataclass\n\n@dataclass\nclass TestData:\n    a: int\n    b: float\n    c: bool\n\ndata = TestData(a=42, b=3.14, c=True)\nserialized = dump(data)\nprint(serialized)\n```\n\n### Loading Bytes to a Dataclass\n\nTo deserialize bytes back to a dataclass instance, use the `load` function:\n\n```python\nfrom databrief.databrief import load\n\ndeserialized = load(serialized, TestData)\nprint(deserialized)\n```\n\n## Example\n\nHere is a complete example:\n\n```python\nfrom dataclasses import dataclass\nfrom databrief.databrief import dump, load\n\n@dataclass\nclass Example:\n    a: int\n    b: float\n    c: bool\n    d: bool\n    e: bool\n    f: bool\n    g: bool\n    h: bool\n    i: bool\n    j: bool\n    k: bool\n    l: float\n    m: int\n    n: int\n    o: bool\n\nexample = Example(1, 2.0, True, False, True, False, True, False, True, True, False, 87543653.35197087, 1351346, -46583278, True)\nserialized = dump(example)\ndeserialized = load(serialized, Example)\nprint(deserialized)\n```\n\n## Contributing\n\nContributions are welcome! Please read our Contributing Guide for more information.\n\n## License\n\nDatabrief is distributed under the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A python library for serializing dataclasses to bytes and back.",
    "version": "0.0.0",
    "project_urls": {
        "Homepage": "https://github.com/blueskysolarracing/databrief",
        "Source": "https://github.com/blueskysolarracing/databrief",
        "Tracker": "https://github.com/blueskysolarracing/databrief/issues"
    },
    "split_keywords": [
        "dataclass",
        " serialization"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97fba34b13d75b2cf63cd487d0c610aa94f57bb7be05235e11999f00d93993c7",
                "md5": "537ed6d88be5e9a3680e273ee63317d6",
                "sha256": "94a208df58e54844596d989ed33e088e9859c59addc0fdc138d2afcd6265ebbe"
            },
            "downloads": -1,
            "filename": "databrief-0.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "537ed6d88be5e9a3680e273ee63317d6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.13",
            "size": 4589,
            "upload_time": "2024-12-01T20:06:13",
            "upload_time_iso_8601": "2024-12-01T20:06:13.135540Z",
            "url": "https://files.pythonhosted.org/packages/97/fb/a34b13d75b2cf63cd487d0c610aa94f57bb7be05235e11999f00d93993c7/databrief-0.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1a3d1151b3c79c65919b55eb16a6bbc9b8a876bac6a441d554b9b511556ac412",
                "md5": "ae1c7c0ac9c1a8fe784128cc9488f2ff",
                "sha256": "39dc6b30bfb9cb239469160f6abf918326f0116c35825f3217a98a22ed8658a9"
            },
            "downloads": -1,
            "filename": "databrief-0.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ae1c7c0ac9c1a8fe784128cc9488f2ff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.13",
            "size": 4265,
            "upload_time": "2024-12-01T20:06:14",
            "upload_time_iso_8601": "2024-12-01T20:06:14.872739Z",
            "url": "https://files.pythonhosted.org/packages/1a/3d/1151b3c79c65919b55eb16a6bbc9b8a876bac6a441d554b9b511556ac412/databrief-0.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-01 20:06:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "blueskysolarracing",
    "github_project": "databrief",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "databrief"
}
        
Elapsed time: 0.37431s