diff options
-rw-r--r-- | CHANGES | 14 | ||||
-rw-r--r-- | README.rst | 11 | ||||
-rw-r--r-- | __init__.py | 15 | ||||
-rw-r--r-- | _doc/api.ryd | 2 | ||||
-rw-r--r-- | _test/lib/test_input_output.py | 4 | ||||
-rw-r--r-- | _test/test_anchor.py | 8 | ||||
-rw-r--r-- | _test/test_numpy.py | 2 | ||||
-rw-r--r-- | _test/test_version.py | 84 | ||||
-rw-r--r-- | comments.py | 22 | ||||
-rw-r--r-- | compat.py | 2 | ||||
-rw-r--r-- | constructor.py | 2 | ||||
-rw-r--r-- | emitter.py | 2 | ||||
-rw-r--r-- | main.py | 2 | ||||
-rw-r--r-- | reader.py | 2 | ||||
-rw-r--r-- | serializer.py | 4 | ||||
-rw-r--r-- | setup.py | 24 | ||||
-rw-r--r-- | tokens.py | 4 | ||||
-rw-r--r-- | tox.ini | 10 |
18 files changed, 132 insertions, 82 deletions
@@ -1,3 +1,17 @@ +[0, 15, 41]: 2018-06-27 + - add detection of C-compile failure (investigation prompted by + `StackOverlow <https://stackoverflow.com/a/51057399/1307905>`__ by + `Emmanuel Blot <https://stackoverflow.com/users/8233409/emmanuel-blot>`__), + which was removed while no longer dependent on ``libyaml``, C-extensions + compilation still needs a compiler though. + +[0, 15, 41]: 2018-06-27 + - add detection of C-compile failure (investigation prompted by + `StackOverlow <https://stackoverflow.com/a/51057399/1307905>`__ by + `Emmanuel Blot <https://stackoverflow.com/users/8233409/emmanuel-blot>`__), + which was removed while no longer dependent on ``libyaml``, C-extensions + compilation still needs a compiler though. + [0, 15, 40]: 2018-06-18 - added links to landing places as suggested in issue 190 by `KostisA <https://bitbucket.org/ankostis/>`__ @@ -4,8 +4,8 @@ ruamel.yaml ``ruamel.yaml`` is a YAML 1.2 loader/dumper package for Python. -:version: 0.15.40 -:updated: 2018-06-18 +:version: 0.15.41 +:updated: 2018-06-27 :documentation: http://yaml.readthedocs.io :repository: https://bitbucket.org/ruamel/ :pypi: https://pypi.org/project/ruamel.yaml/ @@ -42,6 +42,13 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key (with empty line) +0.15.41 (2018-06-27): + - add detection of C-compile failure (investigation prompted by + `StackOverlow <https://stackoverflow.com/a/51057399/1307905>`__ by + `Emmanuel Blot <https://stackoverflow.com/users/8233409/emmanuel-blot>`__), + which was removed while no longer dependent on ``libyaml``, C-extensions + compilation still needs a compiler though. + 0.15.40 (2018-06-18): - added links to landing places as suggested in issue 190 by `KostisA <https://bitbucket.org/ankostis/>`__ diff --git a/__init__.py b/__init__.py index 4c6bda2..29d2938 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, 40), - __version__='0.15.40', + version_info=(0, 15, 41), + __version__='0.15.41', 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 @@ -27,11 +27,17 @@ _package_data = dict( 'ext/emitter.c', ], lib=[], + test=""" + int main(int argc, char* argv[]) + { + /* prevent warning */ + return 0; + } + """, # NOQA )], # test='#include "ext/yaml.h"\n\nint main(int argc, char* argv[])\n{\nyaml_parser_t parser;\nparser = parser; /* prevent warning */\nreturn 0;\n}\n', # NOQA classifiers=[ 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.3', 'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', @@ -46,8 +52,9 @@ _package_data = dict( windows_wheels=True, read_the_docs='yaml', many_linux='libyaml-devel', - supported=[(2, 7), (3, 3)], # minimum + supported=[(2, 7), (3, 4)], # minimum tox=dict( + flake8=dict(version='==2.5.5'), env='*p', deps='ruamel.std.pathlib', fl8excl='_test/lib', diff --git a/_doc/api.ryd b/_doc/api.ryd index bd4985d..a6c5afd 100644 --- a/_doc/api.ryd +++ b/_doc/api.ryd @@ -79,7 +79,7 @@ is possible by setting the attributes ``.Parser``, ``.Constructor``, ``.Emitter``, etc., to the class of the type to create for that stage (typically a subclass of an existing class implementing that). -The default loader (``t`` is a direct derivative of the safe loader, without the +The default loader (``typ='rt'``) is a direct derivative of the safe loader, without the methods to construct arbitrary Python objects that make the ``unsafe`` loader unsafe, but with the changes needed for round-trip preservation of comments, etc.. For trusted Python classes a constructor can of course be added to the round-trip diff --git a/_test/lib/test_input_output.py b/_test/lib/test_input_output.py index d83cb5a..27f7aed 100644 --- a/_test/lib/test_input_output.py +++ b/_test/lib/test_input_output.py @@ -167,8 +167,8 @@ else: assert isinstance(data2, str), (type(data2), encoding) data2.decode('utf-8') if encoding is None: - assert isinstance(data3, unicode), (type(data3), encoding) # NOQA - assert isinstance(data4, unicode), (type(data4), encoding) # NOQA + assert isinstance(data3, unicode), (type(data3), encoding) # NOQA + assert isinstance(data4, unicode), (type(data4), encoding) # NOQA else: assert isinstance(data3, str), (type(data3), encoding) data3.decode(encoding) diff --git a/_test/test_anchor.py b/_test/test_anchor.py index 34cc822..8b83c3e 100644 --- a/_test/test_anchor.py +++ b/_test/test_anchor.py @@ -127,10 +127,10 @@ class TestAnchorsAliases: - *blake - *alice """) - l = data['nut1'] - assert isinstance(l, CommentedSeq) - assert l.yaml_anchor() is not None - assert l.yaml_anchor().value == 'alice' + r = data['nut1'] + assert isinstance(r, CommentedSeq) + assert r.yaml_anchor() is not None + assert r.yaml_anchor().value == 'alice' merge_yaml = dedent(""" - &CENTER {x: 1, y: 2} diff --git a/_test/test_numpy.py b/_test/test_numpy.py index 1a6eabb..6a096af 100644 --- a/_test/test_numpy.py +++ b/_test/test_numpy.py @@ -4,7 +4,7 @@ from __future__ import print_function, absolute_import, division, unicode_litera try: import numpy -except: +except: # NOQA numpy = None import ruamel.yaml diff --git a/_test/test_version.py b/_test/test_version.py index 0c270d7..f49cafd 100644 --- a/_test/test_version.py +++ b/_test/test_version.py @@ -12,7 +12,7 @@ def load(s, version=None): class TestVersions: def test_explicit_1_2(self): - l = load("""\ + r = load("""\ %YAML 1.2 --- - 12:34:56 @@ -25,18 +25,18 @@ class TestVersions: - no - true """) - assert l[0] == '12:34:56' - assert l[1] == 12 - assert l[2] == '012345678' - assert l[3] == 10 - assert l[4] == 'on' - assert l[5] == 'off' - assert l[6] == 'yes' - assert l[7] == 'no' - assert l[8] is True + assert r[0] == '12:34:56' + assert r[1] == 12 + assert r[2] == '012345678' + assert r[3] == 10 + assert r[4] == 'on' + assert r[5] == 'off' + assert r[6] == 'yes' + assert r[7] == 'no' + assert r[8] is True def test_explicit_1_1(self): - l = load("""\ + r = load("""\ %YAML 1.1 --- - 12:34:56 @@ -49,18 +49,18 @@ class TestVersions: - no - true """) - assert l[0] == 45296 - assert l[1] == 10 - assert l[2] == '012345678' - assert l[3] == '0o12' - assert l[4] is True - assert l[5] is False - assert l[6] is True - assert l[7] is False - assert l[8] is True + assert r[0] == 45296 + assert r[1] == 10 + assert r[2] == '012345678' + assert r[3] == '0o12' + assert r[4] is True + assert r[5] is False + assert r[6] is True + assert r[7] is False + assert r[8] is True def test_implicit_1_2(self): - l = load("""\ + r = load("""\ - 12:34:56 - 12:34:56.78 - 012 @@ -72,19 +72,19 @@ class TestVersions: - no - true """) - assert l[0] == '12:34:56' - assert l[1] == '12:34:56.78' - assert l[2] == 12 - assert l[3] == '012345678' - assert l[4] == 10 - assert l[5] == 'on' - assert l[6] == 'off' - assert l[7] == 'yes' - assert l[8] == 'no' - assert l[9] is True + assert r[0] == '12:34:56' + assert r[1] == '12:34:56.78' + assert r[2] == 12 + assert r[3] == '012345678' + assert r[4] == 10 + assert r[5] == 'on' + assert r[6] == 'off' + assert r[7] == 'yes' + assert r[8] == 'no' + assert r[9] is True def test_load_version_1_1(self): - l = load("""\ + r = load("""\ - 12:34:56 - 12:34:56.78 - 012 @@ -96,16 +96,16 @@ class TestVersions: - no - true """, version="1.1") - assert l[0] == 45296 - assert l[1] == 45296.78 - assert l[2] == 10 - assert l[3] == '012345678' - assert l[4] == '0o12' - assert l[5] is True - assert l[6] is False - assert l[7] is True - assert l[8] is False - assert l[9] is True + assert r[0] == 45296 + assert r[1] == 45296.78 + assert r[2] == 10 + assert r[3] == '012345678' + assert r[4] == '0o12' + assert r[5] is True + assert r[6] is False + assert r[7] is True + assert r[8] is False + assert r[9] is True class TestIssue62: diff --git a/comments.py b/comments.py index 6aa8be8..afbcbf0 100644 --- a/comments.py +++ b/comments.py @@ -200,25 +200,25 @@ class CommentedBase(object): def yaml_key_comment_extend(self, key, comment, clear=False): # type: (Any, Any, bool) -> None - l = self.ca._items.setdefault(key, [None, None, None, None]) - if clear or l[1] is None: + r = self.ca._items.setdefault(key, [None, None, None, None]) + if clear or r[1] is None: if comment[1] is not None: assert isinstance(comment[1], list) - l[1] = comment[1] + r[1] = comment[1] else: - l[1].extend(comment[0]) - l[0] = comment[0] + r[1].extend(comment[0]) + r[0] = comment[0] def yaml_value_comment_extend(self, key, comment, clear=False): # type: (Any, Any, bool) -> None - l = self.ca._items.setdefault(key, [None, None, None, None]) - if clear or l[3] is None: + r = self.ca._items.setdefault(key, [None, None, None, None]) + if clear or r[3] is None: if comment[1] is not None: assert isinstance(comment[1], list) - l[3] = comment[1] + r[3] = comment[1] else: - l[3].extend(comment[0]) - l[2] = comment[0] + r[3].extend(comment[0]) + r[2] = comment[0] def yaml_set_start_comment(self, comment, indent=0): # type: (Any, Any) -> None @@ -736,7 +736,7 @@ class CommentedMap(ordereddict, CommentedBase): # type: (Any, Any) -> Any try: return self.__getitem__(key) - except: + except: # NOQA return default def __repr__(self): @@ -15,7 +15,7 @@ _DEFAULT_YAML_VERSION = (1, 2) try: from ruamel.ordereddict import ordereddict -except: +except: # NOQA try: from collections import OrderedDict except ImportError: diff --git a/constructor.py b/constructor.py index 7769874..05aeb55 100644 --- a/constructor.py +++ b/constructor.py @@ -1438,7 +1438,7 @@ class RoundTripConstructor(SafeConstructor): data.yaml_set_tag(node.tag) yield data return - except: + except: # NOQA pass raise ConstructorError( None, None, @@ -1405,7 +1405,7 @@ class Emitter(object): data = data.encode(self.encoding) try: self.stream.write(data) - except: + except: # NOQA print(repr(data)) raise start = end @@ -32,7 +32,7 @@ if False: # MYPY try: from _ruamel_yaml import CParser, CEmitter # type: ignore -except: +except: # NOQA CParser = CEmitter = None # import io @@ -183,7 +183,7 @@ class Reader(object): # 4 if 32 bit unicode supported, 2 e.g. on MacOS (issue 56) try: re.compile(u'[^\U00010000]') - except: + except: # NOQA NON_PRINTABLE = RegExp( u'[^\x09\x0A\x0D\x20-\x7E\x85' u'\xA0-\uD7FF' diff --git a/serializer.py b/serializer.py index d6012db..c88539d 100644 --- a/serializer.py +++ b/serializer.py @@ -116,7 +116,7 @@ class Serializer(object): try: if node.anchor.always_dump: anchor = node.anchor.value - except: + except: # NOQA pass self.anchors[node] = anchor if isinstance(node, SequenceNode): @@ -131,7 +131,7 @@ class Serializer(object): # type: (Any) -> Any try: anchor = node.anchor.value - except: + except: # NOQA anchor = None if anchor is None: self.last_anchor_id += 1 @@ -51,6 +51,17 @@ if sys.version_info < (2, 7) or platform.python_implementation() == 'Jython': class Set(): pass +if os.environ.get('DVDEBUG', '') == '': + def debug(*args, **kw): + pass +else: + def debug(*args, **kw): + with open(os.environ['DVDEBUG'], 'a') as fp: + kw1 = kw.copy() + kw1['file'] = fp + print('{:%Y-%d-%mT%H:%M:%S}'.format(datetime.datetime.now()), file=fp, end=' ') + print(*args, **kw1) + def literal_eval(node_or_string): """ @@ -696,8 +707,9 @@ class NameSpacePackager(object): @property def ext_modules(self): - """check if all modules specified in the value for 'ext_modules' can be build - that value (if not None) is a list of dicts with 'name', 'src', 'lib' + """ + Check if all modules specified in the value for 'ext_modules' can be build. + That value (if not None) is a list of dicts with 'name', 'src', 'lib' Optional 'test' can be used to make sure trying to compile will work on the host creates and return the external modules as Extensions, unless that @@ -749,6 +761,7 @@ class NameSpacePackager(object): sources=[self.pn(x) for x in target['src']], libraries=[self.pn(x) for x in target.get('lib')], ) + # debug('test in target', 'test' in target, target) if 'test' not in target: # no test just hope it works self._ext_modules.append(ext) continue @@ -783,13 +796,16 @@ class NameSpacePackager(object): libraries=ext.libraries, ) except CompileError: + debug('compile error:', file_name) print('compile error:', file_name) continue except LinkError: + debug('libyaml link error', file_name) print('libyaml link error', file_name) continue self._ext_modules.append(ext) except Exception as e: # NOQA + debug('Exception:', e) print('Exception:', e) pass finally: @@ -814,7 +830,7 @@ class NameSpacePackager(object): fp.write('[bdist_wheel]\nuniversal = 1\n') try: setup(**kw) - except: + except Exception: raise finally: os.remove(file_name) @@ -877,7 +893,7 @@ def main(): try: with open('README.rst') as fp: kw['long_description'] = fp.read() - except: + except Exception: pass if nsp.wheel(kw, setup): return @@ -26,7 +26,7 @@ class Token(object): if SHOWLINES: try: arguments += u', line: ' + str(self.start_mark.line) - except: + except: # NOQA pass return u'{}({})'.format(self.__class__.__name__, arguments) @@ -259,6 +259,6 @@ class CommentToken(Token): if SHOWLINES: try: v += u', line: ' + str(self.start_mark.line) - except: + except: # NOQA pass return 'CommentToken({})'.format(v) @@ -1,15 +1,21 @@ [tox] -envlist = pep8,py36,py27,py35,py34,pypy +envlist = cs,py36,py27,py35,py34,pypy [testenv] commands = /bin/bash -c 'pytest _test/test_*.py' deps = pytest - flake8==3.3.0 + flake8==2.5.5 ruamel.std.pathlib +[testenv:cs] +basepython = python3.6 +commands = + flake8 --exclude .tox,jabsy,jinja2,base,cmd,convert{posargs} + [testenv:pep8] +basepython = python3.6 commands = flake8 --exclude .tox,jabsy,jinja2,base,cmd,convert{posargs} |