Python установить модуль yaml

PyYAML

YAML is a data serialization format designed for human readability and interaction with scripting languages.

PyYAML is a YAML parser and emitter for the Python programming language.

  • a completeYAML 1.1 parser. In particular, PyYAML can parse all examples from the specification. The parsing algorithm is simple enough to be a reference for YAML parser implementors.
  • Unicode support including UTF-8/UTF-16 input/output and *
  • low-level event-based parser and emitter API (like SAX).
  • high-level API for serializing and deserializing native Python objects (like DOM or pickle).
  • support for all types from the YAML types repository. A simple extension API is provided.
  • both pure-Python and fast LibYAML-based parsers and emitters.
  • relatively sensible error messages.

Requirements

PyYAML requires Python 2.7 or Python 3.5+.

Download and Installation

The current stable release of PyYAML: 5.3.

  • TAR.GZ package: http://pyyaml.org/download/pyyaml/PyYAML-5.3.1.tar.gz —>
  • Windows installers (32-bit):
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp27-cp27m-win32.whl (for Python 2.7)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp35-cp35m-win32.whl (for Python 3.5)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp36-cp36m-win32.whl (for Python 3.6)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp37-cp37m-win32.whl (for Python 3.7)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp38-cp38m-win32.whl (for Python 3.8)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp27-cp27m-win_amd64.whl (for Python 2.7)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp35-cp35m-win_amd64.whl (for Python 3.5)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp36-cp36m-win_amd64.whl (for Python 3.6)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp37-cp37m-win_amd64.whl (for Python 3.7)
    • http://pyyaml.org/download/pyyaml/PyYAML-5.3.1-cp38-cp38m-win_amd64.whl (for Python 3.8)

    Unpack the archive and install the package by executing

    If you want to use LibYAML bindings, you need to download and install LibYAML. Then you may install the bindings by executing

    $ python setup.py --with-libyaml install

    The source distribution includes a comprehensive test suite. To run the tests, type

    Documentation

    Quick example (see documentation for loading multiple documents):

    >>> import yaml >>> print yaml.load(""" . name: Vorlin Laruknuzum . sex: Male . class: Priest . title: Acolyte . hp: [32, 71] . sp: [1, 13] . gold: 423 . inventory: . - a Holy Book of Prayers (Words of Wisdom) . - an Azure Potion of Cure Light Wounds . - a Silver Wand of Wonder . """) 'name': 'Vorlin Laruknuzum', 'gold': 423, 'title': 'Acolyte', 'hp': [32, 71], 'sp': [1, 13], 'sex': 'Male', 'inventory': ['a Holy Book of Prayers (Words of Wisdom)', 'an Azure Potion of Cure Light Wounds', 'a Siver Wand of Wonder'], 'class': 'Priest'> >>> print yaml.dump('name': "The Cloak 'Colluin'", 'depth': 5, 'rarity': 45, . 'weight': 10, 'cost': 50000, 'flags': ['INT', 'WIS', 'SPEED', 'STEALTH']>) name: The Cloak 'Colluin' rarity: 45 flags: [INT, WIS, SPEED, STEALTH] weight: 10 cost: 50000 depth: 5

    For more details, please check PyYAML Documentation.

    History

    • #290 – Use is instead of equality for comparing with None
    • #270 – fix typos and stylistic nit
    • #309 – Fix up small typo
    • #161 – Fix handling of slots
    • #358 – Allow calling add_multi_constructor with None
    • #285 – Add use of safe_load() function in README
    • #351 – Fix reader for Unicode code points over 0xFFFF
    • #360 – Enable certain unicode tests when maxunicode not > 0xffff
    • #359 – Use full_load in yaml-highlight example
    • #244 – Document that PyYAML is implemented with Cython
    • #329 – Fix for Python 3.10
    • #310 – increase size of index, line, and column fields
    • #260 – remove some unused imports
    • #163 – Create timezone-aware datetimes when parsed as such
    • #363 – Add tests for timezone
    • Repair incompatibilities introduced with 5.1. The default Loader was changed, but several methods like add_constructor still used the old default #279 – A more flexible fix for custom tag constructors #287 – Change default loader for yaml.add_constructor #305 – Change default loader for add_implicit_resolver, add_path_resolver
    • Make FullLoader safer by removing python/object/apply from the default FullLoader #347 – Move constructor for object/apply to UnsafeConstructor
    • Fix bug introduced in 5.1 where quoting went wrong on systems with sys.maxunicode
    • Other PRs: #280 – Update CHANGES for 5.1
    • Incompatible changes:
    • #257 – Deprecate yaml.load and add FullLoader and UnsafeLoader classes
    • #256 – Make default_flow_style=False
    • Features:
    • #158 – Support escaped slash in double quotes “/”
    • #45 – Allow colon in a plain scalar in a flow context
    • #63 – Adding support to Unicode characters over codepoint 0xffff
    • #254 – Allow to turn off sorting keys in Dumper
    • Bugfixes:
    • #129 – Remove call to ord in lib3 emitter code
    • Other:
    • #35 – Some modernization of the test running
    • #42 – Install tox in a virtualenv
    • #48 – Fix typos
    • #55 – Improve RepresenterError creation
    • #59 – Resolves #57, update readme issues link
    • #60 – Document and test Python 3.6 support
    • #61 – Use Travis CI built in pip cache support
    • #62 – Remove tox workaround for Travis CI
    • #75 – add 3.12 changelog
    • #76 – Fallback to Pure Python if Compilation fails
    • #84 – Drop unsupported Python 3.3
    • #102 – Include license file in the generated wheel package
    • #105 – Removed Python 2.6 & 3.3 support
    • #111 – Remove commented out Psyco code
    • #149 – Test on Python 3.7-dev
    • #175 – Updated link to pypi in release announcement
    • #181 – Import Hashable from collections.abc
    • #194 – Reverting https://github.com/yaml/pyyaml/pull/74
    • #195 – Build libyaml on travis
    • #196 – Force cython when building sdist
    • #261 – Skip certain unicode tests when maxunicode not > 0xffff
    • #263 – Windows Appveyor build
    • Wheel packages for Windows binaries.
    • Adding an implicit resolver to a derived loader should not affect the base loader (fixes issue #57).
    • Uniform representation for OrderedDict across different versions of Python (fixes issue #61).
    • Fixed comparison to None warning (closes issue #64).
    • Do not try to build LibYAML bindings on platforms other than CPython; this fixed installation under Jython (Thank to olt(at)bogosoft(dot)com).
    • Clear cyclic references in the parser and the emitter (Thank to kristjan(at)ccpgames(dot)com).
    • LibYAML bindings are rebuilt with the latest version of Cython.
    • Dropped support for Python 2.3 and 2.4; currently supported versions are 2.5 to 3.2.
    • Fixed use of uninitialized memory when emitting anchors with LibYAML bindings (Thank to cegner(at)yahoo-inc(dot)com).
    • Fixed emitting incorrect BOM characters for UTF-16 (Thank to Valentin Nechayev)
    • Fixed the emitter for folded scalars not respecting the preferred line width (Thank to Ingy).
    • Fixed a subtle ordering issue with emitting %TAG directives (Thank to Andrey Somov).
    • Fixed performance regression with LibYAML bindings.
    • Python 3 support (Thank to Erick Tryzelaar).
    • Use Cython instead of Pyrex to build LibYAML bindings.
    • Refactored support for unicode and byte input/output streams.
    • The emitter learned to use an optional indentation indicator for block scalar; thus scalars with leading whitespaces could now be represented in a literal or folded style.
    • The test suite is now included in the source distribution. To run the tests, type python setup.py test .
    • Refactored the test suite: dropped unittest in favor of a custom test appliance.
    • Fixed the path resolver in CDumper .
    • Forced an explicit document end indicator when there is a possibility of parsing ambiguity.
    • More setup.py improvements: the package should be usable when any combination of setuptools , Pyrex and LibYAML is installed.
    • Windows binary packages are built against LibYAML-0.1.2.
    • Minor typos and corrections. Thank to Ingy dot Net and Andrey Somov.
    • setup.py checks whether LibYAML is installed and if so, builds and installs LibYAML bindings. To force or disable installation of LibYAML bindings, use —with-libyaml or —without-libyaml respectively (partially fixes #34).
    • Building LibYAML bindings no longer requires Pyrex installed (fixed #33).
    • yaml.load() raises an exception if the input stream contains more than one YAML document (fixed #54).
    • Fixed exceptions produced by LibYAML bindings (fixed #50).
    • Fixed a dot ‘.’ character being recognized as !!float (fixed #62).
    • Fixed Python 2.3 compatibility issue in constructing !!timestamp values.
    • Windows binary packages are built against the LibYAML stable branch.
    • Added attributes yaml.__version__ and yaml.__with_libyaml__ (fixed #85).
    • Allow for immutable subclasses of YAMLObject. Fixed #53.
    • Make the encoding of the unicode->str conversion explicit; fixed #52.
    • Fixed a problem when the DOCUMENT-END event is not emitted until the beginning of the next document is available. Fixed #51. Thanks edward(at)sweetbytes.net for the bug report.
    • Improve output of float values. Fixed #49.
    • Fix the bug when the path in add_path_resolver contains boolean values. Fixed #43 (thanks to jstroud(at)mbi.ucla.edu for reporting and pointing to the cause).
    • Use the types module instead of constructing type objects by hand. Fixed #41. Thanks to v.haisman(at)sh.cvut.cz for the patch.
    • Fix loss of microsecond precision in datetime.datetime constructor (fix #30). Thanks to edemaine(at)mit.edu for the bug report and the patch.
    • Fixed loading an empty YAML stream.
    • Include experimental LibYAML bindings.
    • Fully support recursive structures (close #5).
    • Sort dictionary keys (close #23). Mapping node values are now represented as lists of pairs instead of dictionaries. Do not check for duplicate mapping keys as it didn’t work correctly anyway.
    • Fix invalid output of single-quoted scalars in cases when a single quote is not escaped when preceeded by whitespaces or line breaks (close #17).
    • To make porting easier, rewrite Parser not using generators.
    • Fix handling of unexpected block mapping values, like >>
    • Fix a bug in Representer.represent_object : copy_reg.dispatch_table was not correctly handled.
    • Fix a bug when a block scalar is incorrectly emitted in the simple key context.
    • Hold references to the objects being represented (close #22).
    • Make Representer not try to guess !!pairs when a list is represented.
    • Fix timestamp constructing and representing (close #25).
    • Fix the ‘N’ plain scalar being incorrectly recognized as !!bool (close #26).
    • Fix Python 2.5 compatibility issues.
    • Fix numerous bugs in the float handling.
    • Fix scanning some ill-formed documents.
    • Other minor fixes.
    • Fix win32 installer. Apparently bdist_wininst does not work well under Linux.
    • Fix a bug in add_path_resolver.
    • Add the yaml-highlight example. Try to run on a color terminal: python yaml_hl.py
    • Initial release. The version number reflects the codename of the project (PyYAML 3000) and differenciates it from the abandoned PyYaml module.

    Copyright (c) 2017-2019 Ingy döt Net Copyright (c) 2006-2016 Kirill Simonov

    The PyYAML module was written by Kirill Simonov. It is now maintained by the YAML community.

    PyYAML is released under the MIT license.

    Источник

    Installing¶

    Make sure you have a recent version of pip and setuptools installed. The later needs environment marker support ( setuptools>=20.6.8 ) and that is e.g. bundled with Python 3.4.6 but not with 3.4.4. It is probably best to do:

    pip install -U pip setuptools wheel 

    in your environment ( virtualenv , (Docker) container, etc) before installing ruamel.yaml .

    ruamel.yaml itself should be installed from PyPI using:

    If you want to process jinja2/YAML templates (which are not valid YAML with the default jinja2 markers), do pip install ruamel.yaml[jinja2] (you might need to quote the last argument because of the [] )

    There also is a commandline utility yaml available after installing:

    pip install ruamel.yaml.cmd 

    that allows for round-trip testing/re-indenting and conversion of YAML files (JSON,INI,HTML tables)

    Optional requirements¶

    If you have the the header files for your Python executables installed then you can use the (non-roundtrip), but faster, C loader and emitter.

    On Debian systems you should use:

    sudo apt-get install python3-dev 

    you can leave out python3-dev if you don’t use python3

    For CentOS (7) based systems you should do:

    sudo yum install python-devel 

    © Copyright 2017-2019, Anthon van der Neut, Ruamel bvba Revision 5a56c4c661ce .

    Versions latest stable Downloads pdf epub On Read the Docs Project Home Builds Free document hosting provided by Read the Docs.

    Источник

    Читайте также:  Php переменная строка запроса
Оцените статью