equal
deleted
inserted
replaced
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 |