Use scripts.utils for colors in scripts.
This commit is contained in:
parent
e26606b0d6
commit
a7c1f38344
@ -43,13 +43,14 @@ import functools
|
|||||||
import contextlib
|
import contextlib
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
import colorama as col
|
|
||||||
import pep257
|
import pep257
|
||||||
import pkg_resources as pkg
|
import pkg_resources as pkg
|
||||||
|
|
||||||
|
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
|
|
||||||
|
from scripts import utils
|
||||||
|
|
||||||
|
|
||||||
# We need to do this because pyroma is braindead enough to use logging instead
|
# We need to do this because pyroma is braindead enough to use logging instead
|
||||||
# of print...
|
# of print...
|
||||||
@ -159,7 +160,7 @@ def check_git():
|
|||||||
untracked.append(name)
|
untracked.append(name)
|
||||||
if untracked:
|
if untracked:
|
||||||
status = False
|
status = False
|
||||||
print("{}Untracked files:{}".format(col.Fore.RED, col.Fore.RESET))
|
utils.print_col("Untracked files:", 'red')
|
||||||
print('\n'.join(untracked))
|
print('\n'.join(untracked))
|
||||||
else:
|
else:
|
||||||
status = True
|
status = True
|
||||||
@ -277,7 +278,6 @@ def _checker_enabled(args, group, name):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Main entry point."""
|
"""Main entry point."""
|
||||||
col.init()
|
|
||||||
exit_status = collections.OrderedDict()
|
exit_status = collections.OrderedDict()
|
||||||
exit_status_bool = {}
|
exit_status_bool = {}
|
||||||
parser = argparse.ArgumentParser(description='Run various checkers.')
|
parser = argparse.ArgumentParser(description='Run various checkers.')
|
||||||
@ -295,11 +295,10 @@ def main():
|
|||||||
|
|
||||||
for group in groups:
|
for group in groups:
|
||||||
print()
|
print()
|
||||||
print("{}==================== {} ===================={}".format(
|
utils.print_col("==================== {} ====================".format(
|
||||||
col.Fore.YELLOW, group, col.Fore.RESET))
|
group), 'yellow')
|
||||||
for name, func in checkers[group].items():
|
for name, func in checkers[group].items():
|
||||||
print("{}------ {} ------{}".format(col.Fore.CYAN, name,
|
utils.print_col("------ {} ------".format(name), 'cyan')
|
||||||
col.Fore.RESET))
|
|
||||||
if _checker_enabled(args, group, name):
|
if _checker_enabled(args, group, name):
|
||||||
status = func()
|
status = func()
|
||||||
key = '{}_{}'.format(group, name)
|
key = '{}_{}'.format(group, name)
|
||||||
@ -314,15 +313,14 @@ def main():
|
|||||||
# means problems.
|
# means problems.
|
||||||
exit_status_bool[key] = (status == 0)
|
exit_status_bool[key] = (status == 0)
|
||||||
else:
|
else:
|
||||||
print("{}Checker disabled.{}".format(
|
utils.print_col("Checker disabled.", 'blue')
|
||||||
col.Fore.BLUE, col.Fore.RESET))
|
|
||||||
print()
|
print()
|
||||||
print("{}Exit status values:{}".format(col.Fore.YELLOW, col.Fore.RESET))
|
utils.print_col("Exit status values:", 'yellow')
|
||||||
for (k, v) in exit_status.items():
|
for (k, v) in exit_status.items():
|
||||||
ok = exit_status_bool[k]
|
ok = exit_status_bool[k]
|
||||||
color = col.Fore.GREEN if ok else col.Fore.RED
|
color = 'green' if ok else 'red'
|
||||||
print('{} {} - {} ({}){}'.format(color, k, 'ok' if ok else 'FAIL',
|
utils.print_col(
|
||||||
v, col.Fore.RESET))
|
' {} - {} ({})'.format(k, 'ok' if ok else 'FAIL', v), color)
|
||||||
|
|
||||||
if all(exit_status_bool):
|
if all(exit_status_bool):
|
||||||
return 0
|
return 0
|
||||||
|
@ -25,7 +25,9 @@ import signal
|
|||||||
import sys
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
import colorama as col
|
sys.path.insert(0, os.getcwd())
|
||||||
|
|
||||||
|
from scripts import utils
|
||||||
|
|
||||||
|
|
||||||
SCRIPT = """
|
SCRIPT = """
|
||||||
@ -53,11 +55,11 @@ app.exec_()
|
|||||||
def print_ret(ret):
|
def print_ret(ret):
|
||||||
"""Print information about an exit status."""
|
"""Print information about an exit status."""
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
print("{}success{}".format(col.Fore.GREEN, col.Fore.RESET))
|
utils.print_col("success", 'green')
|
||||||
elif ret == -signal.SIGSEGV:
|
elif ret == -signal.SIGSEGV:
|
||||||
print("{}segfault{}".format(col.Fore.RED, col.Fore.RESET))
|
utils.print_col("segfault", 'red')
|
||||||
else:
|
else:
|
||||||
print("{}error {}{}".format(col.Fore.YELLOW, ret, col.Fore.RESET))
|
utils.print_col("error {}".format(ret), 'yellow')
|
||||||
print()
|
print()
|
||||||
|
|
||||||
|
|
||||||
@ -86,8 +88,7 @@ def main():
|
|||||||
else:
|
else:
|
||||||
pages = [(e, True) for e in sys.argv[1:]]
|
pages = [(e, True) for e in sys.argv[1:]]
|
||||||
for page, test_harfbuzz in pages:
|
for page, test_harfbuzz in pages:
|
||||||
print("{}==== {} ===={}".format(col.Style.BRIGHT, page,
|
utils.print_bold("==== {} ====".format(page))
|
||||||
col.Style.NORMAL))
|
|
||||||
if test_harfbuzz:
|
if test_harfbuzz:
|
||||||
print("With system harfbuzz:")
|
print("With system harfbuzz:")
|
||||||
ret = subprocess.call([sys.executable, '-c', SCRIPT, page])
|
ret = subprocess.call([sys.executable, '-c', SCRIPT, page])
|
||||||
|
@ -31,17 +31,15 @@ import collections
|
|||||||
import tempfile
|
import tempfile
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
import colorama as col
|
|
||||||
|
|
||||||
sys.path.insert(0, os.getcwd())
|
sys.path.insert(0, os.getcwd())
|
||||||
|
|
||||||
# We import qutebrowser.app so all @cmdutils-register decorators are run.
|
# We import qutebrowser.app so all @cmdutils-register decorators are run.
|
||||||
import qutebrowser.app
|
import qutebrowser.app
|
||||||
from scripts import asciidoc2html
|
from scripts import asciidoc2html, utils
|
||||||
from qutebrowser import qutebrowser
|
from qutebrowser import qutebrowser
|
||||||
from qutebrowser.commands import cmdutils
|
from qutebrowser.commands import cmdutils
|
||||||
from qutebrowser.config import configdata
|
from qutebrowser.config import configdata
|
||||||
from qutebrowser.utils import utils
|
from qutebrowser.utils import utils as quteutils
|
||||||
|
|
||||||
|
|
||||||
class UsageFormatter(argparse.HelpFormatter):
|
class UsageFormatter(argparse.HelpFormatter):
|
||||||
@ -153,7 +151,7 @@ def _get_command_doc(name, cmd):
|
|||||||
if syntax != name:
|
if syntax != name:
|
||||||
output.append('Syntax: +:{}+'.format(syntax))
|
output.append('Syntax: +:{}+'.format(syntax))
|
||||||
output.append("")
|
output.append("")
|
||||||
parser = utils.DocstringParser(cmd.handler)
|
parser = quteutils.DocstringParser(cmd.handler)
|
||||||
output.append(parser.short_desc)
|
output.append(parser.short_desc)
|
||||||
if parser.long_desc:
|
if parser.long_desc:
|
||||||
output.append("")
|
output.append("")
|
||||||
@ -397,8 +395,7 @@ def regenerate_manpage(filename):
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
"""Regenerate all documentation."""
|
"""Regenerate all documentation."""
|
||||||
print("{}Generating asciidoc files...{}".format(
|
utils.print_col("Generating asciidoc files...", 'cyan')
|
||||||
col.Fore.CYAN, col.Fore.RESET))
|
|
||||||
regenerate_manpage('doc/qutebrowser.1.asciidoc')
|
regenerate_manpage('doc/qutebrowser.1.asciidoc')
|
||||||
generate_settings('doc/help/settings.asciidoc')
|
generate_settings('doc/help/settings.asciidoc')
|
||||||
generate_commands('doc/help/commands.asciidoc')
|
generate_commands('doc/help/commands.asciidoc')
|
||||||
|
Loading…
Reference in New Issue
Block a user