Skip to main content

Parse streamed (incomplete) single-level YAML

Project description

Streamed YAML

Parse streamed (incomplete) single-level YAML

pip install streamed-yaml

Partial Parsing

Parse a partial, single-level YAML document. Returns values, done, where done[key] indicated whether values[key] is fully parsed.

from streamed_yaml import parse

parse('key: value') # { 'key': 'value }, { 'key': False }` (values, done)

parse('''
  key: value
  key2
''') # { 'key': 'value }, { 'key': True }

parse('''
  key: value
  key2:
''') # { 'key': 'value', 'key2': '' }, { 'key': True, 'key2': False }

parse('''
  key: value
  key2: "Val...
''') # { 'key': 'value', 'key2': 'Val...' }, { 'key': True, 'key2': False }

Streaming Updates

Parse an arbitrarily chunked stream of single-level YAML. Yields updates at the end of each chunk, s.t. concatenating them yields the full document.

from streamed_yaml import chunked_parse

async def stream():
  yield 'key'      # no update
  yield ': value'  # -> Update(key='key', value='value', done=False)
  yield '\nke'     # -> Update(key='key', value='', done=True)
  yield 'y2: '     # -> Update(key='key2', value='', done=False)
  yield 'value2\n' # -> Update(key='key2', value='value2', done=True)

async for update in chunked_parse(stream()):
  print(update)

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

streamed_yaml-0.1.3.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

streamed_yaml-0.1.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file streamed_yaml-0.1.3.tar.gz.

File metadata

  • Download URL: streamed_yaml-0.1.3.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.10

File hashes

Hashes for streamed_yaml-0.1.3.tar.gz
Algorithm Hash digest
SHA256 d01ea7527b31197941bb02d75bcd1b720651fbb639445dde96b2ace1c21e886b
MD5 814bab92c6f5044f2ced56bd3e56ddb9
BLAKE2b-256 4f3a558393877c655b91760702716ff12a510bed98ccc0d80a2b30c7163fa577

See more details on using hashes here.

File details

Details for the file streamed_yaml-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for streamed_yaml-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 45a0f7aad1067261e9184f098868953195216326e865d0abdcd2754f4385b7b6
MD5 6cababd24915d0e8e4411ac55d69934e
BLAKE2b-256 70fa5b1bc08c67286c254abf0c7ea230266dbdf62eafe99e2df94e983cc028e1

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