Name | pydatastreams JSON |
Version |
1.3.3
JSON |
| download |
home_page | None |
Summary | A simple and easy to use library for reading and writing data streams. |
upload_time | 2024-07-03 00:45:56 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.11 |
license | None |
keywords |
binary
data
file
io
stream
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# datastream
![PyPI - Version](https://img.shields.io/pypi/v/pydatastreams?style=for-the-badge)
![PyPI - License](https://img.shields.io/pypi/l/pydatastreams?style=for-the-badge)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydatastreams?style=for-the-badge)
[![Lint and test](https://github.com/yntha/datastream/actions/workflows/python-app.yml/badge.svg)](https://github.com/yntha/datastream/actions/workflows/python-app.yml)
Because `construct` was too complicated.
This is a simple and easy to use library that provides two classes. One class serializes data, and the other one deserializes. These classes behave like streams in which they have `read`, `write`, `close` among other stream related functions. The goal of this library is to be as simple as possible while providing flexibility.
To install the library, use the following:
```console
python -m pip install --user -U pydatastreams
```
To import the library, use the following:
```python
from datastream import SerializingStream, DeserializingStream, TwoWayStream, ByteOrder
```
Retrieving serialized data from a SerializingStream:
```python
with SerializingStream() as stream:
stream.write_int32(42)
serialized = stream.bytes()
# this also works
serialized = bytes(stream)
```
Note: This library also contains a stream for both serializing and deserializing data. This stream is called [`TwoWayStream`](datastream/twoway.py#L9).
The stream classes support serializing/deserializing the standard data types:
| Data Type | Description | [Serializer](datastream/serializing.py#L8) | [Deserializer](datastream/deserializing.py#L8)
| --- | --- | ---| --- |
| `int8_t` | Signed 8-bit number | [`write_int8(value: int)`](datastream/serializing.py#L52) | [`read_int8() -> int`](datastream/deserializing.py#L65) |
| `uint8_t` | Unsigned 8-bit number | [`write_uint8(value: int)`](datastream/serializing.py#L55) | [`read_uint8() -> int`](datastream/deserializing.py#L68) |
| `int16_t` | Signed 16-bit number | [`write_int16(value: int)`](datastream/serializing.py#L46) | [`read_int16() -> int`](datastream/deserializing.py#L59) |
| `uint16_t` | Unsigned 16-bit number | [`write_uint16(value: int)`](datastream/serializing.py#L49) | [`read_uint16() -> int`](datastream/deserializing.py#L62) |
| `int32_t` | Signed 32-bit number | [`write_int32(value: int)`](datastream/serializing.py#L40) | [`read_int32() -> int`](datastream/deserializing.py#L53) |
| `uint32_t` | Unsigned 32-bit number | [`write_uint32(value: int)`](datastream/serializing.py#L43) | [`read_uint32() -> int`](datastream/deserializing.py#L56) |
| `int64_t` | Signed 64-bit number | [`write_int64(value: int)`](datastream/serializing.py#L34) | [`read_int64() -> int`](datastream/deserializing.py#L47) |
| `uint64_t` | Unsigned 64-bit number | [`write_uint64(value: int)`](datastream/serializing.py#L37) | [`read_uint64() -> int`](datastream/deserializing.py#L50) |
| `float` | 32-bit floating point number | [`write_float(value: float)`](datastream/serializing.py#L58) | [`read_float() -> float`](datastream/deserializing.py#L71) |
| `double` | 64-bit floating point number | [`write_double(value: float)`](datastream/serializing.py#L61) | [`read_double() -> float`](datastream/deserializing.py#L74) |
Additionally, the stream classes also provide the following non-standard data types:
| Data Type | Description | [Serializer](datastream/serializing.py#L8) | [Deserializer](datastream/deserializing.py#L8)
| --- | --- | ---| --- |
| `bool` | True/False value encoded as a single byte | [`write_bool(value: bool)`](datastream/serializing.py#L64) | [`read_bool() -> bool`](datastream/deserializing.py#L77) |
| `uleb128` | Variable sized unsigned 128-bit number | [`write_uleb128(value: int)`](datastream/serializing.py#L67) | [`read_uleb128() -> int`](datastream/deserializing.py#L80) |
| | | [`write_uleb128_safe(value: int, max_bytes: int = 16)`](datastream/serializing.py#L78) | [`read_uleb128_safe(max_bytes: int = 16) -> int`](datastream/deserializing.py#L92) |
| `sleb128` | Variable sized signed 128-bit number | [`write_sleb128(value: int)`](datastream/serializing.py#L99) | [`read_sleb128() -> int`](datastream/deserializing.py#L122) |
| | | [`write_sleb128_safe(value: int, max_bytes: int = 16)`](datastream/serializing.py#L110) | [`read_sleb128_safe(max_bytes: int = 16) -> int`](datastream/deserializing.py#L134) |
Finally, the stream classes also provide the following utility functions:
| Function | Description |
| --- | --- |
| [`set(buffer: bytes \| typing.IO[bytes])`](datastream/deserializing.py#L25) | Sets the backing stream to the given buffer. DeserializingStream only. |
| [`read_until(terminator: bytes) -> bytes`](datastream/deserializing.py#L37) | Reads `len(terminator)` bytes from the stream until `terminator` is found. DeserializingStream only. |
| [`read(size: int) -> bytes`](datastream/base.py#L64) | Reads up to `size` bytes from the backing stream. |
| [`write(data: bytes)`](datastream/base.py#L120) | Writes the given data to the backing stream. |
| [`size() -> int`](datastream/base.py#L76) | Returns the size of the backing stream. |
| [`seek(offset: int, whence: int = io.SEEK_SET)`](datastream/base.py#L94) | Change the stream position to the given offset. |
| [`tell() -> int`](datastream/base.py#L105) | Returns the current position of the stream. |
| [`close()`](datastream/base.py#L114) | Closes the backing stream. |
| [`remaining() -> int`](datastream/base.py#L85) | Returns the number of bytes remaining in the backing stream. |
| [`clone() -> typing.Self`](datastream/base.py#L129) | Returns a new instance of the same class with the same byte order and contents. |
| [`substream(start: int, end: int) -> typing.Self`](datastream/base.py#L140) | Returns a new instance of the same class, representing a substream of the current stream. |
| [`peek(size: int) -> bytes`](datastream/base.py#L157) | Returns the next `size` bytes from the stream without advancing the position. |
| [`seekpeek(offset: int, size: int) -> bytes`](datastream/base.py#L175) | Seeks to the specified offset in the data stream, reads the specified number of bytes, and then restores the original position. |
| [`search(data: bytes) -> int`](datastream/base.py#L196) | Searches for the given data in the backing stream. |
| [`rsearch(data: bytes) -> int`](datastream/base.py#L223) | Searches for the given data in the reverse order within the backing stream. |
| [`clear()`](datastream/base.py#L252) | Clears the backing stream by truncating it to 0 bytes and resetting the stream position to the beginning. |
Raw data
{
"_id": null,
"home_page": null,
"name": "pydatastreams",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": "binary, data, file, io, stream",
"author": null,
"author_email": "yntha <bguznvjk@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/71/54/84e9d512ecf3190205a4a19c308a0a2a2bf03985c35f9f0cf9a465573c4f/pydatastreams-1.3.3.tar.gz",
"platform": null,
"description": "# datastream\n![PyPI - Version](https://img.shields.io/pypi/v/pydatastreams?style=for-the-badge)\n![PyPI - License](https://img.shields.io/pypi/l/pydatastreams?style=for-the-badge)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pydatastreams?style=for-the-badge)\n[![Lint and test](https://github.com/yntha/datastream/actions/workflows/python-app.yml/badge.svg)](https://github.com/yntha/datastream/actions/workflows/python-app.yml)\n\n\nBecause `construct` was too complicated.\n\nThis is a simple and easy to use library that provides two classes. One class serializes data, and the other one deserializes. These classes behave like streams in which they have `read`, `write`, `close` among other stream related functions. The goal of this library is to be as simple as possible while providing flexibility.\n\nTo install the library, use the following:\n```console\npython -m pip install --user -U pydatastreams\n```\n\nTo import the library, use the following:\n```python\nfrom datastream import SerializingStream, DeserializingStream, TwoWayStream, ByteOrder\n```\n\nRetrieving serialized data from a SerializingStream:\n```python\nwith SerializingStream() as stream:\n stream.write_int32(42)\n\n serialized = stream.bytes()\n\n # this also works\n serialized = bytes(stream)\n```\n\nNote: This library also contains a stream for both serializing and deserializing data. This stream is called [`TwoWayStream`](datastream/twoway.py#L9).\n\nThe stream classes support serializing/deserializing the standard data types:\n| Data Type | Description | [Serializer](datastream/serializing.py#L8) | [Deserializer](datastream/deserializing.py#L8)\n| --- | --- | ---| --- |\n| `int8_t` | Signed 8-bit number | [`write_int8(value: int)`](datastream/serializing.py#L52) | [`read_int8() -> int`](datastream/deserializing.py#L65) |\n| `uint8_t` | Unsigned 8-bit number | [`write_uint8(value: int)`](datastream/serializing.py#L55) | [`read_uint8() -> int`](datastream/deserializing.py#L68) |\n| `int16_t` | Signed 16-bit number | [`write_int16(value: int)`](datastream/serializing.py#L46) | [`read_int16() -> int`](datastream/deserializing.py#L59) |\n| `uint16_t` | Unsigned 16-bit number | [`write_uint16(value: int)`](datastream/serializing.py#L49) | [`read_uint16() -> int`](datastream/deserializing.py#L62) |\n| `int32_t` | Signed 32-bit number | [`write_int32(value: int)`](datastream/serializing.py#L40) | [`read_int32() -> int`](datastream/deserializing.py#L53) |\n| `uint32_t` | Unsigned 32-bit number | [`write_uint32(value: int)`](datastream/serializing.py#L43) | [`read_uint32() -> int`](datastream/deserializing.py#L56) |\n| `int64_t` | Signed 64-bit number | [`write_int64(value: int)`](datastream/serializing.py#L34) | [`read_int64() -> int`](datastream/deserializing.py#L47) |\n| `uint64_t` | Unsigned 64-bit number | [`write_uint64(value: int)`](datastream/serializing.py#L37) | [`read_uint64() -> int`](datastream/deserializing.py#L50) |\n| `float` | 32-bit floating point number | [`write_float(value: float)`](datastream/serializing.py#L58) | [`read_float() -> float`](datastream/deserializing.py#L71) |\n| `double` | 64-bit floating point number | [`write_double(value: float)`](datastream/serializing.py#L61) | [`read_double() -> float`](datastream/deserializing.py#L74) |\n\nAdditionally, the stream classes also provide the following non-standard data types:\n| Data Type | Description | [Serializer](datastream/serializing.py#L8) | [Deserializer](datastream/deserializing.py#L8)\n| --- | --- | ---| --- |\n| `bool` | True/False value encoded as a single byte | [`write_bool(value: bool)`](datastream/serializing.py#L64) | [`read_bool() -> bool`](datastream/deserializing.py#L77) |\n| `uleb128` | Variable sized unsigned 128-bit number | [`write_uleb128(value: int)`](datastream/serializing.py#L67) | [`read_uleb128() -> int`](datastream/deserializing.py#L80) |\n| | | [`write_uleb128_safe(value: int, max_bytes: int = 16)`](datastream/serializing.py#L78) | [`read_uleb128_safe(max_bytes: int = 16) -> int`](datastream/deserializing.py#L92) |\n| `sleb128` | Variable sized signed 128-bit number | [`write_sleb128(value: int)`](datastream/serializing.py#L99) | [`read_sleb128() -> int`](datastream/deserializing.py#L122) |\n| | | [`write_sleb128_safe(value: int, max_bytes: int = 16)`](datastream/serializing.py#L110) | [`read_sleb128_safe(max_bytes: int = 16) -> int`](datastream/deserializing.py#L134) |\n\nFinally, the stream classes also provide the following utility functions:\n| Function | Description |\n| --- | --- |\n| [`set(buffer: bytes \\| typing.IO[bytes])`](datastream/deserializing.py#L25) | Sets the backing stream to the given buffer. DeserializingStream only. |\n| [`read_until(terminator: bytes) -> bytes`](datastream/deserializing.py#L37) | Reads `len(terminator)` bytes from the stream until `terminator` is found. DeserializingStream only. |\n| [`read(size: int) -> bytes`](datastream/base.py#L64) | Reads up to `size` bytes from the backing stream. |\n| [`write(data: bytes)`](datastream/base.py#L120) | Writes the given data to the backing stream. |\n| [`size() -> int`](datastream/base.py#L76) | Returns the size of the backing stream. |\n| [`seek(offset: int, whence: int = io.SEEK_SET)`](datastream/base.py#L94) | Change the stream position to the given offset. |\n| [`tell() -> int`](datastream/base.py#L105) | Returns the current position of the stream. |\n| [`close()`](datastream/base.py#L114) | Closes the backing stream. |\n| [`remaining() -> int`](datastream/base.py#L85) | Returns the number of bytes remaining in the backing stream. |\n| [`clone() -> typing.Self`](datastream/base.py#L129) | Returns a new instance of the same class with the same byte order and contents. |\n| [`substream(start: int, end: int) -> typing.Self`](datastream/base.py#L140) | Returns a new instance of the same class, representing a substream of the current stream. |\n| [`peek(size: int) -> bytes`](datastream/base.py#L157) | Returns the next `size` bytes from the stream without advancing the position. |\n| [`seekpeek(offset: int, size: int) -> bytes`](datastream/base.py#L175) | Seeks to the specified offset in the data stream, reads the specified number of bytes, and then restores the original position. |\n| [`search(data: bytes) -> int`](datastream/base.py#L196) | Searches for the given data in the backing stream. |\n| [`rsearch(data: bytes) -> int`](datastream/base.py#L223) | Searches for the given data in the reverse order within the backing stream. |\n| [`clear()`](datastream/base.py#L252) | Clears the backing stream by truncating it to 0 bytes and resetting the stream position to the beginning. |",
"bugtrack_url": null,
"license": null,
"summary": "A simple and easy to use library for reading and writing data streams.",
"version": "1.3.3",
"project_urls": {
"Homepage": "https://github.com/yntha/datastream",
"Issues": "https://github.com/yntha/datastream/issues",
"Repository": "https://github.com/yntha/datastream.git"
},
"split_keywords": [
"binary",
" data",
" file",
" io",
" stream"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "1c2fa70784ca850634c36e8f0664ba5714628bcb75875e5503a1f2651294cba9",
"md5": "85b0d9e9815c99b1ed60123a6456431c",
"sha256": "da64bc63926c54d073e721c36fca0a681e9f9db3bea93091007b58a6554d7e07"
},
"downloads": -1,
"filename": "pydatastreams-1.3.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "85b0d9e9815c99b1ed60123a6456431c",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.11",
"size": 21045,
"upload_time": "2024-07-03T00:45:55",
"upload_time_iso_8601": "2024-07-03T00:45:55.762731Z",
"url": "https://files.pythonhosted.org/packages/1c/2f/a70784ca850634c36e8f0664ba5714628bcb75875e5503a1f2651294cba9/pydatastreams-1.3.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "715484e9d512ecf3190205a4a19c308a0a2a2bf03985c35f9f0cf9a465573c4f",
"md5": "ea3d18c10abbe8e236a6b8ad8f8eb73a",
"sha256": "cc27809ef6b6cc7e5c65c316b88e42459f07fdcd220dced61543f7d5029ed8bc"
},
"downloads": -1,
"filename": "pydatastreams-1.3.3.tar.gz",
"has_sig": false,
"md5_digest": "ea3d18c10abbe8e236a6b8ad8f8eb73a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 20497,
"upload_time": "2024-07-03T00:45:56",
"upload_time_iso_8601": "2024-07-03T00:45:56.864915Z",
"url": "https://files.pythonhosted.org/packages/71/54/84e9d512ecf3190205a4a19c308a0a2a2bf03985c35f9f0cf9a465573c4f/pydatastreams-1.3.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-03 00:45:56",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yntha",
"github_project": "datastream",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pydatastreams"
}