Skip to main content

orderedYAML

A small Python package to recursively convert Python dicts/lists into ruamel.yaml-compatible, ordered YAML using CommentedMap. Preserves formatting, ordering, and supports custom key orders at any nesting depth.

Features

  • Recursively reorders YAML dictionaries based on custom paths
  • Outputs block-style YAML using ruamel.yaml
  • Compatible with Python 3.7+

Installation

pip install orderedYAML

Usage

from core import OrderedYAML

data = {
    "outerlist": {
        "outeritems": [
            {
                "id": 1,
                "name": "inner-1",
                "inneritems": [
                    {"z": 3, "a": 1, "m": 2},
                    {"a": 4, "z": 5, "m": 6},
                ]
            },
            {
                "id": 2,
                "inneritems": [
                    {"m": 9, "z": 8, "a": 7}
                ],
                "name": "inner-2"
            }
        ]
    }
}

ordering = {
    "outerlist.outeritems[*]": ["name", "id", "inneritems"],
    "outerlist.outeritems[].inneritems[*]": ["z", "m", "a", "q"]
}
oy = OrderedYAML(data, path_ordering=ordering)
print(oy.dumps())

Resulting in

outerlist:
  outeritems:
  - name: inner-1
    id: 1
    inneritems:
    - z: 3
      m: 2
      a: 1
    - z: 5
      m: 6
      a: 4
  - name: inner-2
    id: 2
    inneritems:
    - z: 8
      m: 9
      a: 7

Metadata

Release files for orderedYAML 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for orderedYAML 0.1.2
File Size Uploaded Provenance Actions
orderedyaml-0.1.2.tar.gz 4.3 kB Without provenance Details for orderedyaml-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for orderedYAML 0.1.2
File Interpreter ABI Platform Actions
orderedyaml-0.1.2-py3-none-any.whl Python 3 none any Details for orderedyaml-0.1.2-py3-none-any.whl

Total release size: 9.7 kB

Release files / orderedyaml-0.1.2.tar.gz

Download URL orderedyaml-0.1.2.tar.gz
Size 4.3 kB
Tags Source
SHA-256 checksum
How to use checksums
69b95cfe1ce72745b59b10362209056715770b9a230a2bb59b5f845470fdedd9
BLAKE2b-256 checksum
How to use checksums
0e3360b65833e15c1bb79026b8db09112fa2e2eca9dce2a54ca60f049781383c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Release files / orderedyaml-0.1.2-py3-none-any.whl

Download URL orderedyaml-0.1.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9c448752293af326029c747c4d6fc3f55d04d4d2043b958bbc9616bc6de2651a
BLAKE2b-256 checksum
How to use checksums
80698ee1160663161cf55748954e9fb81e439eb52849d32e4e7c1868d6952f79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.0

Security for orderedYAML 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page