fix slug RE and handle Wybor with no <pytanie> tag
authorMarcin Koziej <marcin.koziej@nowoczesnapolska.org.pl>
Mon, 11 Feb 2013 13:13:32 +0000 (14:13 +0100)
committerLibrary Admin <librarian@szo.nowoczesnapolska.org.pl>
Mon, 11 Feb 2013 13:16:29 +0000 (14:16 +0100)
librarian/__init__.py
librarian/pyhtml.py

index 224b7fd..215cacb 100644 (file)
@@ -80,7 +80,7 @@ class WLURI(object):
     slug = None
 
     example = 'http://edukacjamedialna.edu.pl/'
-    _re_wl_uri = re.compile(r'http://(www\.)?edukacjamedialna.edu.pl/'
+    _re_wl_uri = re.compile(r'http://(www\.)?edukacjamedialna.edu.pl/(lekcje/)?'
             '(?P<slug>[-a-z0-9]+)/?$')
 
     def __init__(self, uri):
index 6a3d40d..56b472c 100644 (file)
@@ -266,7 +266,10 @@ class Wybor(Exercise):
     def handle_cwiczenie(self, element):
         pre, post = super(Wybor, self).handle_cwiczenie(element)
         is_single_choice = True
-        for p in element.xpath(".//pytanie"):
+        pytania = element.xpath(".//pytanie")
+        if not pytania: 
+            pytania = [element]
+        for p in pytania:
             solutions = re.split(r"[, ]+", p.attrib['rozw'])
             if len(solutions) != 1:
                 is_single_choice = False