1
2 u"""
3 :Copyright:
4
5 Copyright 2006 - 2013
6 Andr\xe9 Malo or his licensors, as applicable
7
8 :License:
9
10 Licensed under the Apache License, Version 2.0 (the "License");
11 you may not use this file except in compliance with the License.
12 You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
21
22 =========================
23 Template Filter Classes
24 =========================
25
26 This module provides the base classes and concrete implementations for
27 filters.
28 """
29 __author__ = u"Andr\xe9 Malo"
30 __docformat__ = "restructuredtext en"
31
32
34 """
35 Base stream filter class, which actually passes everything unfiltered
36
37 :IVariables:
38 `_stream` : ``file``
39 The decorated stream
40 """
41
43 """
44 Initialization
45
46 :Parameters:
47 `stream` : ``file``
48 The stream to decorate
49 """
50 self._stream = stream
51
53 """
54 Delegate unknown symbols to the next stream (downwards)
55
56 :Parameters:
57 `name` : ``str``
58 The symbol to look up
59
60 :Return: The requested symbol
61 :Rtype: any
62
63 :Exceptions:
64 - `AttributeError` : The symbol was not found
65 """
66 return getattr(self._stream, name)
67
68
70 """
71 Provide filename for upchain stream filters
72
73 :IVariables:
74 `filename` : ``str``
75 The provided filename
76 """
77
79 """
80 Initialization
81
82 :Parameters:
83 `stream` : ``stream``
84 The next stream layer
85
86 `filename` : ``str``
87 The filename to provide
88 """
89 super(StreamFilename, self).__init__(stream)
90 self.filename = filename
91
92
94 """
95 Base event filter class, which actually passes everything unfiltered
96
97 Override the event handlers you need.
98
99 :See: `BuildingListenerInterface`
100
101 :IVariables:
102 `builder` : `BuildingListenerInterface`
103 The next level builder
104 """
105 __slots__ = ('builder',)
106
108 """
109 Store the next level builder
110
111 :Parameters:
112 `builder` : `BuildingListenerInterface`
113 The next level builder
114 """
115 self.builder = builder
116
118 """
119 Delegate unknown symbols to the next level builder (upwards)
120
121 :Parameters:
122 `name` : ``str``
123 The symbol to look up
124
125 :Return: The requested symbol
126 :Rtype: any
127
128 :Exceptions:
129 - `AttributeError` : The symbol was not found
130 """
131 return getattr(self.builder, name)
132
133
134 from tdi import c
135 c = c.load('impl')
136 if c is not None:
137 BaseEventFilter = c.BaseEventFilter
138 del c
139
140
142 """
143 Provide the filename for down-chain filters
144
145 :IVariables:
146 `filename` : ``str``
147 The provided filename
148 """
149
151 """
152 Initialization
153
154 :Parameters:
155 `builder` : `BuildingListenerInterface`
156 The next level builder
157
158 `filename` : ``str``
159 The filename to provide
160 """
161 super(FilterFilename, self).__init__(builder)
162 self.filename = filename
163