Preferences/ConfigurationPages/EditorHighlightingStylesPage.py

changeset 97
c4086afea02b
parent 50
a36eecf45b2e
child 244
30be2b4a9721
equal deleted inserted replaced
96:9624a110667d 97:c4086afea02b
5 5
6 """ 6 """
7 Module implementing the Editor Highlighting Styles configuration page. 7 Module implementing the Editor Highlighting Styles configuration page.
8 """ 8 """
9 9
10 import os 10 import io
11 11
12 from PyQt4.QtCore import pyqtSlot, QFileInfo 12 from PyQt4.QtCore import pyqtSlot, QFileInfo
13 from PyQt4.QtGui import QPalette, QFileDialog, QColorDialog, QFontDialog, \ 13 from PyQt4.QtGui import QPalette, QFileDialog, QColorDialog, QFontDialog, \
14 QInputDialog, QMessageBox 14 QInputDialog, QMessageBox
15 15
322 return 322 return
323 323
324 try: 324 try:
325 f = open(fn, "r", encoding = "utf-8") 325 f = open(fn, "r", encoding = "utf-8")
326 try: 326 try:
327 line = f.readline() 327 f.readline()
328 dtdLine = f.readline() 328 dtdLine = f.readline()
329 finally: 329 finally:
330 f.close() 330 f.close()
331 except IOError as err: 331 except IOError as err:
332 QMessageBox.critical(self, 332 QMessageBox.critical(self,
352 try: 352 try:
353 try: 353 try:
354 parser.parse(f) 354 parser.parse(f)
355 except UnicodeEncodeError: 355 except UnicodeEncodeError:
356 f.seek(0) 356 f.seek(0)
357 buf = cStringIO.StringIO(f.read()) 357 buf = io.StringIO(f.read())
358 parser.parse(buf) 358 parser.parse(buf)
359 finally: 359 finally:
360 f.close() 360 f.close()
361 except IOError as err: 361 except IOError as err:
362 QMessageBox.critical(self, 362 QMessageBox.critical(self,

eric ide

mercurial