././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1695390375.4418056 yamlordereddictloader-0.4.2/0000755000175000017500000000000014503315247016315 5ustar00francoisfrancois././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695215569.0 yamlordereddictloader-0.4.2/LICENSE.txt0000644000175000017500000000204214502567721020143 0ustar00francoisfrancoisCopyright 2017 François Ménabé Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695215569.0 yamlordereddictloader-0.4.2/MANIFEST.in0000644000175000017500000000004714502567721020061 0ustar00francoisfrancoisinclude README.rst include LICENSE.txt ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1695390375.4418056 yamlordereddictloader-0.4.2/PKG-INFO0000644000175000017500000000736114503315247017421 0ustar00francoisfrancoisMetadata-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 `_ **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 `_, 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``. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695215569.0 yamlordereddictloader-0.4.2/README.rst0000644000175000017500000000556214502567721020021 0ustar00francoisfrancoispython-yamlordereddictloader ============================ **DEPRECATED: the** `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 `_, 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``. ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1695390375.4418056 yamlordereddictloader-0.4.2/setup.cfg0000644000175000017500000000004614503315247020136 0ustar00francoisfrancois[egg_info] tag_build = tag_date = 0 ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695390268.0 yamlordereddictloader-0.4.2/setup.py0000644000175000017500000000236214503315074020030 0ustar00francoisfrancois# -*- coding: utf-8 -*- import sys from setuptools import setup requires = ['pyyaml'] if float('%d.%d' % sys.version_info[:2]) < 2.7: requires.append('ordereddict') setup( name='yamlordereddictloader', version='0.4.2', author='François Ménabé', author_email='francois.menabe@gmail.com', url='https://github.com/fmenabe/python-yamlordereddictloader', download_url='https://github.com/fmenabe/python-yamlordereddictloader', license='MIT License', description='YAML loader and dumper for PyYAML allowing to keep keys order.', long_description=open('README.rst').read(), keywords=['YAML', 'loader', 'dumper', 'ordered', 'OrderedDict', 'pyyaml'], classifiers=['Development Status :: 5 - Production/Stable', 'Intended Audience :: Developers', 'Intended Audience :: System Administrators', 'License :: OSI Approved :: MIT License', 'Programming Language :: Python', 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Topic :: Utilities'], py_modules=['yamlordereddictloader'], install_requires=requires) ././@PaxHeader0000000000000000000000000000003400000000000010212 xustar0028 mtime=1695390375.4418056 yamlordereddictloader-0.4.2/yamlordereddictloader.egg-info/0000755000175000017500000000000014503315247024351 5ustar00francoisfrancois././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695390375.0 yamlordereddictloader-0.4.2/yamlordereddictloader.egg-info/PKG-INFO0000644000175000017500000000736114503315247025455 0ustar00francoisfrancoisMetadata-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 `_ **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 `_, 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``. ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695390375.0 yamlordereddictloader-0.4.2/yamlordereddictloader.egg-info/SOURCES.txt0000644000175000017500000000044414503315247026237 0ustar00francoisfrancoisLICENSE.txt MANIFEST.in README.rst setup.py yamlordereddictloader.py yamlordereddictloader.egg-info/PKG-INFO yamlordereddictloader.egg-info/SOURCES.txt yamlordereddictloader.egg-info/dependency_links.txt yamlordereddictloader.egg-info/requires.txt yamlordereddictloader.egg-info/top_level.txt././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695390375.0 yamlordereddictloader-0.4.2/yamlordereddictloader.egg-info/dependency_links.txt0000644000175000017500000000000114503315247030417 0ustar00francoisfrancois ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695390375.0 yamlordereddictloader-0.4.2/yamlordereddictloader.egg-info/requires.txt0000644000175000017500000000000714503315247026746 0ustar00francoisfrancoispyyaml ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695390375.0 yamlordereddictloader-0.4.2/yamlordereddictloader.egg-info/top_level.txt0000644000175000017500000000002614503315247027101 0ustar00francoisfrancoisyamlordereddictloader ././@PaxHeader0000000000000000000000000000002600000000000010213 xustar0022 mtime=1695215569.0 yamlordereddictloader-0.4.2/yamlordereddictloader.py0000644000175000017500000000534314502567721023243 0ustar00francoisfrancois# -*- coding: utf-8 -*- """YAML loaders and dumpers for PyYAML allowing to keep keys order.""" import sys import yaml if float('%d.%d' % sys.version_info[:2]) < 2.7: from ordereddict import OrderedDict else: from collections import OrderedDict # ## Loaders # def construct_yaml_map(self, node): data = OrderedDict() yield data value = self.construct_mapping(node) data.update(value) def construct_mapping(self, node, deep=False): if isinstance(node, yaml.MappingNode): self.flatten_mapping(node) else: msg = 'expected a mapping node, but found %s' % node.id raise yaml.constructor.ConstructError(None, None, msg, node.start_mark) mapping = OrderedDict() for key_node, value_node in node.value: key = self.construct_object(key_node, deep=deep) try: hash(key) except TypeError as err: raise yaml.constructor.ConstructError( 'while constructing a mapping', node.start_mark, 'found unacceptable key (%s)' % err, key_node.start_mark) value = self.construct_object(value_node, deep=deep) mapping[key] = value return mapping class Loader(yaml.Loader): def __init__(self, *args, **kwargs): yaml.Loader.__init__(self, *args, **kwargs) self.add_constructor( 'tag:yaml.org,2002:map', type(self).construct_yaml_map) self.add_constructor( 'tag:yaml.org,2002:omap', type(self).construct_yaml_map) construct_yaml_map = construct_yaml_map construct_mapping = construct_mapping class SafeLoader(yaml.SafeLoader): def __init__(self, *args, **kwargs): yaml.SafeLoader.__init__(self, *args, **kwargs) self.add_constructor( 'tag:yaml.org,2002:map', type(self).construct_yaml_map) self.add_constructor( 'tag:yaml.org,2002:omap', type(self).construct_yaml_map) construct_yaml_map = construct_yaml_map construct_mapping = construct_mapping # ## Dumpers # def represent_ordereddict(self, data): return self.represent_mapping('tag:yaml.org,2002:map', data.items()) class Dumper(yaml.Dumper): def __init__(self, *args, **kwargs): yaml.Dumper.__init__(self, *args, **kwargs) self.add_representer(OrderedDict, type(self).represent_ordereddict) represent_ordereddict = represent_ordereddict class SafeDumper(yaml.SafeDumper): def __init__(self, *args, **kwargs): yaml.SafeDumper.__init__(self, *args, **kwargs) self.add_representer(OrderedDict, type(self).represent_ordereddict) represent_ordereddict = represent_ordereddict