From: philipp Date: Tue, 11 Oct 2016 19:37:32 +0000 (+0000) Subject: Fixed two issues in wrvalidators module - now all tests pass for that module. X-Git-Url: https://git.toastfreeware.priv.at/philipp/winterrodeln/wrpylib.git/commitdiff_plain/23b4b760fd05b638f376ba5f1460fd61556a8078 Fixed two issues in wrvalidators module - now all tests pass for that module. git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2499 7aebc617-e5e2-0310-91dc-80fb5f6d2477 --- diff --git a/wrpylib/wrvalidators.py b/wrpylib/wrvalidators.py index c736750..6697be9 100644 --- a/wrpylib/wrvalidators.py +++ b/wrpylib/wrvalidators.py @@ -700,8 +700,8 @@ def wikibox_to_template(value, name, converter_dict): def template_from_str(value, name): wikicode = mwparserfromhell.parse(value) - template_list = wikicode.filter_templates(name) - if len(name) == 0: + template_list = [template for template in wikicode.filter_templates(name) if template.name.strip() == name] + if len(template_list) == 0: raise ValueError('No "{}" template was found'.format(name)) if len(template_list) > 1: raise ValueError('{} "{}" templates were found'.format(len(template_list), name)) @@ -756,7 +756,7 @@ def rodelbahnbox_from_template(template): def rodelbahnbox_to_template(value): - return wikibox_to_template(value, RODELBAHNBOX_DICT, RODELBAHNBOX_TEMPLATE_NAME) + return wikibox_to_template(value, RODELBAHNBOX_TEMPLATE_NAME, RODELBAHNBOX_DICT) def rodelbahnbox_from_str(value):