[Python-modules-commits] [ruamel.yaml] 01/03: Imported Upstream version 0.11.14
Vincent Bernat
bernat at moszumanska.debian.org
Fri Jul 15 06:10:10 UTC 2016
This is an automated email from the git hooks/post-receive script.
bernat pushed a commit to branch master
in repository ruamel.yaml.
commit 39c2f2198bf6ead31741a4db0e334b635711ee67
Author: Vincent Bernat <bernat at debian.org>
Date: Fri Jul 15 08:06:15 2016 +0200
Imported Upstream version 0.11.14
---
.hg_archival.txt | 4 ++--
.hgignore | 1 +
.hgtags | 3 +++
Dockerfile | 19 +++++++++++++++++++
README.rst | 11 +++++++++++
__init__.py | 3 ++-
_test/roundtrip.py | 9 +++++----
_test/test_string.py | 23 +++++++++++++++++++++--
composer.py | 15 ++++++++++-----
constructor.py | 8 +++++++-
cyaml.py | 2 +-
docker-compose.yml | 11 +++++++++++
loader.py | 10 +++++-----
main.py | 12 ++++++------
representer.py | 24 ++++++++++++++++++++++++
scalarstring.py | 13 ++++++++++++-
serializer.py | 13 +++++++++----
setup.py | 5 ++++-
tox.ini | 2 +-
19 files changed, 154 insertions(+), 34 deletions(-)
diff --git a/.hg_archival.txt b/.hg_archival.txt
index 3f3782a..ff1f0ee 100644
--- a/.hg_archival.txt
+++ b/.hg_archival.txt
@@ -1,4 +1,4 @@
repo: e99c8d58f995a8f13dfbeadbf4dbcbe458caccb0
-node: 9870512ae409df49e9528954a072a9772e68125f
+node: 63986ab6f97004ccb79984ec571d6e96ea19c499
branch: default
-tag: 0.11.11
+tag: 0.11.14
diff --git a/.hgignore b/.hgignore
index a80e935..303c646 100644
--- a/.hgignore
+++ b/.hgignore
@@ -25,3 +25,4 @@ convert
cmd
TODO.rst
_doc/_build
+.dcw_alt.yml
diff --git a/.hgtags b/.hgtags
index aa98814..1b0c7db 100644
--- a/.hgtags
+++ b/.hgtags
@@ -18,3 +18,6 @@ b6ea93b67e983fd38fc3835b723aca5edc4e94b8 0.11.4
2309d082da2d8ffca483112089223f0b77c6876e 0.11.8
12756d40a6d4cf21af22e125ea019c32a94282b1 0.11.9
0574cc19d4ca1d123ef45d09e4b879daab2f2c46 0.11.10
+9870512ae409df49e9528954a072a9772e68125f 0.11.11
+9d266b434de53721015b2263b51ff5620dcdd9b4 0.11.12
+1e3e1113a711a180ec4ba8d90864a9b10d2ffdb8 0.11.13
diff --git a/Dockerfile b/Dockerfile
new file mode 100644
index 0000000..20151c6
--- /dev/null
+++ b/Dockerfile
@@ -0,0 +1,19 @@
+FROM quay.io/pypa/manylinux1_x86_64
+
+MAINTAINER Anthon van der Neut <a.van.der.neut at ruamel.eu>
+
+RUN echo 'cd /src' > /usr/bin/makewheel
+RUN echo 'for PYBIN in /opt/python/$1*/bin/; do' >> /usr/bin/makewheel
+RUN echo ' echo "$PYBIN"' >> /usr/bin/makewheel
+RUN echo ' ${PYBIN}/pip wheel . -w /tmp' >> /usr/bin/makewheel
+RUN echo 'done' >> /usr/bin/makewheel
+RUN echo '' >> /usr/bin/makewheel
+RUN echo 'for whl in /tmp/*.whl; do' >> /usr/bin/makewheel
+RUN echo ' auditwheel repair "$whl" -w /src/dist/' >> /usr/bin/makewheel
+RUN echo 'done' >> /usr/bin/makewheel
+RUN chmod 755 /usr/bin/makewheel
+
+RUN yum install -y libyaml-devel
+
+
+CMD /usr/bin/makewheel
\ No newline at end of file
diff --git a/README.rst b/README.rst
index bcdd7d2..929160a 100644
--- a/README.rst
+++ b/README.rst
@@ -18,6 +18,17 @@ ChangeLog
::
+ 0.11.13 (2016-07-06):
+ - fix preserve_quotes missing on original Loaders (as reported
+ by Leynos, bitbucket issue 38)
+
+ 0.11.13 (2016-07-06):
+ - documentation only, automated linux wheels
+
+ 0.11.12 (2016-07-06):
+ - added support for roundtrip of single/double quoted scalars using:
+ ruamel.yaml.round_trip_load(stream, preserve_quotes=True)
+
0.11.0 (2016-02-18):
- RoundTripLoader loads 1.2 by default (no sexagesimals, 012 octals nor
yes/no/on/off booleans
diff --git a/__init__.py b/__init__.py
index 9be2082..1ff3424 100644
--- a/__init__.py
+++ b/__init__.py
@@ -9,7 +9,7 @@ from __future__ import absolute_import
_package_data = dict(
full_package_name="ruamel.yaml",
- version_info=(0, 11, 11),
+ version_info=(0, 11, 14),
author="Anthon van der Neut",
author_email="a.van.der.neut at ruamel.eu",
description="ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order", # NOQA
@@ -42,6 +42,7 @@ _package_data = dict(
],
windows_wheels=True,
read_the_docs='yaml',
+ many_linux='libyaml-devel',
)
diff --git a/_test/roundtrip.py b/_test/roundtrip.py
index d82c001..9872239 100644
--- a/_test/roundtrip.py
+++ b/_test/roundtrip.py
@@ -22,9 +22,9 @@ def dedent(data):
return textwrap.dedent(data)
-def round_trip_load(inp):
+def round_trip_load(inp, preserve_quotes=None):
dinp = dedent(inp)
- return ruamel.yaml.load(dinp, ruamel.yaml.RoundTripLoader)
+ return ruamel.yaml.load(dinp, ruamel.yaml.RoundTripLoader, preserve_quotes=preserve_quotes)
def round_trip_dump(data, indent=None, block_seq_indent=None, top_level_colon_align=None,
@@ -36,13 +36,14 @@ def round_trip_dump(data, indent=None, block_seq_indent=None, top_level_colon_al
def round_trip(inp, outp=None, extra=None, intermediate=None, indent=None,
- block_seq_indent=None, top_level_colon_align=None, prefix_colon=None):
+ block_seq_indent=None, top_level_colon_align=None, prefix_colon=None,
+ preserve_quotes=None):
if outp is None:
outp = inp
doutp = dedent(outp)
if extra is not None:
doutp += extra
- data = round_trip_load(inp)
+ data = round_trip_load(inp, preserve_quotes=preserve_quotes)
if intermediate is not None:
if isinstance(intermediate, dict):
for k, v in intermediate.items():
diff --git a/_test/test_string.py b/_test/test_string.py
index 5aa0700..13474b5 100644
--- a/_test/test_string.py
+++ b/_test/test_string.py
@@ -22,13 +22,13 @@ import platform
from roundtrip import round_trip, dedent, round_trip_load, round_trip_dump # NOQA
-class TestYAML:
+class TestPreservedScalarString:
def test_basic_string(self):
round_trip("""
a: abcdefg
""", )
- def test_quoted_string(self):
+ def test_quoted_integer_string(self):
round_trip("""
a: '12345'
""")
@@ -105,3 +105,22 @@ class TestYAML:
def
""", intermediate=dict(a='abc def\n\n'))
+
+
+class TestQuotedScalarString:
+ def test_single_quoted_string(self):
+ round_trip("""
+ a: 'abc'
+ """, preserve_quotes=True)
+
+ def test_double_quoted_string(self):
+ round_trip("""
+ a: "abc"
+ """, preserve_quotes=True)
+
+ def test_non_preserved_double_quoted_string(self):
+ round_trip("""
+ a: "abc"
+ """, outp="""
+ a: abc
+ """)
diff --git a/composer.py b/composer.py
index cf2508e..e193fdb 100644
--- a/composer.py
+++ b/composer.py
@@ -3,19 +3,24 @@
from __future__ import absolute_import
from __future__ import print_function
-__all__ = ['Composer', 'ComposerError']
try:
from .error import MarkedYAMLError
- from .events import * # NOQA
- from .nodes import * # NOQA
from .compat import utf8
except (ImportError, ValueError): # for Jython
from ruamel.yaml.error import MarkedYAMLError
- from ruamel.yaml.events import * # NOQA
- from ruamel.yaml.nodes import * # NOQA
from ruamel.yaml.compat import utf8
+from ruamel.yaml.events import (
+ StreamStartEvent, StreamEndEvent, MappingStartEvent, MappingEndEvent,
+ SequenceStartEvent, SequenceEndEvent, AliasEvent, ScalarEvent,
+)
+from ruamel.yaml.nodes import (
+ MappingNode, ScalarNode, SequenceNode,
+)
+
+__all__ = ['Composer', 'ComposerError']
+
class ComposerError(MarkedYAMLError):
pass
diff --git a/constructor.py b/constructor.py
index 81635de..f809df4 100644
--- a/constructor.py
+++ b/constructor.py
@@ -39,11 +39,12 @@ class BaseConstructor(object):
yaml_constructors = {}
yaml_multi_constructors = {}
- def __init__(self):
+ def __init__(self, preserve_quotes=None):
self.constructed_objects = {}
self.recursive_objects = {}
self.state_generators = []
self.deep_construct = False
+ self._preserve_quotes = preserve_quotes
def check_data(self):
# If there are more documents available?
@@ -830,6 +831,11 @@ class RoundTripConstructor(SafeConstructor):
if node.style == '|' and isinstance(node.value, text_type):
return PreservedScalarString(node.value)
+ elif self._preserve_quotes and isinstance(node.value, text_type):
+ if node.style == "'":
+ return SingleQuotedScalarString(node.value)
+ if node.style == '"':
+ return DoubleQuotedScalarString(node.value)
return node.value
def construct_yaml_str(self, node):
diff --git a/cyaml.py b/cyaml.py
index 11c5676..05dccd6 100644
--- a/cyaml.py
+++ b/cyaml.py
@@ -34,7 +34,7 @@ class CSafeLoader(CParser, SafeConstructor, Resolver):
class CLoader(CParser, Constructor, Resolver):
- def __init__(self, stream, version=None):
+ def __init__(self, stream, version=None, preserve_quotes=None):
CParser.__init__(self, stream)
Constructor.__init__(self)
Resolver.__init__(self)
diff --git a/docker-compose.yml b/docker-compose.yml
new file mode 100644
index 0000000..87ee45c
--- /dev/null
+++ b/docker-compose.yml
@@ -0,0 +1,11 @@
+version: '2'
+user-data:
+ author: Anthon van der Neut <a.van.der.neut at ruamel.eu>
+ description: manylinux1 wheel build container for ruamel.yaml
+ # env-defaults:
+services:
+ yamlmanylinux1:
+ container_name: yamlmanylinux1
+ build: .
+ volumes:
+ - .:/src
diff --git a/loader.py b/loader.py
index 10ed99f..b5ba20a 100644
--- a/loader.py
+++ b/loader.py
@@ -21,7 +21,7 @@ except (ImportError, ValueError): # for Jython
class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolver):
- def __init__(self, stream, version=None):
+ def __init__(self, stream, version=None, preserve_quotes=None):
Reader.__init__(self, stream)
Scanner.__init__(self)
Parser.__init__(self)
@@ -31,7 +31,7 @@ class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolve
class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver):
- def __init__(self, stream, version=None):
+ def __init__(self, stream, version=None, preserve_quotes=None):
Reader.__init__(self, stream)
Scanner.__init__(self)
Parser.__init__(self)
@@ -41,7 +41,7 @@ class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver):
class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver):
- def __init__(self, stream, version=None):
+ def __init__(self, stream, version=None, preserve_quotes=None):
Reader.__init__(self, stream)
Scanner.__init__(self)
Parser.__init__(self)
@@ -52,10 +52,10 @@ class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver):
class RoundTripLoader(Reader, RoundTripScanner, RoundTripParser, Composer,
RoundTripConstructor, VersionedResolver):
- def __init__(self, stream, version=None):
+ def __init__(self, stream, version=None, preserve_quotes=None):
Reader.__init__(self, stream)
RoundTripScanner.__init__(self)
RoundTripParser.__init__(self)
Composer.__init__(self)
- RoundTripConstructor.__init__(self)
+ RoundTripConstructor.__init__(self, preserve_quotes=preserve_quotes)
VersionedResolver.__init__(self, version)
diff --git a/main.py b/main.py
index e0041bc..797bdcd 100644
--- a/main.py
+++ b/main.py
@@ -65,12 +65,12 @@ def compose_all(stream, Loader=Loader):
loader.dispose()
-def load(stream, Loader=Loader, version=None):
+def load(stream, Loader=Loader, version=None, preserve_quotes=None):
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
"""
- loader = Loader(stream, version)
+ loader = Loader(stream, version, preserve_quotes=preserve_quotes)
try:
return loader.get_single_data()
finally:
@@ -108,22 +108,22 @@ def safe_load_all(stream, version=None):
return load_all(stream, SafeLoader, version)
-def round_trip_load(stream, version=None):
+def round_trip_load(stream, version=None, preserve_quotes=None):
"""
Parse the first YAML document in a stream
and produce the corresponding Python object.
Resolve only basic YAML tags.
"""
- return load(stream, RoundTripLoader, version)
+ return load(stream, RoundTripLoader, version, preserve_quotes=preserve_quotes)
-def round_trip_load_all(stream, version=None):
+def round_trip_load_all(stream, version=None, preserve_quotes=None):
"""
Parse all YAML documents in a stream
and produce corresponding Python objects.
Resolve only basic YAML tags.
"""
- return load_all(stream, RoundTripLoader, version)
+ return load_all(stream, RoundTripLoader, version, preserve_quotes=preserve_quotes)
def emit(events, stream=None, Dumper=Dumper,
diff --git a/representer.py b/representer.py
index e3f07ae..7498443 100644
--- a/representer.py
+++ b/representer.py
@@ -605,6 +605,22 @@ class RoundTripRepresenter(SafeRepresenter):
tag = u'tag:yaml.org,2002:str'
return self.represent_scalar(tag, data, style=style)
+ def represent_single_quoted_scalarstring(self, data):
+ tag = None
+ style = "'"
+ if PY2 and not isinstance(data, unicode):
+ data = unicode(data, 'ascii')
+ tag = u'tag:yaml.org,2002:str'
+ return self.represent_scalar(tag, data, style=style)
+
+ def represent_double_quoted_scalarstring(self, data):
+ tag = None
+ style = '"'
+ if PY2 and not isinstance(data, unicode):
+ data = unicode(data, 'ascii')
+ tag = u'tag:yaml.org,2002:str'
+ return self.represent_scalar(tag, data, style=style)
+
def represent_sequence(self, tag, sequence, flow_style=None):
value = []
# if the flow_style is None, the flow style tacked on to the object
@@ -843,6 +859,14 @@ RoundTripRepresenter.add_representer(
PreservedScalarString,
RoundTripRepresenter.represent_preserved_scalarstring)
+RoundTripRepresenter.add_representer(
+ SingleQuotedScalarString,
+ RoundTripRepresenter.represent_single_quoted_scalarstring)
+
+RoundTripRepresenter.add_representer(
+ DoubleQuotedScalarString,
+ RoundTripRepresenter.represent_double_quoted_scalarstring)
+
RoundTripRepresenter.add_representer(CommentedSeq,
RoundTripRepresenter.represent_list)
diff --git a/scalarstring.py b/scalarstring.py
index 3885425..d3abaff 100644
--- a/scalarstring.py
+++ b/scalarstring.py
@@ -3,7 +3,8 @@
from __future__ import absolute_import
from __future__ import print_function
-__all__ = ["ScalarString", "PreservedScalarString"]
+__all__ = ["ScalarString", "PreservedScalarString", "SingleQuotedScalarString",
+ "DoubleQuotedScalarString"]
try:
from .compat import text_type
@@ -21,6 +22,16 @@ class PreservedScalarString(ScalarString):
return ScalarString.__new__(cls, value)
+class SingleQuotedScalarString(ScalarString):
+ def __new__(cls, value):
+ return ScalarString.__new__(cls, value)
+
+
+class DoubleQuotedScalarString(ScalarString):
+ def __new__(cls, value):
+ return ScalarString.__new__(cls, value)
+
+
def preserve_literal(s):
return PreservedScalarString(s.replace('\r\n', '\n').replace('\r', '\n'))
diff --git a/serializer.py b/serializer.py
index 7ed9ff9..60dd517 100644
--- a/serializer.py
+++ b/serializer.py
@@ -6,15 +6,20 @@ import re
try:
from .error import YAMLError
- from .events import * # NOQA
- from .nodes import * # NOQA
from .compat import nprint, DBG_NODE, dbg, string_types
except (ImportError, ValueError): # for Jython
from ruamel.yaml.error import YAMLError
- from ruamel.yaml.events import * # NOQA
- from ruamel.yaml.nodes import * # NOQA
from ruamel.yaml.compat import nprint, DBG_NODE, dbg, string_types
+from ruamel.yaml.events import (
+ StreamStartEvent, StreamEndEvent, MappingStartEvent, MappingEndEvent,
+ SequenceStartEvent, SequenceEndEvent, AliasEvent, ScalarEvent,
+ DocumentStartEvent, DocumentEndEvent,
+)
+from ruamel.yaml.nodes import (
+ MappingNode, ScalarNode, SequenceNode,
+)
+
__all__ = ['Serializer', 'SerializerError']
diff --git a/setup.py b/setup.py
index 8987ff6..e844a81 100644
--- a/setup.py
+++ b/setup.py
@@ -7,6 +7,7 @@ from __future__ import print_function, absolute_import, division, unicode_litera
import sys
import os
+import datetime
sys.path = [path for path in sys.path if path not in [os.getcwd(), '']]
import platform # NOQA
from _ast import * # NOQA
@@ -505,6 +506,8 @@ class NameSpacePackager(object):
return self._pkg
# 'any' for all builds, 'py27' etc for specifics versions
packages = ir.get('any', [])
+ if isinstance(packages, string_type):
+ packages = packages.split() # assume white space separated string
implementation = platform.python_implementation()
if implementation == 'CPython':
pyver = 'py{0}{1}'.format(*sys.version_info)
@@ -557,7 +560,7 @@ class NameSpacePackager(object):
return None
try:
plat = sys.argv.index('--plat-name')
- if 'win' in sys.argv[plat+1]:
+ if 'win' in sys.argv[plat + 1]:
return None
except ValueError:
pass
diff --git a/tox.ini b/tox.ini
index fdc70a7..18f789f 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,7 @@ commands =
/bin/bash -c 'py.test _test/test_*.py'
deps =
pytest
- flake8
+ flake8==2.5.5
[pytest]
norecursedirs = test/lib .tox
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/ruamel.yaml.git
More information about the Python-modules-commits
mailing list