| Line | |
|---|
| 1 | |
|---|
| 2 | class Node: |
|---|
| 3 | def __init__(self, tag, value, start_marker, end_marker): |
|---|
| 4 | self.tag = tag |
|---|
| 5 | self.value = value |
|---|
| 6 | self.start_marker = start_marker |
|---|
| 7 | self.end_marker = end_marker |
|---|
| 8 | def __repr__(self): |
|---|
| 9 | value = self.value |
|---|
| 10 | if isinstance(value, list): |
|---|
| 11 | if len(value) == 0: |
|---|
| 12 | value = '<empty>' |
|---|
| 13 | elif len(value) == 1: |
|---|
| 14 | value = '<1 item>' |
|---|
| 15 | else: |
|---|
| 16 | value = '<%d items>' % len(value) |
|---|
| 17 | else: |
|---|
| 18 | if len(value) > 75: |
|---|
| 19 | value = repr(value[:70]+u' ... ') |
|---|
| 20 | else: |
|---|
| 21 | value = repr(value) |
|---|
| 22 | return '%s(tag=%r, value=%s)' % (self.__class__.__name__, self.tag, value) |
|---|
| 23 | |
|---|
| 24 | class ScalarNode(Node): |
|---|
| 25 | pass |
|---|
| 26 | |
|---|
| 27 | class CollectionNode(Node): |
|---|
| 28 | pass |
|---|
| 29 | |
|---|
| 30 | class SequenceNode(CollectionNode): |
|---|
| 31 | pass |
|---|
| 32 | |
|---|
| 33 | class MappingNode(CollectionNode): |
|---|
| 34 | pass |
|---|
| 35 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.