Skip to content

Commit

Permalink
Replace try/except with hasattr (thanks @felixfontein)
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Dec 18, 2016
1 parent c79164b commit 2420964
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions nikola/utils.py
Expand Up @@ -1766,12 +1766,11 @@ def clone_treenode(treenode, parent=None, acceptor=lambda x: True):
node_clone.indent_levels = treenode.indent_levels
node_clone.indent_change_before = treenode.indent_change_before
node_clone.indent_change_after = treenode.indent_change_after
try:
if hasattr(node_clone, 'classification_path'):
# Copy stuff added by taxonomies_classifier plugin
node_clone.classification_path = treenode.classification_path
node_clone.classification_name = treenode.classification_name
except AttributeError:
pass

# Accept this node if there are no children (left) and acceptor fails
if not node_clone.children and not acceptor(treenode):
return None
Expand Down

0 comments on commit 2420964

Please sign in to comment.