Ticket #68: select-namespaces-68-stab1.patch
| File select-namespaces-68-stab1.patch, 1.5 KB (added by David Fraser <davidf@…>, 17 years ago) |
|---|
-
genshi/path.py
35 35 import re 36 36 37 37 from genshi.core import Stream, Attrs, Namespace, QName 38 from genshi.core import START, END, TEXT, COMMENT, PI38 from genshi.core import START, END, START_NS, END_NS, TEXT, COMMENT, PI 39 39 40 40 __all__ = ['Path', 'PathSyntaxError'] 41 41 … … 117 117 stream = iter(stream) 118 118 def _generate(): 119 119 test = self.test() 120 start_namespace_events = [] 121 reverse_namespaces = dict([(value, key) for (key, value) in namespaces.items()]) 120 122 for kind, data, pos in stream: 123 if kind is START_NS: 124 prefix, namespace = data 125 if namespace in reverse_namespaces: 126 yield (kind, (reverse_namespaces[namespace], namespace), pos) 121 127 result = test(kind, data, pos, namespaces, variables) 122 128 if result is True: 123 129 yield kind, data, pos … … 130 136 depth -= 1 131 137 yield subkind, subdata, subpos 132 138 test(subkind, subdata, subpos, namespaces, variables) 139 start_namespace_events = [] 133 140 elif result: 134 141 yield result 142 elif kind is END_NS: 143 yield END_NS, data, pos 135 144 return Stream(_generate()) 136 145 137 146 def test(self, ignore_context=False):
