summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2014-10-14 09:54:17 +0200
committerGeorg Brandl <georg@python.org>2014-10-14 09:54:17 +0200
commite9fca35b51f448a344b0ae5221a3b40ef45a391d (patch)
tree93f91e70a1133c0c31245c61ce74701cdb3a0993
parent6b264a62daf62185b1358ccfda216628b7930f72 (diff)
downloadpygments-e9fca35b51f448a344b0ae5221a3b40ef45a391d.tar.gz
terminal formatters: PEP8 cleanup
-rw-r--r--pygments/formatters/terminal.py7
-rw-r--r--pygments/formatters/terminal256.py47
2 files changed, 27 insertions, 27 deletions
diff --git a/pygments/formatters/terminal.py b/pygments/formatters/terminal.py
index 34af3afe..8046c504 100644
--- a/pygments/formatters/terminal.py
+++ b/pygments/formatters/terminal.py
@@ -13,7 +13,7 @@ import sys
from pygments.formatter import Formatter
from pygments.token import Keyword, Name, Comment, String, Error, \
- Number, Operator, Generic, Token, Whitespace
+ Number, Operator, Generic, Token, Whitespace
from pygments.console import ansiformat
from pygments.util import get_choice_opt
@@ -108,8 +108,8 @@ class TerminalFormatter(Formatter):
for ttype, value in tokensource:
if value.endswith("\n"):
- self._write_lineno(outfile)
- value = value[:-1]
+ self._write_lineno(outfile)
+ value = value[:-1]
color = self.colorscheme.get(ttype)
while color is None:
ttype = ttype[:-1]
@@ -149,4 +149,3 @@ class TerminalFormatter(Formatter):
outfile.write(ansiformat(color, spl[-1]))
else:
outfile.write(value)
-
diff --git a/pygments/formatters/terminal256.py b/pygments/formatters/terminal256.py
index 60b698c9..38963800 100644
--- a/pygments/formatters/terminal256.py
+++ b/pygments/formatters/terminal256.py
@@ -66,6 +66,7 @@ class EscapeSequence:
attrs.append("00")
return self.escape(attrs)
+
class Terminal256Formatter(Formatter):
r"""
Format tokens with ANSI color sequences, for output in a 256-color
@@ -98,28 +99,28 @@ class Terminal256Formatter(Formatter):
self.usebold = 'nobold' not in options
self.useunderline = 'nounderline' not in options
- self._build_color_table() # build an RGB-to-256 color conversion table
- self._setup_styles() # convert selected style's colors to term. colors
+ self._build_color_table() # build an RGB-to-256 color conversion table
+ self._setup_styles() # convert selected style's colors to term. colors
def _build_color_table(self):
# colors 0..15: 16 basic colors
- self.xterm_colors.append((0x00, 0x00, 0x00)) # 0
- self.xterm_colors.append((0xcd, 0x00, 0x00)) # 1
- self.xterm_colors.append((0x00, 0xcd, 0x00)) # 2
- self.xterm_colors.append((0xcd, 0xcd, 0x00)) # 3
- self.xterm_colors.append((0x00, 0x00, 0xee)) # 4
- self.xterm_colors.append((0xcd, 0x00, 0xcd)) # 5
- self.xterm_colors.append((0x00, 0xcd, 0xcd)) # 6
- self.xterm_colors.append((0xe5, 0xe5, 0xe5)) # 7
- self.xterm_colors.append((0x7f, 0x7f, 0x7f)) # 8
- self.xterm_colors.append((0xff, 0x00, 0x00)) # 9
- self.xterm_colors.append((0x00, 0xff, 0x00)) # 10
- self.xterm_colors.append((0xff, 0xff, 0x00)) # 11
- self.xterm_colors.append((0x5c, 0x5c, 0xff)) # 12
- self.xterm_colors.append((0xff, 0x00, 0xff)) # 13
- self.xterm_colors.append((0x00, 0xff, 0xff)) # 14
- self.xterm_colors.append((0xff, 0xff, 0xff)) # 15
+ self.xterm_colors.append((0x00, 0x00, 0x00)) # 0
+ self.xterm_colors.append((0xcd, 0x00, 0x00)) # 1
+ self.xterm_colors.append((0x00, 0xcd, 0x00)) # 2
+ self.xterm_colors.append((0xcd, 0xcd, 0x00)) # 3
+ self.xterm_colors.append((0x00, 0x00, 0xee)) # 4
+ self.xterm_colors.append((0xcd, 0x00, 0xcd)) # 5
+ self.xterm_colors.append((0x00, 0xcd, 0xcd)) # 6
+ self.xterm_colors.append((0xe5, 0xe5, 0xe5)) # 7
+ self.xterm_colors.append((0x7f, 0x7f, 0x7f)) # 8
+ self.xterm_colors.append((0xff, 0x00, 0x00)) # 9
+ self.xterm_colors.append((0x00, 0xff, 0x00)) # 10
+ self.xterm_colors.append((0xff, 0xff, 0x00)) # 11
+ self.xterm_colors.append((0x5c, 0x5c, 0xff)) # 12
+ self.xterm_colors.append((0xff, 0x00, 0xff)) # 13
+ self.xterm_colors.append((0x00, 0xff, 0xff)) # 14
+ self.xterm_colors.append((0xff, 0xff, 0xff)) # 15
# colors 16..232: the 6x6x6 color cube
@@ -138,7 +139,7 @@ class Terminal256Formatter(Formatter):
self.xterm_colors.append((v, v, v))
def _closest_color(self, r, g, b):
- distance = 257*257*3 # "infinity" (>distance from #000000 to #ffffff)
+ distance = 257*257*3 # "infinity" (>distance from #000000 to #ffffff)
match = 0
for i in range(0, 254):
@@ -197,7 +198,7 @@ class Terminal256Formatter(Formatter):
not_found = True
while ttype and not_found:
try:
- #outfile.write( "<" + str(ttype) + ">" )
+ # outfile.write( "<" + str(ttype) + ">" )
on, off = self.style_string[str(ttype)]
# Like TerminalFormatter, add "reset colors" escape sequence
@@ -211,12 +212,12 @@ class Terminal256Formatter(Formatter):
outfile.write(on + spl[-1] + off)
not_found = False
- #outfile.write( '#' + str(ttype) + '#' )
+ # outfile.write( '#' + str(ttype) + '#' )
except KeyError:
- #ottype = ttype
+ # ottype = ttype
ttype = ttype[:-1]
- #outfile.write( '!' + str(ottype) + '->' + str(ttype) + '!' )
+ # outfile.write( '!' + str(ottype) + '->' + str(ttype) + '!' )
if not_found:
outfile.write(value)