Mercurial > public > mercurial-scm > hg
comparison mercurial/util.py @ 52360:fca7d38e040b
util: stop using the `pycompat.open()` shim
It looks like we don't actually need this leftover from the py2 days.
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 04 Dec 2024 19:50:32 -0500 |
parents | 82e2c99c84f3 |
children | 24ee91ba9aa8 |
comparison
equal
deleted
inserted
replaced
52359:3f0cf7bb3086 | 52360:fca7d38e040b |
---|---|
55 # Force pytype to use the non-vendored package | 55 # Force pytype to use the non-vendored package |
56 if typing.TYPE_CHECKING: | 56 if typing.TYPE_CHECKING: |
57 # noinspection PyPackageRequirements | 57 # noinspection PyPackageRequirements |
58 import attr | 58 import attr |
59 | 59 |
60 from .pycompat import ( | |
61 open, | |
62 ) | |
63 from hgdemandimport import tracing | 60 from hgdemandimport import tracing |
64 from . import ( | 61 from . import ( |
65 encoding, | 62 encoding, |
66 error, | 63 error, |
67 i18n, | 64 i18n, |
2752 if mode is not None: | 2749 if mode is not None: |
2753 os.chmod(name, mode) | 2750 os.chmod(name, mode) |
2754 | 2751 |
2755 | 2752 |
2756 def readfile(path: bytes) -> bytes: | 2753 def readfile(path: bytes) -> bytes: |
2757 with open(path, b'rb') as fp: | 2754 with open(path, 'rb') as fp: |
2758 return fp.read() | 2755 return fp.read() |
2759 | 2756 |
2760 | 2757 |
2761 def writefile(path: bytes, text: bytes) -> None: | 2758 def writefile(path: bytes, text: bytes) -> None: |
2762 with open(path, b'wb') as fp: | 2759 with open(path, 'wb') as fp: |
2763 fp.write(text) | 2760 fp.write(text) |
2764 | 2761 |
2765 | 2762 |
2766 def appendfile(path: bytes, text: bytes) -> None: | 2763 def appendfile(path: bytes, text: bytes) -> None: |
2767 with open(path, b'ab') as fp: | 2764 with open(path, 'ab') as fp: |
2768 fp.write(text) | 2765 fp.write(text) |
2769 | 2766 |
2770 | 2767 |
2771 class chunkbuffer: | 2768 class chunkbuffer: |
2772 """Allow arbitrary sized chunks of data to be efficiently read from an | 2769 """Allow arbitrary sized chunks of data to be efficiently read from an |