comparison markup/input.py @ 182:2f30ce3fb85e trunk

Renamed `Attributes` to `Attrs` to reduce the verbosity.
author cmlenz
date Mon, 21 Aug 2006 20:03:13 +0000
parents d19e8a2c549e
children 28bfc6aafab7
comparison
equal deleted inserted replaced
181:e103b75a96ce 182:2f30ce3fb85e
19 from sets import ImmutableSet as frozenset 19 from sets import ImmutableSet as frozenset
20 import HTMLParser as html 20 import HTMLParser as html
21 import htmlentitydefs 21 import htmlentitydefs
22 from StringIO import StringIO 22 from StringIO import StringIO
23 23
24 from markup.core import Attributes, QName, Stream 24 from markup.core import Attrs, QName, Stream
25 from markup.core import DOCTYPE, START, END, START_NS, END_NS, TEXT, \ 25 from markup.core import DOCTYPE, START, END, START_NS, END_NS, TEXT, \
26 START_CDATA, END_CDATA, PI, COMMENT 26 START_CDATA, END_CDATA, PI, COMMENT
27 27
28 __all__ = ['ParseError', 'XMLParser', 'XML', 'HTMLParser', 'HTML'] 28 __all__ = ['ParseError', 'XMLParser', 'XML', 'HTMLParser', 'HTML']
29 29
144 def _getpos(self): 144 def _getpos(self):
145 return (self.filename, self.expat.CurrentLineNumber, 145 return (self.filename, self.expat.CurrentLineNumber,
146 self.expat.CurrentColumnNumber) 146 self.expat.CurrentColumnNumber)
147 147
148 def _handle_start(self, tag, attrib): 148 def _handle_start(self, tag, attrib):
149 self._enqueue(START, (QName(tag), Attributes(zip(*[iter(attrib)] * 2)))) 149 self._enqueue(START, (QName(tag), Attrs(zip(*[iter(attrib)] * 2))))
150 150
151 def _handle_end(self, tag): 151 def _handle_end(self, tag):
152 self._enqueue(END, QName(tag)) 152 self._enqueue(END, QName(tag))
153 153
154 def _handle_data(self, text): 154 def _handle_data(self, text):
266 for name, value in attrib: # Fixup minimized attributes 266 for name, value in attrib: # Fixup minimized attributes
267 if value is None: 267 if value is None:
268 value = name 268 value = name
269 fixed_attrib.append((name, unicode(value))) 269 fixed_attrib.append((name, unicode(value)))
270 270
271 self._enqueue(START, (QName(tag), Attributes(fixed_attrib))) 271 self._enqueue(START, (QName(tag), Attrs(fixed_attrib)))
272 if tag in self._EMPTY_ELEMS: 272 if tag in self._EMPTY_ELEMS:
273 self._enqueue(END, QName(tag)) 273 self._enqueue(END, QName(tag))
274 else: 274 else:
275 self._open_tags.append(tag) 275 self._open_tags.append(tag)
276 276
Copyright (C) 2012-2017 Edgewall Software