don't assume that headers have text
authorJan Szejko <jan.szejko@gmail.com>
Wed, 22 Jun 2016 11:34:17 +0000 (13:34 +0200)
committerJan Szejko <jan.szejko@gmail.com>
Wed, 22 Jun 2016 11:34:17 +0000 (13:34 +0200)
apps/catalogue/models/book.py

index b0862f0..626dd9c 100755 (executable)
@@ -479,7 +479,8 @@ 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):
+            # 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')