X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/e8993f5e4209eb1ab0b6435691df9217d843c76d..54cbe1753f95bb2dd3441ba5966c32ea63ffcbad:/apps/catalogue/models/book.py?ds=inline diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index b0862f00..09164a39 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -479,7 +479,10 @@ class Book(models.Model): # print '.', w1t = i1.xslt(t) for h in w1t.findall('//aktywnosc/opis'): - if not re.match(r'\d\.\s', h[0].text): + if len(h) == 0: + raise ParseError('Pusty element aktywnosc/opis') + # FIXME assumption that every lesson has at most 9 parts + if not h[0].text or not re.match(r'\d\.\s', h[0].text): raise ParseError('Niepoprawny nagłówek (aktywnosc/opis): %s' % repr(h[0].text)) h[0].text = h[0].text[3:] return etree.tostring(w1t, encoding='utf-8')