-# """
-# add_class = ""
-# self.question_counter += 1
-# self.piece_counter = 0
-# solution = element.attrib.get('rozw', None)
-# if solution: solution_s = ' data-solution="%s"' % solution
-# else: solution_s = ''
-
-# handles = element.attrib.get('uchwyty', None)
-# if handles:
-# add_class += ' handles handles-%s' % handles
-# self.options = {'handles': handles}
-
-# minimum = element.attrib.get('min', None)
-# if minimum: minimum_s = ' data-minimum="%d"' % int(minimum)
-# else: minimum_s = ''
-
-# return '' %\
-# (add_class, self.question_counter, solution_s + minimum_s), \
-# "
"
+ def handle_lista(self, element, attrs=None):
+ ltype = element.attrib.get('typ', 'punkt')
+ if not element.findall("punkt"):
+ if ltype == 'czytelnia':
+ return 'W przygotowaniu.'
+ else:
+ return None
+ if ltype == 'slowniczek':
+ surl = element.attrib.get('src', None)
+ if surl is None:
+ # print '** missing src on , setting default'
+ surl = 'http://edukacjamedialna.edu.pl/lekcje/slowniczek/'
+ sxml = etree.fromstring(self.options['wldoc'].provider.by_uri(surl).get_string())
+ self.options = {'slowniczek': True, 'slowniczek_xml': sxml}
+
+ listcmd = {
+ 'num': 'enumerate',
+ 'punkt': 'itemize',
+ 'alfa': 'itemize',
+ 'slowniczek': 'itemize',
+ 'czytelnia': 'itemize'
+ }[ltype]
+
+ return u'' % listcmd, u''
+
+ def handle_punkt(self, element):
+ return '', ''
+
+ def handle_cwiczenie(self, element):
+ exercise_handlers = {
+ 'wybor': Wybor,
+ 'uporzadkuj': Uporzadkuj,
+ 'luki': Luki,
+ 'zastap': Zastap,
+ 'przyporzadkuj': Przyporzadkuj,
+ 'prawdafalsz': PrawdaFalsz
+ }
+
+ typ = element.attrib['typ']
+ self.exercise_counter += 1
+ if typ not in exercise_handlers:
+ return '(no handler)'
+ self.options = {'exercise_counter': self.exercise_counter}
+ handler = exercise_handlers[typ](self.options, self.state)
+ return handler.generate(element)
+
+ # XXX this is copied from pyhtml.py, except for return and
+ # should be refactored for no code duplication
+ def handle_definiendum(self, element):
+ nxt = element.getnext()
+ definiens_s = ''
+
+ # let's pull definiens from another document
+ if self.options['slowniczek_xml'] is not None and (nxt is None or nxt.tag != 'definiens'):
+ sxml = self.options['slowniczek_xml']
+ assert element.text != ''
+ if "'" in (element.text or ''):
+ defloc = sxml.xpath("//definiendum[text()=\"%s\"]" % (element.text or '').strip())
+ else:
+ defloc = sxml.xpath("//definiendum[text()='%s']" % (element.text or '').strip())
+ if defloc:
+ definiens = defloc[0].getnext()
+ if definiens.tag == 'definiens':
+ subgen = EduModule(self.options, self.state)
+ definiens_s = subgen.generate(definiens)
+
+ return u'', u": " + definiens_s
+
+ def handle_definiens(self, element):
+ return u"", u""
+
+ def handle_podpis(self, element):
+ return u"""""", u""
+
+ def handle_tabela(self, element):
+ max_col = 0
+ for w in element.xpath("wiersz"):
+ ks = w.xpath("kol")
+ if max_col < len(ks):
+ max_col = len(ks)
+ self.options = {'columnts': max_col}
+ # styling:
+ # has_frames = int(element.attrib.get("ramki", "0"))
+ # if has_frames: frames_c = "framed"
+ # else: frames_c = ""
+ # return u""""
+ return u'''
+tabular%s
+ ''' % ('l' * max_col), u'''tabular'''
+
+ @escape(1)
+ def handle_wiersz(self, element):
+ return u"", u''
+
+ @escape(1)
+ def handle_kol(self, element):
+ if element.getnext() is not None:
+ return u"", u''
+ return u"", u""
+
+ def handle_link(self, element):
+ if element.attrib.get('url'):
+ url = element.attrib.get('url')
+ if url == element.text:
+ return cmd('url')(self, element)
+ else:
+ return cmd('href', parms=[element.attrib['url']])(self, element)
+ else:
+ return cmd('emph')(self, element)
+
+ def handle_obraz(self, element):
+ frmt = self.options['format']
+ name = element.attrib.get('nazwa', '').strip()
+ image = frmt.get_image(name.strip())
+ name = image.get_filename().rsplit('/', 1)[-1]
+ img_path = "obraz/%s" % name.replace("_", "")
+ frmt.attachments[img_path] = image
+ return cmd("obraz", parms=[img_path])(self)
+
+ def handle_video(self, element):
+ url = element.attrib.get('url')
+ if not url:
+ print '!!