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.2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

streamed_yaml-0.1.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: streamed_yaml-0.1.2.tar.gz
  • Upload date:
  • Size: 3.0 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.2.tar.gz
Algorithm Hash digest
SHA256 783472131acfc735c43e5f63ae364ef8a7dfb67759274914ac25a7bb4c1674bb
MD5 641dcdddd68be9b9ac043b5e49bc8143
BLAKE2b-256 872835ae630029623189a5c9bc996eeee24426db98c45e825a1e058b2597ee0e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for streamed_yaml-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7cd03a5b667e7c29596fedf449ab7b75052c3b6a9818e1a034c27cc71ea28e81
MD5 a1b9107cfdd8b6165fef8130e8afe45f
BLAKE2b-256 1d186714a11933cebc392333390d16d266d96cd99db573e3174a23388d5e2f3d

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