UI/FindFileDialog.py

changeset 5603
4f2dd0850803
parent 5558
858abfcbaf28
child 5986
1e78a1aa438b
equal deleted inserted replaced
5602:77755a5ea30c 5603:4f2dd0850803
445 fn = os.path.join(self.project.ppath, file) 445 fn = os.path.join(self.project.ppath, file)
446 else: 446 else:
447 fn = file 447 fn = file
448 # read the file and split it into textlines 448 # read the file and split it into textlines
449 try: 449 try:
450 text, encoding, hash = Utilities.readEncodedFileWithHash(fn) 450 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn)
451 lines = text.splitlines(True) 451 lines = text.splitlines(True)
452 except (UnicodeError, IOError): 452 except (UnicodeError, IOError):
453 progress += 1 453 progress += 1
454 self.findProgress.setValue(progress) 454 self.findProgress.setValue(progress)
455 continue 455 continue
478 if len(rline) > 1024: 478 if len(rline) > 1024:
479 rline = "{0} ...".format(line[:1024]) 479 rline = "{0} ...".format(line[:1024])
480 line = "- {0}\n+ {1}".format( 480 line = "- {0}\n+ {1}".format(
481 line, self.__stripEol(rline)) 481 line, self.__stripEol(rline))
482 self.__createItem(file, count, line, start, end, 482 self.__createItem(file, count, line, start, end,
483 rline, hash) 483 rline, hashStr)
484 484
485 if self.feelLikeCheckBox.isChecked(): 485 if self.feelLikeCheckBox.isChecked():
486 fn = os.path.join(self.project.ppath, file) 486 fn = os.path.join(self.project.ppath, file)
487 self.sourceFile.emit(fn, count, "", start, end) 487 self.sourceFile.emit(fn, count, "", start, end)
488 QApplication.processEvents() 488 QApplication.processEvents()
606 else: 606 else:
607 fn = file 607 fn = file
608 608
609 # read the file and split it into textlines 609 # read the file and split it into textlines
610 try: 610 try:
611 text, encoding, hash = \ 611 text, encoding, hashStr = \
612 Utilities.readEncodedFileWithHash(fn) 612 Utilities.readEncodedFileWithHash(fn)
613 lines = text.splitlines(True) 613 lines = text.splitlines(True)
614 except (UnicodeError, IOError) as err: 614 except (UnicodeError, IOError) as err:
615 E5MessageBox.critical( 615 E5MessageBox.critical(
616 self, 616 self,
624 self.findProgress.setValue(progress) 624 self.findProgress.setValue(progress)
625 continue 625 continue
626 626
627 # Check the original and the current hash. Skip the file, 627 # Check the original and the current hash. Skip the file,
628 # if hashes are different. 628 # if hashes are different.
629 if origHash != hash: 629 if origHash != hashStr:
630 E5MessageBox.critical( 630 E5MessageBox.critical(
631 self, 631 self,
632 self.tr("Replace in Files"), 632 self.tr("Replace in Files"),
633 self.tr( 633 self.tr(
634 """<p>The current and the original hash of the""" 634 """<p>The current and the original hash of the"""
635 """ file <b>{0}</b> are different. Skipping it.""" 635 """ file <b>{0}</b> are different. Skipping it."""
636 """</p><p>Hash 1: {1}</p><p>Hash 2: {2}</p>""") 636 """</p><p>Hash 1: {1}</p><p>Hash 2: {2}</p>""")
637 .format(fn, origHash, hash) 637 .format(fn, origHash, hashStr)
638 ) 638 )
639 progress += 1 639 progress += 1
640 self.findProgress.setValue(progress) 640 self.findProgress.setValue(progress)
641 continue 641 continue
642 642

eric ide

mercurial