QScintilla/Exporters/ExporterHTML.py

changeset 12
1d8dd9706f46
parent 0
de9c2efb9d02
child 13
1af94a91f439
equal deleted inserted replaced
11:b0996e4a289e 12:1d8dd9706f46
14 14
15 from PyQt4.QtCore import * 15 from PyQt4.QtCore import *
16 from PyQt4.QtGui import * 16 from PyQt4.QtGui import *
17 from PyQt4.Qsci import QsciScintilla 17 from PyQt4.Qsci import QsciScintilla
18 18
19 from ExporterBase import ExporterBase 19 from .ExporterBase import ExporterBase
20 20
21 import Preferences 21 import Preferences
22 import Utilities 22 import Utilities
23 23
24 class ExporterHTML(ExporterBase): 24 class ExporterHTML(ExporterBase):
71 for index in range(QsciScintilla.STYLE_MAX + 1): 71 for index in range(QsciScintilla.STYLE_MAX + 1):
72 styleIsUsed[index] = True 72 styleIsUsed[index] = True
73 styleIsUsed[QsciScintilla.STYLE_DEFAULT] = True 73 styleIsUsed[QsciScintilla.STYLE_DEFAULT] = True
74 74
75 try: 75 try:
76 f = open(filename, "wb") 76 f = open(filename, "w")
77 77
78 f.write( 78 f.write(
79 '''<!DOCTYPE html PUBLIC "-//W3C//DTD''' 79 '''<!DOCTYPE html PUBLIC "-//W3C//DTD'''
80 ''' XHTML 1.0 Transitional//EN"\n''') 80 ''' XHTML 1.0 Transitional//EN"\n''')
81 f.write( 81 f.write(
348 else: 348 else:
349 f.write('''</pre>''') 349 f.write('''</pre>''')
350 350
351 f.write('''</body>\n</html>\n''') 351 f.write('''</body>\n</html>\n''')
352 f.close() 352 f.close()
353 except IOError, err: 353 except IOError as err:
354 QApplication.restoreOverrideCursor() 354 QApplication.restoreOverrideCursor()
355 QMessageBox.critical(self.editor, 355 QMessageBox.critical(self.editor,
356 self.trUtf8("Export source"), 356 self.trUtf8("Export source"),
357 self.trUtf8(\ 357 self.trUtf8(\
358 """<p>The source could not be exported to <b>{0}</b>.</p>""" 358 """<p>The source could not be exported to <b>{0}</b>.</p>"""
359 """<p>Reason: {1}</p>""")\ 359 """<p>Reason: {1}</p>""")\
360 .format(filename, unicode(err)), 360 .format(filename, str(err)),
361 QMessageBox.StandardButtons(\ 361 QMessageBox.StandardButtons(\
362 QMessageBox.Ok)) 362 QMessageBox.Ok))
363 finally: 363 finally:
364 QApplication.restoreOverrideCursor() 364 QApplication.restoreOverrideCursor()

eric ide

mercurial