Skip to main content

Utility to write network protocol parser without any I/O

Project description

Utility library to write network protocol parser, sans I/O.

Ohne I/O (without I/O in German) is a library using asyncio corouting programming style.

ohneio allows you to write protocol parsers the way you would write an asyncio protocol:

>>> import base64
>>> import ohneio
>>>
>>> def wait_for(s):
...     while True:
...         data = yield from ohneio.peek()
...         pos = data.find(s)
...         if pos >= 0:
...             return pos
...         yield from ohneio.wait()
...
>>> def read_until(s):
...     pos = yield from wait_for(s)
...     data = yield from ohneio.read(pos)
...     return data
...
>>> @ohneio.protocol
... def echo_base64(separator):
...     while True:
...         segment = yield from read_until(separator)
...         yield from ohneio.read(len(separator))
...         yield from ohneio.write(base64.b64encode(segment) + separator)
...
>>> connection = echo_base64(b'\r\n')
>>> connection.send(b'hello')
>>> connection.read()
b''
>>> connection.send(b'\r\nworld\r\n')
>>> connection.read()
b'aGVsbG8=\r\nd29ybGQ=\r\n'

The example above also shows how ohneio allows you to combine primitives into bigger parsing functions (like wait_for and read_until).

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

ohneio-0.8.1.tar.gz (3.5 kB view details)

Uploaded Source

File details

Details for the file ohneio-0.8.1.tar.gz.

File metadata

  • Download URL: ohneio-0.8.1.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ohneio-0.8.1.tar.gz
Algorithm Hash digest
SHA256 4d09754ddc90a7785e1c3457b7b8a5654badd7e1611dc0f42ee5a70ca5b4fdc7
MD5 1129414f3990e7477090fcc88517cc1a
BLAKE2b-256 784fbf2d82f575ac8122e86d55c2a78afa23e442f56d15e78b3edb6134732390

See more details on using hashes here.

Supported by

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