diff options
author | shadchin <shadchin@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:44:30 +0300 |
commit | 2598ef1d0aee359b4b6d5fdd1758916d5907d04f (patch) | |
tree | 012bb94d777798f1f56ac1cec429509766d05181 /contrib/python/PyYAML | |
parent | 6751af0b0c1b952fede40b19b71da8025b5d8bcf (diff) | |
download | ydb-2598ef1d0aee359b4b6d5fdd1758916d5907d04f.tar.gz |
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'contrib/python/PyYAML')
41 files changed, 1189 insertions, 1189 deletions
diff --git a/contrib/python/PyYAML/py2/.dist-info/METADATA b/contrib/python/PyYAML/py2/.dist-info/METADATA index 565f05b737..3e019fa6e0 100644 --- a/contrib/python/PyYAML/py2/.dist-info/METADATA +++ b/contrib/python/PyYAML/py2/.dist-info/METADATA @@ -1,46 +1,46 @@ -Metadata-Version: 2.1 -Name: PyYAML -Version: 5.4.1 -Summary: YAML parser and emitter for Python -Home-page: https://pyyaml.org/ -Author: Kirill Simonov -Author-email: xi@resolvent.net -License: MIT -Download-URL: https://pypi.org/project/PyYAML/ -Project-URL: Bug Tracker, https://github.com/yaml/pyyaml/issues -Project-URL: CI, https://github.com/yaml/pyyaml/actions -Project-URL: Documentation, https://pyyaml.org/wiki/PyYAMLDocumentation -Project-URL: Mailing lists, http://lists.sourceforge.net/lists/listinfo/yaml-core -Project-URL: Source Code, https://github.com/yaml/pyyaml -Platform: Any -Classifier: Development Status :: 5 - Production/Stable -Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Cython -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.6 -Classifier: Programming Language :: Python :: 3.7 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy -Classifier: Topic :: Software Development :: Libraries :: Python Modules -Classifier: Topic :: Text Processing :: Markup -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* - -YAML is a data serialization format designed for human readability -and interaction with scripting languages. PyYAML is a YAML parser -and emitter for Python. - -PyYAML features a complete YAML 1.1 parser, Unicode support, pickle -support, capable extension API, and sensible error messages. PyYAML -supports standard YAML tags and provides Python-specific tags that -allow to represent an arbitrary Python object. - -PyYAML is applicable for a broad range of tasks from complex -configuration files to object serialization and persistence. - +Metadata-Version: 2.1 +Name: PyYAML +Version: 5.4.1 +Summary: YAML parser and emitter for Python +Home-page: https://pyyaml.org/ +Author: Kirill Simonov +Author-email: xi@resolvent.net +License: MIT +Download-URL: https://pypi.org/project/PyYAML/ +Project-URL: Bug Tracker, https://github.com/yaml/pyyaml/issues +Project-URL: CI, https://github.com/yaml/pyyaml/actions +Project-URL: Documentation, https://pyyaml.org/wiki/PyYAMLDocumentation +Project-URL: Mailing lists, http://lists.sourceforge.net/lists/listinfo/yaml-core +Project-URL: Source Code, https://github.com/yaml/pyyaml +Platform: Any +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Cython +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: Implementation :: CPython +Classifier: Programming Language :: Python :: Implementation :: PyPy +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Classifier: Topic :: Text Processing :: Markup +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* + +YAML is a data serialization format designed for human readability +and interaction with scripting languages. PyYAML is a YAML parser +and emitter for Python. + +PyYAML features a complete YAML 1.1 parser, Unicode support, pickle +support, capable extension API, and sensible error messages. PyYAML +supports standard YAML tags and provides Python-specific tags that +allow to represent an arbitrary Python object. + +PyYAML is applicable for a broad range of tasks from complex +configuration files to object serialization and persistence. + diff --git a/contrib/python/PyYAML/py2/.dist-info/top_level.txt b/contrib/python/PyYAML/py2/.dist-info/top_level.txt index e6475e911f..a723c44d26 100644 --- a/contrib/python/PyYAML/py2/.dist-info/top_level.txt +++ b/contrib/python/PyYAML/py2/.dist-info/top_level.txt @@ -1,2 +1,2 @@ -_yaml -yaml +_yaml +yaml diff --git a/contrib/python/PyYAML/py2/LICENSE b/contrib/python/PyYAML/py2/LICENSE index 2f1b8e15e5..85dab73827 100644 --- a/contrib/python/PyYAML/py2/LICENSE +++ b/contrib/python/PyYAML/py2/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017-2021 Ingy döt Net +Copyright (c) 2017-2021 Ingy döt Net Copyright (c) 2006-2016 Kirill Simonov Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/contrib/python/PyYAML/py2/README b/contrib/python/PyYAML/py2/README index 49c87e7642..51245142cc 100644 --- a/contrib/python/PyYAML/py2/README +++ b/contrib/python/PyYAML/py2/README @@ -1,43 +1,43 @@ -PyYAML - The next generation YAML parser and emitter for Python. - -To install, type 'python setup.py install'. - -By default, the setup.py script checks whether LibYAML is installed -and if so, builds and installs LibYAML bindings. To skip the check -and force installation of LibYAML bindings, use the option '--with-libyaml': -'python setup.py --with-libyaml install'. To disable the check and -skip building and installing LibYAML bindings, use '--without-libyaml': -'python setup.py --without-libyaml install'. - -When LibYAML bindings are installed, you may use fast LibYAML-based -parser and emitter as follows: - - >>> yaml.load(stream, Loader=yaml.CLoader) - >>> yaml.dump(data, Dumper=yaml.CDumper) - -If you don't trust the input stream, you should use: - - >>> yaml.safe_load(stream) - -PyYAML includes a comprehensive test suite. To run the tests, -type 'python setup.py test'. - -For more information, check the PyYAML homepage: -'https://github.com/yaml/pyyaml'. - -For PyYAML tutorial and reference, see: -'http://pyyaml.org/wiki/PyYAMLDocumentation'. - -Discuss PyYAML with the maintainers in IRC #pyyaml irc.freenode.net. - -You may also use the YAML-Core mailing list: -'http://lists.sourceforge.net/lists/listinfo/yaml-core'. - -Submit bug reports and feature requests to the PyYAML bug tracker: -'https://github.com/yaml/pyyaml/issues'. - -The PyYAML module was written by Kirill Simonov <xi@resolvent.net>. -It is currently maintained by the YAML and Python communities. - -PyYAML is released under the MIT license. -See the file LICENSE for more details. +PyYAML - The next generation YAML parser and emitter for Python. + +To install, type 'python setup.py install'. + +By default, the setup.py script checks whether LibYAML is installed +and if so, builds and installs LibYAML bindings. To skip the check +and force installation of LibYAML bindings, use the option '--with-libyaml': +'python setup.py --with-libyaml install'. To disable the check and +skip building and installing LibYAML bindings, use '--without-libyaml': +'python setup.py --without-libyaml install'. + +When LibYAML bindings are installed, you may use fast LibYAML-based +parser and emitter as follows: + + >>> yaml.load(stream, Loader=yaml.CLoader) + >>> yaml.dump(data, Dumper=yaml.CDumper) + +If you don't trust the input stream, you should use: + + >>> yaml.safe_load(stream) + +PyYAML includes a comprehensive test suite. To run the tests, +type 'python setup.py test'. + +For more information, check the PyYAML homepage: +'https://github.com/yaml/pyyaml'. + +For PyYAML tutorial and reference, see: +'http://pyyaml.org/wiki/PyYAMLDocumentation'. + +Discuss PyYAML with the maintainers in IRC #pyyaml irc.freenode.net. + +You may also use the YAML-Core mailing list: +'http://lists.sourceforge.net/lists/listinfo/yaml-core'. + +Submit bug reports and feature requests to the PyYAML bug tracker: +'https://github.com/yaml/pyyaml/issues'. + +The PyYAML module was written by Kirill Simonov <xi@resolvent.net>. +It is currently maintained by the YAML and Python communities. + +PyYAML is released under the MIT license. +See the file LICENSE for more details. diff --git a/contrib/python/PyYAML/py2/_yaml/__init__.py b/contrib/python/PyYAML/py2/_yaml/__init__.py index 7baa8c4b68..fb6764718a 100644 --- a/contrib/python/PyYAML/py2/_yaml/__init__.py +++ b/contrib/python/PyYAML/py2/_yaml/__init__.py @@ -1,33 +1,33 @@ -# This is a stub package designed to roughly emulate the _yaml -# extension module, which previously existed as a standalone module -# and has been moved into the `yaml` package namespace. -# It does not perfectly mimic its old counterpart, but should get -# close enough for anyone who's relying on it even when they shouldn't. -import yaml - -# in some circumstances, the yaml module we imoprted may be from a different version, so we need -# to tread carefully when poking at it here (it may not have the attributes we expect) -if not getattr(yaml, '__with_libyaml__', False): - from sys import version_info - - exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError - raise exc("No module named '_yaml'") -else: - from yaml._yaml import * - import warnings - warnings.warn( - 'The _yaml extension module is now located at yaml._yaml' - ' and its location is subject to change. To use the' - ' LibYAML-based parser and emitter, import from `yaml`:' - ' `from yaml import CLoader as Loader, CDumper as Dumper`.', - DeprecationWarning - ) - del warnings - # Don't `del yaml` here because yaml is actually an existing - # namespace member of _yaml. - -__name__ = '_yaml' -# If the module is top-level (i.e. not a part of any specific package) -# then the attribute should be set to ''. -# https://docs.python.org/3.8/library/types.html -__package__ = '' +# This is a stub package designed to roughly emulate the _yaml +# extension module, which previously existed as a standalone module +# and has been moved into the `yaml` package namespace. +# It does not perfectly mimic its old counterpart, but should get +# close enough for anyone who's relying on it even when they shouldn't. +import yaml + +# in some circumstances, the yaml module we imoprted may be from a different version, so we need +# to tread carefully when poking at it here (it may not have the attributes we expect) +if not getattr(yaml, '__with_libyaml__', False): + from sys import version_info + + exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError + raise exc("No module named '_yaml'") +else: + from yaml._yaml import * + import warnings + warnings.warn( + 'The _yaml extension module is now located at yaml._yaml' + ' and its location is subject to change. To use the' + ' LibYAML-based parser and emitter, import from `yaml`:' + ' `from yaml import CLoader as Loader, CDumper as Dumper`.', + DeprecationWarning + ) + del warnings + # Don't `del yaml` here because yaml is actually an existing + # namespace member of _yaml. + +__name__ = '_yaml' +# If the module is top-level (i.e. not a part of any specific package) +# then the attribute should be set to ''. +# https://docs.python.org/3.8/library/types.html +__package__ = '' diff --git a/contrib/python/PyYAML/py2/ya.make b/contrib/python/PyYAML/py2/ya.make index 1ec5c0c301..55002f1130 100644 --- a/contrib/python/PyYAML/py2/ya.make +++ b/contrib/python/PyYAML/py2/ya.make @@ -2,21 +2,21 @@ PY2_LIBRARY() LICENSE(MIT) -VERSION(5.4.1) +VERSION(5.4.1) OWNER(g:python-contrib borman g:testenv) -PEERDIR( - contrib/libs/yaml -) +PEERDIR( + contrib/libs/yaml +) -ADDINCL( - contrib/python/PyYAML/py2/yaml -) +ADDINCL( + contrib/python/PyYAML/py2/yaml +) PY_SRCS( TOP_LEVEL - _yaml/__init__.py + _yaml/__init__.py yaml/__init__.py yaml/composer.py yaml/constructor.py @@ -34,18 +34,18 @@ PY_SRCS( yaml/scanner.py yaml/serializer.py yaml/tokens.py - CYTHON_C - yaml/_yaml.pyx -) - -RESOURCE_FILES( - PREFIX contrib/python/PyYAML/ - .dist-info/METADATA - .dist-info/top_level.txt + CYTHON_C + yaml/_yaml.pyx ) +RESOURCE_FILES( + PREFIX contrib/python/PyYAML/ + .dist-info/METADATA + .dist-info/top_level.txt +) + NO_LINT() -NO_COMPILER_WARNINGS() - +NO_COMPILER_WARNINGS() + END() diff --git a/contrib/python/PyYAML/py2/yaml/__init__.py b/contrib/python/PyYAML/py2/yaml/__init__.py index 3c988198d5..72d4f23eff 100644 --- a/contrib/python/PyYAML/py2/yaml/__init__.py +++ b/contrib/python/PyYAML/py2/yaml/__init__.py @@ -8,7 +8,7 @@ from nodes import * from loader import * from dumper import * -__version__ = '5.4.1' +__version__ = '5.4.1' try: from cyaml import * @@ -16,45 +16,45 @@ try: except ImportError: __with_libyaml__ = False - -#------------------------------------------------------------------------------ -# Warnings control -#------------------------------------------------------------------------------ - -# 'Global' warnings state: -_warnings_enabled = { - 'YAMLLoadWarning': True, -} - -# Get or set global warnings' state -def warnings(settings=None): - if settings is None: - return _warnings_enabled - - if type(settings) is dict: - for key in settings: - if key in _warnings_enabled: - _warnings_enabled[key] = settings[key] - -# Warn when load() is called without Loader=... -class YAMLLoadWarning(RuntimeWarning): - pass - -def load_warning(method): - if _warnings_enabled['YAMLLoadWarning'] is False: - return - - import warnings - - message = ( - "calling yaml.%s() without Loader=... is deprecated, as the " - "default Loader is unsafe. Please read " - "https://msg.pyyaml.org/load for full details." - ) % method - - warnings.warn(message, YAMLLoadWarning, stacklevel=3) - -#------------------------------------------------------------------------------ + +#------------------------------------------------------------------------------ +# Warnings control +#------------------------------------------------------------------------------ + +# 'Global' warnings state: +_warnings_enabled = { + 'YAMLLoadWarning': True, +} + +# Get or set global warnings' state +def warnings(settings=None): + if settings is None: + return _warnings_enabled + + if type(settings) is dict: + for key in settings: + if key in _warnings_enabled: + _warnings_enabled[key] = settings[key] + +# Warn when load() is called without Loader=... +class YAMLLoadWarning(RuntimeWarning): + pass + +def load_warning(method): + if _warnings_enabled['YAMLLoadWarning'] is False: + return + + import warnings + + message = ( + "calling yaml.%s() without Loader=... is deprecated, as the " + "default Loader is unsafe. Please read " + "https://msg.pyyaml.org/load for full details." + ) % method + + warnings.warn(message, YAMLLoadWarning, stacklevel=3) + +#------------------------------------------------------------------------------ def scan(stream, Loader=Loader): """ Scan a YAML stream and produce scanning tokens. @@ -100,30 +100,30 @@ def compose_all(stream, Loader=Loader): finally: loader.dispose() -def load(stream, Loader=None): +def load(stream, Loader=None): """ Parse the first YAML document in a stream and produce the corresponding Python object. """ - if Loader is None: - load_warning('load') - Loader = FullLoader - + if Loader is None: + load_warning('load') + Loader = FullLoader + loader = Loader(stream) try: return loader.get_single_data() finally: loader.dispose() -def load_all(stream, Loader=None): +def load_all(stream, Loader=None): """ Parse all YAML documents in a stream and produce corresponding Python objects. """ - if Loader is None: - load_warning('load_all') - Loader = FullLoader - + if Loader is None: + load_warning('load_all') + Loader = FullLoader + loader = Loader(stream) try: while loader.check_data(): @@ -131,33 +131,33 @@ def load_all(stream, Loader=None): finally: loader.dispose() -def full_load(stream): - """ - Parse the first YAML document in a stream - and produce the corresponding Python object. - - Resolve all tags except those known to be - unsafe on untrusted input. - """ - return load(stream, FullLoader) - -def full_load_all(stream): - """ - Parse all YAML documents in a stream - and produce corresponding Python objects. - - Resolve all tags except those known to be - unsafe on untrusted input. - """ - return load_all(stream, FullLoader) - +def full_load(stream): + """ + Parse the first YAML document in a stream + and produce the corresponding Python object. + + Resolve all tags except those known to be + unsafe on untrusted input. + """ + return load(stream, FullLoader) + +def full_load_all(stream): + """ + Parse all YAML documents in a stream + and produce corresponding Python objects. + + Resolve all tags except those known to be + unsafe on untrusted input. + """ + return load_all(stream, FullLoader) + def safe_load(stream): """ Parse the first YAML document in a stream and produce the corresponding Python object. - - Resolve only basic YAML tags. This is known - to be safe for untrusted input. + + Resolve only basic YAML tags. This is known + to be safe for untrusted input. """ return load(stream, SafeLoader) @@ -165,32 +165,32 @@ def safe_load_all(stream): """ Parse all YAML documents in a stream and produce corresponding Python objects. - - Resolve only basic YAML tags. This is known - to be safe for untrusted input. + + Resolve only basic YAML tags. This is known + to be safe for untrusted input. """ return load_all(stream, SafeLoader) -def unsafe_load(stream): - """ - Parse the first YAML document in a stream - and produce the corresponding Python object. - - Resolve all tags, even those known to be - unsafe on untrusted input. - """ - return load(stream, UnsafeLoader) - -def unsafe_load_all(stream): - """ - Parse all YAML documents in a stream - and produce corresponding Python objects. - - Resolve all tags, even those known to be - unsafe on untrusted input. - """ - return load_all(stream, UnsafeLoader) - +def unsafe_load(stream): + """ + Parse the first YAML document in a stream + and produce the corresponding Python object. + + Resolve all tags, even those known to be + unsafe on untrusted input. + """ + return load(stream, UnsafeLoader) + +def unsafe_load_all(stream): + """ + Parse all YAML documents in a stream + and produce corresponding Python objects. + + Resolve all tags, even those known to be + unsafe on untrusted input. + """ + return load_all(stream, UnsafeLoader) + def emit(events, stream=None, Dumper=Dumper, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None): @@ -252,11 +252,11 @@ def serialize(node, stream=None, Dumper=Dumper, **kwds): return serialize_all([node], stream, Dumper=Dumper, **kwds) def dump_all(documents, stream=None, Dumper=Dumper, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding='utf-8', explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): """ Serialize a sequence of Python objects into a YAML stream. If stream is None, return the produced string instead. @@ -274,7 +274,7 @@ def dump_all(documents, stream=None, Dumper=Dumper, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break, encoding=encoding, version=version, tags=tags, - explicit_start=explicit_start, explicit_end=explicit_end, sort_keys=sort_keys) + explicit_start=explicit_start, explicit_end=explicit_end, sort_keys=sort_keys) try: dumper.open() for data in documents: @@ -309,62 +309,62 @@ def safe_dump(data, stream=None, **kwds): return dump_all([data], stream, Dumper=SafeDumper, **kwds) def add_implicit_resolver(tag, regexp, first=None, - Loader=None, Dumper=Dumper): + Loader=None, Dumper=Dumper): """ Add an implicit scalar detector. If an implicit scalar value matches the given regexp, the corresponding tag is assigned to the scalar. first is a sequence of possible initial characters or None. """ - if Loader is None: - loader.Loader.add_implicit_resolver(tag, regexp, first) - loader.FullLoader.add_implicit_resolver(tag, regexp, first) - loader.UnsafeLoader.add_implicit_resolver(tag, regexp, first) - else: - Loader.add_implicit_resolver(tag, regexp, first) + if Loader is None: + loader.Loader.add_implicit_resolver(tag, regexp, first) + loader.FullLoader.add_implicit_resolver(tag, regexp, first) + loader.UnsafeLoader.add_implicit_resolver(tag, regexp, first) + else: + Loader.add_implicit_resolver(tag, regexp, first) Dumper.add_implicit_resolver(tag, regexp, first) -def add_path_resolver(tag, path, kind=None, Loader=None, Dumper=Dumper): +def add_path_resolver(tag, path, kind=None, Loader=None, Dumper=Dumper): """ Add a path based resolver for the given tag. A path is a list of keys that forms a path to a node in the representation tree. Keys can be string values, integers, or None. """ - if Loader is None: - loader.Loader.add_path_resolver(tag, path, kind) - loader.FullLoader.add_path_resolver(tag, path, kind) - loader.UnsafeLoader.add_path_resolver(tag, path, kind) - else: - Loader.add_path_resolver(tag, path, kind) + if Loader is None: + loader.Loader.add_path_resolver(tag, path, kind) + loader.FullLoader.add_path_resolver(tag, path, kind) + loader.UnsafeLoader.add_path_resolver(tag, path, kind) + else: + Loader.add_path_resolver(tag, path, kind) Dumper.add_path_resolver(tag, path, kind) -def add_constructor(tag, constructor, Loader=None): +def add_constructor(tag, constructor, Loader=None): """ Add a constructor for the given tag. Constructor is a function that accepts a Loader instance and a node object and produces the corresponding Python object. """ - if Loader is None: - loader.Loader.add_constructor(tag, constructor) - loader.FullLoader.add_constructor(tag, constructor) - loader.UnsafeLoader.add_constructor(tag, constructor) - else: - Loader.add_constructor(tag, constructor) + if Loader is None: + loader.Loader.add_constructor(tag, constructor) + loader.FullLoader.add_constructor(tag, constructor) + loader.UnsafeLoader.add_constructor(tag, constructor) + else: + Loader.add_constructor(tag, constructor) -def add_multi_constructor(tag_prefix, multi_constructor, Loader=None): +def add_multi_constructor(tag_prefix, multi_constructor, Loader=None): """ Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object. """ - if Loader is None: - loader.Loader.add_multi_constructor(tag_prefix, multi_constructor) - loader.FullLoader.add_multi_constructor(tag_prefix, multi_constructor) - loader.UnsafeLoader.add_multi_constructor(tag_prefix, multi_constructor) - else: - Loader.add_multi_constructor(tag_prefix, multi_constructor) + if Loader is None: + loader.Loader.add_multi_constructor(tag_prefix, multi_constructor) + loader.FullLoader.add_multi_constructor(tag_prefix, multi_constructor) + loader.UnsafeLoader.add_multi_constructor(tag_prefix, multi_constructor) + else: + Loader.add_multi_constructor(tag_prefix, multi_constructor) def add_representer(data_type, representer, Dumper=Dumper): """ @@ -391,12 +391,12 @@ class YAMLObjectMetaclass(type): def __init__(cls, name, bases, kwds): super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None: - if isinstance(cls.yaml_loader, list): - for loader in cls.yaml_loader: - loader.add_constructor(cls.yaml_tag, cls.from_yaml) - else: - cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) - + if isinstance(cls.yaml_loader, list): + for loader in cls.yaml_loader: + loader.add_constructor(cls.yaml_tag, cls.from_yaml) + else: + cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) + cls.yaml_dumper.add_representer(cls, cls.to_yaml) class YAMLObject(object): @@ -408,7 +408,7 @@ class YAMLObject(object): __metaclass__ = YAMLObjectMetaclass __slots__ = () # no direct instantiation, so allow immutable subclasses - yaml_loader = [Loader, FullLoader, UnsafeLoader] + yaml_loader = [Loader, FullLoader, UnsafeLoader] yaml_dumper = Dumper yaml_tag = None diff --git a/contrib/python/PyYAML/py2/yaml/_yaml.h b/contrib/python/PyYAML/py2/yaml/_yaml.h index 21fd6a991b..2d593e7f70 100644 --- a/contrib/python/PyYAML/py2/yaml/_yaml.h +++ b/contrib/python/PyYAML/py2/yaml/_yaml.h @@ -3,7 +3,7 @@ #if PY_MAJOR_VERSION < 3 -#define PyUnicode_FromString(s) PyUnicode_DecodeUTF8((s), strlen(s), "strict") +#define PyUnicode_FromString(s) PyUnicode_DecodeUTF8((s), strlen(s), "strict") #else diff --git a/contrib/python/PyYAML/py2/yaml/_yaml.pxd b/contrib/python/PyYAML/py2/yaml/_yaml.pxd index 7937c9db51..e6913b5847 100644 --- a/contrib/python/PyYAML/py2/yaml/_yaml.pxd +++ b/contrib/python/PyYAML/py2/yaml/_yaml.pxd @@ -1,5 +1,5 @@ -cdef extern from "_yaml.h": +cdef extern from "_yaml.h": void malloc(int l) void memcpy(char *d, char *s, int l) @@ -85,22 +85,22 @@ cdef extern from "_yaml.h": YAML_MAPPING_START_EVENT YAML_MAPPING_END_EVENT - ctypedef int yaml_read_handler_t(void *data, char *buffer, + ctypedef int yaml_read_handler_t(void *data, char *buffer, size_t size, size_t *size_read) except 0 - ctypedef int yaml_write_handler_t(void *data, char *buffer, + ctypedef int yaml_write_handler_t(void *data, char *buffer, size_t size) except 0 ctypedef struct yaml_mark_t: - size_t index - size_t line - size_t column + size_t index + size_t line + size_t column ctypedef struct yaml_version_directive_t: int major int minor ctypedef struct yaml_tag_directive_t: - char *handle - char *prefix + char *handle + char *prefix ctypedef struct _yaml_token_stream_start_data_t: yaml_encoding_t encoding @@ -109,18 +109,18 @@ cdef extern from "_yaml.h": ctypedef struct _yaml_token_anchor_data_t: char *value ctypedef struct _yaml_token_tag_data_t: - char *handle - char *suffix + char *handle + char *suffix ctypedef struct _yaml_token_scalar_data_t: char *value - size_t length + size_t length yaml_scalar_style_t style ctypedef struct _yaml_token_version_directive_data_t: int major int minor ctypedef struct _yaml_token_tag_directive_data_t: - char *handle - char *prefix + char *handle + char *prefix ctypedef union _yaml_token_data_t: _yaml_token_stream_start_data_t stream_start _yaml_token_alias_data_t alias @@ -152,7 +152,7 @@ cdef extern from "_yaml.h": char *anchor char *tag char *value - size_t length + size_t length int plain_implicit int quoted_implicit yaml_scalar_style_t style @@ -183,7 +183,7 @@ cdef extern from "_yaml.h": ctypedef struct yaml_parser_t: yaml_error_type_t error char *problem - size_t problem_offset + size_t problem_offset int problem_value yaml_mark_t problem_mark char *context @@ -208,23 +208,23 @@ cdef extern from "_yaml.h": int implicit) int yaml_document_end_event_initialize(yaml_event_t *event, int implicit) - int yaml_alias_event_initialize(yaml_event_t *event, char *anchor) + int yaml_alias_event_initialize(yaml_event_t *event, char *anchor) int yaml_scalar_event_initialize(yaml_event_t *event, - char *anchor, char *tag, char *value, size_t length, + char *anchor, char *tag, char *value, size_t length, int plain_implicit, int quoted_implicit, yaml_scalar_style_t style) int yaml_sequence_start_event_initialize(yaml_event_t *event, - char *anchor, char *tag, int implicit, yaml_sequence_style_t style) + char *anchor, char *tag, int implicit, yaml_sequence_style_t style) int yaml_sequence_end_event_initialize(yaml_event_t *event) int yaml_mapping_start_event_initialize(yaml_event_t *event, - char *anchor, char *tag, int implicit, yaml_mapping_style_t style) + char *anchor, char *tag, int implicit, yaml_mapping_style_t style) int yaml_mapping_end_event_initialize(yaml_event_t *event) void yaml_event_delete(yaml_event_t *event) int yaml_parser_initialize(yaml_parser_t *parser) void yaml_parser_delete(yaml_parser_t *parser) void yaml_parser_set_input_string(yaml_parser_t *parser, - char *input, size_t size) + char *input, size_t size) void yaml_parser_set_input(yaml_parser_t *parser, yaml_read_handler_t *handler, void *data) void yaml_parser_set_encoding(yaml_parser_t *parser, @@ -235,7 +235,7 @@ cdef extern from "_yaml.h": int yaml_emitter_initialize(yaml_emitter_t *emitter) void yaml_emitter_delete(yaml_emitter_t *emitter) void yaml_emitter_set_output_string(yaml_emitter_t *emitter, - char *output, size_t size, size_t *size_written) + char *output, size_t size, size_t *size_written) void yaml_emitter_set_output(yaml_emitter_t *emitter, yaml_write_handler_t *handler, void *data) void yaml_emitter_set_encoding(yaml_emitter_t *emitter, diff --git a/contrib/python/PyYAML/py2/yaml/_yaml.pyx b/contrib/python/PyYAML/py2/yaml/_yaml.pyx index ff4efe80b5..9a8daeecbf 100644 --- a/contrib/python/PyYAML/py2/yaml/_yaml.pyx +++ b/contrib/python/PyYAML/py2/yaml/_yaml.pyx @@ -2,7 +2,7 @@ import yaml def get_version_string(): - cdef char *value + cdef char *value value = yaml_get_version_string() if PY_MAJOR_VERSION < 3: return value @@ -63,13 +63,13 @@ MappingNode = yaml.nodes.MappingNode cdef class Mark: cdef readonly object name - cdef readonly size_t index - cdef readonly size_t line - cdef readonly size_t column + cdef readonly size_t index + cdef readonly size_t line + cdef readonly size_t column cdef readonly buffer cdef readonly pointer - def __init__(self, object name, size_t index, size_t line, size_t column, + def __init__(self, object name, size_t index, size_t line, size_t column, object buffer, object pointer): self.name = name self.index = index @@ -255,8 +255,8 @@ cdef class CParser: cdef object current_event cdef object anchors cdef object stream_cache - cdef int stream_cache_len - cdef int stream_cache_pos + cdef int stream_cache_len + cdef int stream_cache_pos cdef int unicode_source def __init__(self, stream): @@ -302,7 +302,7 @@ cdef class CParser: else: raise TypeError(u"a string or stream input is required") self.stream = stream - yaml_parser_set_input_string(&self.parser, PyString_AS_STRING(stream), PyString_GET_SIZE(stream)) + yaml_parser_set_input_string(&self.parser, PyString_AS_STRING(stream), PyString_GET_SIZE(stream)) self.current_token = None self.current_event = None self.anchors = {} @@ -414,8 +414,8 @@ cdef class CParser: token.data.version_directive.minor), start_mark, end_mark) elif token.type == YAML_TAG_DIRECTIVE_TOKEN: - handle = PyUnicode_FromString(token.data.tag_directive.handle) - prefix = PyUnicode_FromString(token.data.tag_directive.prefix) + handle = PyUnicode_FromString(token.data.tag_directive.handle) + prefix = PyUnicode_FromString(token.data.tag_directive.prefix) return DirectiveToken(u"TAG", (handle, prefix), start_mark, end_mark) elif token.type == YAML_DOCUMENT_START_TOKEN: @@ -451,13 +451,13 @@ cdef class CParser: value = PyUnicode_FromString(token.data.anchor.value) return AnchorToken(value, start_mark, end_mark) elif token.type == YAML_TAG_TOKEN: - handle = PyUnicode_FromString(token.data.tag.handle) - suffix = PyUnicode_FromString(token.data.tag.suffix) + handle = PyUnicode_FromString(token.data.tag.handle) + suffix = PyUnicode_FromString(token.data.tag.suffix) if not handle: handle = None return TagToken((handle, suffix), start_mark, end_mark) elif token.type == YAML_SCALAR_TOKEN: - value = PyUnicode_DecodeUTF8(token.data.scalar.value, + value = PyUnicode_DecodeUTF8(token.data.scalar.value, token.data.scalar.length, 'strict') plain = False style = None @@ -571,8 +571,8 @@ cdef class CParser: tags = {} tag_directive = event.data.document_start.tag_directives.start while tag_directive != event.data.document_start.tag_directives.end: - handle = PyUnicode_FromString(tag_directive.handle) - prefix = PyUnicode_FromString(tag_directive.prefix) + handle = PyUnicode_FromString(tag_directive.handle) + prefix = PyUnicode_FromString(tag_directive.prefix) tags[handle] = prefix tag_directive = tag_directive+1 return DocumentStartEvent(start_mark, end_mark, @@ -592,7 +592,7 @@ cdef class CParser: tag = None if event.data.scalar.tag != NULL: tag = PyUnicode_FromString(event.data.scalar.tag) - value = PyUnicode_DecodeUTF8(event.data.scalar.value, + value = PyUnicode_DecodeUTF8(event.data.scalar.value, event.data.scalar.length, 'strict') plain_implicit = False if event.data.scalar.plain_implicit == 1: @@ -762,11 +762,11 @@ cdef class CParser: self.parsed_event.start_mark.column, None, None) if PY_MAJOR_VERSION < 3: - raise ComposerError("found duplicate anchor; first occurrence", - self.anchors[anchor].start_mark, "second occurrence", mark) + raise ComposerError("found duplicate anchor; first occurrence", + self.anchors[anchor].start_mark, "second occurrence", mark) else: - raise ComposerError(u"found duplicate anchor; first occurrence", - self.anchors[anchor].start_mark, u"second occurrence", mark) + raise ComposerError(u"found duplicate anchor; first occurrence", + self.anchors[anchor].start_mark, u"second occurrence", mark) self.descend_resolver(parent, index) if self.parsed_event.type == YAML_SCALAR_EVENT: node = self._compose_scalar_node(anchor) @@ -788,7 +788,7 @@ cdef class CParser: self.parsed_event.end_mark.line, self.parsed_event.end_mark.column, None, None) - value = PyUnicode_DecodeUTF8(self.parsed_event.data.scalar.value, + value = PyUnicode_DecodeUTF8(self.parsed_event.data.scalar.value, self.parsed_event.data.scalar.length, 'strict') plain_implicit = False if self.parsed_event.data.scalar.plain_implicit == 1: @@ -905,7 +905,7 @@ cdef class CParser: raise error return 1 -cdef int input_handler(void *data, char *buffer, size_t size, size_t *read) except 0: +cdef int input_handler(void *data, char *buffer, size_t size, size_t *read) except 0: cdef CParser parser parser = <CParser>data if parser.stream_cache is None: @@ -924,7 +924,7 @@ cdef int input_handler(void *data, char *buffer, size_t size, size_t *read) exce if (parser.stream_cache_len - parser.stream_cache_pos) < size: size = parser.stream_cache_len - parser.stream_cache_pos if size > 0: - memcpy(buffer, PyString_AS_STRING(parser.stream_cache) + memcpy(buffer, PyString_AS_STRING(parser.stream_cache) + parser.stream_cache_pos, size) read[0] = size parser.stream_cache_pos += size @@ -964,7 +964,7 @@ cdef class CEmitter: if hasattr(stream, u'encoding'): self.dump_unicode = 1 self.use_encoding = encoding - yaml_emitter_set_output(&self.emitter, output_handler, <void *>self) + yaml_emitter_set_output(&self.emitter, output_handler, <void *>self) if canonical: yaml_emitter_set_canonical(&self.emitter, 1) if indent is not None: @@ -1071,7 +1071,7 @@ cdef class CEmitter: raise TypeError("tag handle must be a string") else: raise TypeError(u"tag handle must be a string") - tag_directives_end.handle = PyString_AS_STRING(handle) + tag_directives_end.handle = PyString_AS_STRING(handle) if PyUnicode_CheckExact(prefix): prefix = PyUnicode_AsUTF8String(prefix) cache.append(prefix) @@ -1080,7 +1080,7 @@ cdef class CEmitter: raise TypeError("tag prefix must be a string") else: raise TypeError(u"tag prefix must be a string") - tag_directives_end.prefix = PyString_AS_STRING(prefix) + tag_directives_end.prefix = PyString_AS_STRING(prefix) tag_directives_end = tag_directives_end+1 implicit = 1 if event_object.explicit: @@ -1104,7 +1104,7 @@ cdef class CEmitter: else: raise TypeError(u"anchor must be a string") anchor = PyString_AS_STRING(anchor_object) - if yaml_alias_event_initialize(event, anchor) == 0: + if yaml_alias_event_initialize(event, anchor) == 0: raise MemoryError elif event_class is ScalarEvent: anchor = NULL @@ -1154,7 +1154,7 @@ cdef class CEmitter: scalar_style = YAML_LITERAL_SCALAR_STYLE elif style_object == ">" or style_object == u">": scalar_style = YAML_FOLDED_SCALAR_STYLE - if yaml_scalar_event_initialize(event, anchor, tag, value, length, + if yaml_scalar_event_initialize(event, anchor, tag, value, length, plain_implicit, quoted_implicit, scalar_style) == 0: raise MemoryError elif event_class is SequenceStartEvent: @@ -1186,7 +1186,7 @@ cdef class CEmitter: sequence_style = YAML_BLOCK_SEQUENCE_STYLE if event_object.flow_style: sequence_style = YAML_FLOW_SEQUENCE_STYLE - if yaml_sequence_start_event_initialize(event, anchor, tag, + if yaml_sequence_start_event_initialize(event, anchor, tag, implicit, sequence_style) == 0: raise MemoryError elif event_class is MappingStartEvent: @@ -1218,7 +1218,7 @@ cdef class CEmitter: mapping_style = YAML_BLOCK_MAPPING_STYLE if event_object.flow_style: mapping_style = YAML_FLOW_MAPPING_STYLE - if yaml_mapping_start_event_initialize(event, anchor, tag, + if yaml_mapping_start_event_initialize(event, anchor, tag, implicit, mapping_style) == 0: raise MemoryError elif event_class is SequenceEndEvent: @@ -1326,7 +1326,7 @@ cdef class CEmitter: raise TypeError("tag handle must be a string") else: raise TypeError(u"tag handle must be a string") - tag_directives_end.handle = PyString_AS_STRING(handle) + tag_directives_end.handle = PyString_AS_STRING(handle) if PyUnicode_CheckExact(prefix): prefix = PyUnicode_AsUTF8String(prefix) cache.append(prefix) @@ -1335,7 +1335,7 @@ cdef class CEmitter: raise TypeError("tag prefix must be a string") else: raise TypeError(u"tag prefix must be a string") - tag_directives_end.prefix = PyString_AS_STRING(prefix) + tag_directives_end.prefix = PyString_AS_STRING(prefix) tag_directives_end = tag_directives_end+1 if yaml_document_start_event_initialize(&event, version_directive, tag_directives_start, tag_directives_end, @@ -1396,7 +1396,7 @@ cdef class CEmitter: raise TypeError(u"anchor must be a string") anchor = PyString_AS_STRING(anchor_object) if node in self.serialized_nodes: - if yaml_alias_event_initialize(&event, anchor) == 0: + if yaml_alias_event_initialize(&event, anchor) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: error = self._emitter_error() @@ -1443,7 +1443,7 @@ cdef class CEmitter: scalar_style = YAML_LITERAL_SCALAR_STYLE elif style_object == ">" or style_object == u">": scalar_style = YAML_FOLDED_SCALAR_STYLE - if yaml_scalar_event_initialize(&event, anchor, tag, value, length, + if yaml_scalar_event_initialize(&event, anchor, tag, value, length, plain_implicit, quoted_implicit, scalar_style) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: @@ -1467,7 +1467,7 @@ cdef class CEmitter: sequence_style = YAML_BLOCK_SEQUENCE_STYLE if node.flow_style: sequence_style = YAML_FLOW_SEQUENCE_STYLE - if yaml_sequence_start_event_initialize(&event, anchor, tag, + if yaml_sequence_start_event_initialize(&event, anchor, tag, implicit, sequence_style) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: @@ -1499,7 +1499,7 @@ cdef class CEmitter: mapping_style = YAML_BLOCK_MAPPING_STYLE if node.flow_style: mapping_style = YAML_FLOW_MAPPING_STYLE - if yaml_mapping_start_event_initialize(&event, anchor, tag, + if yaml_mapping_start_event_initialize(&event, anchor, tag, implicit, mapping_style) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: @@ -1515,13 +1515,13 @@ cdef class CEmitter: self.ascend_resolver() return 1 -cdef int output_handler(void *data, char *buffer, size_t size) except 0: +cdef int output_handler(void *data, char *buffer, size_t size) except 0: cdef CEmitter emitter emitter = <CEmitter>data if emitter.dump_unicode == 0: - value = PyString_FromStringAndSize(buffer, size) + value = PyString_FromStringAndSize(buffer, size) else: - value = PyUnicode_DecodeUTF8(buffer, size, 'strict') + value = PyUnicode_DecodeUTF8(buffer, size, 'strict') emitter.stream.write(value) return 1 diff --git a/contrib/python/PyYAML/py2/yaml/composer.py b/contrib/python/PyYAML/py2/yaml/composer.py index df85ef653b..5ace29064f 100644 --- a/contrib/python/PyYAML/py2/yaml/composer.py +++ b/contrib/python/PyYAML/py2/yaml/composer.py @@ -72,9 +72,9 @@ class Composer(object): anchor = event.anchor if anchor is not None: if anchor in self.anchors: - raise ComposerError("found duplicate anchor %r; first occurrence" + raise ComposerError("found duplicate anchor %r; first occurrence" % anchor.encode('utf-8'), self.anchors[anchor].start_mark, - "second occurrence", event.start_mark) + "second occurrence", event.start_mark) self.descend_resolver(parent, index) if self.check_event(ScalarEvent): node = self.compose_scalar_node(anchor) diff --git a/contrib/python/PyYAML/py2/yaml/constructor.py b/contrib/python/PyYAML/py2/yaml/constructor.py index ff4e36828e..41144077b0 100644 --- a/contrib/python/PyYAML/py2/yaml/constructor.py +++ b/contrib/python/PyYAML/py2/yaml/constructor.py @@ -1,12 +1,12 @@ -__all__ = [ - 'BaseConstructor', - 'SafeConstructor', - 'FullConstructor', - 'UnsafeConstructor', - 'Constructor', - 'ConstructorError' -] +__all__ = [ + 'BaseConstructor', + 'SafeConstructor', + 'FullConstructor', + 'UnsafeConstructor', + 'Constructor', + 'ConstructorError' +] from error import * from nodes import * @@ -18,35 +18,35 @@ import binascii, re, sys, types class ConstructorError(MarkedYAMLError): pass - -class timezone(datetime.tzinfo): - def __init__(self, offset): - self._offset = offset - seconds = abs(offset).total_seconds() - self._name = 'UTC%s%02d:%02d' % ( - '-' if offset.days < 0 else '+', - seconds // 3600, - seconds % 3600 // 60 - ) - - def tzname(self, dt=None): - return self._name - - def utcoffset(self, dt=None): - return self._offset - - def dst(self, dt=None): - return datetime.timedelta(0) - - def __copy__(self): - return self.__deepcopy__() - - def __deepcopy__(self, memodict={}): - return self.__class__(self.utcoffset()) - - __repr__ = __str__ = tzname - - + +class timezone(datetime.tzinfo): + def __init__(self, offset): + self._offset = offset + seconds = abs(offset).total_seconds() + self._name = 'UTC%s%02d:%02d' % ( + '-' if offset.days < 0 else '+', + seconds // 3600, + seconds % 3600 // 60 + ) + + def tzname(self, dt=None): + return self._name + + def utcoffset(self, dt=None): + return self._offset + + def dst(self, dt=None): + return datetime.timedelta(0) + + def __copy__(self): + return self.__deepcopy__() + + def __deepcopy__(self, memodict={}): + return self.__class__(self.utcoffset()) + + __repr__ = __str__ = tzname + + class BaseConstructor(object): yaml_constructors = {} @@ -62,14 +62,14 @@ class BaseConstructor(object): # If there are more documents available? return self.check_node() - def check_state_key(self, key): - """Block special attributes/methods from being set in a newly created - object, to prevent user-controlled methods from being called during - deserialization""" - if self.get_state_keys_blacklist_regexp().match(key): - raise ConstructorError(None, None, - "blacklisted key '%s' in instance state found" % (key,), None) - + def check_state_key(self, key): + """Block special attributes/methods from being set in a newly created + object, to prevent user-controlled methods from being called during + deserialization""" + if self.get_state_keys_blacklist_regexp().match(key): + raise ConstructorError(None, None, + "blacklisted key '%s' in instance state found" % (key,), None) + def get_data(self): # Construct and return the next document. if self.check_node(): @@ -111,7 +111,7 @@ class BaseConstructor(object): constructor = self.yaml_constructors[node.tag] else: for tag_prefix in self.yaml_multi_constructors: - if tag_prefix is not None and node.tag.startswith(tag_prefix): + if tag_prefix is not None and node.tag.startswith(tag_prefix): tag_suffix = node.tag[len(tag_prefix):] constructor = self.yaml_multi_constructors[tag_prefix] break @@ -330,7 +330,7 @@ class SafeConstructor(BaseConstructor): return str(value).decode('base64') except (binascii.Error, UnicodeEncodeError), exc: raise ConstructorError(None, None, - "failed to decode base64 data: %s" % exc, node.start_mark) + "failed to decode base64 data: %s" % exc, node.start_mark) timestamp_regexp = re.compile( ur'''^(?P<year>[0-9][0-9][0-9][0-9]) @@ -357,7 +357,7 @@ class SafeConstructor(BaseConstructor): minute = int(values['minute']) second = int(values['second']) fraction = 0 - tzinfo = None + tzinfo = None if values['fraction']: fraction = values['fraction'][:6] while len(fraction) < 6: @@ -369,11 +369,11 @@ class SafeConstructor(BaseConstructor): delta = datetime.timedelta(hours=tz_hour, minutes=tz_minute) if values['tz_sign'] == '-': delta = -delta - tzinfo = timezone(delta) - elif values['tz']: - tzinfo = timezone(datetime.timedelta(0)) - return datetime.datetime(year, month, day, hour, minute, second, fraction, - tzinfo=tzinfo) + tzinfo = timezone(delta) + elif values['tz']: + tzinfo = timezone(datetime.timedelta(0)) + return datetime.datetime(year, month, day, hour, minute, second, fraction, + tzinfo=tzinfo) def construct_yaml_omap(self, node): # Note: we do not check for duplicate keys, because it's too @@ -508,18 +508,18 @@ SafeConstructor.add_constructor( SafeConstructor.add_constructor(None, SafeConstructor.construct_undefined) -class FullConstructor(SafeConstructor): - # 'extend' is blacklisted because it is used by - # construct_python_object_apply to add `listitems` to a newly generate - # python instance - def get_state_keys_blacklist(self): - return ['^extend$', '^__.*__$'] - - def get_state_keys_blacklist_regexp(self): - if not hasattr(self, 'state_keys_blacklist_regexp'): - self.state_keys_blacklist_regexp = re.compile('(' + '|'.join(self.get_state_keys_blacklist()) + ')') - return self.state_keys_blacklist_regexp - +class FullConstructor(SafeConstructor): + # 'extend' is blacklisted because it is used by + # construct_python_object_apply to add `listitems` to a newly generate + # python instance + def get_state_keys_blacklist(self): + return ['^extend$', '^__.*__$'] + + def get_state_keys_blacklist_regexp(self): + if not hasattr(self, 'state_keys_blacklist_regexp'): + self.state_keys_blacklist_regexp = re.compile('(' + '|'.join(self.get_state_keys_blacklist()) + ')') + return self.state_keys_blacklist_regexp + def construct_python_str(self, node): return self.construct_scalar(node).encode('utf-8') @@ -535,22 +535,22 @@ class FullConstructor(SafeConstructor): def construct_python_tuple(self, node): return tuple(self.construct_sequence(node)) - def find_python_module(self, name, mark, unsafe=False): + def find_python_module(self, name, mark, unsafe=False): if not name: raise ConstructorError("while constructing a Python module", mark, "expected non-empty name appended to the tag", mark) - if unsafe: - try: - __import__(name) - except ImportError, exc: - raise ConstructorError("while constructing a Python module", mark, - "cannot find module %r (%s)" % (name.encode('utf-8'), exc), mark) - if name not in sys.modules: + if unsafe: + try: + __import__(name) + except ImportError, exc: + raise ConstructorError("while constructing a Python module", mark, + "cannot find module %r (%s)" % (name.encode('utf-8'), exc), mark) + if name not in sys.modules: raise ConstructorError("while constructing a Python module", mark, - "module %r is not imported" % name.encode('utf-8'), mark) + "module %r is not imported" % name.encode('utf-8'), mark) return sys.modules[name] - def find_python_name(self, name, mark, unsafe=False): + def find_python_name(self, name, mark, unsafe=False): if not name: raise ConstructorError("while constructing a Python object", mark, "expected non-empty name appended to the tag", mark) @@ -559,15 +559,15 @@ class FullConstructor(SafeConstructor): else: module_name = '__builtin__' object_name = name - if unsafe: - try: - __import__(module_name) - except ImportError, exc: - raise ConstructorError("while constructing a Python object", mark, - "cannot find module %r (%s)" % (module_name.encode('utf-8'), exc), mark) - if module_name not in sys.modules: + if unsafe: + try: + __import__(module_name) + except ImportError, exc: + raise ConstructorError("while constructing a Python object", mark, + "cannot find module %r (%s)" % (module_name.encode('utf-8'), exc), mark) + if module_name not in sys.modules: raise ConstructorError("while constructing a Python object", mark, - "module %r is not imported" % module_name.encode('utf-8'), mark) + "module %r is not imported" % module_name.encode('utf-8'), mark) module = sys.modules[module_name] if not hasattr(module, object_name): raise ConstructorError("while constructing a Python object", mark, @@ -594,16 +594,16 @@ class FullConstructor(SafeConstructor): class classobj: pass def make_python_instance(self, suffix, node, - args=None, kwds=None, newobj=False, unsafe=False): + args=None, kwds=None, newobj=False, unsafe=False): if not args: args = [] if not kwds: kwds = {} cls = self.find_python_name(suffix, node.start_mark) - if not (unsafe or isinstance(cls, type) or isinstance(cls, type(self.classobj))): - raise ConstructorError("while constructing a Python instance", node.start_mark, - "expected a class, but found %r" % type(cls), - node.start_mark) + if not (unsafe or isinstance(cls, type) or isinstance(cls, type(self.classobj))): + raise ConstructorError("while constructing a Python instance", node.start_mark, + "expected a class, but found %r" % type(cls), + node.start_mark) if newobj and isinstance(cls, type(self.classobj)) \ and not args and not kwds: instance = self.classobj() @@ -614,7 +614,7 @@ class FullConstructor(SafeConstructor): else: return cls(*args, **kwds) - def set_python_instance_state(self, instance, state, unsafe=False): + def set_python_instance_state(self, instance, state, unsafe=False): if hasattr(instance, '__setstate__'): instance.__setstate__(state) else: @@ -622,16 +622,16 @@ class FullConstructor(SafeConstructor): if isinstance(state, tuple) and len(state) == 2: state, slotstate = state if hasattr(instance, '__dict__'): - if not unsafe and state: - for key in state.keys(): - self.check_state_key(key) + if not unsafe and state: + for key in state.keys(): + self.check_state_key(key) instance.__dict__.update(state) elif state: slotstate.update(state) for key, value in slotstate.items(): - if not unsafe: - self.check_state_key(key) - setattr(instance, key, value) + if not unsafe: + self.check_state_key(key) + setattr(instance, key, value) def construct_python_object(self, suffix, node): # Format: @@ -680,87 +680,87 @@ class FullConstructor(SafeConstructor): def construct_python_object_new(self, suffix, node): return self.construct_python_object_apply(suffix, node, newobj=True) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/none', - FullConstructor.construct_yaml_null) + FullConstructor.construct_yaml_null) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/bool', - FullConstructor.construct_yaml_bool) + FullConstructor.construct_yaml_bool) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/str', - FullConstructor.construct_python_str) + FullConstructor.construct_python_str) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/unicode', - FullConstructor.construct_python_unicode) + FullConstructor.construct_python_unicode) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/int', - FullConstructor.construct_yaml_int) + FullConstructor.construct_yaml_int) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/long', - FullConstructor.construct_python_long) + FullConstructor.construct_python_long) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/float', - FullConstructor.construct_yaml_float) + FullConstructor.construct_yaml_float) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/complex', - FullConstructor.construct_python_complex) + FullConstructor.construct_python_complex) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/list', - FullConstructor.construct_yaml_seq) + FullConstructor.construct_yaml_seq) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/tuple', - FullConstructor.construct_python_tuple) + FullConstructor.construct_python_tuple) -FullConstructor.add_constructor( +FullConstructor.add_constructor( u'tag:yaml.org,2002:python/dict', - FullConstructor.construct_yaml_map) + FullConstructor.construct_yaml_map) -FullConstructor.add_multi_constructor( +FullConstructor.add_multi_constructor( u'tag:yaml.org,2002:python/name:', - FullConstructor.construct_python_name) - -class UnsafeConstructor(FullConstructor): - - def find_python_module(self, name, mark): - return super(UnsafeConstructor, self).find_python_module(name, mark, unsafe=True) - - def find_python_name(self, name, mark): - return super(UnsafeConstructor, self).find_python_name(name, mark, unsafe=True) - - def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False): - return super(UnsafeConstructor, self).make_python_instance( - suffix, node, args, kwds, newobj, unsafe=True) - - def set_python_instance_state(self, instance, state): - return super(UnsafeConstructor, self).set_python_instance_state( - instance, state, unsafe=True) - -UnsafeConstructor.add_multi_constructor( - u'tag:yaml.org,2002:python/module:', - UnsafeConstructor.construct_python_module) - -UnsafeConstructor.add_multi_constructor( - u'tag:yaml.org,2002:python/object:', - UnsafeConstructor.construct_python_object) - -UnsafeConstructor.add_multi_constructor( - u'tag:yaml.org,2002:python/object/new:', - UnsafeConstructor.construct_python_object_new) - -UnsafeConstructor.add_multi_constructor( - u'tag:yaml.org,2002:python/object/apply:', - UnsafeConstructor.construct_python_object_apply) - -# Constructor is same as UnsafeConstructor. Need to leave this in place in case -# people have extended it directly. -class Constructor(UnsafeConstructor): - pass + FullConstructor.construct_python_name) + +class UnsafeConstructor(FullConstructor): + + def find_python_module(self, name, mark): + return super(UnsafeConstructor, self).find_python_module(name, mark, unsafe=True) + + def find_python_name(self, name, mark): + return super(UnsafeConstructor, self).find_python_name(name, mark, unsafe=True) + + def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False): + return super(UnsafeConstructor, self).make_python_instance( + suffix, node, args, kwds, newobj, unsafe=True) + + def set_python_instance_state(self, instance, state): + return super(UnsafeConstructor, self).set_python_instance_state( + instance, state, unsafe=True) + +UnsafeConstructor.add_multi_constructor( + u'tag:yaml.org,2002:python/module:', + UnsafeConstructor.construct_python_module) + +UnsafeConstructor.add_multi_constructor( + u'tag:yaml.org,2002:python/object:', + UnsafeConstructor.construct_python_object) + +UnsafeConstructor.add_multi_constructor( + u'tag:yaml.org,2002:python/object/new:', + UnsafeConstructor.construct_python_object_new) + +UnsafeConstructor.add_multi_constructor( + u'tag:yaml.org,2002:python/object/apply:', + UnsafeConstructor.construct_python_object_apply) + +# Constructor is same as UnsafeConstructor. Need to leave this in place in case +# people have extended it directly. +class Constructor(UnsafeConstructor): + pass diff --git a/contrib/python/PyYAML/py2/yaml/cyaml.py b/contrib/python/PyYAML/py2/yaml/cyaml.py index 768b49d6b9..c671e70831 100644 --- a/contrib/python/PyYAML/py2/yaml/cyaml.py +++ b/contrib/python/PyYAML/py2/yaml/cyaml.py @@ -1,10 +1,10 @@ -__all__ = [ - 'CBaseLoader', 'CSafeLoader', 'CFullLoader', 'CUnsafeLoader', 'CLoader', - 'CBaseDumper', 'CSafeDumper', 'CDumper' -] +__all__ = [ + 'CBaseLoader', 'CSafeLoader', 'CFullLoader', 'CUnsafeLoader', 'CLoader', + 'CBaseDumper', 'CSafeDumper', 'CDumper' +] -from yaml._yaml import CParser, CEmitter +from yaml._yaml import CParser, CEmitter from constructor import * @@ -27,20 +27,20 @@ class CSafeLoader(CParser, SafeConstructor, Resolver): SafeConstructor.__init__(self) Resolver.__init__(self) -class CFullLoader(CParser, FullConstructor, Resolver): - - def __init__(self, stream): - CParser.__init__(self, stream) - FullConstructor.__init__(self) - Resolver.__init__(self) - -class CUnsafeLoader(CParser, UnsafeConstructor, Resolver): - - def __init__(self, stream): - CParser.__init__(self, stream) - UnsafeConstructor.__init__(self) - Resolver.__init__(self) - +class CFullLoader(CParser, FullConstructor, Resolver): + + def __init__(self, stream): + CParser.__init__(self, stream) + FullConstructor.__init__(self) + Resolver.__init__(self) + +class CUnsafeLoader(CParser, UnsafeConstructor, Resolver): + + def __init__(self, stream): + CParser.__init__(self, stream) + UnsafeConstructor.__init__(self) + Resolver.__init__(self) + class CLoader(CParser, Constructor, Resolver): def __init__(self, stream): @@ -51,51 +51,51 @@ class CLoader(CParser, Constructor, Resolver): class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): CEmitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, encoding=encoding, allow_unicode=allow_unicode, line_break=line_break, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class CSafeDumper(CEmitter, SafeRepresenter, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): CEmitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, encoding=encoding, allow_unicode=allow_unicode, line_break=line_break, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) SafeRepresenter.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class CDumper(CEmitter, Serializer, Representer, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): CEmitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, encoding=encoding, allow_unicode=allow_unicode, line_break=line_break, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) diff --git a/contrib/python/PyYAML/py2/yaml/dumper.py b/contrib/python/PyYAML/py2/yaml/dumper.py index f9cd49fda5..53750021b9 100644 --- a/contrib/python/PyYAML/py2/yaml/dumper.py +++ b/contrib/python/PyYAML/py2/yaml/dumper.py @@ -9,11 +9,11 @@ from resolver import * class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) @@ -21,17 +21,17 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) @@ -39,17 +39,17 @@ class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) SafeRepresenter.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class Dumper(Emitter, Serializer, Representer, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) @@ -57,6 +57,6 @@ class Dumper(Emitter, Serializer, Representer, Resolver): explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) diff --git a/contrib/python/PyYAML/py2/yaml/emitter.py b/contrib/python/PyYAML/py2/yaml/emitter.py index 23c25ca80a..7c18ba5c30 100644 --- a/contrib/python/PyYAML/py2/yaml/emitter.py +++ b/contrib/python/PyYAML/py2/yaml/emitter.py @@ -8,13 +8,13 @@ __all__ = ['Emitter', 'EmitterError'] -import sys - +import sys + from error import YAMLError from events import * -has_ucs4 = sys.maxunicode > 0xffff - +has_ucs4 = sys.maxunicode > 0xffff + class EmitterError(YAMLError): pass @@ -45,7 +45,7 @@ class Emitter(object): # The stream should have the methods `write` and possibly `flush`. self.stream = stream - # Encoding can be overridden by STREAM-START. + # Encoding can be overridden by STREAM-START. self.encoding = None # Emitter is a state machine with a stack of states to handle nested @@ -659,7 +659,7 @@ class Emitter(object): flow_indicators = True # First character or preceded by a whitespace. - preceded_by_whitespace = True + preceded_by_whitespace = True # Last character or followed by a whitespace. followed_by_whitespace = (len(scalar) == 1 or @@ -678,7 +678,7 @@ class Emitter(object): # Check for indicators. if index == 0: # Leading indicators are special characters. - if ch in u'#,[]{}&*!|>\'\"%@`': + if ch in u'#,[]{}&*!|>\'\"%@`': flow_indicators = True block_indicators = True if ch in u'?:': @@ -696,7 +696,7 @@ class Emitter(object): flow_indicators = True if followed_by_whitespace: block_indicators = True - if ch == u'#' and preceded_by_whitespace: + if ch == u'#' and preceded_by_whitespace: flow_indicators = True block_indicators = True @@ -705,8 +705,8 @@ class Emitter(object): line_breaks = True if not (ch == u'\n' or u'\x20' <= ch <= u'\x7E'): if (ch == u'\x85' or u'\xA0' <= ch <= u'\uD7FF' - or u'\uE000' <= ch <= u'\uFFFD' - or (u'\U00010000' <= ch < u'\U0010ffff')) and ch != u'\uFEFF': + or u'\uE000' <= ch <= u'\uFFFD' + or (u'\U00010000' <= ch < u'\U0010ffff')) and ch != u'\uFEFF': unicode_characters = True if not self.allow_unicode: special_characters = True @@ -738,7 +738,7 @@ class Emitter(object): # Prepare for the next character. index += 1 - preceded_by_whitespace = (ch in u'\0 \t\r\n\x85\u2028\u2029') + preceded_by_whitespace = (ch in u'\0 \t\r\n\x85\u2028\u2029') followed_by_whitespace = (index+1 >= len(scalar) or scalar[index+1] in u'\0 \t\r\n\x85\u2028\u2029') diff --git a/contrib/python/PyYAML/py2/yaml/loader.py b/contrib/python/PyYAML/py2/yaml/loader.py index 4d773c3cc1..bc93d97582 100644 --- a/contrib/python/PyYAML/py2/yaml/loader.py +++ b/contrib/python/PyYAML/py2/yaml/loader.py @@ -1,5 +1,5 @@ -__all__ = ['BaseLoader', 'FullLoader', 'SafeLoader', 'Loader', 'UnsafeLoader'] +__all__ = ['BaseLoader', 'FullLoader', 'SafeLoader', 'Loader', 'UnsafeLoader'] from reader import * from scanner import * @@ -18,16 +18,16 @@ class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolve BaseConstructor.__init__(self) BaseResolver.__init__(self) -class FullLoader(Reader, Scanner, Parser, Composer, FullConstructor, Resolver): - - def __init__(self, stream): - Reader.__init__(self, stream) - Scanner.__init__(self) - Parser.__init__(self) - Composer.__init__(self) - FullConstructor.__init__(self) - Resolver.__init__(self) - +class FullLoader(Reader, Scanner, Parser, Composer, FullConstructor, Resolver): + + def __init__(self, stream): + Reader.__init__(self, stream) + Scanner.__init__(self) + Parser.__init__(self) + Composer.__init__(self) + FullConstructor.__init__(self) + Resolver.__init__(self) + class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver): def __init__(self, stream): @@ -48,16 +48,16 @@ class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver): Constructor.__init__(self) Resolver.__init__(self) -# UnsafeLoader is the same as Loader (which is and was always unsafe on -# untrusted input). Use of either Loader or UnsafeLoader should be rare, since -# FullLoad should be able to load almost all YAML safely. Loader is left intact -# to ensure backwards compatibility. -class UnsafeLoader(Reader, Scanner, Parser, Composer, Constructor, Resolver): - - def __init__(self, stream): - Reader.__init__(self, stream) - Scanner.__init__(self) - Parser.__init__(self) - Composer.__init__(self) - Constructor.__init__(self) - Resolver.__init__(self) +# UnsafeLoader is the same as Loader (which is and was always unsafe on +# untrusted input). Use of either Loader or UnsafeLoader should be rare, since +# FullLoad should be able to load almost all YAML safely. Loader is left intact +# to ensure backwards compatibility. +class UnsafeLoader(Reader, Scanner, Parser, Composer, Constructor, Resolver): + + def __init__(self, stream): + Reader.__init__(self, stream) + Scanner.__init__(self) + Parser.__init__(self) + Composer.__init__(self) + Constructor.__init__(self) + Resolver.__init__(self) diff --git a/contrib/python/PyYAML/py2/yaml/reader.py b/contrib/python/PyYAML/py2/yaml/reader.py index 4c42150989..d998dceb7c 100644 --- a/contrib/python/PyYAML/py2/yaml/reader.py +++ b/contrib/python/PyYAML/py2/yaml/reader.py @@ -19,10 +19,10 @@ __all__ = ['Reader', 'ReaderError'] from error import YAMLError, Mark -import codecs, re, sys - -has_ucs4 = sys.maxunicode > 0xffff +import codecs, re, sys +has_ucs4 = sys.maxunicode > 0xffff + class ReaderError(YAMLError): def __init__(self, name, position, character, encoding, reason): @@ -136,15 +136,15 @@ class Reader(object): self.encoding = 'utf-8' self.update(1) - if has_ucs4: - NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]' - elif sys.platform.startswith('java'): - # Jython doesn't support lone surrogates https://bugs.jython.org/issue2048 - NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]' - else: - # Need to use eval here due to the above Jython issue - NON_PRINTABLE = eval(r"u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)'") - NON_PRINTABLE = re.compile(NON_PRINTABLE) + if has_ucs4: + NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]' + elif sys.platform.startswith('java'): + # Jython doesn't support lone surrogates https://bugs.jython.org/issue2048 + NON_PRINTABLE = u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD]' + else: + # Need to use eval here due to the above Jython issue + NON_PRINTABLE = eval(r"u'[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uFFFD]|(?:^|[^\uD800-\uDBFF])[\uDC00-\uDFFF]|[\uD800-\uDBFF](?:[^\uDC00-\uDFFF]|$)'") + NON_PRINTABLE = re.compile(NON_PRINTABLE) def check_printable(self, data): match = self.NON_PRINTABLE.search(data) if match: diff --git a/contrib/python/PyYAML/py2/yaml/representer.py b/contrib/python/PyYAML/py2/yaml/representer.py index 93e09b67b3..fec15eb201 100644 --- a/contrib/python/PyYAML/py2/yaml/representer.py +++ b/contrib/python/PyYAML/py2/yaml/representer.py @@ -3,12 +3,12 @@ __all__ = ['BaseRepresenter', 'SafeRepresenter', 'Representer', 'RepresenterError'] from error import * - + from nodes import * import datetime -import copy_reg, types +import copy_reg, types class RepresenterError(YAMLError): pass @@ -18,10 +18,10 @@ class BaseRepresenter(object): yaml_representers = {} yaml_multi_representers = {} - def __init__(self, default_style=None, default_flow_style=False, sort_keys=True): + def __init__(self, default_style=None, default_flow_style=False, sort_keys=True): self.default_style = default_style self.default_flow_style = default_flow_style - self.sort_keys = sort_keys + self.sort_keys = sort_keys self.represented_objects = {} self.object_keeper = [] self.alias_key = None @@ -119,8 +119,8 @@ class BaseRepresenter(object): best_style = True if hasattr(mapping, 'items'): mapping = mapping.items() - if self.sort_keys: - mapping.sort() + if self.sort_keys: + mapping.sort() for item_key, item_value in mapping: node_key = self.represent_data(item_key) node_value = self.represent_data(item_value) @@ -249,7 +249,7 @@ class SafeRepresenter(BaseRepresenter): return self.represent_mapping(tag, state, flow_style=flow_style) def represent_undefined(self, data): - raise RepresenterError("cannot represent an object", data) + raise RepresenterError("cannot represent an object", data) SafeRepresenter.add_representer(type(None), SafeRepresenter.represent_none) @@ -414,7 +414,7 @@ class Representer(SafeRepresenter): elif hasattr(data, '__reduce__'): reduce = data.__reduce__() else: - raise RepresenterError("cannot represent an object", data) + raise RepresenterError("cannot represent an object", data) reduce = (list(reduce)+[None]*5)[:5] function, args, state, listitems, dictitems = reduce args = list(args) diff --git a/contrib/python/PyYAML/py2/yaml/resolver.py b/contrib/python/PyYAML/py2/yaml/resolver.py index ba9aeab21d..3565d20872 100644 --- a/contrib/python/PyYAML/py2/yaml/resolver.py +++ b/contrib/python/PyYAML/py2/yaml/resolver.py @@ -146,8 +146,8 @@ class BaseResolver(object): resolvers = self.yaml_implicit_resolvers.get(u'', []) else: resolvers = self.yaml_implicit_resolvers.get(value[0], []) - wildcard_resolvers = self.yaml_implicit_resolvers.get(None, []) - for tag, regexp in resolvers + wildcard_resolvers: + wildcard_resolvers = self.yaml_implicit_resolvers.get(None, []) + for tag, regexp in resolvers + wildcard_resolvers: if regexp.match(value): return tag implicit = implicit[1] diff --git a/contrib/python/PyYAML/py2/yaml/scanner.py b/contrib/python/PyYAML/py2/yaml/scanner.py index 587b73d8b4..00beebc30d 100644 --- a/contrib/python/PyYAML/py2/yaml/scanner.py +++ b/contrib/python/PyYAML/py2/yaml/scanner.py @@ -126,13 +126,13 @@ class Scanner(object): def peek_token(self): # Return the next token, but do not delete if from the queue. - # Return None if no more tokens. + # Return None if no more tokens. while self.need_more_tokens(): self.fetch_more_tokens() if self.tokens: return self.tokens[0] - else: - return None + else: + return None def get_token(self): # Return the next token. @@ -334,7 +334,7 @@ class Scanner(object): ## } #if self.flow_level and self.indent > column: # raise ScannerError(None, None, - # "invalid indentation or unclosed '[' or '{'", + # "invalid indentation or unclosed '[' or '{'", # self.get_mark()) # In the flow context, indentation is ignored. We make the scanner less @@ -372,7 +372,7 @@ class Scanner(object): def fetch_stream_end(self): - # Set the current indentation to -1. + # Set the current indentation to -1. self.unwind_indent(-1) # Reset simple keys. @@ -391,7 +391,7 @@ class Scanner(object): def fetch_directive(self): - # Set the current indentation to -1. + # Set the current indentation to -1. self.unwind_indent(-1) # Reset simple keys. @@ -409,7 +409,7 @@ class Scanner(object): def fetch_document_indicator(self, TokenClass): - # Set the current indentation to -1. + # Set the current indentation to -1. self.unwind_indent(-1) # Reset simple keys. Note that there could not be a block collection @@ -521,7 +521,7 @@ class Scanner(object): # Block context needs additional checks. if not self.flow_level: - # Are we allowed to start a key (not necessary a simple)? + # Are we allowed to start a key (not necessary a simple)? if not self.allow_simple_key: raise ScannerError(None, None, "mapping keys are not allowed here", @@ -569,7 +569,7 @@ class Scanner(object): else: # Block context needs additional checks. - # (Do we really need them? They will be caught by the parser + # (Do we really need them? They will be caught by the parser # anyway.) if not self.flow_level: @@ -907,7 +907,7 @@ class Scanner(object): # The specification does not restrict characters for anchors and # aliases. This may lead to problems, for instance, the document: # [ *alias, value ] - # can be interpreted in two ways, as + # can be interpreted in two ways, as # [ "value" ] # and # [ *alias , "value" ] @@ -1177,7 +1177,7 @@ class Scanner(object): u' ': u'\x20', u'\"': u'\"', u'\\': u'\\', - u'/': u'/', + u'/': u'/', u'N': u'\x85', u'_': u'\xA0', u'L': u'\u2028', @@ -1281,7 +1281,7 @@ class Scanner(object): def scan_plain(self): # See the specification for details. # We add an additional restriction for the flow context: - # plain scalars in the flow context cannot contain ',' or '?'. + # plain scalars in the flow context cannot contain ',' or '?'. # We also keep track of the `allow_simple_key` flag here. # Indentation rules are loosed for the flow context. chunks = [] @@ -1300,10 +1300,10 @@ class Scanner(object): while True: ch = self.peek(length) if ch in u'\0 \t\r\n\x85\u2028\u2029' \ - or (ch == u':' and - self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029' - + (u',[]{}' if self.flow_level else u''))\ - or (self.flow_level and ch in u',?[]{}'): + or (ch == u':' and + self.peek(length+1) in u'\0 \t\r\n\x85\u2028\u2029' + + (u',[]{}' if self.flow_level else u''))\ + or (self.flow_level and ch in u',?[]{}'): break length += 1 if length == 0: diff --git a/contrib/python/PyYAML/py3/.dist-info/METADATA b/contrib/python/PyYAML/py3/.dist-info/METADATA index 565f05b737..3e019fa6e0 100644 --- a/contrib/python/PyYAML/py3/.dist-info/METADATA +++ b/contrib/python/PyYAML/py3/.dist-info/METADATA @@ -1,46 +1,46 @@ -Metadata-Version: 2.1 -Name: PyYAML -Version: 5.4.1 -Summary: YAML parser and emitter for Python -Home-page: https://pyyaml.org/ -Author: Kirill Simonov -Author-email: xi@resolvent.net -License: MIT -Download-URL: https://pypi.org/project/PyYAML/ -Project-URL: Bug Tracker, https://github.com/yaml/pyyaml/issues -Project-URL: CI, https://github.com/yaml/pyyaml/actions -Project-URL: Documentation, https://pyyaml.org/wiki/PyYAMLDocumentation -Project-URL: Mailing lists, http://lists.sourceforge.net/lists/listinfo/yaml-core -Project-URL: Source Code, https://github.com/yaml/pyyaml -Platform: Any -Classifier: Development Status :: 5 - Production/Stable -Classifier: Intended Audience :: Developers -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: OS Independent -Classifier: Programming Language :: Cython -Classifier: Programming Language :: Python -Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.7 -Classifier: Programming Language :: Python :: 3 -Classifier: Programming Language :: Python :: 3.6 -Classifier: Programming Language :: Python :: 3.7 -Classifier: Programming Language :: Python :: 3.8 -Classifier: Programming Language :: Python :: 3.9 -Classifier: Programming Language :: Python :: Implementation :: CPython -Classifier: Programming Language :: Python :: Implementation :: PyPy -Classifier: Topic :: Software Development :: Libraries :: Python Modules -Classifier: Topic :: Text Processing :: Markup -Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* - -YAML is a data serialization format designed for human readability -and interaction with scripting languages. PyYAML is a YAML parser -and emitter for Python. - -PyYAML features a complete YAML 1.1 parser, Unicode support, pickle -support, capable extension API, and sensible error messages. PyYAML -supports standard YAML tags and provides Python-specific tags that -allow to represent an arbitrary Python object. - -PyYAML is applicable for a broad range of tasks from complex -configuration files to object serialization and persistence. - +Metadata-Version: 2.1 +Name: PyYAML +Version: 5.4.1 +Summary: YAML parser and emitter for Python +Home-page: https://pyyaml.org/ +Author: Kirill Simonov +Author-email: xi@resolvent.net +License: MIT +Download-URL: https://pypi.org/project/PyYAML/ +Project-URL: Bug Tracker, https://github.com/yaml/pyyaml/issues +Project-URL: CI, https://github.com/yaml/pyyaml/actions +Project-URL: Documentation, https://pyyaml.org/wiki/PyYAMLDocumentation +Project-URL: Mailing lists, http://lists.sourceforge.net/lists/listinfo/yaml-core +Project-URL: Source Code, https://github.com/yaml/pyyaml +Platform: Any +Classifier: Development Status :: 5 - Production/Stable +Classifier: Intended Audience :: Developers +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Cython +Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: Implementation :: CPython +Classifier: Programming Language :: Python :: Implementation :: PyPy +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Classifier: Topic :: Text Processing :: Markup +Requires-Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.* + +YAML is a data serialization format designed for human readability +and interaction with scripting languages. PyYAML is a YAML parser +and emitter for Python. + +PyYAML features a complete YAML 1.1 parser, Unicode support, pickle +support, capable extension API, and sensible error messages. PyYAML +supports standard YAML tags and provides Python-specific tags that +allow to represent an arbitrary Python object. + +PyYAML is applicable for a broad range of tasks from complex +configuration files to object serialization and persistence. + diff --git a/contrib/python/PyYAML/py3/.dist-info/top_level.txt b/contrib/python/PyYAML/py3/.dist-info/top_level.txt index e6475e911f..a723c44d26 100644 --- a/contrib/python/PyYAML/py3/.dist-info/top_level.txt +++ b/contrib/python/PyYAML/py3/.dist-info/top_level.txt @@ -1,2 +1,2 @@ -_yaml -yaml +_yaml +yaml diff --git a/contrib/python/PyYAML/py3/LICENSE b/contrib/python/PyYAML/py3/LICENSE index 2f1b8e15e5..85dab73827 100644 --- a/contrib/python/PyYAML/py3/LICENSE +++ b/contrib/python/PyYAML/py3/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2017-2021 Ingy döt Net +Copyright (c) 2017-2021 Ingy döt Net Copyright (c) 2006-2016 Kirill Simonov Permission is hereby granted, free of charge, to any person obtaining a copy of diff --git a/contrib/python/PyYAML/py3/README b/contrib/python/PyYAML/py3/README index 49c87e7642..51245142cc 100644 --- a/contrib/python/PyYAML/py3/README +++ b/contrib/python/PyYAML/py3/README @@ -1,43 +1,43 @@ -PyYAML - The next generation YAML parser and emitter for Python. - -To install, type 'python setup.py install'. - -By default, the setup.py script checks whether LibYAML is installed -and if so, builds and installs LibYAML bindings. To skip the check -and force installation of LibYAML bindings, use the option '--with-libyaml': -'python setup.py --with-libyaml install'. To disable the check and -skip building and installing LibYAML bindings, use '--without-libyaml': -'python setup.py --without-libyaml install'. - -When LibYAML bindings are installed, you may use fast LibYAML-based -parser and emitter as follows: - - >>> yaml.load(stream, Loader=yaml.CLoader) - >>> yaml.dump(data, Dumper=yaml.CDumper) - -If you don't trust the input stream, you should use: - - >>> yaml.safe_load(stream) - -PyYAML includes a comprehensive test suite. To run the tests, -type 'python setup.py test'. - -For more information, check the PyYAML homepage: -'https://github.com/yaml/pyyaml'. - -For PyYAML tutorial and reference, see: -'http://pyyaml.org/wiki/PyYAMLDocumentation'. - -Discuss PyYAML with the maintainers in IRC #pyyaml irc.freenode.net. - -You may also use the YAML-Core mailing list: -'http://lists.sourceforge.net/lists/listinfo/yaml-core'. - -Submit bug reports and feature requests to the PyYAML bug tracker: -'https://github.com/yaml/pyyaml/issues'. - -The PyYAML module was written by Kirill Simonov <xi@resolvent.net>. -It is currently maintained by the YAML and Python communities. - -PyYAML is released under the MIT license. -See the file LICENSE for more details. +PyYAML - The next generation YAML parser and emitter for Python. + +To install, type 'python setup.py install'. + +By default, the setup.py script checks whether LibYAML is installed +and if so, builds and installs LibYAML bindings. To skip the check +and force installation of LibYAML bindings, use the option '--with-libyaml': +'python setup.py --with-libyaml install'. To disable the check and +skip building and installing LibYAML bindings, use '--without-libyaml': +'python setup.py --without-libyaml install'. + +When LibYAML bindings are installed, you may use fast LibYAML-based +parser and emitter as follows: + + >>> yaml.load(stream, Loader=yaml.CLoader) + >>> yaml.dump(data, Dumper=yaml.CDumper) + +If you don't trust the input stream, you should use: + + >>> yaml.safe_load(stream) + +PyYAML includes a comprehensive test suite. To run the tests, +type 'python setup.py test'. + +For more information, check the PyYAML homepage: +'https://github.com/yaml/pyyaml'. + +For PyYAML tutorial and reference, see: +'http://pyyaml.org/wiki/PyYAMLDocumentation'. + +Discuss PyYAML with the maintainers in IRC #pyyaml irc.freenode.net. + +You may also use the YAML-Core mailing list: +'http://lists.sourceforge.net/lists/listinfo/yaml-core'. + +Submit bug reports and feature requests to the PyYAML bug tracker: +'https://github.com/yaml/pyyaml/issues'. + +The PyYAML module was written by Kirill Simonov <xi@resolvent.net>. +It is currently maintained by the YAML and Python communities. + +PyYAML is released under the MIT license. +See the file LICENSE for more details. diff --git a/contrib/python/PyYAML/py3/_yaml/__init__.py b/contrib/python/PyYAML/py3/_yaml/__init__.py index 7baa8c4b68..fb6764718a 100644 --- a/contrib/python/PyYAML/py3/_yaml/__init__.py +++ b/contrib/python/PyYAML/py3/_yaml/__init__.py @@ -1,33 +1,33 @@ -# This is a stub package designed to roughly emulate the _yaml -# extension module, which previously existed as a standalone module -# and has been moved into the `yaml` package namespace. -# It does not perfectly mimic its old counterpart, but should get -# close enough for anyone who's relying on it even when they shouldn't. -import yaml - -# in some circumstances, the yaml module we imoprted may be from a different version, so we need -# to tread carefully when poking at it here (it may not have the attributes we expect) -if not getattr(yaml, '__with_libyaml__', False): - from sys import version_info - - exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError - raise exc("No module named '_yaml'") -else: - from yaml._yaml import * - import warnings - warnings.warn( - 'The _yaml extension module is now located at yaml._yaml' - ' and its location is subject to change. To use the' - ' LibYAML-based parser and emitter, import from `yaml`:' - ' `from yaml import CLoader as Loader, CDumper as Dumper`.', - DeprecationWarning - ) - del warnings - # Don't `del yaml` here because yaml is actually an existing - # namespace member of _yaml. - -__name__ = '_yaml' -# If the module is top-level (i.e. not a part of any specific package) -# then the attribute should be set to ''. -# https://docs.python.org/3.8/library/types.html -__package__ = '' +# This is a stub package designed to roughly emulate the _yaml +# extension module, which previously existed as a standalone module +# and has been moved into the `yaml` package namespace. +# It does not perfectly mimic its old counterpart, but should get +# close enough for anyone who's relying on it even when they shouldn't. +import yaml + +# in some circumstances, the yaml module we imoprted may be from a different version, so we need +# to tread carefully when poking at it here (it may not have the attributes we expect) +if not getattr(yaml, '__with_libyaml__', False): + from sys import version_info + + exc = ModuleNotFoundError if version_info >= (3, 6) else ImportError + raise exc("No module named '_yaml'") +else: + from yaml._yaml import * + import warnings + warnings.warn( + 'The _yaml extension module is now located at yaml._yaml' + ' and its location is subject to change. To use the' + ' LibYAML-based parser and emitter, import from `yaml`:' + ' `from yaml import CLoader as Loader, CDumper as Dumper`.', + DeprecationWarning + ) + del warnings + # Don't `del yaml` here because yaml is actually an existing + # namespace member of _yaml. + +__name__ = '_yaml' +# If the module is top-level (i.e. not a part of any specific package) +# then the attribute should be set to ''. +# https://docs.python.org/3.8/library/types.html +__package__ = '' diff --git a/contrib/python/PyYAML/py3/ya.make b/contrib/python/PyYAML/py3/ya.make index 0401c04651..87d4977dd6 100644 --- a/contrib/python/PyYAML/py3/ya.make +++ b/contrib/python/PyYAML/py3/ya.make @@ -1,22 +1,22 @@ -PY3_LIBRARY() +PY3_LIBRARY() LICENSE(MIT) -VERSION(5.4.1) +VERSION(5.4.1) OWNER(g:python-contrib borman g:testenv) -PEERDIR( - contrib/libs/yaml -) +PEERDIR( + contrib/libs/yaml +) -ADDINCL( - contrib/python/PyYAML/py3/yaml -) +ADDINCL( + contrib/python/PyYAML/py3/yaml +) PY_SRCS( TOP_LEVEL - _yaml/__init__.py + _yaml/__init__.py yaml/__init__.py yaml/composer.py yaml/constructor.py @@ -34,18 +34,18 @@ PY_SRCS( yaml/scanner.py yaml/serializer.py yaml/tokens.py - CYTHON_C - yaml/_yaml.pyx -) - -RESOURCE_FILES( - PREFIX contrib/python/PyYAML/ - .dist-info/METADATA - .dist-info/top_level.txt + CYTHON_C + yaml/_yaml.pyx ) +RESOURCE_FILES( + PREFIX contrib/python/PyYAML/ + .dist-info/METADATA + .dist-info/top_level.txt +) + NO_LINT() -NO_COMPILER_WARNINGS() - +NO_COMPILER_WARNINGS() + END() diff --git a/contrib/python/PyYAML/py3/yaml/__init__.py b/contrib/python/PyYAML/py3/yaml/__init__.py index 86d07b5525..0c0bb5521d 100644 --- a/contrib/python/PyYAML/py3/yaml/__init__.py +++ b/contrib/python/PyYAML/py3/yaml/__init__.py @@ -8,7 +8,7 @@ from .nodes import * from .loader import * from .dumper import * -__version__ = '5.4.1' +__version__ = '5.4.1' try: from .cyaml import * __with_libyaml__ = True @@ -17,44 +17,44 @@ except ImportError: import io -#------------------------------------------------------------------------------ -# Warnings control -#------------------------------------------------------------------------------ - -# 'Global' warnings state: -_warnings_enabled = { - 'YAMLLoadWarning': True, -} - -# Get or set global warnings' state -def warnings(settings=None): - if settings is None: - return _warnings_enabled - - if type(settings) is dict: - for key in settings: - if key in _warnings_enabled: - _warnings_enabled[key] = settings[key] - -# Warn when load() is called without Loader=... -class YAMLLoadWarning(RuntimeWarning): - pass - -def load_warning(method): - if _warnings_enabled['YAMLLoadWarning'] is False: - return - - import warnings - - message = ( - "calling yaml.%s() without Loader=... is deprecated, as the " - "default Loader is unsafe. Please read " - "https://msg.pyyaml.org/load for full details." - ) % method - - warnings.warn(message, YAMLLoadWarning, stacklevel=3) - -#------------------------------------------------------------------------------ +#------------------------------------------------------------------------------ +# Warnings control +#------------------------------------------------------------------------------ + +# 'Global' warnings state: +_warnings_enabled = { + 'YAMLLoadWarning': True, +} + +# Get or set global warnings' state +def warnings(settings=None): + if settings is None: + return _warnings_enabled + + if type(settings) is dict: + for key in settings: + if key in _warnings_enabled: + _warnings_enabled[key] = settings[key] + +# Warn when load() is called without Loader=... +class YAMLLoadWarning(RuntimeWarning): + pass + +def load_warning(method): + if _warnings_enabled['YAMLLoadWarning'] is False: + return + + import warnings + + message = ( + "calling yaml.%s() without Loader=... is deprecated, as the " + "default Loader is unsafe. Please read " + "https://msg.pyyaml.org/load for full details." + ) % method + + warnings.warn(message, YAMLLoadWarning, stacklevel=3) + +#------------------------------------------------------------------------------ def scan(stream, Loader=Loader): """ Scan a YAML stream and produce scanning tokens. @@ -100,30 +100,30 @@ def compose_all(stream, Loader=Loader): finally: loader.dispose() -def load(stream, Loader=None): +def load(stream, Loader=None): """ Parse the first YAML document in a stream and produce the corresponding Python object. """ - if Loader is None: - load_warning('load') - Loader = FullLoader - + if Loader is None: + load_warning('load') + Loader = FullLoader + loader = Loader(stream) try: return loader.get_single_data() finally: loader.dispose() -def load_all(stream, Loader=None): +def load_all(stream, Loader=None): """ Parse all YAML documents in a stream and produce corresponding Python objects. """ - if Loader is None: - load_warning('load_all') - Loader = FullLoader - + if Loader is None: + load_warning('load_all') + Loader = FullLoader + loader = Loader(stream) try: while loader.check_data(): @@ -131,33 +131,33 @@ def load_all(stream, Loader=None): finally: loader.dispose() -def full_load(stream): - """ - Parse the first YAML document in a stream - and produce the corresponding Python object. - - Resolve all tags except those known to be - unsafe on untrusted input. - """ - return load(stream, FullLoader) - -def full_load_all(stream): - """ - Parse all YAML documents in a stream - and produce corresponding Python objects. - - Resolve all tags except those known to be - unsafe on untrusted input. - """ - return load_all(stream, FullLoader) - +def full_load(stream): + """ + Parse the first YAML document in a stream + and produce the corresponding Python object. + + Resolve all tags except those known to be + unsafe on untrusted input. + """ + return load(stream, FullLoader) + +def full_load_all(stream): + """ + Parse all YAML documents in a stream + and produce corresponding Python objects. + + Resolve all tags except those known to be + unsafe on untrusted input. + """ + return load_all(stream, FullLoader) + def safe_load(stream): """ Parse the first YAML document in a stream and produce the corresponding Python object. - - Resolve only basic YAML tags. This is known - to be safe for untrusted input. + + Resolve only basic YAML tags. This is known + to be safe for untrusted input. """ return load(stream, SafeLoader) @@ -165,32 +165,32 @@ def safe_load_all(stream): """ Parse all YAML documents in a stream and produce corresponding Python objects. - - Resolve only basic YAML tags. This is known - to be safe for untrusted input. + + Resolve only basic YAML tags. This is known + to be safe for untrusted input. """ return load_all(stream, SafeLoader) -def unsafe_load(stream): - """ - Parse the first YAML document in a stream - and produce the corresponding Python object. - - Resolve all tags, even those known to be - unsafe on untrusted input. - """ - return load(stream, UnsafeLoader) - -def unsafe_load_all(stream): - """ - Parse all YAML documents in a stream - and produce corresponding Python objects. - - Resolve all tags, even those known to be - unsafe on untrusted input. - """ - return load_all(stream, UnsafeLoader) - +def unsafe_load(stream): + """ + Parse the first YAML document in a stream + and produce the corresponding Python object. + + Resolve all tags, even those known to be + unsafe on untrusted input. + """ + return load(stream, UnsafeLoader) + +def unsafe_load_all(stream): + """ + Parse all YAML documents in a stream + and produce corresponding Python objects. + + Resolve all tags, even those known to be + unsafe on untrusted input. + """ + return load_all(stream, UnsafeLoader) + def emit(events, stream=None, Dumper=Dumper, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None): @@ -250,11 +250,11 @@ def serialize(node, stream=None, Dumper=Dumper, **kwds): return serialize_all([node], stream, Dumper=Dumper, **kwds) def dump_all(documents, stream=None, Dumper=Dumper, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): """ Serialize a sequence of Python objects into a YAML stream. If stream is None, return the produced string instead. @@ -271,7 +271,7 @@ def dump_all(documents, stream=None, Dumper=Dumper, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break, encoding=encoding, version=version, tags=tags, - explicit_start=explicit_start, explicit_end=explicit_end, sort_keys=sort_keys) + explicit_start=explicit_start, explicit_end=explicit_end, sort_keys=sort_keys) try: dumper.open() for data in documents: @@ -306,62 +306,62 @@ def safe_dump(data, stream=None, **kwds): return dump_all([data], stream, Dumper=SafeDumper, **kwds) def add_implicit_resolver(tag, regexp, first=None, - Loader=None, Dumper=Dumper): + Loader=None, Dumper=Dumper): """ Add an implicit scalar detector. If an implicit scalar value matches the given regexp, the corresponding tag is assigned to the scalar. first is a sequence of possible initial characters or None. """ - if Loader is None: - loader.Loader.add_implicit_resolver(tag, regexp, first) - loader.FullLoader.add_implicit_resolver(tag, regexp, first) - loader.UnsafeLoader.add_implicit_resolver(tag, regexp, first) - else: - Loader.add_implicit_resolver(tag, regexp, first) + if Loader is None: + loader.Loader.add_implicit_resolver(tag, regexp, first) + loader.FullLoader.add_implicit_resolver(tag, regexp, first) + loader.UnsafeLoader.add_implicit_resolver(tag, regexp, first) + else: + Loader.add_implicit_resolver(tag, regexp, first) Dumper.add_implicit_resolver(tag, regexp, first) -def add_path_resolver(tag, path, kind=None, Loader=None, Dumper=Dumper): +def add_path_resolver(tag, path, kind=None, Loader=None, Dumper=Dumper): """ Add a path based resolver for the given tag. A path is a list of keys that forms a path to a node in the representation tree. Keys can be string values, integers, or None. """ - if Loader is None: - loader.Loader.add_path_resolver(tag, path, kind) - loader.FullLoader.add_path_resolver(tag, path, kind) - loader.UnsafeLoader.add_path_resolver(tag, path, kind) - else: - Loader.add_path_resolver(tag, path, kind) + if Loader is None: + loader.Loader.add_path_resolver(tag, path, kind) + loader.FullLoader.add_path_resolver(tag, path, kind) + loader.UnsafeLoader.add_path_resolver(tag, path, kind) + else: + Loader.add_path_resolver(tag, path, kind) Dumper.add_path_resolver(tag, path, kind) -def add_constructor(tag, constructor, Loader=None): +def add_constructor(tag, constructor, Loader=None): """ Add a constructor for the given tag. Constructor is a function that accepts a Loader instance and a node object and produces the corresponding Python object. """ - if Loader is None: - loader.Loader.add_constructor(tag, constructor) - loader.FullLoader.add_constructor(tag, constructor) - loader.UnsafeLoader.add_constructor(tag, constructor) - else: - Loader.add_constructor(tag, constructor) + if Loader is None: + loader.Loader.add_constructor(tag, constructor) + loader.FullLoader.add_constructor(tag, constructor) + loader.UnsafeLoader.add_constructor(tag, constructor) + else: + Loader.add_constructor(tag, constructor) -def add_multi_constructor(tag_prefix, multi_constructor, Loader=None): +def add_multi_constructor(tag_prefix, multi_constructor, Loader=None): """ Add a multi-constructor for the given tag prefix. Multi-constructor is called for a node if its tag starts with tag_prefix. Multi-constructor accepts a Loader instance, a tag suffix, and a node object and produces the corresponding Python object. """ - if Loader is None: - loader.Loader.add_multi_constructor(tag_prefix, multi_constructor) - loader.FullLoader.add_multi_constructor(tag_prefix, multi_constructor) - loader.UnsafeLoader.add_multi_constructor(tag_prefix, multi_constructor) - else: - Loader.add_multi_constructor(tag_prefix, multi_constructor) + if Loader is None: + loader.Loader.add_multi_constructor(tag_prefix, multi_constructor) + loader.FullLoader.add_multi_constructor(tag_prefix, multi_constructor) + loader.UnsafeLoader.add_multi_constructor(tag_prefix, multi_constructor) + else: + Loader.add_multi_constructor(tag_prefix, multi_constructor) def add_representer(data_type, representer, Dumper=Dumper): """ @@ -388,12 +388,12 @@ class YAMLObjectMetaclass(type): def __init__(cls, name, bases, kwds): super(YAMLObjectMetaclass, cls).__init__(name, bases, kwds) if 'yaml_tag' in kwds and kwds['yaml_tag'] is not None: - if isinstance(cls.yaml_loader, list): - for loader in cls.yaml_loader: - loader.add_constructor(cls.yaml_tag, cls.from_yaml) - else: - cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) - + if isinstance(cls.yaml_loader, list): + for loader in cls.yaml_loader: + loader.add_constructor(cls.yaml_tag, cls.from_yaml) + else: + cls.yaml_loader.add_constructor(cls.yaml_tag, cls.from_yaml) + cls.yaml_dumper.add_representer(cls, cls.to_yaml) class YAMLObject(metaclass=YAMLObjectMetaclass): @@ -404,7 +404,7 @@ class YAMLObject(metaclass=YAMLObjectMetaclass): __slots__ = () # no direct instantiation, so allow immutable subclasses - yaml_loader = [Loader, FullLoader, UnsafeLoader] + yaml_loader = [Loader, FullLoader, UnsafeLoader] yaml_dumper = Dumper yaml_tag = None diff --git a/contrib/python/PyYAML/py3/yaml/_yaml.h b/contrib/python/PyYAML/py3/yaml/_yaml.h index 21fd6a991b..2d593e7f70 100644 --- a/contrib/python/PyYAML/py3/yaml/_yaml.h +++ b/contrib/python/PyYAML/py3/yaml/_yaml.h @@ -3,7 +3,7 @@ #if PY_MAJOR_VERSION < 3 -#define PyUnicode_FromString(s) PyUnicode_DecodeUTF8((s), strlen(s), "strict") +#define PyUnicode_FromString(s) PyUnicode_DecodeUTF8((s), strlen(s), "strict") #else diff --git a/contrib/python/PyYAML/py3/yaml/_yaml.pxd b/contrib/python/PyYAML/py3/yaml/_yaml.pxd index 7937c9db51..e6913b5847 100644 --- a/contrib/python/PyYAML/py3/yaml/_yaml.pxd +++ b/contrib/python/PyYAML/py3/yaml/_yaml.pxd @@ -1,5 +1,5 @@ -cdef extern from "_yaml.h": +cdef extern from "_yaml.h": void malloc(int l) void memcpy(char *d, char *s, int l) @@ -85,22 +85,22 @@ cdef extern from "_yaml.h": YAML_MAPPING_START_EVENT YAML_MAPPING_END_EVENT - ctypedef int yaml_read_handler_t(void *data, char *buffer, + ctypedef int yaml_read_handler_t(void *data, char *buffer, size_t size, size_t *size_read) except 0 - ctypedef int yaml_write_handler_t(void *data, char *buffer, + ctypedef int yaml_write_handler_t(void *data, char *buffer, size_t size) except 0 ctypedef struct yaml_mark_t: - size_t index - size_t line - size_t column + size_t index + size_t line + size_t column ctypedef struct yaml_version_directive_t: int major int minor ctypedef struct yaml_tag_directive_t: - char *handle - char *prefix + char *handle + char *prefix ctypedef struct _yaml_token_stream_start_data_t: yaml_encoding_t encoding @@ -109,18 +109,18 @@ cdef extern from "_yaml.h": ctypedef struct _yaml_token_anchor_data_t: char *value ctypedef struct _yaml_token_tag_data_t: - char *handle - char *suffix + char *handle + char *suffix ctypedef struct _yaml_token_scalar_data_t: char *value - size_t length + size_t length yaml_scalar_style_t style ctypedef struct _yaml_token_version_directive_data_t: int major int minor ctypedef struct _yaml_token_tag_directive_data_t: - char *handle - char *prefix + char *handle + char *prefix ctypedef union _yaml_token_data_t: _yaml_token_stream_start_data_t stream_start _yaml_token_alias_data_t alias @@ -152,7 +152,7 @@ cdef extern from "_yaml.h": char *anchor char *tag char *value - size_t length + size_t length int plain_implicit int quoted_implicit yaml_scalar_style_t style @@ -183,7 +183,7 @@ cdef extern from "_yaml.h": ctypedef struct yaml_parser_t: yaml_error_type_t error char *problem - size_t problem_offset + size_t problem_offset int problem_value yaml_mark_t problem_mark char *context @@ -208,23 +208,23 @@ cdef extern from "_yaml.h": int implicit) int yaml_document_end_event_initialize(yaml_event_t *event, int implicit) - int yaml_alias_event_initialize(yaml_event_t *event, char *anchor) + int yaml_alias_event_initialize(yaml_event_t *event, char *anchor) int yaml_scalar_event_initialize(yaml_event_t *event, - char *anchor, char *tag, char *value, size_t length, + char *anchor, char *tag, char *value, size_t length, int plain_implicit, int quoted_implicit, yaml_scalar_style_t style) int yaml_sequence_start_event_initialize(yaml_event_t *event, - char *anchor, char *tag, int implicit, yaml_sequence_style_t style) + char *anchor, char *tag, int implicit, yaml_sequence_style_t style) int yaml_sequence_end_event_initialize(yaml_event_t *event) int yaml_mapping_start_event_initialize(yaml_event_t *event, - char *anchor, char *tag, int implicit, yaml_mapping_style_t style) + char *anchor, char *tag, int implicit, yaml_mapping_style_t style) int yaml_mapping_end_event_initialize(yaml_event_t *event) void yaml_event_delete(yaml_event_t *event) int yaml_parser_initialize(yaml_parser_t *parser) void yaml_parser_delete(yaml_parser_t *parser) void yaml_parser_set_input_string(yaml_parser_t *parser, - char *input, size_t size) + char *input, size_t size) void yaml_parser_set_input(yaml_parser_t *parser, yaml_read_handler_t *handler, void *data) void yaml_parser_set_encoding(yaml_parser_t *parser, @@ -235,7 +235,7 @@ cdef extern from "_yaml.h": int yaml_emitter_initialize(yaml_emitter_t *emitter) void yaml_emitter_delete(yaml_emitter_t *emitter) void yaml_emitter_set_output_string(yaml_emitter_t *emitter, - char *output, size_t size, size_t *size_written) + char *output, size_t size, size_t *size_written) void yaml_emitter_set_output(yaml_emitter_t *emitter, yaml_write_handler_t *handler, void *data) void yaml_emitter_set_encoding(yaml_emitter_t *emitter, diff --git a/contrib/python/PyYAML/py3/yaml/_yaml.pyx b/contrib/python/PyYAML/py3/yaml/_yaml.pyx index ff4efe80b5..9a8daeecbf 100644 --- a/contrib/python/PyYAML/py3/yaml/_yaml.pyx +++ b/contrib/python/PyYAML/py3/yaml/_yaml.pyx @@ -2,7 +2,7 @@ import yaml def get_version_string(): - cdef char *value + cdef char *value value = yaml_get_version_string() if PY_MAJOR_VERSION < 3: return value @@ -63,13 +63,13 @@ MappingNode = yaml.nodes.MappingNode cdef class Mark: cdef readonly object name - cdef readonly size_t index - cdef readonly size_t line - cdef readonly size_t column + cdef readonly size_t index + cdef readonly size_t line + cdef readonly size_t column cdef readonly buffer cdef readonly pointer - def __init__(self, object name, size_t index, size_t line, size_t column, + def __init__(self, object name, size_t index, size_t line, size_t column, object buffer, object pointer): self.name = name self.index = index @@ -255,8 +255,8 @@ cdef class CParser: cdef object current_event cdef object anchors cdef object stream_cache - cdef int stream_cache_len - cdef int stream_cache_pos + cdef int stream_cache_len + cdef int stream_cache_pos cdef int unicode_source def __init__(self, stream): @@ -302,7 +302,7 @@ cdef class CParser: else: raise TypeError(u"a string or stream input is required") self.stream = stream - yaml_parser_set_input_string(&self.parser, PyString_AS_STRING(stream), PyString_GET_SIZE(stream)) + yaml_parser_set_input_string(&self.parser, PyString_AS_STRING(stream), PyString_GET_SIZE(stream)) self.current_token = None self.current_event = None self.anchors = {} @@ -414,8 +414,8 @@ cdef class CParser: token.data.version_directive.minor), start_mark, end_mark) elif token.type == YAML_TAG_DIRECTIVE_TOKEN: - handle = PyUnicode_FromString(token.data.tag_directive.handle) - prefix = PyUnicode_FromString(token.data.tag_directive.prefix) + handle = PyUnicode_FromString(token.data.tag_directive.handle) + prefix = PyUnicode_FromString(token.data.tag_directive.prefix) return DirectiveToken(u"TAG", (handle, prefix), start_mark, end_mark) elif token.type == YAML_DOCUMENT_START_TOKEN: @@ -451,13 +451,13 @@ cdef class CParser: value = PyUnicode_FromString(token.data.anchor.value) return AnchorToken(value, start_mark, end_mark) elif token.type == YAML_TAG_TOKEN: - handle = PyUnicode_FromString(token.data.tag.handle) - suffix = PyUnicode_FromString(token.data.tag.suffix) + handle = PyUnicode_FromString(token.data.tag.handle) + suffix = PyUnicode_FromString(token.data.tag.suffix) if not handle: handle = None return TagToken((handle, suffix), start_mark, end_mark) elif token.type == YAML_SCALAR_TOKEN: - value = PyUnicode_DecodeUTF8(token.data.scalar.value, + value = PyUnicode_DecodeUTF8(token.data.scalar.value, token.data.scalar.length, 'strict') plain = False style = None @@ -571,8 +571,8 @@ cdef class CParser: tags = {} tag_directive = event.data.document_start.tag_directives.start while tag_directive != event.data.document_start.tag_directives.end: - handle = PyUnicode_FromString(tag_directive.handle) - prefix = PyUnicode_FromString(tag_directive.prefix) + handle = PyUnicode_FromString(tag_directive.handle) + prefix = PyUnicode_FromString(tag_directive.prefix) tags[handle] = prefix tag_directive = tag_directive+1 return DocumentStartEvent(start_mark, end_mark, @@ -592,7 +592,7 @@ cdef class CParser: tag = None if event.data.scalar.tag != NULL: tag = PyUnicode_FromString(event.data.scalar.tag) - value = PyUnicode_DecodeUTF8(event.data.scalar.value, + value = PyUnicode_DecodeUTF8(event.data.scalar.value, event.data.scalar.length, 'strict') plain_implicit = False if event.data.scalar.plain_implicit == 1: @@ -762,11 +762,11 @@ cdef class CParser: self.parsed_event.start_mark.column, None, None) if PY_MAJOR_VERSION < 3: - raise ComposerError("found duplicate anchor; first occurrence", - self.anchors[anchor].start_mark, "second occurrence", mark) + raise ComposerError("found duplicate anchor; first occurrence", + self.anchors[anchor].start_mark, "second occurrence", mark) else: - raise ComposerError(u"found duplicate anchor; first occurrence", - self.anchors[anchor].start_mark, u"second occurrence", mark) + raise ComposerError(u"found duplicate anchor; first occurrence", + self.anchors[anchor].start_mark, u"second occurrence", mark) self.descend_resolver(parent, index) if self.parsed_event.type == YAML_SCALAR_EVENT: node = self._compose_scalar_node(anchor) @@ -788,7 +788,7 @@ cdef class CParser: self.parsed_event.end_mark.line, self.parsed_event.end_mark.column, None, None) - value = PyUnicode_DecodeUTF8(self.parsed_event.data.scalar.value, + value = PyUnicode_DecodeUTF8(self.parsed_event.data.scalar.value, self.parsed_event.data.scalar.length, 'strict') plain_implicit = False if self.parsed_event.data.scalar.plain_implicit == 1: @@ -905,7 +905,7 @@ cdef class CParser: raise error return 1 -cdef int input_handler(void *data, char *buffer, size_t size, size_t *read) except 0: +cdef int input_handler(void *data, char *buffer, size_t size, size_t *read) except 0: cdef CParser parser parser = <CParser>data if parser.stream_cache is None: @@ -924,7 +924,7 @@ cdef int input_handler(void *data, char *buffer, size_t size, size_t *read) exce if (parser.stream_cache_len - parser.stream_cache_pos) < size: size = parser.stream_cache_len - parser.stream_cache_pos if size > 0: - memcpy(buffer, PyString_AS_STRING(parser.stream_cache) + memcpy(buffer, PyString_AS_STRING(parser.stream_cache) + parser.stream_cache_pos, size) read[0] = size parser.stream_cache_pos += size @@ -964,7 +964,7 @@ cdef class CEmitter: if hasattr(stream, u'encoding'): self.dump_unicode = 1 self.use_encoding = encoding - yaml_emitter_set_output(&self.emitter, output_handler, <void *>self) + yaml_emitter_set_output(&self.emitter, output_handler, <void *>self) if canonical: yaml_emitter_set_canonical(&self.emitter, 1) if indent is not None: @@ -1071,7 +1071,7 @@ cdef class CEmitter: raise TypeError("tag handle must be a string") else: raise TypeError(u"tag handle must be a string") - tag_directives_end.handle = PyString_AS_STRING(handle) + tag_directives_end.handle = PyString_AS_STRING(handle) if PyUnicode_CheckExact(prefix): prefix = PyUnicode_AsUTF8String(prefix) cache.append(prefix) @@ -1080,7 +1080,7 @@ cdef class CEmitter: raise TypeError("tag prefix must be a string") else: raise TypeError(u"tag prefix must be a string") - tag_directives_end.prefix = PyString_AS_STRING(prefix) + tag_directives_end.prefix = PyString_AS_STRING(prefix) tag_directives_end = tag_directives_end+1 implicit = 1 if event_object.explicit: @@ -1104,7 +1104,7 @@ cdef class CEmitter: else: raise TypeError(u"anchor must be a string") anchor = PyString_AS_STRING(anchor_object) - if yaml_alias_event_initialize(event, anchor) == 0: + if yaml_alias_event_initialize(event, anchor) == 0: raise MemoryError elif event_class is ScalarEvent: anchor = NULL @@ -1154,7 +1154,7 @@ cdef class CEmitter: scalar_style = YAML_LITERAL_SCALAR_STYLE elif style_object == ">" or style_object == u">": scalar_style = YAML_FOLDED_SCALAR_STYLE - if yaml_scalar_event_initialize(event, anchor, tag, value, length, + if yaml_scalar_event_initialize(event, anchor, tag, value, length, plain_implicit, quoted_implicit, scalar_style) == 0: raise MemoryError elif event_class is SequenceStartEvent: @@ -1186,7 +1186,7 @@ cdef class CEmitter: sequence_style = YAML_BLOCK_SEQUENCE_STYLE if event_object.flow_style: sequence_style = YAML_FLOW_SEQUENCE_STYLE - if yaml_sequence_start_event_initialize(event, anchor, tag, + if yaml_sequence_start_event_initialize(event, anchor, tag, implicit, sequence_style) == 0: raise MemoryError elif event_class is MappingStartEvent: @@ -1218,7 +1218,7 @@ cdef class CEmitter: mapping_style = YAML_BLOCK_MAPPING_STYLE if event_object.flow_style: mapping_style = YAML_FLOW_MAPPING_STYLE - if yaml_mapping_start_event_initialize(event, anchor, tag, + if yaml_mapping_start_event_initialize(event, anchor, tag, implicit, mapping_style) == 0: raise MemoryError elif event_class is SequenceEndEvent: @@ -1326,7 +1326,7 @@ cdef class CEmitter: raise TypeError("tag handle must be a string") else: raise TypeError(u"tag handle must be a string") - tag_directives_end.handle = PyString_AS_STRING(handle) + tag_directives_end.handle = PyString_AS_STRING(handle) if PyUnicode_CheckExact(prefix): prefix = PyUnicode_AsUTF8String(prefix) cache.append(prefix) @@ -1335,7 +1335,7 @@ cdef class CEmitter: raise TypeError("tag prefix must be a string") else: raise TypeError(u"tag prefix must be a string") - tag_directives_end.prefix = PyString_AS_STRING(prefix) + tag_directives_end.prefix = PyString_AS_STRING(prefix) tag_directives_end = tag_directives_end+1 if yaml_document_start_event_initialize(&event, version_directive, tag_directives_start, tag_directives_end, @@ -1396,7 +1396,7 @@ cdef class CEmitter: raise TypeError(u"anchor must be a string") anchor = PyString_AS_STRING(anchor_object) if node in self.serialized_nodes: - if yaml_alias_event_initialize(&event, anchor) == 0: + if yaml_alias_event_initialize(&event, anchor) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: error = self._emitter_error() @@ -1443,7 +1443,7 @@ cdef class CEmitter: scalar_style = YAML_LITERAL_SCALAR_STYLE elif style_object == ">" or style_object == u">": scalar_style = YAML_FOLDED_SCALAR_STYLE - if yaml_scalar_event_initialize(&event, anchor, tag, value, length, + if yaml_scalar_event_initialize(&event, anchor, tag, value, length, plain_implicit, quoted_implicit, scalar_style) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: @@ -1467,7 +1467,7 @@ cdef class CEmitter: sequence_style = YAML_BLOCK_SEQUENCE_STYLE if node.flow_style: sequence_style = YAML_FLOW_SEQUENCE_STYLE - if yaml_sequence_start_event_initialize(&event, anchor, tag, + if yaml_sequence_start_event_initialize(&event, anchor, tag, implicit, sequence_style) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: @@ -1499,7 +1499,7 @@ cdef class CEmitter: mapping_style = YAML_BLOCK_MAPPING_STYLE if node.flow_style: mapping_style = YAML_FLOW_MAPPING_STYLE - if yaml_mapping_start_event_initialize(&event, anchor, tag, + if yaml_mapping_start_event_initialize(&event, anchor, tag, implicit, mapping_style) == 0: raise MemoryError if yaml_emitter_emit(&self.emitter, &event) == 0: @@ -1515,13 +1515,13 @@ cdef class CEmitter: self.ascend_resolver() return 1 -cdef int output_handler(void *data, char *buffer, size_t size) except 0: +cdef int output_handler(void *data, char *buffer, size_t size) except 0: cdef CEmitter emitter emitter = <CEmitter>data if emitter.dump_unicode == 0: - value = PyString_FromStringAndSize(buffer, size) + value = PyString_FromStringAndSize(buffer, size) else: - value = PyUnicode_DecodeUTF8(buffer, size, 'strict') + value = PyUnicode_DecodeUTF8(buffer, size, 'strict') emitter.stream.write(value) return 1 diff --git a/contrib/python/PyYAML/py3/yaml/composer.py b/contrib/python/PyYAML/py3/yaml/composer.py index 6d15cb40e3..17668e565d 100644 --- a/contrib/python/PyYAML/py3/yaml/composer.py +++ b/contrib/python/PyYAML/py3/yaml/composer.py @@ -72,9 +72,9 @@ class Composer: anchor = event.anchor if anchor is not None: if anchor in self.anchors: - raise ComposerError("found duplicate anchor %r; first occurrence" + raise ComposerError("found duplicate anchor %r; first occurrence" % anchor, self.anchors[anchor].start_mark, - "second occurrence", event.start_mark) + "second occurrence", event.start_mark) self.descend_resolver(parent, index) if self.check_event(ScalarEvent): node = self.compose_scalar_node(anchor) diff --git a/contrib/python/PyYAML/py3/yaml/constructor.py b/contrib/python/PyYAML/py3/yaml/constructor.py index 619acd3070..33da8979b8 100644 --- a/contrib/python/PyYAML/py3/yaml/constructor.py +++ b/contrib/python/PyYAML/py3/yaml/constructor.py @@ -1,17 +1,17 @@ -__all__ = [ - 'BaseConstructor', - 'SafeConstructor', - 'FullConstructor', - 'UnsafeConstructor', - 'Constructor', - 'ConstructorError' -] +__all__ = [ + 'BaseConstructor', + 'SafeConstructor', + 'FullConstructor', + 'UnsafeConstructor', + 'Constructor', + 'ConstructorError' +] from .error import * from .nodes import * -import collections.abc, datetime, base64, binascii, re, sys, types +import collections.abc, datetime, base64, binascii, re, sys, types class ConstructorError(MarkedYAMLError): pass @@ -31,14 +31,14 @@ class BaseConstructor: # If there are more documents available? return self.check_node() - def check_state_key(self, key): - """Block special attributes/methods from being set in a newly created - object, to prevent user-controlled methods from being called during - deserialization""" - if self.get_state_keys_blacklist_regexp().match(key): - raise ConstructorError(None, None, - "blacklisted key '%s' in instance state found" % (key,), None) - + def check_state_key(self, key): + """Block special attributes/methods from being set in a newly created + object, to prevent user-controlled methods from being called during + deserialization""" + if self.get_state_keys_blacklist_regexp().match(key): + raise ConstructorError(None, None, + "blacklisted key '%s' in instance state found" % (key,), None) + def get_data(self): # Construct and return the next document. if self.check_node(): @@ -80,7 +80,7 @@ class BaseConstructor: constructor = self.yaml_constructors[node.tag] else: for tag_prefix in self.yaml_multi_constructors: - if tag_prefix is not None and node.tag.startswith(tag_prefix): + if tag_prefix is not None and node.tag.startswith(tag_prefix): tag_suffix = node.tag[len(tag_prefix):] constructor = self.yaml_multi_constructors[tag_prefix] break @@ -137,7 +137,7 @@ class BaseConstructor: mapping = {} for key_node, value_node in node.value: key = self.construct_object(key_node, deep=deep) - if not isinstance(key, collections.abc.Hashable): + if not isinstance(key, collections.abc.Hashable): raise ConstructorError("while constructing a mapping", node.start_mark, "found unhashable key", key_node.start_mark) value = self.construct_object(value_node, deep=deep) @@ -332,7 +332,7 @@ class SafeConstructor(BaseConstructor): minute = int(values['minute']) second = int(values['second']) fraction = 0 - tzinfo = None + tzinfo = None if values['fraction']: fraction = values['fraction'][:6] while len(fraction) < 6: @@ -344,11 +344,11 @@ class SafeConstructor(BaseConstructor): delta = datetime.timedelta(hours=tz_hour, minutes=tz_minute) if values['tz_sign'] == '-': delta = -delta - tzinfo = datetime.timezone(delta) - elif values['tz']: - tzinfo = datetime.timezone.utc - return datetime.datetime(year, month, day, hour, minute, second, fraction, - tzinfo=tzinfo) + tzinfo = datetime.timezone(delta) + elif values['tz']: + tzinfo = datetime.timezone.utc + return datetime.datetime(year, month, day, hour, minute, second, fraction, + tzinfo=tzinfo) def construct_yaml_omap(self, node): # Note: we do not check for duplicate keys, because it's too @@ -479,18 +479,18 @@ SafeConstructor.add_constructor( SafeConstructor.add_constructor(None, SafeConstructor.construct_undefined) -class FullConstructor(SafeConstructor): - # 'extend' is blacklisted because it is used by - # construct_python_object_apply to add `listitems` to a newly generate - # python instance - def get_state_keys_blacklist(self): - return ['^extend$', '^__.*__$'] - - def get_state_keys_blacklist_regexp(self): - if not hasattr(self, 'state_keys_blacklist_regexp'): - self.state_keys_blacklist_regexp = re.compile('(' + '|'.join(self.get_state_keys_blacklist()) + ')') - return self.state_keys_blacklist_regexp - +class FullConstructor(SafeConstructor): + # 'extend' is blacklisted because it is used by + # construct_python_object_apply to add `listitems` to a newly generate + # python instance + def get_state_keys_blacklist(self): + return ['^extend$', '^__.*__$'] + + def get_state_keys_blacklist_regexp(self): + if not hasattr(self, 'state_keys_blacklist_regexp'): + self.state_keys_blacklist_regexp = re.compile('(' + '|'.join(self.get_state_keys_blacklist()) + ')') + return self.state_keys_blacklist_regexp + def construct_python_str(self, node): return self.construct_scalar(node) @@ -522,22 +522,22 @@ class FullConstructor(SafeConstructor): def construct_python_tuple(self, node): return tuple(self.construct_sequence(node)) - def find_python_module(self, name, mark, unsafe=False): + def find_python_module(self, name, mark, unsafe=False): if not name: raise ConstructorError("while constructing a Python module", mark, "expected non-empty name appended to the tag", mark) - if unsafe: - try: - __import__(name) - except ImportError as exc: - raise ConstructorError("while constructing a Python module", mark, - "cannot find module %r (%s)" % (name, exc), mark) - if name not in sys.modules: + if unsafe: + try: + __import__(name) + except ImportError as exc: + raise ConstructorError("while constructing a Python module", mark, + "cannot find module %r (%s)" % (name, exc), mark) + if name not in sys.modules: raise ConstructorError("while constructing a Python module", mark, - "module %r is not imported" % name, mark) + "module %r is not imported" % name, mark) return sys.modules[name] - def find_python_name(self, name, mark, unsafe=False): + def find_python_name(self, name, mark, unsafe=False): if not name: raise ConstructorError("while constructing a Python object", mark, "expected non-empty name appended to the tag", mark) @@ -546,15 +546,15 @@ class FullConstructor(SafeConstructor): else: module_name = 'builtins' object_name = name - if unsafe: - try: - __import__(module_name) - except ImportError as exc: - raise ConstructorError("while constructing a Python object", mark, - "cannot find module %r (%s)" % (module_name, exc), mark) - if module_name not in sys.modules: + if unsafe: + try: + __import__(module_name) + except ImportError as exc: + raise ConstructorError("while constructing a Python object", mark, + "cannot find module %r (%s)" % (module_name, exc), mark) + if module_name not in sys.modules: raise ConstructorError("while constructing a Python object", mark, - "module %r is not imported" % module_name, mark) + "module %r is not imported" % module_name, mark) module = sys.modules[module_name] if not hasattr(module, object_name): raise ConstructorError("while constructing a Python object", mark, @@ -577,22 +577,22 @@ class FullConstructor(SafeConstructor): return self.find_python_module(suffix, node.start_mark) def make_python_instance(self, suffix, node, - args=None, kwds=None, newobj=False, unsafe=False): + args=None, kwds=None, newobj=False, unsafe=False): if not args: args = [] if not kwds: kwds = {} cls = self.find_python_name(suffix, node.start_mark) - if not (unsafe or isinstance(cls, type)): - raise ConstructorError("while constructing a Python instance", node.start_mark, - "expected a class, but found %r" % type(cls), - node.start_mark) + if not (unsafe or isinstance(cls, type)): + raise ConstructorError("while constructing a Python instance", node.start_mark, + "expected a class, but found %r" % type(cls), + node.start_mark) if newobj and isinstance(cls, type): return cls.__new__(cls, *args, **kwds) else: return cls(*args, **kwds) - def set_python_instance_state(self, instance, state, unsafe=False): + def set_python_instance_state(self, instance, state, unsafe=False): if hasattr(instance, '__setstate__'): instance.__setstate__(state) else: @@ -600,16 +600,16 @@ class FullConstructor(SafeConstructor): if isinstance(state, tuple) and len(state) == 2: state, slotstate = state if hasattr(instance, '__dict__'): - if not unsafe and state: - for key in state.keys(): - self.check_state_key(key) + if not unsafe and state: + for key in state.keys(): + self.check_state_key(key) instance.__dict__.update(state) elif state: slotstate.update(state) for key, value in slotstate.items(): - if not unsafe: - self.check_state_key(key) - setattr(instance, key, value) + if not unsafe: + self.check_state_key(key) + setattr(instance, key, value) def construct_python_object(self, suffix, node): # Format: @@ -658,91 +658,91 @@ class FullConstructor(SafeConstructor): def construct_python_object_new(self, suffix, node): return self.construct_python_object_apply(suffix, node, newobj=True) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/none', - FullConstructor.construct_yaml_null) + FullConstructor.construct_yaml_null) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/bool', - FullConstructor.construct_yaml_bool) + FullConstructor.construct_yaml_bool) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/str', - FullConstructor.construct_python_str) + FullConstructor.construct_python_str) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/unicode', - FullConstructor.construct_python_unicode) + FullConstructor.construct_python_unicode) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/bytes', - FullConstructor.construct_python_bytes) + FullConstructor.construct_python_bytes) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/int', - FullConstructor.construct_yaml_int) + FullConstructor.construct_yaml_int) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/long', - FullConstructor.construct_python_long) + FullConstructor.construct_python_long) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/float', - FullConstructor.construct_yaml_float) + FullConstructor.construct_yaml_float) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/complex', - FullConstructor.construct_python_complex) + FullConstructor.construct_python_complex) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/list', - FullConstructor.construct_yaml_seq) + FullConstructor.construct_yaml_seq) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/tuple', - FullConstructor.construct_python_tuple) + FullConstructor.construct_python_tuple) -FullConstructor.add_constructor( +FullConstructor.add_constructor( 'tag:yaml.org,2002:python/dict', - FullConstructor.construct_yaml_map) + FullConstructor.construct_yaml_map) -FullConstructor.add_multi_constructor( +FullConstructor.add_multi_constructor( 'tag:yaml.org,2002:python/name:', - FullConstructor.construct_python_name) - -class UnsafeConstructor(FullConstructor): - - def find_python_module(self, name, mark): - return super(UnsafeConstructor, self).find_python_module(name, mark, unsafe=True) - - def find_python_name(self, name, mark): - return super(UnsafeConstructor, self).find_python_name(name, mark, unsafe=True) - - def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False): - return super(UnsafeConstructor, self).make_python_instance( - suffix, node, args, kwds, newobj, unsafe=True) - - def set_python_instance_state(self, instance, state): - return super(UnsafeConstructor, self).set_python_instance_state( - instance, state, unsafe=True) - -UnsafeConstructor.add_multi_constructor( - 'tag:yaml.org,2002:python/module:', - UnsafeConstructor.construct_python_module) - -UnsafeConstructor.add_multi_constructor( - 'tag:yaml.org,2002:python/object:', - UnsafeConstructor.construct_python_object) - -UnsafeConstructor.add_multi_constructor( - 'tag:yaml.org,2002:python/object/new:', - UnsafeConstructor.construct_python_object_new) - -UnsafeConstructor.add_multi_constructor( - 'tag:yaml.org,2002:python/object/apply:', - UnsafeConstructor.construct_python_object_apply) - -# Constructor is same as UnsafeConstructor. Need to leave this in place in case -# people have extended it directly. -class Constructor(UnsafeConstructor): - pass + FullConstructor.construct_python_name) + +class UnsafeConstructor(FullConstructor): + + def find_python_module(self, name, mark): + return super(UnsafeConstructor, self).find_python_module(name, mark, unsafe=True) + + def find_python_name(self, name, mark): + return super(UnsafeConstructor, self).find_python_name(name, mark, unsafe=True) + + def make_python_instance(self, suffix, node, args=None, kwds=None, newobj=False): + return super(UnsafeConstructor, self).make_python_instance( + suffix, node, args, kwds, newobj, unsafe=True) + + def set_python_instance_state(self, instance, state): + return super(UnsafeConstructor, self).set_python_instance_state( + instance, state, unsafe=True) + +UnsafeConstructor.add_multi_constructor( + 'tag:yaml.org,2002:python/module:', + UnsafeConstructor.construct_python_module) + +UnsafeConstructor.add_multi_constructor( + 'tag:yaml.org,2002:python/object:', + UnsafeConstructor.construct_python_object) + +UnsafeConstructor.add_multi_constructor( + 'tag:yaml.org,2002:python/object/new:', + UnsafeConstructor.construct_python_object_new) + +UnsafeConstructor.add_multi_constructor( + 'tag:yaml.org,2002:python/object/apply:', + UnsafeConstructor.construct_python_object_apply) + +# Constructor is same as UnsafeConstructor. Need to leave this in place in case +# people have extended it directly. +class Constructor(UnsafeConstructor): + pass diff --git a/contrib/python/PyYAML/py3/yaml/cyaml.py b/contrib/python/PyYAML/py3/yaml/cyaml.py index 0c21345879..543a5d385b 100644 --- a/contrib/python/PyYAML/py3/yaml/cyaml.py +++ b/contrib/python/PyYAML/py3/yaml/cyaml.py @@ -1,10 +1,10 @@ -__all__ = [ - 'CBaseLoader', 'CSafeLoader', 'CFullLoader', 'CUnsafeLoader', 'CLoader', - 'CBaseDumper', 'CSafeDumper', 'CDumper' -] +__all__ = [ + 'CBaseLoader', 'CSafeLoader', 'CFullLoader', 'CUnsafeLoader', 'CLoader', + 'CBaseDumper', 'CSafeDumper', 'CDumper' +] -from yaml._yaml import CParser, CEmitter +from yaml._yaml import CParser, CEmitter from .constructor import * @@ -27,20 +27,20 @@ class CSafeLoader(CParser, SafeConstructor, Resolver): SafeConstructor.__init__(self) Resolver.__init__(self) -class CFullLoader(CParser, FullConstructor, Resolver): - - def __init__(self, stream): - CParser.__init__(self, stream) - FullConstructor.__init__(self) - Resolver.__init__(self) - -class CUnsafeLoader(CParser, UnsafeConstructor, Resolver): - - def __init__(self, stream): - CParser.__init__(self, stream) - UnsafeConstructor.__init__(self) - Resolver.__init__(self) - +class CFullLoader(CParser, FullConstructor, Resolver): + + def __init__(self, stream): + CParser.__init__(self, stream) + FullConstructor.__init__(self) + Resolver.__init__(self) + +class CUnsafeLoader(CParser, UnsafeConstructor, Resolver): + + def __init__(self, stream): + CParser.__init__(self, stream) + UnsafeConstructor.__init__(self) + Resolver.__init__(self) + class CLoader(CParser, Constructor, Resolver): def __init__(self, stream): @@ -51,51 +51,51 @@ class CLoader(CParser, Constructor, Resolver): class CBaseDumper(CEmitter, BaseRepresenter, BaseResolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): CEmitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, encoding=encoding, allow_unicode=allow_unicode, line_break=line_break, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class CSafeDumper(CEmitter, SafeRepresenter, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): CEmitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, encoding=encoding, allow_unicode=allow_unicode, line_break=line_break, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) SafeRepresenter.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class CDumper(CEmitter, Serializer, Representer, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): CEmitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, encoding=encoding, allow_unicode=allow_unicode, line_break=line_break, explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) diff --git a/contrib/python/PyYAML/py3/yaml/dumper.py b/contrib/python/PyYAML/py3/yaml/dumper.py index 6aadba551f..e779481cf7 100644 --- a/contrib/python/PyYAML/py3/yaml/dumper.py +++ b/contrib/python/PyYAML/py3/yaml/dumper.py @@ -9,11 +9,11 @@ from .resolver import * class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) @@ -21,17 +21,17 @@ class BaseDumper(Emitter, Serializer, BaseRepresenter, BaseResolver): explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) @@ -39,17 +39,17 @@ class SafeDumper(Emitter, Serializer, SafeRepresenter, Resolver): explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) SafeRepresenter.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) class Dumper(Emitter, Serializer, Representer, Resolver): def __init__(self, stream, - default_style=None, default_flow_style=False, + default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, - version=None, tags=None, sort_keys=True): + version=None, tags=None, sort_keys=True): Emitter.__init__(self, stream, canonical=canonical, indent=indent, width=width, allow_unicode=allow_unicode, line_break=line_break) @@ -57,6 +57,6 @@ class Dumper(Emitter, Serializer, Representer, Resolver): explicit_start=explicit_start, explicit_end=explicit_end, version=version, tags=tags) Representer.__init__(self, default_style=default_style, - default_flow_style=default_flow_style, sort_keys=sort_keys) + default_flow_style=default_flow_style, sort_keys=sort_keys) Resolver.__init__(self) diff --git a/contrib/python/PyYAML/py3/yaml/emitter.py b/contrib/python/PyYAML/py3/yaml/emitter.py index a664d01116..ba3ccf1854 100644 --- a/contrib/python/PyYAML/py3/yaml/emitter.py +++ b/contrib/python/PyYAML/py3/yaml/emitter.py @@ -41,7 +41,7 @@ class Emitter: # The stream should have the methods `write` and possibly `flush`. self.stream = stream - # Encoding can be overridden by STREAM-START. + # Encoding can be overridden by STREAM-START. self.encoding = None # Emitter is a state machine with a stack of states to handle nested @@ -604,7 +604,7 @@ class Emitter: start = end = end+1 data = ch.encode('utf-8') for ch in data: - chunks.append('%%%02X' % ch) + chunks.append('%%%02X' % ch) if start < end: chunks.append(suffix[start:end]) suffix_text = ''.join(chunks) @@ -652,7 +652,7 @@ class Emitter: flow_indicators = True # First character or preceded by a whitespace. - preceded_by_whitespace = True + preceded_by_whitespace = True # Last character or followed by a whitespace. followed_by_whitespace = (len(scalar) == 1 or @@ -671,7 +671,7 @@ class Emitter: # Check for indicators. if index == 0: # Leading indicators are special characters. - if ch in '#,[]{}&*!|>\'\"%@`': + if ch in '#,[]{}&*!|>\'\"%@`': flow_indicators = True block_indicators = True if ch in '?:': @@ -689,7 +689,7 @@ class Emitter: flow_indicators = True if followed_by_whitespace: block_indicators = True - if ch == '#' and preceded_by_whitespace: + if ch == '#' and preceded_by_whitespace: flow_indicators = True block_indicators = True @@ -698,8 +698,8 @@ class Emitter: line_breaks = True if not (ch == '\n' or '\x20' <= ch <= '\x7E'): if (ch == '\x85' or '\xA0' <= ch <= '\uD7FF' - or '\uE000' <= ch <= '\uFFFD' - or '\U00010000' <= ch < '\U0010ffff') and ch != '\uFEFF': + or '\uE000' <= ch <= '\uFFFD' + or '\U00010000' <= ch < '\U0010ffff') and ch != '\uFEFF': unicode_characters = True if not self.allow_unicode: special_characters = True @@ -731,7 +731,7 @@ class Emitter: # Prepare for the next character. index += 1 - preceded_by_whitespace = (ch in '\0 \t\r\n\x85\u2028\u2029') + preceded_by_whitespace = (ch in '\0 \t\r\n\x85\u2028\u2029') followed_by_whitespace = (index+1 >= len(scalar) or scalar[index+1] in '\0 \t\r\n\x85\u2028\u2029') diff --git a/contrib/python/PyYAML/py3/yaml/loader.py b/contrib/python/PyYAML/py3/yaml/loader.py index e90c11224c..85c93f1998 100644 --- a/contrib/python/PyYAML/py3/yaml/loader.py +++ b/contrib/python/PyYAML/py3/yaml/loader.py @@ -1,5 +1,5 @@ -__all__ = ['BaseLoader', 'FullLoader', 'SafeLoader', 'Loader', 'UnsafeLoader'] +__all__ = ['BaseLoader', 'FullLoader', 'SafeLoader', 'Loader', 'UnsafeLoader'] from .reader import * from .scanner import * @@ -18,16 +18,16 @@ class BaseLoader(Reader, Scanner, Parser, Composer, BaseConstructor, BaseResolve BaseConstructor.__init__(self) BaseResolver.__init__(self) -class FullLoader(Reader, Scanner, Parser, Composer, FullConstructor, Resolver): - - def __init__(self, stream): - Reader.__init__(self, stream) - Scanner.__init__(self) - Parser.__init__(self) - Composer.__init__(self) - FullConstructor.__init__(self) - Resolver.__init__(self) - +class FullLoader(Reader, Scanner, Parser, Composer, FullConstructor, Resolver): + + def __init__(self, stream): + Reader.__init__(self, stream) + Scanner.__init__(self) + Parser.__init__(self) + Composer.__init__(self) + FullConstructor.__init__(self) + Resolver.__init__(self) + class SafeLoader(Reader, Scanner, Parser, Composer, SafeConstructor, Resolver): def __init__(self, stream): @@ -48,16 +48,16 @@ class Loader(Reader, Scanner, Parser, Composer, Constructor, Resolver): Constructor.__init__(self) Resolver.__init__(self) -# UnsafeLoader is the same as Loader (which is and was always unsafe on -# untrusted input). Use of either Loader or UnsafeLoader should be rare, since -# FullLoad should be able to load almost all YAML safely. Loader is left intact -# to ensure backwards compatibility. -class UnsafeLoader(Reader, Scanner, Parser, Composer, Constructor, Resolver): - - def __init__(self, stream): - Reader.__init__(self, stream) - Scanner.__init__(self) - Parser.__init__(self) - Composer.__init__(self) - Constructor.__init__(self) - Resolver.__init__(self) +# UnsafeLoader is the same as Loader (which is and was always unsafe on +# untrusted input). Use of either Loader or UnsafeLoader should be rare, since +# FullLoad should be able to load almost all YAML safely. Loader is left intact +# to ensure backwards compatibility. +class UnsafeLoader(Reader, Scanner, Parser, Composer, Constructor, Resolver): + + def __init__(self, stream): + Reader.__init__(self, stream) + Scanner.__init__(self) + Parser.__init__(self) + Composer.__init__(self) + Constructor.__init__(self) + Resolver.__init__(self) diff --git a/contrib/python/PyYAML/py3/yaml/reader.py b/contrib/python/PyYAML/py3/yaml/reader.py index 774b0219b5..a44b0f8bf6 100644 --- a/contrib/python/PyYAML/py3/yaml/reader.py +++ b/contrib/python/PyYAML/py3/yaml/reader.py @@ -134,7 +134,7 @@ class Reader(object): self.encoding = 'utf-8' self.update(1) - NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]') + NON_PRINTABLE = re.compile('[^\x09\x0A\x0D\x20-\x7E\x85\xA0-\uD7FF\uE000-\uFFFD\U00010000-\U0010ffff]') def check_printable(self, data): match = self.NON_PRINTABLE.search(data) if match: diff --git a/contrib/python/PyYAML/py3/yaml/representer.py b/contrib/python/PyYAML/py3/yaml/representer.py index 8d0d1fe251..a50075ea30 100644 --- a/contrib/python/PyYAML/py3/yaml/representer.py +++ b/contrib/python/PyYAML/py3/yaml/representer.py @@ -5,7 +5,7 @@ __all__ = ['BaseRepresenter', 'SafeRepresenter', 'Representer', from .error import * from .nodes import * -import datetime, copyreg, types, base64, collections +import datetime, copyreg, types, base64, collections class RepresenterError(YAMLError): pass @@ -15,9 +15,9 @@ class BaseRepresenter: yaml_representers = {} yaml_multi_representers = {} - def __init__(self, default_style=None, default_flow_style=False, sort_keys=True): + def __init__(self, default_style=None, default_flow_style=False, sort_keys=True): self.default_style = default_style - self.sort_keys = sort_keys + self.sort_keys = sort_keys self.default_flow_style = default_flow_style self.represented_objects = {} self.object_keeper = [] @@ -108,11 +108,11 @@ class BaseRepresenter: best_style = True if hasattr(mapping, 'items'): mapping = list(mapping.items()) - if self.sort_keys: - try: - mapping = sorted(mapping) - except TypeError: - pass + if self.sort_keys: + try: + mapping = sorted(mapping) + except TypeError: + pass for item_key, item_value in mapping: node_key = self.represent_data(item_key) node_value = self.represent_data(item_value) @@ -145,7 +145,7 @@ class SafeRepresenter(BaseRepresenter): return self.represent_scalar('tag:yaml.org,2002:null', 'null') def represent_str(self, data): - return self.represent_scalar('tag:yaml.org,2002:str', str(data)) + return self.represent_scalar('tag:yaml.org,2002:str', str(data)) def represent_binary(self, data): if hasattr(base64, 'encodebytes'): @@ -228,7 +228,7 @@ class SafeRepresenter(BaseRepresenter): return self.represent_mapping(tag, state, flow_style=flow_style) def represent_undefined(self, data): - raise RepresenterError("cannot represent an object", data) + raise RepresenterError("cannot represent an object", data) SafeRepresenter.add_representer(type(None), SafeRepresenter.represent_none) @@ -318,7 +318,7 @@ class Representer(SafeRepresenter): elif hasattr(data, '__reduce__'): reduce = data.__reduce__() else: - raise RepresenterError("cannot represent an object", data) + raise RepresenterError("cannot represent an object", data) reduce = (list(reduce)+[None]*5)[:5] function, args, state, listitems, dictitems = reduce args = list(args) diff --git a/contrib/python/PyYAML/py3/yaml/resolver.py b/contrib/python/PyYAML/py3/yaml/resolver.py index 013896d2f1..47e91090af 100644 --- a/contrib/python/PyYAML/py3/yaml/resolver.py +++ b/contrib/python/PyYAML/py3/yaml/resolver.py @@ -146,8 +146,8 @@ class BaseResolver: resolvers = self.yaml_implicit_resolvers.get('', []) else: resolvers = self.yaml_implicit_resolvers.get(value[0], []) - wildcard_resolvers = self.yaml_implicit_resolvers.get(None, []) - for tag, regexp in resolvers + wildcard_resolvers: + wildcard_resolvers = self.yaml_implicit_resolvers.get(None, []) + for tag, regexp in resolvers + wildcard_resolvers: if regexp.match(value): return tag implicit = implicit[1] diff --git a/contrib/python/PyYAML/py3/yaml/scanner.py b/contrib/python/PyYAML/py3/yaml/scanner.py index 7437ede1c6..8c342981a7 100644 --- a/contrib/python/PyYAML/py3/yaml/scanner.py +++ b/contrib/python/PyYAML/py3/yaml/scanner.py @@ -124,13 +124,13 @@ class Scanner: def peek_token(self): # Return the next token, but do not delete if from the queue. - # Return None if no more tokens. + # Return None if no more tokens. while self.need_more_tokens(): self.fetch_more_tokens() if self.tokens: return self.tokens[0] - else: - return None + else: + return None def get_token(self): # Return the next token. @@ -332,7 +332,7 @@ class Scanner: ## } #if self.flow_level and self.indent > column: # raise ScannerError(None, None, - # "invalid indentation or unclosed '[' or '{'", + # "invalid indentation or unclosed '[' or '{'", # self.get_mark()) # In the flow context, indentation is ignored. We make the scanner less @@ -370,7 +370,7 @@ class Scanner: def fetch_stream_end(self): - # Set the current indentation to -1. + # Set the current indentation to -1. self.unwind_indent(-1) # Reset simple keys. @@ -389,7 +389,7 @@ class Scanner: def fetch_directive(self): - # Set the current indentation to -1. + # Set the current indentation to -1. self.unwind_indent(-1) # Reset simple keys. @@ -407,7 +407,7 @@ class Scanner: def fetch_document_indicator(self, TokenClass): - # Set the current indentation to -1. + # Set the current indentation to -1. self.unwind_indent(-1) # Reset simple keys. Note that there could not be a block collection @@ -519,7 +519,7 @@ class Scanner: # Block context needs additional checks. if not self.flow_level: - # Are we allowed to start a key (not necessary a simple)? + # Are we allowed to start a key (not necessary a simple)? if not self.allow_simple_key: raise ScannerError(None, None, "mapping keys are not allowed here", @@ -567,7 +567,7 @@ class Scanner: else: # Block context needs additional checks. - # (Do we really need them? They will be caught by the parser + # (Do we really need them? They will be caught by the parser # anyway.) if not self.flow_level: @@ -900,7 +900,7 @@ class Scanner: # The specification does not restrict characters for anchors and # aliases. This may lead to problems, for instance, the document: # [ *alias, value ] - # can be interpreted in two ways, as + # can be interpreted in two ways, as # [ "value" ] # and # [ *alias , "value" ] @@ -1169,7 +1169,7 @@ class Scanner: ' ': '\x20', '\"': '\"', '\\': '\\', - '/': '/', + '/': '/', 'N': '\x85', '_': '\xA0', 'L': '\u2028', @@ -1270,7 +1270,7 @@ class Scanner: def scan_plain(self): # See the specification for details. # We add an additional restriction for the flow context: - # plain scalars in the flow context cannot contain ',' or '?'. + # plain scalars in the flow context cannot contain ',' or '?'. # We also keep track of the `allow_simple_key` flag here. # Indentation rules are loosed for the flow context. chunks = [] @@ -1289,10 +1289,10 @@ class Scanner: while True: ch = self.peek(length) if ch in '\0 \t\r\n\x85\u2028\u2029' \ - or (ch == ':' and - self.peek(length+1) in '\0 \t\r\n\x85\u2028\u2029' - + (u',[]{}' if self.flow_level else u''))\ - or (self.flow_level and ch in ',?[]{}'): + or (ch == ':' and + self.peek(length+1) in '\0 \t\r\n\x85\u2028\u2029' + + (u',[]{}' if self.flow_level else u''))\ + or (self.flow_level and ch in ',?[]{}'): break length += 1 if length == 0: diff --git a/contrib/python/PyYAML/ya.make b/contrib/python/PyYAML/ya.make index a604fce51f..0c573c7b9a 100644 --- a/contrib/python/PyYAML/ya.make +++ b/contrib/python/PyYAML/ya.make @@ -2,23 +2,23 @@ PY23_LIBRARY() LICENSE(MIT) -OWNER(g:python-contrib) +OWNER(g:python-contrib) -IF (PYTHON2) - PEERDIR( - contrib/python/PyYAML/py2 +IF (PYTHON2) + PEERDIR( + contrib/python/PyYAML/py2 ) -ELSE() - PEERDIR( - contrib/python/PyYAML/py3 +ELSE() + PEERDIR( + contrib/python/PyYAML/py3 ) -ENDIF() +ENDIF() NO_LINT() -END() - -RECURSE( - py2 - py3 -) +END() + +RECURSE( + py2 + py3 +) |