[epub, mobi] Fix for a problem with epubs, mobi in drama ebooks without acts
[librarian.git] / librarian / epub.py
index 4855de8..6a2b3c5 100644 (file)
@@ -292,25 +292,19 @@ def chop(main_text):
 
     last_node_part = False
     
 
     last_node_part = False
     
-    # the below loops are workaround for a problem with epubs in drama ebooks without acts
+    # the below loop are workaround for a problem with epubs in drama ebooks without acts
     is_scene = False
     is_scene = False
+    is_act = False
     for one_part in main_text:
     for one_part in main_text:
-       name = one_part.tag
-        if name in ('naglowek_scena'):
+        name = one_part.tag
+        if name == 'naglowek_scena':
             is_scene = True
             is_scene = True
-            break
-    if is_scene is True:
-        is_scene_with_acts = False
-        for one_part in main_text:
-            if one_part.tag == 'naglowek_akt':
-                is_scene_with_acts = True
-                break
-    else:
-        is_scene_with_acts = False
+        elif name == 'naglowek_akt':
+            is_act = True
     
     for one_part in main_text:
         name = one_part.tag
     
     for one_part in main_text:
         name = one_part.tag
-        if is_scene_with_acts is False and is_scene is True:
+        if is_act is False and is_scene is True:
             if name == 'naglowek_czesc':
                 yield part_xml
                 last_node_part = True
             if name == 'naglowek_czesc':
                 yield part_xml
                 last_node_part = True