summaryrefslogtreecommitdiff
path: root/sphinx/util/console.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2015-03-08 16:55:34 +0100
committerGeorg Brandl <georg@python.org>2015-03-08 16:55:34 +0100
commitd0efb42a4179f331dd67d4d301c81b2c01d8e386 (patch)
tree172f81f7d18e2e6fb28c0ead629e10a8443ec6ee /sphinx/util/console.py
parent2a6b9d58088a186884884d8f30542df8963de075 (diff)
downloadsphinx-git-d0efb42a4179f331dd67d4d301c81b2c01d8e386.tar.gz
util: pep8 fixes
Diffstat (limited to 'sphinx/util/console.py')
-rw-r--r--sphinx/util/console.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/sphinx/util/console.py b/sphinx/util/console.py
index 24d3e4568..ee6e4ea91 100644
--- a/sphinx/util/console.py
+++ b/sphinx/util/console.py
@@ -22,6 +22,7 @@ except ImportError:
_ansi_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm')
codes = {}
+
def get_terminal_width():
"""Borrowed from the py lib."""
try:
@@ -41,6 +42,8 @@ def get_terminal_width():
_tw = get_terminal_width()
+
+
def term_width_line(text):
if not codes:
# if no coloring, don't output fancy backspaces
@@ -49,6 +52,7 @@ def term_width_line(text):
# codes are not displayed, this must be taken into account
return text.ljust(_tw + len(text) - len(_ansi_re.sub('', text))) + '\r'
+
def color_terminal():
if sys.platform == 'win32' and colorama is not None:
colorama.init()
@@ -70,15 +74,19 @@ def nocolor():
colorama.deinit()
codes.clear()
+
def coloron():
codes.update(_orig_codes)
+
def colorize(name, text):
return codes.get(name, '') + text + codes.get('reset', '')
+
def strip_colors(s):
return re.compile('\x1b.*?m').sub('', s)
+
def create_color_func(name):
def inner(text):
return colorize(name, text)