From: Marcin Koziej Date: Mon, 11 Feb 2013 13:13:32 +0000 (+0100) Subject: fix slug RE and handle Wybor with no tag X-Git-Url: https://git.mdrn.pl/librarian.git/commitdiff_plain/e07236f7f77ec01a973775605906a0bdf5eb735a?ds=inline fix slug RE and handle Wybor with no tag --- diff --git a/librarian/__init__.py b/librarian/__init__.py index 224b7fd..215cacb 100644 --- a/librarian/__init__.py +++ b/librarian/__init__.py @@ -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[-a-z0-9]+)/?$') def __init__(self, uri): diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 6a3d40d..56b472c 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -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