File: queued_node.py

package info (click to toggle)
python-pyforge 1.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 464 kB
  • sloc: python: 3,666; makefile: 12; sh: 7
file content (31 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
class QueuedNode(object):
    """Base class for all nodes in the call tree. A node may be an actual call or attribute set/get, in this case this
    is a leaf node, or a call group (ordered, unordered, etc.), in that case it's a branch node."""

    def __init__(self):
        super(QueuedNode, self).__init__()
        self._parent = None

    def get_parent(self):
        return self._parent

    def set_parent(self, parent):
        self._parent = parent

    def get_expected(self):
        return [self]

    def get_available(self):
        return [self]

    def pop_matching(self, queue_object):
        """Provide the node with the opportunity to remove queue_object from its subtree. Usually called after
        a call to matches(queue_object) as been made.
        Returns the matching queued object or None if not found."""
        raise NotImplementedError()  # pragma: no cover


class QueuedNodeParent(QueuedNode):
    """Base class for all non-leaf nodes."""
    def discard_child(self, child):
        raise NotImplementedError()  # pragma: no cover