summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES4
-rw-r--r--README.rst8
-rw-r--r--__init__.py4
-rw-r--r--_doc/_static/pypi.svg2
-rw-r--r--_test/test_issues.py20
-rw-r--r--comments.py13
6 files changed, 41 insertions, 10 deletions
diff --git a/CHANGES b/CHANGES
index fa6ff80..fc64df0 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,7 @@
+[0, 15, 57]: 2018-08-15
+ - Fix that CommentedSeq could no longer be used in adding or do a copy
+ (reported by `Christopher Wright <https://bitbucket.org/CJ-Wright4242/>`__)
+
[0, 15, 56]: 2018-08-15
- fix issue with ``python -O`` optimizing away code (reported, and detailed cause
pinpointed, by `Alex Grönholm <https://bitbucket.org/agronholm/>`__
diff --git a/README.rst b/README.rst
index ea80c6a..2eeda47 100644
--- a/README.rst
+++ b/README.rst
@@ -4,7 +4,7 @@ ruamel.yaml
``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python.
-:version: 0.15.56
+:version: 0.15.57
:updated: 2018-08-15
:documentation: http://yaml.readthedocs.io
:repository: https://bitbucket.org/ruamel/
@@ -54,9 +54,13 @@ ChangeLog
.. should insert NEXT: at the beginning of line for next key (with empty line)
+0.15.57 (2018-08-15):
+ - Fix that CommentedSeq could no longer be used in adding or do a copy
+ (reported by `Christopher Wright <https://bitbucket.org/CJ-Wright4242/>`__)
+
0.15.56 (2018-08-15):
- fix issue with ``python -O`` optimizing away code (reported, and detailed cause
- pinpointed, by `Alex Grönholm <https://bitbucket.org/agronholm/>`__
+ pinpointed, by `Alex Grönholm <https://bitbucket.org/agronholm/>`__)
0.15.55 (2018-08-14):
- unmade ``CommentedSeq`` a subclass of ``list``. It is now
diff --git a/__init__.py b/__init__.py
index ed2bf5a..7bfc69e 100644
--- a/__init__.py
+++ b/__init__.py
@@ -7,8 +7,8 @@ if False: # MYPY
_package_data = dict(
full_package_name='ruamel.yaml',
- version_info=(0, 15, 56),
- __version__='0.15.56',
+ version_info=(0, 15, 57),
+ __version__='0.15.57',
author='Anthon van der Neut',
author_email='a.van.der.neut@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
diff --git a/_doc/_static/pypi.svg b/_doc/_static/pypi.svg
index 566fda4..0e2e85f 100644
--- a/_doc/_static/pypi.svg
+++ b/_doc/_static/pypi.svg
@@ -1 +1 @@
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.56</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.56</text></g> </svg>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="86" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="86" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h33v20H0z"/><path fill="#007ec6" d="M33 0h53v20H33z"/><path fill="url(#b)" d="M0 0h86v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="175" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="230">pypi</text><text x="175" y="140" transform="scale(.1)" textLength="230">pypi</text><text x="585" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="430">0.15.57</text><text x="585" y="140" transform="scale(.1)" textLength="430">0.15.57</text></g> </svg>
diff --git a/_test/test_issues.py b/_test/test_issues.py
index 19eb577..681dc6d 100644
--- a/_test/test_issues.py
+++ b/_test/test_issues.py
@@ -248,23 +248,33 @@ class TestIssues:
'''
assert save_and_run(dedent(program_src), tmpdir, optimized=True) == 0
- @pytest.mark.xfail(strict=True)
def test_issue_221_add(self):
from ruamel.yaml.comments import CommentedSeq
+
a = CommentedSeq([1, 2, 3])
a + [4, 5]
- @pytest.mark.xfail(strict=True)
- def test_issue_221_copy(self):
+ def test_issue_221_sort(self):
from ruamel.yaml import YAML
+ from ruamel.yaml.compat import StringIO
+
yaml = YAML()
inp = dedent("""\
- - d # 4
+ - d
- a # 1
- c # 3
- e # 5
- b # 2
""")
a = yaml.load(dedent(inp))
- print(a)
a.sort()
+ buf = StringIO()
+ yaml.dump(a, buf)
+ exp = dedent("""\
+ - a # 1
+ - b # 2
+ - c # 3
+ - d
+ - e # 5
+ """)
+ assert buf.getvalue() == exp
diff --git a/comments.py b/comments.py
index 283a943..09ba705 100644
--- a/comments.py
+++ b/comments.py
@@ -492,6 +492,19 @@ class CommentedSeq(MutableSliceableSequence, CommentedBase):
self.copy_attributes(res, deep=True)
return res
+ def __add__(self, other):
+ return self._lst + other
+
+ def sort(self):
+ tmp_lst = sorted(zip(self._lst, range(len(self._lst))))
+ self._lst = [x[0] for x in tmp_lst]
+ itm = self.ca.items
+ self.ca._items = {}
+ for idx, x in enumerate(tmp_lst):
+ old_index = x[1]
+ if old_index in itm:
+ self.ca.items[idx] = itm[old_index]
+
class CommentedKeySeq(tuple, CommentedBase):
"""This primarily exists to be able to roundtrip keys that are sequences"""