From 3490275dc06fd4cf902ca60035a7418e17fbb85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9cile=20Tonglet?= Date: Wed, 22 Feb 2012 12:40:09 +0100 Subject: [PATCH] [REF] Clean up of tools.graph bzr revid: cto@openerp.com-20120222114009-nyalbc7uyelf54f0 --- openerp/tools/graph.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/openerp/tools/graph.py b/openerp/tools/graph.py index b54e101eec4..9ad1f34e91f 100755 --- a/openerp/tools/graph.py +++ b/openerp/tools/graph.py @@ -438,26 +438,19 @@ class graph(object): l.reverse() no = len(l) - if no%2==0: - first_half = l[no/2:] - factor = 1 - else: - first_half = l[no/2+1:] - factor = 0 - + rest = no%2 + first_half = l[no/2+rest:] last_half = l[:no/2] - i=1 - for child in first_half: - self.result[child]['y'] = mid_pos - (i - (factor * 0.5)) - i += 1 + for i, child in enumerate(first_half): + self.result[child]['y'] = mid_pos - (i+1 - (0 if rest else 0.5)) if self.transitions.get(child, False): if last: self.result[child]['y'] = last + len(self.transitions[child])/2 + 1 last = self.tree_order(child, last) - if no%2: + if rest: mid_node = l[no/2] self.result[mid_node]['y'] = mid_pos @@ -474,7 +467,7 @@ class graph(object): i=1 last_child = None for child in last_half: - self.result[child]['y'] = mid_pos + (i - (factor * 0.5)) + self.result[child]['y'] = mid_pos + (i - (0 if rest else 0.5)) last_child = child i += 1 if self.transitions.get(child, False):