serialise


Nameserialise JSON
Version 0.0.0 PyPI version JSON
download
home_pageNone
SummaryA project to allow serialising and deserialising python objects
upload_time2024-06-28 20:34:36
maintainerNone
docs_urlNone
authorRJ_Infinity
requires_python>=3.12
licenseMIT License Copyright (c) 2024 RJ_Infinity Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords serialiser serialisation deserialiser deserialisation binary format saving
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # serialise

this is a simple library to serialise and deserialise python
objects. it can serialise any object given it has a serialiser
written for it. Many python builtins already have serialisers

to create a serialiser you use the Serialiser class

here is an example (the default list serialiser but more friendly)
```py
from serialiser import Serialiser, read_size, write_size, serialise, deserialise
from io import BytesIO
def list_serialiser(data: list)->bytes:
	# create a bytearray this is a more convient way of creating bytes
	rv = bytearray()
	# add the length of the list
	# write size writes an int
	rv.extend(write_size(len(data)))
	# for each element in the list add the serialised element
	for el in data: rv.extend(serialise(el))
	return bytes(rv)
def list_deserialiser(data: bytes)->list:
	# the serialiser in reverse
	# create a BytesIO which is a more convient way of reading bytes
	data = BytesIO(data)
	# first read the length
	length = read_size(data, "list length")
	# then deserialise length elements from the data and reutrn them in an array
	return [deserialise(data) for _ in range(length)]
# register the Serialiser by createing a new instance of the Serialiser class
Serialiser(
	list,
	list_serialiser,
	list_deserialiser
)
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "serialise",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "serialiser, serialisation, deserialiser, deserialisation, binary, format, saving",
    "author": "RJ_Infinity",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/6f/ad/b59b3f7fb711274c4c4195fd9070ab0923231b2fdaea1ae0870d1566e11e/serialise-0.0.0.tar.gz",
    "platform": null,
    "description": "# serialise\r\n\r\nthis is a simple library to serialise and deserialise python\r\nobjects. it can serialise any object given it has a serialiser\r\nwritten for it. Many python builtins already have serialisers\r\n\r\nto create a serialiser you use the Serialiser class\r\n\r\nhere is an example (the default list serialiser but more friendly)\r\n```py\r\nfrom serialiser import Serialiser, read_size, write_size, serialise, deserialise\r\nfrom io import BytesIO\r\ndef list_serialiser(data: list)->bytes:\r\n\t# create a bytearray this is a more convient way of creating bytes\r\n\trv = bytearray()\r\n\t# add the length of the list\r\n\t# write size writes an int\r\n\trv.extend(write_size(len(data)))\r\n\t# for each element in the list add the serialised element\r\n\tfor el in data: rv.extend(serialise(el))\r\n\treturn bytes(rv)\r\ndef list_deserialiser(data: bytes)->list:\r\n\t# the serialiser in reverse\r\n\t# create a BytesIO which is a more convient way of reading bytes\r\n\tdata = BytesIO(data)\r\n\t# first read the length\r\n\tlength = read_size(data, \"list length\")\r\n\t# then deserialise length elements from the data and reutrn them in an array\r\n\treturn [deserialise(data) for _ in range(length)]\r\n# register the Serialiser by createing a new instance of the Serialiser class\r\nSerialiser(\r\n\tlist,\r\n\tlist_serialiser,\r\n\tlist_deserialiser\r\n)\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2024 RJ_Infinity  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "A project to allow serialising and deserialising python objects",
    "version": "0.0.0",
    "project_urls": {
        "Documentation": "https://github.com/RJ-Infinity/serialise",
        "Homepage": "https://github.com/RJ-Infinity/serialise",
        "Issues": "https://github.com/RJ-Infinity/serialise/issues",
        "Repository": "https://github.com/RJ-Infinity/serialise"
    },
    "split_keywords": [
        "serialiser",
        " serialisation",
        " deserialiser",
        " deserialisation",
        " binary",
        " format",
        " saving"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e4341c52245d3b54956e196e857c9930577bb6f567b3a5e1835e41a26ca66781",
                "md5": "6e9af48bcb8442fe95d6fd91186c9740",
                "sha256": "45c06bb3d0b875af88b3a93dac70a8a066127318efd740ac926c28e14cd7fbe6"
            },
            "downloads": -1,
            "filename": "serialise-0.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6e9af48bcb8442fe95d6fd91186c9740",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 9246,
            "upload_time": "2024-06-28T20:34:30",
            "upload_time_iso_8601": "2024-06-28T20:34:30.936325Z",
            "url": "https://files.pythonhosted.org/packages/e4/34/1c52245d3b54956e196e857c9930577bb6f567b3a5e1835e41a26ca66781/serialise-0.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6fadb59b3f7fb711274c4c4195fd9070ab0923231b2fdaea1ae0870d1566e11e",
                "md5": "8222507b8f35de94c71c3cab3c8fbefd",
                "sha256": "5bf89866ccff50cf42cda08d21959d8ac4f8aaf8c24c113060a53588fb0ebbdd"
            },
            "downloads": -1,
            "filename": "serialise-0.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "8222507b8f35de94c71c3cab3c8fbefd",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 8895,
            "upload_time": "2024-06-28T20:34:36",
            "upload_time_iso_8601": "2024-06-28T20:34:36.146327Z",
            "url": "https://files.pythonhosted.org/packages/6f/ad/b59b3f7fb711274c4c4195fd9070ab0923231b2fdaea1ae0870d1566e11e/serialise-0.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-06-28 20:34:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "RJ-Infinity",
    "github_project": "serialise",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "serialise"
}
        
Elapsed time: 0.25433s