From 6390eb410af0848b5ac1ca5e91bab577bf7f4b2b Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 2 Jun 2011 20:09:42 -0700 Subject: [PATCH] Use bool(digraph) instead of empty()/is_empty(). --- pym/_emerge/actions.py | 2 +- pym/_emerge/depgraph.py | 8 ++++---- pym/_emerge/resolver/circular_dependency.py | 2 +- pym/portage/dbapi/vartree.py | 2 +- pym/portage/tests/util/test_digraph.py | 10 +++++----- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index f6b6928f3..860192901 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -1200,7 +1200,7 @@ def calc_depclean(settings, trees, ldpath_mtimes, ignore_priority_range = [None] ignore_priority_range.extend( range(UnmergeDepPriority.MIN, UnmergeDepPriority.MAX + 1)) - while not graph.empty(): + while graph: for ignore_priority in ignore_priority_range: nodes = graph.root_nodes(ignore_priority=ignore_priority) if nodes: diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index d05b5642a..98cc88d80 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -293,7 +293,7 @@ class _rebuild_config(object): # Trigger rebuilds bottom-up (starting with the leaves) so that parents # will always know which children are being rebuilt. - while not graph.empty(): + while graph: if not leaf_nodes: # We're interested in intersection of buildtime and runtime, # so ignore edges that do not contain both. @@ -4922,7 +4922,7 @@ class depgraph(object): # If no nodes are selected on the last iteration, it is due to # unresolved blockers or circular dependencies. - while not mygraph.empty(): + while mygraph: self._spinner_update() selected_nodes = None ignore_priority = None @@ -5053,7 +5053,7 @@ class depgraph(object): selected_nodes = list(selected_nodes) selected_nodes.sort(key=cmp_sort_key(cmp_circular_bias)) - if not selected_nodes and not myblocker_uninstalls.is_empty(): + if not selected_nodes and myblocker_uninstalls: # An Uninstall task needs to be executed in order to # avoid conflict if possible. @@ -5273,7 +5273,7 @@ class depgraph(object): drop_satisfied = True continue - if not selected_nodes and not myblocker_uninstalls.is_empty(): + if not selected_nodes and myblocker_uninstalls: # If possible, drop an uninstall task here in order to avoid # the circular deps code path. The corresponding blocker will # still be counted as an unresolved conflict. diff --git a/pym/_emerge/resolver/circular_dependency.py b/pym/_emerge/resolver/circular_dependency.py index 9d3f5c68d..f612d8edc 100644 --- a/pym/_emerge/resolver/circular_dependency.py +++ b/pym/_emerge/resolver/circular_dependency.py @@ -42,7 +42,7 @@ class circular_dependency_handler(object): """ display_order = [] tempgraph = self.graph.copy() - while not tempgraph.empty(): + while tempgraph: nodes = tempgraph.leaf_nodes() if not nodes: node = tempgraph.order[0] diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index 3c7e9345f..11eaca302 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -2618,7 +2618,7 @@ class dblink(object): break cpv_lib_map = {} - while not lib_graph.empty(): + while lib_graph: root_nodes = preserved_nodes.intersection(lib_graph.root_nodes()) if not root_nodes: break diff --git a/pym/portage/tests/util/test_digraph.py b/pym/portage/tests/util/test_digraph.py index 9b95a596f..899d6a7bb 100644 --- a/pym/portage/tests/util/test_digraph.py +++ b/pym/portage/tests/util/test_digraph.py @@ -13,7 +13,7 @@ class DigraphTest(TestCase): f = g.copy() g.addnode("A", None) self.assertEqual("A" in g, True) - self.assertEqual(g.empty(), False) + self.assertEqual(bool(g), True) self.assertEqual(g.allnodes(), ["A"]) self.assertEqual(g.allzeros(), ["A"]) self.assertEqual(g.hasnode("A"), True) @@ -22,7 +22,7 @@ class DigraphTest(TestCase): g = digraph() f = g.clone() for x in g, f: - self.assertEqual(x.is_empty(), True) + self.assertEqual(bool(x), False) self.assertEqual(x.contains("A"), False) self.assertEqual(x.firstzero(), None) self.assertRaises(KeyError, x.remove, "A") @@ -54,7 +54,7 @@ class DigraphTest(TestCase): f = g.clone() for x in g, f: - self.assertEqual(x.is_empty(), False) + self.assertEqual(bool(x), True) self.assertEqual(x.contains("A"), True) self.assertEqual(x.firstzero(), None) self.assertRaises(KeyError, x.remove, "Z") @@ -96,7 +96,7 @@ class DigraphTest(TestCase): f = g.clone() for x in g, f: - self.assertEqual(x.is_empty(), False) + self.assertEqual(bool(x), True) self.assertEqual(x.contains("A"), True) self.assertEqual(x.firstzero(), "B") self.assertRaises(KeyError, x.remove, "Z") @@ -141,7 +141,7 @@ class DigraphTest(TestCase): f = g.clone() for x in g, f: - self.assertEqual(x.is_empty(), False) + self.assertEqual(bool(x), True) self.assertEqual(x.contains("A"), True) self.assertEqual(x.firstzero(), None) self.assertRaises(KeyError, x.remove, "Z") -- 2.26.2