ugly fix (error reporting)
[librarian.git] / librarian / pypdf.py
index 759e1f3..bb2881f 100644 (file)
@@ -261,7 +261,7 @@ class EduModule(Xmill):
 
         counter = self.activity_counter
 
-        if element.getnext().tag == 'aktywnosc' or self.activity_last.getnext() == element:
+        if element.getnext().tag == 'aktywnosc' or (self.activity_last and self.activity_last.getnext() == element):
             counter_tex = """<cmd name="activitycounter"><parm>%(counter)d.</parm></cmd>""" % locals()
         else:
             counter_tex = ''
@@ -350,7 +350,10 @@ class EduModule(Xmill):
         if self.options['slowniczek_xml'] is not None and (nxt is None or nxt.tag != 'definiens'):
             sxml = self.options['slowniczek_xml']
             assert element.text != ''
-            defloc = sxml.xpath("//definiendum[text()='%s']" % 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':