460 fn = file |
460 fn = file |
461 # read the file and split it into textlines |
461 # read the file and split it into textlines |
462 try: |
462 try: |
463 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn) |
463 text, encoding, hashStr = Utilities.readEncodedFileWithHash(fn) |
464 lines = text.splitlines(True) |
464 lines = text.splitlines(True) |
465 except (UnicodeError, IOError): |
465 except (UnicodeError, OSError): |
466 progress += 1 |
466 progress += 1 |
467 self.findProgress.setValue(progress) |
467 self.findProgress.setValue(progress) |
468 continue |
468 continue |
469 |
469 |
470 # now perform the search and display the lines found |
470 # now perform the search and display the lines found |
623 try: |
623 try: |
624 text, encoding, hashStr = ( |
624 text, encoding, hashStr = ( |
625 Utilities.readEncodedFileWithHash(fn) |
625 Utilities.readEncodedFileWithHash(fn) |
626 ) |
626 ) |
627 lines = text.splitlines(True) |
627 lines = text.splitlines(True) |
628 except (UnicodeError, IOError) as err: |
628 except (UnicodeError, OSError) as err: |
629 E5MessageBox.critical( |
629 E5MessageBox.critical( |
630 self, |
630 self, |
631 self.tr("Replace in Files"), |
631 self.tr("Replace in Files"), |
632 self.tr( |
632 self.tr( |
633 """<p>Could not read the file <b>{0}</b>.""" |
633 """<p>Could not read the file <b>{0}</b>.""" |
664 |
664 |
665 # write the file |
665 # write the file |
666 txt = "".join(lines) |
666 txt = "".join(lines) |
667 try: |
667 try: |
668 Utilities.writeEncodedFile(fn, txt, encoding) |
668 Utilities.writeEncodedFile(fn, txt, encoding) |
669 except (IOError, Utilities.CodingError, UnicodeError) as err: |
669 except (OSError, Utilities.CodingError, UnicodeError) as err: |
670 E5MessageBox.critical( |
670 E5MessageBox.critical( |
671 self, |
671 self, |
672 self.tr("Replace in Files"), |
672 self.tr("Replace in Files"), |
673 self.tr( |
673 self.tr( |
674 """<p>Could not save the file <b>{0}</b>.""" |
674 """<p>Could not save the file <b>{0}</b>.""" |