Skip to main content

Pythonic implementation of the 'postcard' wire format

Project description

Pohlednice

Pohlednice is a pythonic implementation of the postcard wire format.

Usage

Variable integer:

from pohlednice import I16, I32

I16.to_bytes(400) // a byte iterator
bytes(I16.to_bytes(400)) // transform into bytes

// or chain multiple
chain(I16.to_bytes(3600), I32.to_bytes(55))

// read from a byte iterable
number I16.from_bytes([1])

De/Serialize Structure:

from pohlednice import Struct, U16, String, Option, ByteArray

class ABC(Struct):
    a: U16
    b: String
    c: Option[ByteArray]


payload = bytes(ABC.to_bytes(ABC(40, 'Trollě', None)))

abc = ABC.from_bytes(payload)

De/Serialize Enum:

class Color(Enum):
    Red: None
    Blue: None
    Green: None
    Custom: Tuple[U8, U8, U8]

payload = Color.to_bytes(Color.Custom((0xff, 0xf0, 0x0f)))
color = Color.from_bytes(payload)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pohlednice-0.2.1.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pohlednice-0.2.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file pohlednice-0.2.1.tar.gz.

File metadata

  • Download URL: pohlednice-0.2.1.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.10.8-arch1-1

File hashes

Hashes for pohlednice-0.2.1.tar.gz
Algorithm Hash digest
SHA256 f4e481352c75d4c6b08677ea58be50676f26ae71786285820dd0060d4c9d1a00
MD5 55f6a9e150ba2370ac5ee7768da9e3c2
BLAKE2b-256 b89608b394ff97c0d8ed588bdaa158bc1e5aaae23d5e642a76360638ce403840

See more details on using hashes here.

File details

Details for the file pohlednice-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: pohlednice-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Linux/6.10.8-arch1-1

File hashes

Hashes for pohlednice-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 456d1e2cbfc9399b44d9939f7486dcd16a5fc6f08f73b9828d39f9a9e16cad5d
MD5 d0c51af7e5b262fbf0a3662caaf5e43c
BLAKE2b-256 92c6767bc3b4b2cebcc6769df2130cf0f0872f3f2f0b38454051ddcf9af6b94c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page