Mercurial > hgrepos > Python > apps > py-cutils
comparison cutils/treesum.py @ 267:b9aa65a30b4c
treesum: optimize the use of flush() somewhat
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 18 Feb 2025 12:43:31 +0100 |
| parents | 0add8276e6b8 |
| children | 8aadffaaad5f |
comparison
equal
deleted
inserted
replaced
| 266:0add8276e6b8 | 267:b9aa65a30b4c |
|---|---|
| 688 self._writer.write_file_digest( | 688 self._writer.write_file_digest( |
| 689 self._algorithm[1], | 689 self._algorithm[1], |
| 690 util.interpolate_bytes(b"%s/./@/", opath), | 690 util.interpolate_bytes(b"%s/./@/", opath), |
| 691 linkdgst.digest(), | 691 linkdgst.digest(), |
| 692 self._use_base64) | 692 self._use_base64) |
| 693 self._writer.flush() | |
| 694 else: | 693 else: |
| 695 # | 694 # |
| 696 # Follow the symlink to dir or handle a "real" directory | 695 # Follow the symlink to dir or handle a "real" directory |
| 697 # | 696 # |
| 698 | 697 |
| 809 self._writer.write_file_digest( | 808 self._writer.write_file_digest( |
| 810 self._algorithm[1], | 809 self._algorithm[1], |
| 811 util.interpolate_bytes(b"%s/./@", opath), | 810 util.interpolate_bytes(b"%s/./@", opath), |
| 812 linkdgst.digest(), | 811 linkdgst.digest(), |
| 813 self._use_base64) | 812 self._use_base64) |
| 814 self._writer.flush() | |
| 815 else: | 813 else: |
| 816 # | 814 # |
| 817 # Follow the symlink to file or handle a "real" file | 815 # Follow the symlink to file or handle a "real" file |
| 818 # | 816 # |
| 819 | 817 |
| 900 sz = fso.stat.st_size if self._print_size else None | 898 sz = fso.stat.st_size if self._print_size else None |
| 901 self._writer.write_file_digest( | 899 self._writer.write_file_digest( |
| 902 self._algorithm[1], opath, dgst, | 900 self._algorithm[1], opath, dgst, |
| 903 use_base64=self._use_base64, | 901 use_base64=self._use_base64, |
| 904 size=sz) | 902 size=sz) |
| 905 self._writer.flush() | 903 self._writer.flush() |
| 906 opath = join_output_path(top, None) | 904 opath = join_output_path(top, None) |
| 907 if opath: | 905 if opath: |
| 908 if self._utf8_mode: | 906 if self._utf8_mode: |
| 909 opath = walk.WalkDirEntry.alt_u8(opath) | 907 opath = walk.WalkDirEntry.alt_u8(opath) |
| 910 else: | 908 else: |
| 1117 def finish(self): | 1115 def finish(self): |
| 1118 """Finish a block and write the current CRC""" | 1116 """Finish a block and write the current CRC""" |
| 1119 crc = self._crc.hexdigest() | 1117 crc = self._crc.hexdigest() |
| 1120 self.write(b"CRC32 = ") | 1118 self.write(b"CRC32 = ") |
| 1121 self.writeln(util.b(crc)) | 1119 self.writeln(util.b(crc)) |
| 1120 self.flush() | |
| 1122 | 1121 |
| 1123 def writeln(self, line): | 1122 def writeln(self, line): |
| 1124 """Write the bytes `line` into the output file and update the CRC | 1123 """Write the bytes `line` into the output file and update the CRC |
| 1125 accordingly. | 1124 accordingly. |
| 1126 | 1125 |
