Skip to content

Commit

Permalink
Merge pull request #59 from Grokzen/feature/ruamel.yaml
Browse files Browse the repository at this point in the history
Feature/ruamel.yaml
  • Loading branch information
Grokzen committed Jun 4, 2016
2 parents bc604d8 + d604714 commit 6596293
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ install:
- pip install -r dev-requirements.txt

script:
- "if [[ $RUAMEL == '1' ]]; then pip install ruamel.yaml; fi"
- coverage erase
- coverage run --source pykwalify -p -m py.test -v
- flake8 --max-line-length=160 --show-source --statistics --exclude=.venv,.tox,dist,docs,build,.git
- python setup.py sdist bdist

env:
- RUAMEL=0
- RUAMEL=1

after_success:
- coverage combine
- coveralls
Expand Down
27 changes: 26 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,31 @@ This readme contains a reduced version of the full documentation.
Latest stable release from pypi

```
$ pip install pykwalify
pip install pykwalify
```


# PyYaml and ruamel.yaml

In release `1.6.0` `PyYaml` will be deprecated in favor of `ruamel.yaml`.

`PyYaml` is still the default installed one but it will removed in release 1.7.0 and `ruamel.yaml` will be the new default yaml parser lib from that release and forward.

Install it for production:

```
pip install 'pykwalify[ruamel]'
```

or for development:

```
pip install -e '.[ruamel]'
```

This decision was based on the following thread in the `PyYaml` repo https://bitbucket.org/xi/pyyaml/issues/59/has-this-project-been-abandoned



# Usage

Expand Down Expand Up @@ -62,6 +83,10 @@ pykwalify -d data.yaml -s schema.yaml
- PyYaml >= 3.11
- python-dateutil >= 2.4.2

Optional dependencies:

- ruamel.yaml >= 0.11.0


## Supported python version

Expand Down
27 changes: 27 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,40 @@ or from source
PyYaml and ruamel.yaml
----------------------

In release ``1.6.0`` ``PyYaml`` will be deprecated in favor of ``ruamel.yaml``.

``PyYaml`` is still the default installed one but it will removed in release 1.7.0 and ``ruamel.yaml`` will be the new default yaml parser lib from that release and forward.

This decision was based on the following thread in the `PyYaml` repo https://bitbucket.org/xi/pyyaml/issues/59/has-this-project-been-abandoned

Install it for production:

.. code-block:: bash
pip install 'pykwalify[ruamel]'
or for development:

.. code-block:: bash
pip install -e '.[ruamel]'
Runtime Dependencies
--------------------

- docopt >= 0.6.2
- PyYaml >= 3.11
- python-dateutil >= 2.4.2

Optional dependencies:

- ruamel.yaml >= 0.11.0



Supported python version
Expand Down
6 changes: 6 additions & 0 deletions docs/release-notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ Next release (??? ?, 2016)
- Convert all documentation to readthedocs
- True/False is no longer considered valid integer
- python3 'bytes' objects is now a valid strings and text type
- The regular PyYaml support is now deprecated in favor of ruamel.yaml, see the following link for more details about
PyYaml being deprecated https://bitbucket.org/xi/pyyaml/issues/59/has-this-project-been-abandoned
PyYaml will still be possible to use in the next major release version (1.6.0) but removed in release (1.7.0) and forward.
- ruamel.yaml is now possible to install with the following command for local development *pip install -e '.[ruamel]'*
and for production, use *pip install 'pykwalify[ruamel]'*
- ruamel.yaml is now used before PyYaml if installed on your system


1.5.1 (Mar 6, 2016)
Expand Down
7 changes: 7 additions & 0 deletions docs/upgrade-instructions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ This document describes all major changes to the validation rules and the API th
If new types were added, they will not be described here because it will not break existing schemas.


1.5.x --> 1.6.0
---------------

ruamel.yaml is now possible to use as a drop-in replacement for PyYaml. Install it with *pip install 'pykwalify[ruamel]'* for production use and with *pip install -e '.[ruamel]'* for development use.

PyYaml is now deprecated and will be removed in favor or ruamel.yaml in release 1.7.0.


1.4.x --> 1.5.0
---------------
Expand Down
16 changes: 16 additions & 0 deletions pykwalify/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

# python stdlib
import sys
import logging


log = logging.getLogger(__name__)


try:
from ruamel import yaml
except ImportError:
try:
import yaml
except ImportError:
log.critical("Unable to import either ruamel.yaml or pyyaml")
sys.exit(1)

log.debug("Using yaml library: {0}".format(yaml.__file__))


if sys.version_info[0] < 3:
Expand Down
2 changes: 1 addition & 1 deletion pykwalify/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from pykwalify.types import is_scalar, tt

# 3rd party imports
import yaml
from pykwalify.compat import yaml
from dateutil.parser import parse

log = logging.getLogger(__name__)
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
license='MIT',
packages=['pykwalify'],
url='http://github.com/grokzen/pykwalify',
extras_require={
'ruamel': ["ruamel.yaml>=0.11.0,<0.12.0"],
},
entry_points={
'console_scripts': [
'pykwalify = pykwalify.cli:cli_entrypoint',
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

# 3rd party imports
import pytest
import yaml
from pykwalify.compat import yaml
from testfixtures import compare


Expand Down
2 changes: 1 addition & 1 deletion tests/test_unicode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from pykwalify.errors import SchemaError

# 3rd party imports
import yaml
from pykwalify.compat import yaml
from testfixtures import compare


Expand Down

0 comments on commit 6596293

Please sign in to comment.