X-Git-Url: https://git.mdrn.pl/librarian.git/blobdiff_plain/6c046904bb9bbd3d7a8d0820ee971c0dc2a761ae..a7133c06fd9738c11a2bf60b4fc09365d15da1d7:/librarian/pyhtml.py diff --git a/librarian/pyhtml.py b/librarian/pyhtml.py index 5538b7f..b3c3ce0 100644 --- a/librarian/pyhtml.py +++ b/librarian/pyhtml.py @@ -16,7 +16,7 @@ class EduModule(Xmill): def __init__(self, options=None): super(EduModule, self).__init__(options) self.activity_counter = 0 - self.register_text_filter(lambda t: functions.substitute_entities(None, t)) + self.register_text_filter(functions.substitute_entities) def handle_powiesc(self, element): return u""" @@ -42,9 +42,9 @@ class EduModule(Xmill): self.activity_counter += 1 self.options = { 'activity': True, - 'activity_counter': self.activity_counter + 'activity_counter': self.activity_counter, } - submill = EduModule(self.options) + submill = EduModule(dict(self.options.items() + {'sub_gen': True}.items())) opis = submill.generate(element.xpath('opis')[0]) @@ -78,10 +78,10 @@ class EduModule(Xmill): """ % locals() - handle_opis = ifoption(activity=True)(tag('div', 'description')) - handle_wskazowki = ifoption(activity=True)(tag('div', ('hints', 'teacher'))) + handle_opis = ifoption(sub_gen=True)(tag('div', 'description')) + handle_wskazowki = ifoption(sub_gen=True)(tag('div', ('hints', 'teacher'))) - @ifoption(activity=True) + @ifoption(sub_gen=True) @tagged('div', 'materials') def handle_pomoce(self, _): return "Pomoce: ", "" @@ -302,7 +302,8 @@ Overrides the returned content default handle_pytanie class Luki(Exercise): def find_pieces(self, question): - return question.xpath("//luka") + print question.xpath(".//luka") + return question.xpath(".//luka") def solution_html(self, piece): return piece.text + ''.join( @@ -325,8 +326,7 @@ class Luki(Exercise): return qpre, qpost def handle_opis(self, element): - pre, post = super(Luki, self).handle_opis(element) - return pre, self.words_html + post + return '', self.words_html def handle_luka(self, element): self.piece_counter += 1 @@ -335,7 +335,7 @@ class Luki(Exercise): class Zastap(Luki): def find_pieces(self, question): - return question.xpath("//zastap") + return question.xpath(".//zastap") def solution_html(self, piece): return piece.attrib['rozw']