diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-08-07 09:43:06 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-08-07 09:43:06 +0200 |
commit | 56035ae630d159ce4d4f32264d3f992a24d6014f (patch) | |
tree | a8a01711504430b1f196e6ac9aafd07fe346a2c4 /tokens.py | |
parent | be4502b57ac2203e3ad075b18a5a94f87dfcf8dc (diff) | |
download | ruamel.yaml-56035ae630d159ce4d4f32264d3f992a24d6014f.tar.gz |
python 2.7 changes float round-trippign
Diffstat (limited to 'tokens.py')
-rw-r--r-- | tokens.py | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -51,14 +51,19 @@ class Token(object): ScalarToken that follows it empty is a special for empty values -> comment after key """ + if self.comment is not None: + print('mci:', self, target, getattr(self, '_comment', None), + getattr(target, '_comment', None), empty) c = self.comment if c is None: return # don't push beyond last element if isinstance(target, StreamEndToken): return - if isinstance(self, ValueToken) and isinstance(target, BlockEntryToken): - return + #if isinstance(self, ValueToken) and isinstance(target, BlockEntryToken): + # if target._comment: + # target._comment[0] = c[0] + # return delattr(self, '_comment') tc = target.comment if not tc: # target comment, just insert @@ -66,6 +71,7 @@ class Token(object): if empty: c = [c[0], c[1], None, None, c[0]] target._comment = c + print('mco2:', self, target, target.comment, empty) return self if c[0] and tc[0] or c[1] and tc[1]: raise NotImplementedError('overlap in comment %r %r' % c, tc) @@ -73,6 +79,14 @@ class Token(object): tc[0] = c[0] if c[1]: tc[1] = c[1] + #if empty: + # if len(tc) == 2: + # tc.extend([None, None, c[0]]) + # elif len(tc) == 4: + # tc.append(d[0]) + # else: + # raise NotImplementedError + print('mco:', self, target, target.comment, empty) return self def split_comment(self): @@ -170,6 +184,9 @@ class KeyToken(Token): __slots__ = () id = '?' + def x__repr__(self): + return 'KeyToken({})'.format( + self.start_mark.buffer[self.start_mark.index:].split(None, 1)[0]) class ValueToken(Token): __slots__ = () |