colored output (#15)
This commit is contained in:
parent
4bb8fd7819
commit
0a0af9fb52
|
@ -53,6 +53,11 @@ padpo --github python/python-docs-fr/pull/978
|
|||
|
||||
![Screenshot](screenshot.png)
|
||||
|
||||
### Color
|
||||
|
||||
By default, the output is colorless, and formatted like GCC messages. You can use `-c`
|
||||
or `--color` option to get a colored output.
|
||||
|
||||
## Installation
|
||||
|
||||
### Automatic installation
|
||||
|
|
|
@ -83,7 +83,6 @@ def main():
|
|||
help="path of pull request in GitHub to check",
|
||||
default="",
|
||||
)
|
||||
files.add_argument("-c", "--color", action="store_true", help="color output")
|
||||
files.add_argument(
|
||||
"-p",
|
||||
"--python-docs-fr",
|
||||
|
@ -93,6 +92,7 @@ def main():
|
|||
default=0,
|
||||
)
|
||||
files.add_argument("--version", action="store_true", help="Return version")
|
||||
parser.add_argument("-c", "--color", action="store_true", help="color output")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.version:
|
||||
|
@ -100,9 +100,13 @@ def main():
|
|||
sys.exit(0)
|
||||
|
||||
if args.color:
|
||||
console_format = "%(log_color)s[%(levelname)-8s]%(reset)s %(message)s"
|
||||
console_format = (
|
||||
"%(log_color)s[%(levelname)-8s]%(reset)s "
|
||||
"%(green)s%(pofile)s:%(poline)s: "
|
||||
"%(cyan)s%(message)s%(reset)s"
|
||||
)
|
||||
else:
|
||||
console_format = "%(message)s"
|
||||
console_format = "%(pofile)s:%(poline)s: %(message)s"
|
||||
log = simplelogging.get_logger("__main__", console_format=console_format)
|
||||
|
||||
if args.verbose < 1:
|
||||
|
|
|
@ -144,11 +144,17 @@ class PoFile:
|
|||
continue
|
||||
for message in item.warnings:
|
||||
if isinstance(message, Error):
|
||||
log.error(f"{self.path}:{item.lineno_start}: error: %s", message)
|
||||
log.error(
|
||||
f"error: %s",
|
||||
message,
|
||||
extra={"pofile": self.path, "poline": item.lineno_start},
|
||||
)
|
||||
errors.append(message)
|
||||
elif isinstance(message, Warning):
|
||||
log.warning(
|
||||
f"{self.path}:{item.lineno_start}: warning: %s", message
|
||||
f"warning: %s",
|
||||
message,
|
||||
extra={"pofile": self.path, "poline": item.lineno_start},
|
||||
)
|
||||
warnings.append(message)
|
||||
return errors, warnings
|
||||
|
|
Loading…
Reference in New Issue
Block a user