From 848af2e2947b56291c243f392cac3723a3898c21 Mon Sep 17 00:00:00 2001 From: knaggita Date: Wed, 24 Aug 2016 15:15:20 +0300 Subject: [PATCH 1/6] Validation of logger names passed to --logfilter --- qutebrowser/qutebrowser.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index f7c6eb904..2aa26ce15 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -23,6 +23,7 @@ import sys import json import qutebrowser +from qutebrowser.utils import log try: from qutebrowser.misc.checkpyver import check_python_version except ImportError: @@ -81,7 +82,7 @@ def get_argparser(): help="Set loglevel", default='info', choices=['critical', 'error', 'warning', 'info', 'debug', 'vdebug']) - debug.add_argument('--logfilter', + debug.add_argument('--logfilter', type=logfilter_error, help="Comma-separated list of things to be logged " "to the debug log on stdout.") debug.add_argument('--loglines', @@ -139,6 +140,14 @@ def get_argparser(): return parser +def logfilter_error(logfilter): + if set(logfilter.split(',')).issubset(log.LOGGER_NAMES)==False: + raise argparse.ArgumentTypeError("filters: Invalid value {} - expected one " + "of: {}".format(logfilter, + ', '.join(log.LOGGER_NAMES))) + return logfilter + + def main(): parser = get_argparser() if sys.platform == 'darwin' and getattr(sys, 'frozen', False): From cf1dc28214a94c187d124ca050ca262e3e2ab169 Mon Sep 17 00:00:00 2001 From: knaggita Date: Wed, 24 Aug 2016 16:12:32 +0300 Subject: [PATCH 2/6] Validate logger names passed to --logfilter --- qutebrowser/qutebrowser.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 2aa26ce15..6805fda58 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -140,12 +140,19 @@ def get_argparser(): return parser -def logfilter_error(logfilter): - if set(logfilter.split(',')).issubset(log.LOGGER_NAMES)==False: - raise argparse.ArgumentTypeError("filters: Invalid value {} - expected one " +def logfilter_error(logfilter: str): + """Validate logger names passed to --logfilter + + Args: + logfilter: A comma separated list of logger names. + """ + if set(logfilter.split(',')).issubset(log.LOGGER_NAMES): + return logfilter + else: + raise argparse.ArgumentTypeError( + "filters: Invalid value {} - expected one " "of: {}".format(logfilter, ', '.join(log.LOGGER_NAMES))) - return logfilter def main(): From 0b60d287426d5fd3d5342f14f3ed208035945526 Mon Sep 17 00:00:00 2001 From: knaggita Date: Wed, 24 Aug 2016 17:09:34 +0300 Subject: [PATCH 3/6] Validate loggernames passed to --logfilter --- qutebrowser/qutebrowser.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 6805fda58..cda0ae004 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -141,7 +141,7 @@ def get_argparser(): def logfilter_error(logfilter: str): - """Validate logger names passed to --logfilter + """Validate logger names passed to --logfilter. Args: logfilter: A comma separated list of logger names. @@ -149,10 +149,10 @@ def logfilter_error(logfilter: str): if set(logfilter.split(',')).issubset(log.LOGGER_NAMES): return logfilter else: - raise argparse.ArgumentTypeError( - "filters: Invalid value {} - expected one " - "of: {}".format(logfilter, - ', '.join(log.LOGGER_NAMES))) + raise argparse.ArgumentTypeError("filters: Invalid value {} - " + "expected one " + "of: {}".format(filters, + ', '.join(log.LOGGER_NAMES))) def main(): From d26566a1f671b15c050279f7c7f235e957b9ffe9 Mon Sep 17 00:00:00 2001 From: knaggita Date: Wed, 24 Aug 2016 18:56:18 +0300 Subject: [PATCH 4/6] Validate loggernames passed to --logfilter --- qutebrowser/qutebrowser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index cda0ae004..1686ac6d5 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -151,7 +151,7 @@ def logfilter_error(logfilter: str): else: raise argparse.ArgumentTypeError("filters: Invalid value {} - " "expected one " - "of: {}".format(filters, + "of: {}".format(logfilter, ', '.join(log.LOGGER_NAMES))) From 76a3bdd94acfafe4952c689ea889adfe5000daf2 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 25 Aug 2016 23:12:51 +0200 Subject: [PATCH 5/6] Improve message for invalid --logfilter --- qutebrowser/qutebrowser.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/qutebrowser/qutebrowser.py b/qutebrowser/qutebrowser.py index 1686ac6d5..51e01d47c 100644 --- a/qutebrowser/qutebrowser.py +++ b/qutebrowser/qutebrowser.py @@ -149,10 +149,9 @@ def logfilter_error(logfilter: str): if set(logfilter.split(',')).issubset(log.LOGGER_NAMES): return logfilter else: - raise argparse.ArgumentTypeError("filters: Invalid value {} - " - "expected one " - "of: {}".format(logfilter, - ', '.join(log.LOGGER_NAMES))) + raise argparse.ArgumentTypeError( + "filters: Invalid value {} - expected a list of: {}".format( + logfilter, ', '.join(log.LOGGER_NAMES))) def main(): From bce5d0f7ccd874c1c3c30b9021624a9a668e76e6 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 25 Aug 2016 23:13:28 +0200 Subject: [PATCH 6/6] Regenerate authors --- README.asciidoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index f79270523..02d3ccc74 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -176,6 +176,7 @@ Contributors, sorted by the number of commits in descending order: * Peter Vilim * Clayton Craft * Oliver Caldwell +* knaggita * Jonas Schürmann * error800 * Michael Hoang @@ -200,7 +201,6 @@ Contributors, sorted by the number of commits in descending order: * Brian Jackson * sbinix * neeasade -* knaggita * jnphilipp * Tobias Patzl * Stefan Tatschner