| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 
 | Metadata-Version: 2.1
Name: yamlordereddictloader
Version: 0.4.2
Summary: YAML loader and dumper for PyYAML allowing to keep keys order.
Home-page: https://github.com/fmenabe/python-yamlordereddictloader
Download-URL: https://github.com/fmenabe/python-yamlordereddictloader
Author: François Ménabé
Author-email: francois.menabe@gmail.com
License: MIT License
Keywords: YAML,loader,dumper,ordered,OrderedDict,pyyaml
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Utilities
License-File: LICENSE.txt
Requires-Dist: pyyaml
python-yamlordereddictloader
============================
**DEPRECATED: the** `Phynix/yamlloader <https://github.com/Phynix/yamlloader>`_ **project
provide an improved version of this library with unit tests, performance improvements
(by providing access to the C implementation of PyYAML) and is more actively developed.
You should use it!**
.. image:: https://img.shields.io/pypi/l/yamlordereddictloader.svg
           :target: https://opensource.org/licenses/MIT
           :alt: License
.. image:: https://img.shields.io/pypi/pyversions/yamlordereddictloader.svg
           :target: https://pypi.python.org/pypi/yamlordereddictloader
           :alt: Versions
.. image:: https://img.shields.io/pypi/v/yamlordereddictloader.svg
           :target: https://pypi.python.org/pypi/yamlordereddictloader
           :alt: PyPi
.. image:: https://img.shields.io/badge/github-repo-yellow.jpg
           :target: https://github.com/fmenabe/python-yamlordereddictloader
           :alt: Code repo
.. image:: https://landscape.io/github/fmenabe/python-yamlordereddictloader/master/landscape.svg?style=flat
           :target: https://landscape.io/github/fmenabe/python-yamlordereddictloader/master
           :alt: Code Health
This module provide a loader and a dumper for PyYAML allowing to keep items order
when loading a file (by putting them in ``OrderedDict`` objects) and to manage
``OrderedDict`` objects when dumping to a file.
The loader is based on stackoverflow topic (thanks to Eric Naeseth):
http://stackoverflow.com/questions/5121931/in-python-how-can-you-load-yaml-mappings-as-ordereddicts#answer-5121963
Self promotion: I use it a lot with `clg <https://clg.readthedocs.io>`_, which
allows to generate command-line definition from a configuration file, for keeping
order of subcommands, options and arguments in the help message!
To install it
-------------
.. code-block:: bash
    $ pip install yamlordereddictloader
Loader usage
------------
.. code-block:: python
    import yaml
    import yamlordereddictloader
    data = yaml.load(open('myfile.yml'), Loader=yamlordereddictloader.Loader)
**Note:** For using the safe loader (which want standard YAML tags and does
not construct arbitrary Python objects), replace ``yamlorderdictloader.Loader`` by
``yamlorderedictloader.SafeLoader``.
Dumper usage
------------
.. code-block:: python
    import yaml
    import yamlordereddictloader
    from collections import OrderedDict
    data = OrderedDict([
        ('key1', 'val1'),
        ('key2', OrderedDict([('key21', 'val21'), ('key22', 'val22')]))
    ])
    yaml.dump(
        data,
        open('myfile.yml', 'w'),
        Dumper=yamlordereddictloader.Dumper,
        default_flow_style=False)
**Note:** For using the safe dumper (which produce standard YAML tags and does
not represent arbitrary Python objects), replace ``yamlorderdictloader.Dumper`` by
``yamlorderedictloader.SafeDumper``.
 |