Show More
@@ -137,7 +137,7 b' class Parser:' | |||||
137 | out should be a file-type object. Optionally, out can be given as the |
|
137 | out should be a file-type object. Optionally, out can be given as the | |
138 | string 'str' and the parser will automatically return the output in a |
|
138 | string 'str' and the parser will automatically return the output in a | |
139 | string.""" |
|
139 | string.""" | |
140 |
|
140 | |||
141 | string_output = 0 |
|
141 | string_output = 0 | |
142 | if out == 'str' or self.out == 'str' or \ |
|
142 | if out == 'str' or self.out == 'str' or \ | |
143 | isinstance(self.out,StringIO.StringIO): |
|
143 | isinstance(self.out,StringIO.StringIO): | |
@@ -159,14 +159,14 b' class Parser:' | |||||
159 | return raw,error |
|
159 | return raw,error | |
160 | else: |
|
160 | else: | |
161 | return None,error |
|
161 | return None,error | |
162 |
|
162 | |||
163 | # local shorthands |
|
163 | # local shorthands | |
164 | colors = self.color_table[scheme].colors |
|
164 | colors = self.color_table[scheme].colors | |
165 | self.colors = colors # put in object so __call__ sees it |
|
165 | self.colors = colors # put in object so __call__ sees it | |
166 |
|
166 | |||
167 | # Remove trailing whitespace and normalize tabs |
|
167 | # Remove trailing whitespace and normalize tabs | |
168 | self.raw = raw.expandtabs().rstrip() |
|
168 | self.raw = raw.expandtabs().rstrip() | |
169 |
|
169 | |||
170 | # store line offsets in self.lines |
|
170 | # store line offsets in self.lines | |
171 | self.lines = [0, 0] |
|
171 | self.lines = [0, 0] | |
172 | pos = 0 |
|
172 | pos = 0 | |
@@ -217,11 +217,6 b' class Parser:' | |||||
217 | newpos = self.lines[srow] + scol |
|
217 | newpos = self.lines[srow] + scol | |
218 | self.pos = newpos + len(toktext) |
|
218 | self.pos = newpos + len(toktext) | |
219 |
|
219 | |||
220 | # handle newlines |
|
|||
221 | #if toktype in [token.NEWLINE, tokenize.NL]: |
|
|||
222 | # owrite(linesep) |
|
|||
223 | # return |
|
|||
224 |
|
||||
225 | # send the original whitespace, if needed |
|
220 | # send the original whitespace, if needed | |
226 | if newpos > oldpos: |
|
221 | if newpos > oldpos: | |
227 | owrite(self.raw[oldpos:newpos]) |
|
222 | owrite(self.raw[oldpos:newpos]) | |
@@ -248,7 +243,7 b' class Parser:' | |||||
248 |
|
243 | |||
249 | # send text |
|
244 | # send text | |
250 | owrite('%s%s%s' % (color,toktext,colors.normal)) |
|
245 | owrite('%s%s%s' % (color,toktext,colors.normal)) | |
251 |
|
246 | |||
252 | def main(argv=None): |
|
247 | def main(argv=None): | |
253 | """Run as a command-line script: colorize a python file or stdin using ANSI |
|
248 | """Run as a command-line script: colorize a python file or stdin using ANSI | |
254 | color escapes and print to stdout. |
|
249 | color escapes and print to stdout. |
General Comments 0
You need to be logged in to leave comments.
Login now