From e07236f7f77ec01a973775605906a0bdf5eb735a Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Mon, 11 Feb 2013 14:13:32 +0100 Subject: [PATCH] fix slug RE and handle Wybor with no tag --- librarian/__init__.py | 2 +- librarian/pyhtml.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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 -- 2.20.1