[PATCH 48 of 54] Docstring update + use a set where due
Wald Commits
scm-commit at wald.intevation.org
Wed Jan 7 10:57:05 CET 2015
# HG changeset patch
# User Benoît Allard <benoit.allard at greenbone.net>
# Date 1419938947 -3600
# Node ID 652f59fbea3afa2d9c1cf8e1030c3d045cab7945
# Parent 1b7f3f4f1238cafd8c45a0745fe92f458531c32f
Docstring update + use a set where due
diff -r 1b7f3f4f1238 -r 652f59fbea3a farolluz/producttree.py
--- a/farolluz/producttree.py Tue Dec 30 12:28:06 2014 +0100
+++ b/farolluz/producttree.py Tue Dec 30 12:29:07 2014 +0100
@@ -81,6 +81,7 @@
)
def getBranch(self, path):
+ """ path is a tuple of indexes """
if len(path) == 0:
return self
branches = self._branches
@@ -120,9 +121,10 @@
The branches that could accept `b2` as new sub-branches
Note that b2 and all its sub-branches cannot be listed
"""
- black_list = []
+ black_list = set()
if b2 is not None:
- black_list = [b2] + list(b2.getBranches())
+ black_list.add(b2)
+ black_list.update(b2.getBranches())
for branch in self.getBranches():
if branch in black_list:
continue
@@ -200,7 +202,8 @@
return self._parentbranch
def getPath(self, string=False):
- """ return the path to that branch element as a tuple """
+ """ return the path to that branch element as a tuple or as '/'
+ separated string """
if self.isRoot():
for i, b in enumerate(self._parentbranch._branches):
if b is self:
@@ -252,7 +255,7 @@
self._parentbranch = None
def link(self, parent):
- """ Actually, only set the parent """
+ """ Set the parent, and add ourself to our parent's childs """
self._parentbranch = parent
if self.isRoot():
parent._branches.append(self)
More information about the Farol-commits
mailing list