some useful shortcuts for pyyaml
Project description
gmanka yml
some useful shortcuts for pyyaml
installation
pip install gmanka_yml
functions
to_str^
converts any data to yml string and returns it
import gmanka_yml as yml
my_dict = {
'element_1': 1,
2: 'element_2',
3: [
'list_element_1',
'list_element_2',
]
}
print(yml.to_str(my_dict))
output:
element_1: 1
2: element_2
3:
- list_element_1
- list_element_2
to_file^
same as to_str, but writes data to file instead of returning
yml.to_file(
data = my_dict,
path = 'file.yml',
)
read_str^
import gmanka_yml as yml
my_str = '''
element_1: 1
2: element_2
3:
- list_element_1
- list_element_2
'''
my_dict = yml.read_str(my_str)
print(my_dict)
print(type(my_dict))
output:
{'element_1': 1, 2: 'element_2', 3: ['list_element_1', 'list_element_2']}
<class 'dict'>
read_file^
same as read_str, but reads data from file
yml.read_file('file.yml')
default values
yml.read_str(1) # raises TypeError
yml.read_str(1, default = None) # returns None
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
gmanka_yml-23.0.1.tar.gz
(1.8 kB
view hashes)
Built Distribution
Close
Hashes for gmanka_yml-23.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 607c7a1cd6bb9ad308b64accd488702815585fbf98da790c78ce3b3149666683 |
|
MD5 | 9d55d77fbe884b34b175fcff7b684d36 |
|
BLAKE2b-256 | df8b40b1cd249b5ff7add4990a4e3209258293edfb5b7c038a3ad2c569ace45a |