implement 'output.colors' options (#2532)
This commit is contained in:
@@ -2877,6 +2877,19 @@ Description
|
|||||||
with a display width greater than 1.
|
with a display width greater than 1.
|
||||||
|
|
||||||
|
|
||||||
|
output.colors
|
||||||
|
-------------
|
||||||
|
Type
|
||||||
|
``object``
|
||||||
|
Default
|
||||||
|
``{"success": "1;32", "skip": "2"}``
|
||||||
|
Description
|
||||||
|
Controls the `ANSI colors <https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797#colors--graphics-mode>`__
|
||||||
|
used with |mode: color|__ for successfully downloaded or skipped files.
|
||||||
|
|
||||||
|
.. __: `output.mode`_
|
||||||
|
|
||||||
|
|
||||||
output.skip
|
output.skip
|
||||||
-----------
|
-----------
|
||||||
Type
|
Type
|
||||||
@@ -3824,6 +3837,7 @@ Description
|
|||||||
.. |Postprocessor Configuration| replace:: ``Postprocessor Configuration``
|
.. |Postprocessor Configuration| replace:: ``Postprocessor Configuration``
|
||||||
.. |strptime| replace:: strftime() and strptime() Behavior
|
.. |strptime| replace:: strftime() and strptime() Behavior
|
||||||
.. |postprocessors| replace:: ``postprocessors``
|
.. |postprocessors| replace:: ``postprocessors``
|
||||||
|
.. |mode: color| replace:: ``"mode": "color"``
|
||||||
|
|
||||||
.. _base-directory: `extractor.*.base-directory`_
|
.. _base-directory: `extractor.*.base-directory`_
|
||||||
.. _date-format: `extractor.*.date-format`_
|
.. _date-format: `extractor.*.date-format`_
|
||||||
|
|||||||
@@ -350,6 +350,10 @@
|
|||||||
"mode": "auto",
|
"mode": "auto",
|
||||||
"progress": true,
|
"progress": true,
|
||||||
"shorten": true,
|
"shorten": true,
|
||||||
|
"colors": {
|
||||||
|
"success": "1;32",
|
||||||
|
"skip" : "2"
|
||||||
|
},
|
||||||
"skip": true,
|
"skip": true,
|
||||||
"log": "[{name}][{levelname}] {message}",
|
"log": "[{name}][{levelname}] {message}",
|
||||||
"logfile": null,
|
"logfile": null,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
# Copyright 2015-2021 Mike Fährmann
|
# Copyright 2015-2022 Mike Fährmann
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# This program is free software; you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License version 2 as
|
# it under the terms of the GNU General Public License version 2 as
|
||||||
@@ -310,16 +310,25 @@ class TerminalOutput(NullOutput):
|
|||||||
|
|
||||||
class ColorOutput(TerminalOutput):
|
class ColorOutput(TerminalOutput):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
TerminalOutput.__init__(self)
|
||||||
|
|
||||||
|
colors = config.get(("output",), "colors") or {}
|
||||||
|
self.color_skip = "\033[{}m".format(
|
||||||
|
colors.get("skip", "2"))
|
||||||
|
self.color_success = "\r\033[{}m".format(
|
||||||
|
colors.get("success", "1;32"))
|
||||||
|
|
||||||
def start(self, path):
|
def start(self, path):
|
||||||
stdout = sys.stdout
|
stdout = sys.stdout
|
||||||
stdout.write(self.shorten(path))
|
stdout.write(self.shorten(path))
|
||||||
stdout.flush()
|
stdout.flush()
|
||||||
|
|
||||||
def skip(self, path):
|
def skip(self, path):
|
||||||
sys.stdout.write("\033[2m" + self.shorten(path) + "\033[0m\n")
|
sys.stdout.write(self.color_skip + self.shorten(path) + "\033[0m\n")
|
||||||
|
|
||||||
def success(self, path, tries):
|
def success(self, path, tries):
|
||||||
sys.stdout.write("\r\033[1;32m" + self.shorten(path) + "\033[0m\n")
|
sys.stdout.write(self.color_success + self.shorten(path) + "\033[0m\n")
|
||||||
|
|
||||||
|
|
||||||
class EAWCache(dict):
|
class EAWCache(dict):
|
||||||
|
|||||||
Reference in New Issue
Block a user