Changeset 196 in tracdarcs
- Timestamp:
- 07/28/10 20:29:28 (19 months ago)
- Hash name:
- 20100728182928-7a6fb-ddd03181113a9599cee3a54b0d10d76fec88486d
- File:
-
- 1 edited
-
tracdarcs/changesparser.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
tracdarcs/changesparser.py
r183 r196 120 120 self.patches.append(patch) 121 121 122 from string import maketrans123 tt = maketrans(BADCHARS, "-"*len(BADCHARS))124 changes = changes.translate(tt)125 126 122 handler = SAXHandler() 127 123 try: 128 124 parseString(changes, handler) 129 125 except SAXParseException, e: 126 # Retry, after removing badchars from the input 127 130 128 lines = changes.splitlines() 131 line = lines[e._linenum-1]132 log.critical("Cannot complete the parse of the XML output due to a SAX Error, "133 "on the changeset %d: %s", len(handler.patches), e)134 log.warning("%s", line)135 129 if e._colnum: 136 log.warning('-'*(e._colnum-1)+'^'*5) 130 line = lines[e._linenum-1][:e._colnum+35] 131 pointer = '\nhere: ' + '-'*(e._colnum-1) + '^'*5 132 else: 133 line = lines[e._linenum-1][:60] 134 pointer = '' 135 log.warning("SAX couldn't parse the XML changes stream " 136 "due to an error at line %d on changeset " 137 "%d: %s\ntext: %s%s\n" 138 "Replacing bad characters with a hyphen " 139 "and retrying...", 140 e._linenum, len(handler.patches), e, 141 repr(line)[1:-1], pointer) 142 143 from string import maketrans 144 tt = maketrans(BADCHARS, "-"*len(BADCHARS)) 145 changes = changes.translate(tt) 146 147 handler = SAXHandler() 148 try: 149 parseString(changes, handler) 150 except SAXParseException, e: 151 log.critical("Sorry, the substitution didn't help, giving up!") 152 else: 153 log.warning("... the replacement did the trick, going on!") 154 137 155 return handler.patches 138 156
Note: See TracChangeset
for help on using the changeset viewer.