1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 """
18 =========================
19 Template Filter Classes
20 =========================
21
22 This module provides the base classes and concrete implementations for
23 filters.
24 """
25 __author__ = u"Andr\xe9 Malo"
26 __docformat__ = "restructuredtext en"
27
28
30 """
31 Base stream filter class, which actually passes everything unfiltered
32
33 :IVariables:
34 `_stream` : ``file``
35 The decorated stream
36 """
37
39 """
40 Initialization
41
42 :Parameters:
43 `stream` : ``file``
44 The stream to decorate
45 """
46 self._stream = stream
47
49 """
50 Delegate unknown symbols to the next stream (downwards)
51
52 :Parameters:
53 `name` : ``str``
54 The symbol to look up
55
56 :Return: The requested symbol
57 :Rtype: any
58
59 :Exceptions:
60 - `AttributeError` : The symbol was not found
61 """
62 return getattr(self._stream, name)
63
64
66 """
67 Provide filename for upchain stream filters
68
69 :IVariables:
70 `filename` : ``str``
71 The provided filename
72 """
73
75 """
76 Initialization
77
78 :Parameters:
79 `stream` : ``stream``
80 The next stream layer
81
82 `filename` : ``str``
83 The filename to provide
84 """
85 super(StreamFilename, self).__init__(stream)
86 self.filename = filename
87
88
90 """
91 Base event filter class, which actually passes everything unfiltered
92
93 Override the event handlers you need.
94
95 :See: `BuildingListenerInterface`
96
97 :IVariables:
98 `builder` : `BuildingListenerInterface`
99 The next level builder
100 """
101 __slots__ = ('builder',)
102
104 """
105 Store the next level builder
106
107 :Parameters:
108 `builder` : `BuildingListenerInterface`
109 The next level builder
110 """
111 self.builder = builder
112
114 """
115 Delegate unknown symbols to the next level builder (upwards)
116
117 :Parameters:
118 `name` : ``str``
119 The symbol to look up
120
121 :Return: The requested symbol
122 :Rtype: any
123
124 :Exceptions:
125 - `AttributeError` : The symbol was not found
126 """
127 return getattr(self.builder, name)
128
129
130 from tdi import c
131 c = c.load('impl')
132 if c is not None:
133 BaseEventFilter = c.BaseEventFilter
134 del c
135
136
138 """
139 Provide the filename for down-chain filters
140
141 :IVariables:
142 `filename` : ``str``
143 The provided filename
144 """
145
147 """
148 Initialization
149
150 :Parameters:
151 `builder` : `BuildingListenerInterface`
152 The next level builder
153
154 `filename` : ``str``
155 The filename to provide
156 """
157 super(FilterFilename, self).__init__(builder)
158 self.filename = filename
159