Do not output colors when redirecting output
This commit is contained in:
parent
8b5d01e3b1
commit
2e6e2c4fde
|
|
@ -15,12 +15,18 @@
|
||||||
"""Check lang files."""
|
"""Check lang files."""
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
from traceback import print_exc
|
from traceback import print_exc
|
||||||
from sys import stderr
|
from sys import stdout, stderr
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
red = lambda text: '\033[0;31m' + text + '\033[0m'
|
def color_maybe(color_attr, text):
|
||||||
green = lambda text: '\033[0;32m' + text + '\033[0m'
|
if stdout.isatty():
|
||||||
yellow = lambda text: '\033[0;33m' + text + '\033[0m'
|
return '\033[0;' + str(color_attr) + 'm' + text + '\033[0m'
|
||||||
|
else:
|
||||||
|
return text
|
||||||
|
|
||||||
|
red = lambda text: color_maybe(31, text)
|
||||||
|
green = lambda text: color_maybe(32, text)
|
||||||
|
yellow = lambda text: color_maybe(33, text)
|
||||||
|
|
||||||
def parse_txt(lang, no_warning):
|
def parse_txt(lang, no_warning):
|
||||||
"""Parse txt file and check strings to display definition."""
|
"""Parse txt file and check strings to display definition."""
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue