Skip to main content

ruamel.yaml.string

This plug-in adds a method dump_to_string (and its equivalent dumps) to the ruamel.yaml.YAML instance that returns the document as a Python string.

Installation

The module can be installed from PyPI using:

pip install ruamel.yaml.string

This module is dependent on ruamel.yaml, so you do not have to explicitly make your module depending on both.

Usage

import ruamel.yaml

yaml = ruamel.yaml.YAML(typ=['rt', 'string'])
data  = dict(abc=42, help=['on', 'its', 'way'])
print('retval', yaml.dump_to_string(data))
print('>>>> done')

which gives:

retval abc: 42
help:
- on
- its
- way
>>>> done

Please note that there is no final newline added to the bytes array returned, and that the >>>> done is on the next line is caused by the print() function adding a newline by default. (This is different from using PyYAML’s dump, as e.g. the output of various print dump(data) examples in the documentation (2021) fail to clearly show the double newline at the end of the examples output. It is similar to json.dumps(data, indent=2) that returns a string without final newline.)

Alternatively the first call to print could be:

print('retval', yaml.dump_to_bytes(data, add_final_eol=True).decode('utf-8'), end='')

with the same effect.

.dump_to_bytes() can be shortened to .dumpb()

Directly writing to ``sys.stdout`` using ``yaml.dump(data, sys.stdout)`` is much more efficient than ``print``-ing the result of ``yaml.dumps(data)``

ChangeLog

NEXT:
  • initial plug-in version

Metadata

Release files for ruamel.yaml.string 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ruamel.yaml.string 0.1.0
File Size Uploaded Provenance Actions
ruamel.yaml.string-0.1.0.tar.gz 13.2 kB Without provenance Details for ruamel.yaml.string-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ruamel.yaml.string 0.1.0
File Interpreter ABI Platform Actions
ruamel.yaml.string-0.1.0-py2.py3-none-any.whl Python 2, Python 3 none any Details for ruamel.yaml.string-0.1.0-py2.py3-none-any.whl

Total release size: 17.5 kB

Release files / ruamel.yaml.string-0.1.0.tar.gz

Download URL ruamel.yaml.string-0.1.0.tar.gz
Size 13.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1dbdd04647d7e5efd9b35ca27df8cb397ea440dd5070760d854c88cd3e5a1b49
BLAKE2b-256 checksum
How to use checksums
43cf13c1980e4a3be3cbe0bb6809f8d4d35978f403ba3b414a50bbad712a1e62
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

Release files / ruamel.yaml.string-0.1.0-py2.py3-none-any.whl

Download URL ruamel.yaml.string-0.1.0-py2.py3-none-any.whl
Size 4.3 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
800761f9c0e28145fc59afd48e6075e117b5b7e69e6d9b3bd2bf53b31be954cf
BLAKE2b-256 checksum
How to use checksums
74a6891a95c42bbb5d47802b490374ccb034b793982cf0fba68d3dcdc7ee69fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.3.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.9.4

Security for ruamel.yaml.string 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page