Fixed two issues in wrvalidators module - now all tests pass for that module.
authorphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 11 Oct 2016 19:37:32 +0000 (19:37 +0000)
committerphilipp <philipp@7aebc617-e5e2-0310-91dc-80fb5f6d2477>
Tue, 11 Oct 2016 19:37:32 +0000 (19:37 +0000)
git-svn-id: http://www.winterrodeln.org/svn/wrpylib/trunk@2499 7aebc617-e5e2-0310-91dc-80fb5f6d2477

wrpylib/wrvalidators.py

index c73675069ab4b4d3f6d929ba897d66a830303705..6697be9cef8a5382accd7c1104bf71f1d6f62a97 100644 (file)
@@ -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):