Changeset 1082 for trunk/genshi/input.py
- Timestamp:
- Nov 12, 2009, 6:01:52 PM (14 years ago)
- File:
-
- 1 edited
-
trunk/genshi/input.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/genshi/input.py
r1080 r1082 17 17 18 18 from itertools import chain 19 try: 20 import htmlentitydefs as entities 21 import HTMLParser as html 22 except ImportError: 23 from html import entities 24 from html import parser as html 25 try: 26 from StringIO import StringIO 27 BytesIO = StringIO 28 except ImportError: 29 from io import BytesIO, StringIO 19 import htmlentitydefs as entities 20 import HTMLParser as html 21 from StringIO import StringIO 30 22 from xml.parsers import expat 31 23 32 24 from genshi.core import Attrs, QName, Stream, stripentities 33 from genshi.core import START, END, XML_DECL, DOCTYPE, TEXT, START_NS, END_NS,\34 START_CDATA, END_CDATA, PI, COMMENT25 from genshi.core import START, END, XML_DECL, DOCTYPE, TEXT, START_NS, \ 26 END_NS, START_CDATA, END_CDATA, PI, COMMENT 35 27 36 28 __all__ = ['ET', 'ParseError', 'XMLParser', 'XML', 'HTMLParser', 'HTML'] 37 29 __docformat__ = 'restructuredtext en' 30 38 31 39 32 def ET(element): … … 178 171 def _build_foreign(self, context, base, sysid, pubid): 179 172 parser = self.expat.ExternalEntityParserCreate(context) 180 parser.ParseFile( BytesIO(self._external_dtd))173 parser.ParseFile(StringIO(self._external_dtd)) 181 174 return 1 182 175 … … 276 269 :raises ParseError: if the XML text is not well-formed 277 270 """ 278 return Stream(list(XMLParser( BytesIO(text))))271 return Stream(list(XMLParser(StringIO(text)))) 279 272 280 273 … … 430 423 fails 431 424 """ 432 return Stream(list(HTMLParser(BytesIO(text), encoding=encoding))) 425 return Stream(list(HTMLParser(StringIO(text), encoding=encoding))) 426 433 427 434 428 def _coalesce(stream):
Note: See TracChangeset
for help on using the changeset viewer.
