Coding style.
Linting.
This commit is contained in:
parent
cbba46d5c0
commit
a3c0a69076
4 changed files with 11 additions and 10 deletions
7
tools.py
7
tools.py
|
|
@ -128,6 +128,7 @@ def _syntax_highlight(text, lexer, style):
|
||||||
if hex_rgb.startswith("#"):
|
if hex_rgb.startswith("#"):
|
||||||
hex_rgb = hex_rgb[1:]
|
hex_rgb = hex_rgb[1:]
|
||||||
return tuple(eval("0x"+hex_rgb[index:index+2]) for index in [0, 2, 4])
|
return tuple(eval("0x"+hex_rgb[index:index+2]) for index in [0, 2, 4])
|
||||||
|
|
||||||
def _char_style_for_token_type(token_type, default_bg_color):
|
def _char_style_for_token_type(token_type, default_bg_color):
|
||||||
token_style = style.style_for_token(token_type)
|
token_style = style.style_for_token(token_type)
|
||||||
fg_color = (None if token_style["color"] is None
|
fg_color = (None if token_style["color"] is None
|
||||||
|
|
@ -138,9 +139,9 @@ def _syntax_highlight(text, lexer, style):
|
||||||
token_style["italic"],
|
token_style["italic"],
|
||||||
token_style["underline"])
|
token_style["underline"])
|
||||||
default_bg_color = _parse_rgb(style.background_color)
|
default_bg_color = _parse_rgb(style.background_color)
|
||||||
text = fill3.join("",
|
text = fill3.join(
|
||||||
[termstr.TermStr(text, _char_style_for_token_type(token_type,
|
"", [termstr.TermStr(text, _char_style_for_token_type(
|
||||||
default_bg_color))
|
token_type, default_bg_color))
|
||||||
for token_type, text in pygments.lex(text, lexer)])
|
for token_type, text in pygments.lex(text, lexer)])
|
||||||
return fill3.Text(text, pad_char=termstr.TermStr(" ").bg_color(
|
return fill3.Text(text, pad_char=termstr.TermStr(" ").bg_color(
|
||||||
default_bg_color))
|
default_bg_color))
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,8 @@ class ToolsTestCase(unittest.TestCase):
|
||||||
[("hi3.cpython-34.pyc", tools.Status.normal)])
|
[("hi3.cpython-34.pyc", tools.Status.normal)])
|
||||||
|
|
||||||
def test_perl_syntax(self):
|
def test_perl_syntax(self):
|
||||||
self._test_tool(tools.perl_syntax, [("perl.pl", tools.Status.ok),
|
self._test_tool(tools.perl_syntax,
|
||||||
|
[("perl.pl", tools.Status.ok),
|
||||||
("perl6.pl", tools.Status.problem)])
|
("perl6.pl", tools.Status.problem)])
|
||||||
|
|
||||||
def test_perldoc(self):
|
def test_perldoc(self):
|
||||||
|
|
|
||||||
1
vigil
1
vigil
|
|
@ -54,7 +54,6 @@ Keys:
|
||||||
import asyncio
|
import asyncio
|
||||||
import collections
|
import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import enum
|
|
||||||
import functools
|
import functools
|
||||||
import gzip
|
import gzip
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue