diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-07-03 08:47:07 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-07-03 08:47:07 +0200 |
commit | 265d675e5eb9a62de4d0ceb916cdea5bd6835c30 (patch) | |
tree | 55ff568f45418e10262734f80f5bb3199b18bdf3 | |
parent | abb64b861ed45367cd9738ffa97ce30bd2d4e4b3 (diff) | |
download | ruamel.yaml-265d675e5eb9a62de4d0ceb916cdea5bd6835c30.tar.gz |
allow output of supplimentary unicode characters0.15.17
-rw-r--r-- | CHANGES | 5 | ||||
-rw-r--r-- | README.rst | 5 | ||||
-rw-r--r-- | __init__.py | 4 | ||||
-rw-r--r-- | _doc/api.rst | 13 | ||||
-rw-r--r-- | _doc/conf.py | 6 | ||||
-rw-r--r-- | emitter.py | 7 |
6 files changed, 34 insertions, 6 deletions
@@ -1,3 +1,8 @@ +[0, 15, 17]: 2017-07-03 + - support for Unicode supplementary Plane **output** with allow_unicode + (input was already supported, triggered by + `this <https://stackoverflow.com/a/44875714/1307905>`_ Stack Overflow Q&A) + [0, 15, 16]: 2017-07-01 - minor typing issues (reported and fix provided by `Manvendra Singh <https://bitbucket.org/manu-chroma/>`_) @@ -32,6 +32,11 @@ ChangeLog .. should insert NEXT: at the beginning of line for next key +0.15.17 (2017-07-03): + - support for Unicode supplementary Plane **output** + (input was already supported, triggered by + `this <https://stackoverflow.com/a/44875714/1307905>`_ Stack Overflow Q&A) + 0.15.16 (2017-07-01): - minor typing issues (reported and fix provided by `Manvendra Singh <https://bitbucket.org/manu-chroma/>`_ diff --git a/__init__.py b/__init__.py index 012f49a..b803bbe 100644 --- a/__init__.py +++ b/__init__.py @@ -7,8 +7,8 @@ if False: # MYPY _package_data = dict( full_package_name='ruamel.yaml', - version_info=(0, 15, 16), - __version__='0.15.16', + version_info=(0, 15, 17), + __version__='0.15.17', author='Anthon van der Neut', author_email='a.van.der.neut@ruamel.eu', description='ruamel.yaml is a YAML parser/emitter that supports roundtrip preservation of comments, seq/map flow style, and map key order', # NOQA diff --git a/_doc/api.rst b/_doc/api.rst index 30ee195..c98193c 100644 --- a/_doc/api.rst +++ b/_doc/api.rst @@ -76,6 +76,7 @@ all functionality of the old interface will be available via Loading ------- + Duplicate keys ++++++++++++++ @@ -96,7 +97,19 @@ In the old API this is a warning starting with 0.15.2 and an error in Dumping ------- +Controls +++++++++ + +On your `YAML()` instance you can set attributes e.g with:: + + yaml = YAML(typ='safe', pure=True) + yaml.allow_unicode = False + +new attributes available are: +`_supplementary` + defaults to `True` if Unicode chars larger than 2 bytes. Set to `False` to + enforce output of the `\U0001f601` ( presumes `allow_unicode` is `True` Transparent usage of new and old API ------------------------------------ diff --git a/_doc/conf.py b/_doc/conf.py index e1b1eea..94f85e5 100644 --- a/_doc/conf.py +++ b/_doc/conf.py @@ -46,7 +46,7 @@ master_doc = 'index' # General information about the project. project = u'yaml' -copyright = u'2016, Anthon van der Neut, Ruamel bvba' +copyright = u'2017, Anthon van der Neut, Ruamel bvba' author = u'Anthon van der Neut' # The version info for the project you're documenting, acts as replacement for @@ -58,7 +58,7 @@ try: # The short X.Y version. version = '.'.join(version_info[:2]) # The full version, including alpha/beta/rc tags. - release = __version__ + version = release = __version__ except: version = release = 'dev' @@ -123,7 +123,7 @@ html_theme = 'default' # The name for this set of Sphinx documents. If None, it defaults to # "<project> v<release> documentation". -# html_title = None +html_title = "python YAML package documentation" # A shorter title for the navigation bar. Default is the same as html_title. # html_short_title = None @@ -10,6 +10,7 @@ from __future__ import print_function # sequence ::= SEQUENCE-START node* SEQUENCE-END # mapping ::= MAPPING-START (node node)* MAPPING-END +import sys from ruamel.yaml.error import YAMLError, YAMLStreamError from ruamel.yaml.events import * # NOQA from ruamel.yaml.compat import utf8, text_type, PY2, nprint, dbg, DBG_EVENT, \ @@ -106,6 +107,8 @@ class Emitter(object): # Formatting details. self.canonical = canonical self.allow_unicode = allow_unicode + # set to False to get "\Uxxxxxxxx" for non-basic unicode like emojis + self.unicode_supplementary = sys.maxunicode > 0xffff self.block_seq_indent = block_seq_indent if block_seq_indent else 0 self.top_level_colon_align = top_level_colon_align self.best_indent = 2 @@ -860,7 +863,9 @@ 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') and ch != u'\uFEFF': + u'\uE000' <= ch <= u'\uFFFD' or + (self.unicode_supplementary and + (u'\U00010000' <= ch <= u'\U0010FFFF'))) and ch != u'\uFEFF': # unicode_characters = True if not self.allow_unicode: special_characters = True |