Metadata-Version: 2.4
Name: parseyaml
Version: 1.2.0
Summary: A small, convenient wrapper around PyYAML
Author: optima1236
Author-email: optima1236 <rin98182@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/optima1236/parseyaml
Project-URL: Repository, https://github.com/optima1236/parseyaml
Project-URL: Issues, https://github.com/optima1236/parseyaml/issues
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyYAML>=5.4
Provides-Extra: dev
Requires-Dist: pytest>=7; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"
Dynamic: author
Dynamic: license-file
Dynamic: requires-python

# parseyaml

A small, convenient wrapper around PyYAML.

## Features

- Friendly load / dump API that mirrors PyYAML's most-used functions.
- First-class loader= and dumper= switches (default, safe, full, base).
- File helpers: load_file, dump_file, load_path, dump_path.
- Automatic use of LibYAML's C implementations when available.
- Small command-line entry point: parseyaml <file>.

## A note on loaders

The default loader is yaml.Loader. According to PyYAML's documentation,
yaml.Loader can be induced to construct arbitrary Python objects and is
not suitable for untrusted input. Use one of the following if that
matters for your use case:

- parseyaml.safe_load(...) / loader="safe" - only basic YAML types.
- loader="full" - full YAML, but without the known unsafe code paths.
- loader="base" - basic types only, no tag resolution.

If you want parseyaml to be safe by default, change
_LOADERS["default"] in parseyaml/core.py from
yaml.Loader/CLoader to yaml.SafeLoader/CSafeLoader.

## Installation

    pip install parseyaml

## Usage

    import parseyaml

    # Default loader (yaml.Loader).
    data = parseyaml.load("name: Alice\nage: 30\n")

    # Explicit safe loader.
    data = parseyaml.safe_load("name: Alice\nage: 30\n")

    # Dump to a string.
    text = parseyaml.dump(data, sort_keys=False, allow_unicode=True)

    # File helpers.
    parseyaml.dump_file({"a": 1}, "config.yaml")
    data = parseyaml.load_file("config.yaml")

    # Which C extensions are available?
    print(parseyaml.is_available())

## License

MIT.
