Package advene :: Package model :: Package util :: Module choice_tree :: Class ChoiceTree
[hide private]
[frames] | no frames]

Class ChoiceTree

source code

object --+
         |
        ChoiceTree

An arc-labeled tree where each node is uniquely described by a sequence of all arc labels joining the root to that node. Some nodes are *instanciated*, which means that they have an =instance= attribute. The class provides several methods to get the most appropriate instance, given a key.

Instance Methods [hide private]
 
__init__(self, instance=None)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
_getOrMakeChildren(self)
Return the dict of children, constructing it if necessary.
source code
 
isEmpty(self)
Return True iff this ChoiceTree has no instanciated node.
source code
 
set(self, seq, instance, override=False)
Instanciate the node identified by =seq= with =instance=.
source code
 
unset(self, seq)
Uninstanciate the node at =seq=.
source code
 
dump(self, _prefix=()) source code
 
getSubtree(self, seq)
Return the subtree rooted on the node identified by =seq=.
source code
 
getAny(self, _whereami=())
Search (depth first) the first instanciated node of this tree, and return a tuple (seq, instance).
source code
 
getAnySeq(self)
Search (depth first) the first instanciated node of this tree, and return its identifying sequence.
source code
 
getAnyInstance(self)
Search (depth first) the first instanciated node of this tree, and return its instance.
source code
 
getMostSpecific(self, seq, _default=None, _whereami=())
Search for the most specific instanciated node in the path leadin to the given =seq=, and return a tuple (seq, instance).
source code
 
getMostSpecificSeq(self, seq)
Search for the most specific instanciated node in the path leadin to the given =seq=, and return its identifying sequence.
source code
 
getMostSpecificInstance(self, seq)
Search for the most specific instanciated node in the path leadin to the given =seq=, and return its instance.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, instance=None)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

set(self, seq, instance, override=False)

source code 

Instanciate the node identified by =seq= with =instance=. If the node is already instanciated, it is replaced only if =override= is True.

getSubtree(self, seq)

source code 

Return the subtree rooted on the node identified by =seq=. Raises a KeyError if no such node exist.