ruamel.yaml.bytes
This plug-in adds a method dump_to_bytes to the ruamel.yaml.YAML instance that returns a (UTF-8) bytes array
Installation
The module can be installed from PyPI using:
pip install ruamel.yaml.bytes
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', 'bytes'])
data = dict(abc=42, help=['on', 'its', 'way'])
print('retval', yaml.dump_to_bytes(data).decode('utf-8'))
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. 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()
ChangeLog
- NEXT:
initial plug-in version
Release files for ruamel.yaml.bytes 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ruamel.yaml.bytes-0.1.0.tar.gz | 13.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ruamel.yaml.bytes-0.1.0-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 17.0 kB
Release files / ruamel.yaml.bytes-0.1.0.tar.gz
| Download URL | ruamel.yaml.bytes-0.1.0.tar.gz |
|---|---|
| Size | 13.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c9392ffcf36aeffb0e2f29a80e7aca7807d4bb3d6de55afabd8192f9ae974e9d
|
|
BLAKE2b-256 checksum How to use checksums |
08b618c75e90313f622fea529244843e1bd677d3650d6f7a2524905a8e67e625
|
| 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.bytes-0.1.0-py2.py3-none-any.whl
| Download URL | ruamel.yaml.bytes-0.1.0-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
894d13babf3c6e53c61ee1927a1ec7e36e16f3b381c3599858a565361e942ca9
|
|
BLAKE2b-256 checksum How to use checksums |
aa921e3d33099c0fd064361d310d72d84784d068d7429b184aa94e4fd0a32099
|
| 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
|