.. image:: https://github.com/Phynix/yamlloader/actions/workflows/ci.yml/badge.svg
:target: https://github.com/Phynix/yamlloader/actions
.. image:: https://img.shields.io/pypi/pyversions/yamlloader.svg
:target: https://pypi.org/project/yamlloader/
.. image:: https://badge.fury.io/py/yamlloader.svg
:target: https://badge.fury.io/py/yamlloader
.. image:: https://coveralls.io/repos/github/Phynix/yamlloader/badge.svg
:target: https://coveralls.io/github/Phynix/yamlloader
yamlloader
==========
This module provides loaders and dumpers for PyYAML. Currently, an OrderedDict loader/dumper is
implemented, allowing to keep items order
when loading resp. dumping a file from/to an OrderedDict (Python 3.7+: Also regular dicts are supported and are the default items to be loaded to. As of Python 3.7 preservation of insertion order is a language feature of regular dicts.)
This project was originally mirrored from
`yamlordereddict <https://github.com/fmenabe/python-yamlordereddictloader>`_
Many thanks to the original author François Ménabé!
The library contains several improvements including automated testing and
the much faster C-versions of the Loaders/Dumpers.
`API Documentation <https://yamlloader.readthedocs.io/>`_
Install
-------
There is a pip and a conda version available
.. code-block:: bash
$ pip install yamlloader
or
.. code-block:: bash
$ conda install yamlloader -c conda-forge
But does [your special case here] also work?
--------------------------------------------
Tests are run continuously using randomly generated yaml files.
Also, there are no fails to be expected.
Still, if you are concerned that *your* special case may breaks in the future, please
add your own tests as `test_ext_anyname.py` under `tests/` or let us know about your needs.
This guarantees that no code will be added that breaks *your* case.
C vs non-C version
------------------
A significant speedup can be reached by replacing the Loader* and Dumper* classes by CLoader*
and CDumper*. The package hereby relies on the implementations from PyYAML. If they have not
been compiled, *yamlloader* **automatically** falls back to the non-C versions.
Therefore using the C-version is safe: if it is not available, the pure Python version is
automatically used.
Usage examples
==============
Loader usage
------------
.. code-block:: python
import yaml
import yamlloader
with open('myfile.yml') as yaml_file:
data = yaml.load(yaml_file,
Loader=yamlloader.ordereddict.CLoader)
# CLoader is faster than Loader
**Note:** For using the safe loader (which takes standard YAML tags and does
not construct arbitrary Python objects), replace ``yamlloader.ordereddict.CLoader`` by
``yamlloader.ordereddict.CSafeLoader``.
Dumper usage
------------
.. code-block:: python
import yaml
import yamlloader
from collections import OrderedDict
data = OrderedDict([('key1', 'val1'),
('key2', OrderedDict([('key21', 'val21'),
('key22', 'val22')]))])
with open('myfile.yaml', 'w') as yaml_file:
yaml.dump(data, yaml_file,
Dumper=yamlloader.ordereddict.CDumper)
**Note:** For using the safe dumper (which produce standard YAML tags and does
not represent arbitrary Python objects), replace ``yamlloader.ordereddict.CDumper`` by
``yamlloader.ordereddict.CSafeDumper``.
FAQ
===
C version not working
---------------------------
If the C version is not working (it falls back by default to a non-C version),
check if yaml.cyaml exists. If not, the cyaml module was not compiled during the installation of
yaml (pyyaml). Make sure that cython is installed (`pip install Cython`) and the yaml.h file is
there (apt: libyaml-dev).
Raw data
{
"_id": null,
"home_page": "https://github.com/Phynix/yamlloader",
"name": "yamlloader",
"maintainer": "Jonas Eschle \"Mayou36\"",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "jonas.eschle@phynix.science",
"keywords": "YAML, loader, dumper, ordered, OrderedDict, pyyaml",
"author": "Jonas Eschle \"Mayou36\", Johannes Lade \"SebastianJL\"",
"author_email": "jonas.eschle@phynix.science, johannes.lade@phynix.science",
"download_url": "https://files.pythonhosted.org/packages/ae/87/a689fcd4f9b0fa98d7def23099d68428ef19e427982d16e83dd788a69bd8/yamlloader-1.4.1.tar.gz",
"platform": null,
"description": "\n.. image:: https://github.com/Phynix/yamlloader/actions/workflows/ci.yml/badge.svg\n :target: https://github.com/Phynix/yamlloader/actions\n.. image:: https://img.shields.io/pypi/pyversions/yamlloader.svg\n :target: https://pypi.org/project/yamlloader/\n.. image:: https://badge.fury.io/py/yamlloader.svg\n :target: https://badge.fury.io/py/yamlloader\n.. image:: https://coveralls.io/repos/github/Phynix/yamlloader/badge.svg\n :target: https://coveralls.io/github/Phynix/yamlloader\n\nyamlloader\n==========\n\n\nThis module provides loaders and dumpers for PyYAML. Currently, an OrderedDict loader/dumper is\nimplemented, allowing to keep items order\nwhen loading resp. dumping a file from/to an OrderedDict (Python 3.7+: Also regular dicts are supported and are the default items to be loaded to. As of Python 3.7 preservation of insertion order is a language feature of regular dicts.)\n\nThis project was originally mirrored from\n`yamlordereddict <https://github.com/fmenabe/python-yamlordereddictloader>`_\nMany thanks to the original author Fran\u00e7ois M\u00e9nab\u00e9!\nThe library contains several improvements including automated testing and\nthe much faster C-versions of the Loaders/Dumpers.\n\n\n`API Documentation <https://yamlloader.readthedocs.io/>`_\n\n\nInstall\n-------\nThere is a pip and a conda version available\n\n.. code-block:: bash\n\n $ pip install yamlloader\n\nor\n\n.. code-block:: bash\n\n $ conda install yamlloader -c conda-forge\n\n\nBut does [your special case here] also work?\n--------------------------------------------\n\nTests are run continuously using randomly generated yaml files.\nAlso, there are no fails to be expected.\n\nStill, if you are concerned that *your* special case may breaks in the future, please\nadd your own tests as `test_ext_anyname.py` under `tests/` or let us know about your needs.\nThis guarantees that no code will be added that breaks *your* case.\n\n\nC vs non-C version\n------------------\n\nA significant speedup can be reached by replacing the Loader* and Dumper* classes by CLoader*\nand CDumper*. The package hereby relies on the implementations from PyYAML. If they have not\nbeen compiled, *yamlloader* **automatically** falls back to the non-C versions.\n\nTherefore using the C-version is safe: if it is not available, the pure Python version is\nautomatically used.\n\nUsage examples\n==============\n\n\nLoader usage\n------------\n\n.. code-block:: python\n\n import yaml\n import yamlloader\n\n with open('myfile.yml') as yaml_file:\n data = yaml.load(yaml_file,\n Loader=yamlloader.ordereddict.CLoader)\n # CLoader is faster than Loader\n\n**Note:** For using the safe loader (which takes standard YAML tags and does\nnot construct arbitrary Python objects), replace ``yamlloader.ordereddict.CLoader`` by\n``yamlloader.ordereddict.CSafeLoader``.\n\nDumper usage\n------------\n\n.. code-block:: python\n\n import yaml\n import yamlloader\n from collections import OrderedDict\n\n data = OrderedDict([('key1', 'val1'),\n ('key2', OrderedDict([('key21', 'val21'),\n ('key22', 'val22')]))])\n\n with open('myfile.yaml', 'w') as yaml_file:\n yaml.dump(data, yaml_file,\n Dumper=yamlloader.ordereddict.CDumper)\n\n**Note:** For using the safe dumper (which produce standard YAML tags and does\nnot represent arbitrary Python objects), replace ``yamlloader.ordereddict.CDumper`` by\n``yamlloader.ordereddict.CSafeDumper``.\n\n\nFAQ\n===\n\nC version not working\n---------------------------\nIf the C version is not working (it falls back by default to a non-C version),\ncheck if yaml.cyaml exists. If not, the cyaml module was not compiled during the installation of\nyaml (pyyaml). Make sure that cython is installed (`pip install Cython`) and the yaml.h file is\nthere (apt: libyaml-dev).\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Ordered YAML loader and dumper for PyYAML.",
"version": "1.4.1",
"project_urls": {
"Download": "https://github.com/Phynix/yamlloader",
"Homepage": "https://github.com/Phynix/yamlloader"
},
"split_keywords": [
"yaml",
" loader",
" dumper",
" ordered",
" ordereddict",
" pyyaml"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1999b2e50c6428f144ed5e60c9f077c79a1c46c380db9c829453c38d152633c0",
"md5": "74404ddfe74795d728b2b625bb536039",
"sha256": "c42c1ecab51da9bfebfdf44ec9b443ef0df66bae9cb5bc653c0612a16f806930"
},
"downloads": -1,
"filename": "yamlloader-1.4.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "74404ddfe74795d728b2b625bb536039",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 6940,
"upload_time": "2024-04-15T05:18:56",
"upload_time_iso_8601": "2024-04-15T05:18:56.547045Z",
"url": "https://files.pythonhosted.org/packages/19/99/b2e50c6428f144ed5e60c9f077c79a1c46c380db9c829453c38d152633c0/yamlloader-1.4.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ae87a689fcd4f9b0fa98d7def23099d68428ef19e427982d16e83dd788a69bd8",
"md5": "657e6d8e216eb89a8a94eef4e873340f",
"sha256": "b6fe40ecf5af596d840e920670ed3475f9813492bf6e55b24f2ad450c212bab5"
},
"downloads": -1,
"filename": "yamlloader-1.4.1.tar.gz",
"has_sig": false,
"md5_digest": "657e6d8e216eb89a8a94eef4e873340f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 12924,
"upload_time": "2024-04-15T05:18:58",
"upload_time_iso_8601": "2024-04-15T05:18:58.145327Z",
"url": "https://files.pythonhosted.org/packages/ae/87/a689fcd4f9b0fa98d7def23099d68428ef19e427982d16e83dd788a69bd8/yamlloader-1.4.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-15 05:18:58",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Phynix",
"github_project": "yamlloader",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "pyyaml",
"specs": []
}
],
"lcname": "yamlloader"
}