summaryrefslogtreecommitdiff
path: root/pygments
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2016-02-14 16:47:28 +0100
committerGeorg Brandl <georg@python.org>2016-02-14 16:47:28 +0100
commit2882c34a141f4f36ded54d1473c6d4f73684ffc7 (patch)
tree3b7f7d5eb6bd3e74d75e44018439f568ad2cf1aa /pygments
parent9ae620fdadc8ca9ad56317754b3d9587f57a6d15 (diff)
downloadpygments-2882c34a141f4f36ded54d1473c6d4f73684ffc7.tar.gz
some pep8 fixups
Diffstat (limited to 'pygments')
-rw-r--r--pygments/__init__.py20
-rw-r--r--pygments/console.py24
-rw-r--r--pygments/filter.py8
-rw-r--r--pygments/formatter.py2
-rw-r--r--pygments/lexer.py4
-rw-r--r--pygments/scanner.py3
-rw-r--r--pygments/sphinxext.py1
-rw-r--r--pygments/token.py31
8 files changed, 47 insertions, 46 deletions
diff --git a/pygments/__init__.py b/pygments/__init__.py
index e825aa39..ffac59ef 100644
--- a/pygments/__init__.py
+++ b/pygments/__init__.py
@@ -25,6 +25,9 @@
:copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
+import sys
+
+from pygments.util import StringIO, BytesIO
__version__ = '2.2a0'
__docformat__ = 'restructuredtext'
@@ -32,11 +35,6 @@ __docformat__ = 'restructuredtext'
__all__ = ['lex', 'format', 'highlight']
-import sys
-
-from pygments.util import StringIO, BytesIO
-
-
def lex(code, lexer):
"""
Lex ``code`` with ``lexer`` and return an iterable of tokens.
@@ -44,9 +42,9 @@ def lex(code, lexer):
try:
return lexer.get_tokens(code)
except TypeError as err:
- if isinstance(err.args[0], str) and \
- ('unbound method get_tokens' in err.args[0] or
- 'missing 1 required positional argument' in err.args[0]):
+ if (isinstance(err.args[0], str) and
+ ('unbound method get_tokens' in err.args[0] or
+ 'missing 1 required positional argument' in err.args[0])):
raise TypeError('lex() argument must be a lexer instance, '
'not a class')
raise
@@ -68,9 +66,9 @@ def format(tokens, formatter, outfile=None): # pylint: disable=redefined-builti
else:
formatter.format(tokens, outfile)
except TypeError as err:
- if isinstance(err.args[0], str) and \
- ('unbound method format' in err.args[0] or
- 'missing 1 required positional argument' in err.args[0]):
+ if (isinstance(err.args[0], str) and
+ ('unbound method format' in err.args[0] or
+ 'missing 1 required positional argument' in err.args[0])):
raise TypeError('format() argument must be a formatter instance, '
'not a class')
raise
diff --git a/pygments/console.py b/pygments/console.py
index 4a2c9acb..4aaf5fcb 100644
--- a/pygments/console.py
+++ b/pygments/console.py
@@ -12,18 +12,18 @@
esc = "\x1b["
codes = {}
-codes[""] = ""
-codes["reset"] = esc + "39;49;00m"
+codes[""] = ""
+codes["reset"] = esc + "39;49;00m"
-codes["bold"] = esc + "01m"
-codes["faint"] = esc + "02m"
-codes["standout"] = esc + "03m"
+codes["bold"] = esc + "01m"
+codes["faint"] = esc + "02m"
+codes["standout"] = esc + "03m"
codes["underline"] = esc + "04m"
-codes["blink"] = esc + "05m"
-codes["overline"] = esc + "06m"
+codes["blink"] = esc + "05m"
+codes["overline"] = esc + "06m"
-dark_colors = ["black", "darkred", "darkgreen", "brown", "darkblue",
- "purple", "teal", "lightgray"]
+dark_colors = ["black", "darkred", "darkgreen", "brown", "darkblue",
+ "purple", "teal", "lightgray"]
light_colors = ["darkgray", "red", "green", "yellow", "blue",
"fuchsia", "turquoise", "white"]
@@ -35,10 +35,10 @@ for d, l in zip(dark_colors, light_colors):
del d, l, x
-codes["darkteal"] = codes["turquoise"]
+codes["darkteal"] = codes["turquoise"]
codes["darkyellow"] = codes["brown"]
-codes["fuscia"] = codes["fuchsia"]
-codes["white"] = codes["bold"]
+codes["fuscia"] = codes["fuchsia"]
+codes["white"] = codes["bold"]
def reset_color():
diff --git a/pygments/filter.py b/pygments/filter.py
index c8176ed9..f3082037 100644
--- a/pygments/filter.py
+++ b/pygments/filter.py
@@ -34,10 +34,10 @@ def simplefilter(f):
yield ttype, value.lower()
"""
return type(f.__name__, (FunctionFilter,), {
- 'function': f,
- '__module__': getattr(f, '__module__'),
- '__doc__': f.__doc__
- })
+ '__module__': getattr(f, '__module__'),
+ '__doc__': f.__doc__,
+ 'function': f,
+ })
class Filter(object):
diff --git a/pygments/formatter.py b/pygments/formatter.py
index addd07d7..9f22b3bc 100644
--- a/pygments/formatter.py
+++ b/pygments/formatter.py
@@ -65,7 +65,7 @@ class Formatter(object):
def __init__(self, **options):
self.style = _lookup_style(options.get('style', 'default'))
- self.full = get_bool_opt(options, 'full', False)
+ self.full = get_bool_opt(options, 'full', False)
self.title = options.get('title', '')
self.encoding = options.get('encoding', None) or None
if self.encoding in ('guess', 'chardet'):
diff --git a/pygments/lexer.py b/pygments/lexer.py
index dd6c01e4..f16d8106 100644
--- a/pygments/lexer.py
+++ b/pygments/lexer.py
@@ -319,8 +319,8 @@ def bygroups(*args):
if data is not None:
if ctx:
ctx.pos = match.start(i + 1)
- for item in action(
- lexer, _PseudoMatch(match.start(i + 1), data), ctx):
+ for item in action(lexer,
+ _PseudoMatch(match.start(i + 1), data), ctx):
if item:
yield item
if ctx:
diff --git a/pygments/scanner.py b/pygments/scanner.py
index 35dbbadd..3ff11e4a 100644
--- a/pygments/scanner.py
+++ b/pygments/scanner.py
@@ -66,7 +66,8 @@ class Scanner(object):
def test(self, pattern):
"""Apply a pattern on the current position and check
- if it patches. Doesn't touch pos."""
+ if it patches. Doesn't touch pos.
+ """
return self.check(pattern) is not None
def scan(self, pattern):
diff --git a/pygments/sphinxext.py b/pygments/sphinxext.py
index 2dc9810f..de8cd73b 100644
--- a/pygments/sphinxext.py
+++ b/pygments/sphinxext.py
@@ -57,6 +57,7 @@ FILTERDOC = '''
'''
+
class PygmentsDoc(Directive):
"""
A directive to collect all lexers/formatters/filters and generate
diff --git a/pygments/token.py b/pygments/token.py
index 40c3214a..fbd5b805 100644
--- a/pygments/token.py
+++ b/pygments/token.py
@@ -9,6 +9,7 @@
:license: BSD, see LICENSE for details.
"""
+
class _TokenType(tuple):
parent = None
@@ -52,30 +53,30 @@ class _TokenType(tuple):
return self
-Token = _TokenType()
+Token = _TokenType()
# Special token types
-Text = Token.Text
-Whitespace = Text.Whitespace
-Escape = Token.Escape
-Error = Token.Error
+Text = Token.Text
+Whitespace = Text.Whitespace
+Escape = Token.Escape
+Error = Token.Error
# Text that doesn't belong to this lexer (e.g. HTML in PHP)
-Other = Token.Other
+Other = Token.Other
# Common token types for source code
-Keyword = Token.Keyword
-Name = Token.Name
-Literal = Token.Literal
-String = Literal.String
-Number = Literal.Number
+Keyword = Token.Keyword
+Name = Token.Name
+Literal = Token.Literal
+String = Literal.String
+Number = Literal.Number
Punctuation = Token.Punctuation
-Operator = Token.Operator
-Comment = Token.Comment
+Operator = Token.Operator
+Comment = Token.Comment
# Generic types for non-source code
-Generic = Token.Generic
+Generic = Token.Generic
-# String and some others are not direct childs of Token.
+# String and some others are not direct children of Token.
# alias them:
Token.Token = Token
Token.String = String