summaryrefslogtreecommitdiff
path: root/emitter.py
diff options
context:
space:
mode:
authorAnthon van der Neut <anthon@mnt.org>2019-08-16 07:24:14 +0200
committerAnthon van der Neut <anthon@mnt.org>2019-08-16 07:24:14 +0200
commit253509a0afc997ab1fc027fc9344aea30dc7632b (patch)
tree3292b0d2d7a69aef781795002429fd4b59a383b5 /emitter.py
parent37703e0ceb151d4a96b434626b4851ffe1250bb2 (diff)
downloadruamel.yaml-253509a0afc997ab1fc027fc9344aea30dc7632b.tar.gz
output of # in TAG directive0.16.4
fixes issue #307 *When this change indeed resolves your problem, please **Close** this issue*. *(You can do so using the WorkFlow pull-down (close to the top right of this page))*
Diffstat (limited to 'emitter.py')
-rw-r--r--emitter.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/emitter.py b/emitter.py
index 02100dd..73fbe05 100644
--- a/emitter.py
+++ b/emitter.py
@@ -169,7 +169,7 @@ class Emitter(object):
self.prefixed_colon = self.colon if prefix_colon is None else prefix_colon + self.colon
# single entry mappings in flow sequence
self.brace_single_entry_mapping_in_flow_sequence = (
- brace_single_entry_mapping_in_flow_sequence
+ brace_single_entry_mapping_in_flow_sequence
) # NOQA
# Formatting details.
@@ -410,8 +410,11 @@ class Emitter(object):
and self.sequence_context
):
self.sequence_context = False
- if root and isinstance(self.event, ScalarEvent) \
- and not self.scalar_after_indicator:
+ if (
+ root
+ and isinstance(self.event, ScalarEvent)
+ and not self.scalar_after_indicator
+ ):
self.write_indent()
self.process_tag()
if isinstance(self.event, ScalarEvent):
@@ -917,14 +920,14 @@ class Emitter(object):
start = end = 0
if prefix[0] == u'!':
end = 1
+ ch_set = u"-;/?:@&=+$,_.~*'()[]"
+ if self.dumper:
+ version = getattr(self.dumper, 'version', (1, 2))
+ if version is None or version >= (1, 2):
+ ch_set += u'#'
while end < len(prefix):
ch = prefix[end]
- if (
- u'0' <= ch <= u'9'
- or u'A' <= ch <= u'Z'
- or u'a' <= ch <= u'z'
- or ch in u"-;/?!:@&=+$,_.~*'()[]"
- ):
+ if u'0' <= ch <= u'9' or u'A' <= ch <= u'Z' or u'a' <= ch <= u'z' or ch in ch_set:
end += 1
else:
if start < end: