1 from concurrent_tree_crawler.abstract_node import AbstractNode, NodeState
4 """Enumeration describing actions that can be taken by a crawler when
5 entering a new node"""
6
7 TO_PROCESS = 0
8 TO_VISIT = 1
9
10 @staticmethod
17
19 """
20 An interface for the tree made of L{AbstractNode}s.
21 """
22
24 """
25 @return: sentinel node
26 @rtype: L{AbstractNode}
27 """
28 raise NotImplementedError
29
31 """
32 @return: root node
33 @rtype: L{AbstractNode}
34 """
35 raise NotImplementedError
36
38 """
39 A convenience method. Returns tree path to the given node.
40
41 @type node: L{AbstractNode}
42 @return: subsequent node names from the tree root to the current node
43 @rtype: list of strings
44 """
45 path = []
46 while node != self.get_sentinel():
47 path.append(node.get_name())
48 node = node.get_parent()
49 path.reverse()
50 return path
51
53 """
54 Append new children to the node and return a child that can be
55 entered by the crawler.
56
57 @param node: node considered
58 @type node: L{AbstractNode}
59 @param possible_children_names: list of children names
60 @type possible_children_names: list of strings
61 @return: children node along with information what the crawler should
62 do with it. C{None} instead is returned if all children have
63 state C{NodeState.CLOSED} or C{NodeState.ERROR} or the node
64 has no children.
65 @rtype: (L{AbstractNode}, L{NodeAction}) pair or C{None}
66 """
67 raise NotImplementedError
68
70 """
71 Set the leaf state of the node
72
73 @param is_leaf: C{True} iff the node is a leaf
74 """
75 raise NotImplementedError
76
78 """Set the node state as C{NodeState.ERROR}"""
79 raise NotImplementedError
80