[meld] dirdiff: Minor refactoring of state filter patch
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] dirdiff: Minor refactoring of state filter patch
- Date: Fri, 17 Jan 2014 22:50:06 +0000 (UTC)
commit fe0b5974f6cac9010db06e82c131fcc458c5d8ec
Author: Kai Willadsen <kai willadsen gmail com>
Date: Sun Jan 12 06:47:15 2014 +1000
dirdiff: Minor refactoring of state filter patch
meld/dirdiff.py | 19 +++++++++----------
1 files changed, 9 insertions(+), 10 deletions(-)
---
diff --git a/meld/dirdiff.py b/meld/dirdiff.py
index ec2aebc..6bc4fe5 100644
--- a/meld/dirdiff.py
+++ b/meld/dirdiff.py
@@ -801,25 +801,24 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
child = self.model.add_entries(it, entries)
differences |= self._update_item_state(child)
else:
- all_present = False not in [ os.path.exists(f) for f in roots ]
- all_dir = False not in [ os.path.isdir(f) for f in roots ]
- if (not all_present) or (not all_dir) or (tree.STATE_NORMAL in self.state_filters):
+ all_dir = all(os.path.isdir(f) for f in roots)
+ if (not all_dir) or (tree.STATE_NORMAL in self.state_filters):
self.model.add_empty(it)
- if self.model.iter_parent(it) == None:
+ if self.model.iter_parent(it) is None:
expanded.add(rootpath) # expand rootpath to show entire tree is empty
else:
- # assert ( roots all_present and all_dir and all_empty, STATE_NORMAL not in
state_filters )
+ # assert ( roots all_dir and all_empty, STATE_NORMAL not in state_filters )
# roots (and all their ancestors to top of tree) were let through in _filter_on_state()
# although STATE_NORMAL is disabled, so that their contents could be compared; as roots
# turned out empty their (and every empty ancestor's) branch in the tree can be removed
- assert (it != None) and (not self.model.iter_has_child(it))
+ assert (it is not None) and (not self.model.iter_has_child(it))
while not self.model.iter_has_child(it):
- if self.model.iter_next(it) == None:
+ if self.model.iter_next(it) is None:
# all siblings of it have been processed, none are left on the todo stack
parent = self.model.iter_parent(it)
- if parent == None: # don't remove top of the tree
+ if parent is None: # don't remove top of the tree
self.model.add_empty(it)
expanded.add(rootpath) # expand roothpath to show entire tree is empty
break
@@ -831,8 +830,8 @@ class DirDiff(melddoc.MeldDoc, gnomeglade.Component):
self.model.remove(it) # all paths of sibling dirs still on the stack are now
invalid!
index = 0
# siblings that are on the stack, all occupy the top positions (in reverse order)
- while it != None:
- one_dir = True in [ os.path.isdir(f) for f in self.model.value_paths(it) ]
+ while it is not None:
+ one_dir = any(os.path.isdir(f) for f in self.model.value_paths(it))
if one_dir:
index += 1
todo[-index] = self.model.get_path(it) # correct the path for this
sibling
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]