Changeset 133 for pyyaml/trunk/lib/yaml/emitter.py
- Timestamp:
- 04/10/06 20:34:16 (7 years ago)
- File:
-
- 1 edited
-
pyyaml/trunk/lib/yaml/emitter.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
pyyaml/trunk/lib/yaml/emitter.py
r132 r133 77 77 # Formatting details. 78 78 self.canonical = False 79 self.allow_unicode = False 79 80 self.best_line_break = u'\n' 80 81 self.best_indent = 2 … … 141 142 self.encoding = self.event.encoding 142 143 self.canonical = self.event.canonical 144 self.allow_unicode = self.event.allow_unicode 143 145 if self.event.indent and self.event.indent > 1: 144 146 self.best_indent = self.event.indent … … 622 624 if followed_by_space or last: 623 625 contains_block_indicator = True 624 if ch == u'-' and followed_by_space or last:626 if ch == u'-' and (followed_by_space or last): 625 627 contains_flow_indicator = True 626 628 contains_block_indicator = True … … 632 634 if followed_by_space or last: 633 635 contains_block_indicator = True 634 if ch == u'#' and preceeded_by_space:636 if ch == u'#' and (preceeded_by_space or first): 635 637 contains_flow_indicator = True 636 638 contains_block_indicator = True … … 641 643 contains_special_characters = True 642 644 else: 643 contains_special_characters = True644 # TODO: We need an option to allow unescaped unicode645 # characters.646 645 contains_unicode_characters = True 647 646 if ch == u' ': … … 692 691 followed_by_space = (index+1 < len(scalar) and 693 692 scalar[index+1] in u'\0 \t\r\n\x85\u2028\u2029') 693 if contains_unicode_characters and not self.allow_unicode: 694 contains_special_characters = True 694 695 allow_flow_plain = not (contains_flow_indicator or contains_special_characters 695 696 or contains_leading_spaces or contains_leading_breaks … … 854 855 if end < len(text): 855 856 ch = text[end] 856 if ch is None or not (u'\x20' <= ch <= u'\x7E') or ch in u'"\\': 857 if ch is None or ch in u'"\\' \ 858 or not (u'\x20' <= ch <= u'\x7E' 859 or (self.allow_unicode and ch > u'\x7F' 860 and ch not in u'\x85\u2028\u2029')): 857 861 if start < end: 858 862 data = text[start:end]
Note: See TracChangeset
for help on using the changeset viewer.
