Commits

ms2ger committed e3b4b1f

Avoid some undefined names.

Comments (0)

Files changed (2)

anolislib/processes/sub.py

         to_remove = set()
 
         # Link
-        in_link = False
+        link_parent = None
+        link = None
         for node in ElementTree.iter():
-            if in_link:
+            if link_parent:
                 if node.tag is etree.Comment and \
                    node.text.strip(utils.spaceCharacters) == u"end-link":
                     if node.getparent() is not link_parent:
                         raise utils.DifferentParentException(u"begin-link and end-link have different parents")
                     utils.removeInteractiveContentChildren(link)
                     link.set(u"href", utils.textContent(link))
-                    in_link = False
+                    link_parent = None
                 else:
                     if node.getparent() is link_parent:
                         link.append(deepcopy(node))
             elif node.tag is etree.Comment and \
                  node.text.strip(utils.spaceCharacters) == u"begin-link":
                 link_parent = node.getparent()
-                in_link = True
                 link = etree.Element(u"a")
                 link.text = node.tail
                 node.tail = None

anolislib/utils.py

 def replaceComment(ElementTree, comment, sub, **kwargs):
     begin_sub = u"begin-%s" % comment
     end_sub = u"end-%s" % comment
-    in_sub = False
+    sub_parent = None
     to_remove = set()
     for node in ElementTree.iter():
-        if in_sub:
+        if sub_parent:
             if node.tag is etree.Comment and \
                node.text.strip(spaceCharacters) == end_sub:
                 if node.getparent() is not sub_parent:
                     raise DifferentParentException(u"%s and %s have different parents" % begin_sub, end_sub)
-                in_sub = False
+                sub_parent = None
             else:
                 to_remove.add(node)
         elif node.tag is etree.Comment:
             if node.text.strip(spaceCharacters) == begin_sub:
                 sub_parent = node.getparent()
-                in_sub = True
                 node.tail = None
                 node.addnext(deepcopy(sub))
                 indentNode(node.getnext(), 0, **kwargs)