changeset 47:652f59fbea3a

Docstring update + use a set where due
author Benoît Allard <benoit.allard@greenbone.net>
date Tue, 30 Dec 2014 12:29:07 +0100
parents 1b7f3f4f1238
children 3826f2701ff2
files farolluz/producttree.py
diffstat 1 files changed, 7 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)