def refresh(self):
"""This should be done offline."""
- self.short_html
- self.single
- self.new_publishable
- self.published
+ self.short_html()
+ self.single()
+ self.new_publishable()
+ self.published()
# Materializing & publishing
# ==========================
import os.path
from django.conf import settings
from fnpdjango.utils.text.slughifi import slughifi
+ from librarian import ParseError
def _register_function(f):
""" Register extension function with lxml """
i1 = etree.parse(f2)
for sect in i1.findall('//section'):
- if sect[0].text == u'Przebieg zajęć':
+ if sect[0].text and sect[0].text.strip() == u'Przebieg zajęć':
# Prostujemy.
first = sect.find('section')
subs = first.findall('.//section')
break
else:
# print 'BRAK PRZEBIEGU'
- raise ValueError('Brak przebiegu')
+ raise ParseError('Brak przebiegu')
i1.getroot().attrib['redslug'] = self.slug
i1.getroot().attrib['wlslug'] = self.slug # THIS!
# print '.',
w1t = i1.xslt(t)
for h in w1t.findall('//aktywnosc/opis'):
- if not re.match(r'\d\.\s', h[0].text):
- raise AssertionError('Niepoprawny nagłówek (aktywnosc/opis): %s' % repr(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')