UI/FindFileDialog.py

changeset 537
72b32daeb8d6
parent 501
5c615a85241a
child 564
b3d966393ba9
equal deleted inserted replaced
536:6d8d39753c82 537:72b32daeb8d6
12 12
13 from PyQt4.QtCore import * 13 from PyQt4.QtCore import *
14 from PyQt4.QtGui import * 14 from PyQt4.QtGui import *
15 15
16 from E5Gui.E5Application import e5App 16 from E5Gui.E5Application import e5App
17 from E5Gui import E5MessageBox
17 18
18 from .Ui_FindFileDialog import Ui_FindFileDialog 19 from .Ui_FindFileDialog import Ui_FindFileDialog
19 20
20 import Utilities 21 import Utilities
21 import Preferences 22 import Preferences
330 if not cs: 331 if not cs:
331 flags |= re.IGNORECASE 332 flags |= re.IGNORECASE
332 try: 333 try:
333 search = re.compile(txt, flags) 334 search = re.compile(txt, flags)
334 except re.error as why: 335 except re.error as why:
335 QMessageBox.critical(None, 336 E5MessageBox.critical(self,
336 self.trUtf8("Invalid search expression"), 337 self.trUtf8("Invalid search expression"),
337 self.trUtf8("""<p>The search expression is not valid.</p>""" 338 self.trUtf8("""<p>The search expression is not valid.</p>"""
338 """<p>Error: {0}</p>""").format(str(why))) 339 """<p>Error: {0}</p>""").format(str(why)))
339 self.stopButton.setEnabled(False) 340 self.stopButton.setEnabled(False)
340 self.findButton.setEnabled(True) 341 self.findButton.setEnabled(True)
552 # read the file and split it into textlines 553 # read the file and split it into textlines
553 try: 554 try:
554 text, encoding = Utilities.readEncodedFile(fn) 555 text, encoding = Utilities.readEncodedFile(fn)
555 lines = text.splitlines() 556 lines = text.splitlines()
556 except (UnicodeError, IOError): 557 except (UnicodeError, IOError):
557 QMessageBox.critical(self, 558 E5MessageBox.critical(self,
558 self.trUtf8("Replace in Files"), 559 self.trUtf8("Replace in Files"),
559 self.trUtf8("""<p>Could not read the file <b>{0}</b>.""" 560 self.trUtf8("""<p>Could not read the file <b>{0}</b>."""
560 """ Skipping it.</p><p>Reason: {1}</p>""")\ 561 """ Skipping it.</p><p>Reason: {1}</p>""")\
561 .format(fn, str(err)) 562 .format(fn, str(err))
562 ) 563 )
575 # write the file 576 # write the file
576 txt = Utilities.linesep().join(lines) 577 txt = Utilities.linesep().join(lines)
577 try: 578 try:
578 Utilities.writeEncodedFile(fn, txt, encoding) 579 Utilities.writeEncodedFile(fn, txt, encoding)
579 except (IOError, Utilities.CodingError, UnicodeError) as err: 580 except (IOError, Utilities.CodingError, UnicodeError) as err:
580 QMessageBox.critical(self, 581 E5MessageBox.critical(self,
581 self.trUtf8("Replace in Files"), 582 self.trUtf8("Replace in Files"),
582 self.trUtf8("""<p>Could not save the file <b>{0}</b>.""" 583 self.trUtf8("""<p>Could not save the file <b>{0}</b>."""
583 """ Skipping it.</p><p>Reason: {1}</p>""")\ 584 """ Skipping it.</p><p>Reason: {1}</p>""")\
584 .format(fn, str(err)) 585 .format(fn, str(err))
585 ) 586 )

eric ide

mercurial