Mercurial > genshi > genshi-test
comparison markup/core.py @ 111:8a4d9064f363
Some fixes and more unit tests for the XPath engine.
author | cmlenz |
---|---|
date | Mon, 31 Jul 2006 17:25:43 +0000 |
parents | 5e9987f34e6c |
children | e815c2c07572 |
comparison
equal
deleted
inserted
replaced
110:44fbc30d78cd | 111:8a4d9064f363 |
---|---|
115 'html': output.HTMLSerializer}[method] | 115 'html': output.HTMLSerializer}[method] |
116 else: | 116 else: |
117 assert issubclass(cls, output.Serializer) | 117 assert issubclass(cls, output.Serializer) |
118 serializer = cls(**kwargs) | 118 serializer = cls(**kwargs) |
119 | 119 |
120 stream = self | 120 stream = _ensure(self) |
121 if filters is None: | 121 if filters is None: |
122 filters = [WhitespaceFilter()] | 122 filters = [WhitespaceFilter()] |
123 for filter_ in filters: | 123 for filter_ in filters: |
124 stream = filter_(iter(stream)) | 124 stream = filter_(iter(stream)) |
125 | 125 |
139 DOCTYPE = Stream.DOCTYPE | 139 DOCTYPE = Stream.DOCTYPE |
140 START_NS = Stream.START_NS | 140 START_NS = Stream.START_NS |
141 END_NS = Stream.END_NS | 141 END_NS = Stream.END_NS |
142 PI = Stream.PI | 142 PI = Stream.PI |
143 COMMENT = Stream.COMMENT | 143 COMMENT = Stream.COMMENT |
144 | |
145 def _ensure(stream): | |
146 """Ensure that every item on the stream is actually a markup event.""" | |
147 for event in stream: | |
148 try: | |
149 kind, data, pos = event | |
150 except ValueError: | |
151 kind, data, pos = event.totuple() | |
152 yield kind, data, pos | |
144 | 153 |
145 | 154 |
146 class Attributes(list): | 155 class Attributes(list): |
147 """Sequence type that stores the attributes of an element. | 156 """Sequence type that stores the attributes of an element. |
148 | 157 |