Skip to content

Commit

Permalink
Avoid DeprecationWarnings for etree
Browse files Browse the repository at this point in the history
  • Loading branch information
waylan committed Jan 4, 2018
1 parent a7d211b commit bbada79
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions markdown/extensions/footnotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def makeFootnotesDiv(self, root):
)
backlink.text = FN_BACKLINK_TEXT

if li.getchildren():
if len(li):
node = li[-1]
if node.tag == "p":
node.text = node.text + NBSP_PLACEHOLDER
Expand Down Expand Up @@ -393,7 +393,7 @@ def run(self, root):
result = self.footnotes.findFootnotesPlaceholder(root)
if result:
child, parent, isText = result
ind = parent.getchildren().index(child)
ind = list(parent).index(child)
if isText:
parent.remove(child)
parent.insert(ind, footnotesDiv)
Expand Down
6 changes: 3 additions & 3 deletions markdown/treeprocessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ def __applyPattern(self, pattern, data, patternIndex, startIndex=0):
def __build_ancestors(self, parent, parents):
"""Build the ancestor list."""
ancestors = []
while parent:
if parent:
while parent is not None:
if parent is not None:
ancestors.append(parent.tag.lower())
parent = self.parent_map.get(parent)
ancestors.reverse()
Expand Down Expand Up @@ -303,7 +303,7 @@ def run(self, tree, ancestors=None):
# to ensure we don't have the user accidentally change it on us.
tree_parents = [] if ancestors is None else ancestors[:]

self.parent_map = dict((c, p) for p in tree.getiterator() for c in p)
self.parent_map = dict((c, p) for p in tree.iter() for c in p)
stack = [(tree, tree_parents)]

while stack:
Expand Down

0 comments on commit bbada79

Please sign in to comment.