From e9cf7882a99aea6be8fc2979e75c755ab2f574ab Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Sun, 15 Jan 2017 03:11:42 -0600 Subject: [PATCH] Slightly better detection of existing parameters. --- earwigbot/tasks/wikiproject_tagger.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/earwigbot/tasks/wikiproject_tagger.py b/earwigbot/tasks/wikiproject_tagger.py index 7a425d4..b394ee7 100644 --- a/earwigbot/tasks/wikiproject_tagger.py +++ b/earwigbot/tasks/wikiproject_tagger.py @@ -319,15 +319,18 @@ class WikiProjectTagger(Task): def update_banner(self, banner, job, code): """Update an existing *banner* based on a *job* and a page's *code*.""" + has = lambda key: (banner.has(key) and + banner.get(key).value.strip() not in ("", "?")) + if job.autoassess is not False: - if not banner.has("class") or not banner.get("class").value: + if not has("class"): assessment = self.get_autoassessment(code, job.autoassess) if assessment: banner.add("class", assessment) if job.append: for param in job.append.split(","): key, value = param.split("=", 1) - if not banner.has(key) or not banner.get(key).value: + if not has(key): banner.add(key, value) def get_autoassessment(self, code, only_classes=None):