Revision 7008
Added by Aaron Marcuse-Kubitza about 12 years ago
lib/xml_func.py | ||
---|---|---|
11 | 11 |
import dates |
12 | 12 |
import exc |
13 | 13 |
import format |
14 |
import lists |
|
14 | 15 |
import maps |
15 | 16 |
import scalar |
16 | 17 |
import sql |
... | ... | |
187 | 188 |
|
188 | 189 |
#### Logic |
189 | 190 |
|
190 |
simplifying_funcs['_and'] = passthru |
|
191 |
simplifying_funcs['_or'] = passthru |
|
191 |
def _and(node): |
|
192 |
values = [v for k, v in xml_dom.NodeTextEntryIter(node)] |
|
193 |
|
|
194 |
if lists.and_(map(is_scalar, values)): # all constants |
|
195 |
xml_dom.replace_with_text(node, lists.and_(values)) |
|
196 |
else: passthru(node) |
|
197 |
simplifying_funcs['_and'] = _and |
|
192 | 198 |
|
199 |
def _or(node): |
|
200 |
values = [v for k, v in xml_dom.NodeTextEntryIter(node)] |
|
201 |
|
|
202 |
if lists.and_(map(is_scalar, values)): # all constants |
|
203 |
xml_dom.replace_with_text(node, lists.or_(values)) |
|
204 |
else: passthru(node) |
|
205 |
simplifying_funcs['_or'] = _or |
|
206 |
|
|
193 | 207 |
def _exists(node): |
194 | 208 |
'''Returns whether its node is non-empty''' |
195 | 209 |
xml_dom.replace_with_text(node, not xml_dom.is_empty(node)) |
Also available in: Unified diff
xml_func.py: Simplifying functions: Logic: _and(), _or(): Evaluate an expression of only constant values