diff options
author | Anthon van der Neut <anthon@mnt.org> | 2017-08-09 14:17:45 +0200 |
---|---|---|
committer | Anthon van der Neut <anthon@mnt.org> | 2017-08-09 14:17:45 +0200 |
commit | 291b2e6757d22061acb8ee9a581dc04e3a791847 (patch) | |
tree | 3f805ec3551ba2e0baa5ce21b1ebadfd3136ccc5 /tokens.py | |
parent | b3b5301e1b0a21d81a2ec1501df9ef92abac5ce2 (diff) | |
download | ruamel.yaml-291b2e6757d22061acb8ee9a581dc04e3a791847.tar.gz |
fix for indenting non-indented sequence after comment
- solves several expected to fail and fixes two incorrect tests (test_09-Sammy Sosa &
test_before_nested_seq_from_scratch)
- still swaps foo and bar on test_issue_25_03
Diffstat (limited to 'tokens.py')
-rw-r--r-- | tokens.py | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -4,6 +4,7 @@ if False: # MYPY from typing import Any, Dict, Optional, List # NOQA +SHOWLINES = True class Token(object): __slots__ = 'start_mark', 'end_mark', '_comment', @@ -15,12 +16,18 @@ class Token(object): def __repr__(self): # type: () -> Any - attributes = [key for key in self.__slots__ if not key.endswith('_mark') and - hasattr('self', key)] + # attributes = [key for key in self.__slots__ if not key.endswith('_mark') and + # hasattr('self', key)] + attributes = [key for key in self.__slots__ if not key.endswith('_mark')] attributes.sort() arguments = ', '.join(['%s=%r' % (key, getattr(self, key)) for key in attributes]) - return '%s(%s)' % (self.__class__.__name__, arguments) + if SHOWLINES: + try: + arguments += u', line: ' + str(self.start_mark.line) + except: + pass + return u'{}({})'.format(self.__class__.__name__, arguments) def add_post_comment(self, comment): # type: (Any) -> None @@ -261,4 +268,10 @@ class CommentToken(Token): def __repr__(self): # type: () -> Any - return 'CommentToken({!r})'.format(self.value) + v = self.value + if SHOWLINES: + try: + v += u', line: ' + str(self.start_mark.line) + except: + pass + return 'CommentToken({!r})'.format(v) |