Show More
@@ -126,7 +126,11 class abstractvfs(abc.ABC): | |||||
126 | return fp.write(data) |
|
126 | return fp.write(data) | |
127 |
|
127 | |||
128 | def writelines( |
|
128 | def writelines( | |
129 | self, path: bytes, data: bytes, mode: bytes = b'wb', notindexed=False |
|
129 | self, | |
|
130 | path: bytes, | |||
|
131 | data: Iterable[bytes], | |||
|
132 | mode: bytes = b'wb', | |||
|
133 | notindexed=False, | |||
130 | ) -> None: |
|
134 | ) -> None: | |
131 | with self(path, mode=mode, notindexed=notindexed) as fp: |
|
135 | with self(path, mode=mode, notindexed=notindexed) as fp: | |
132 | return fp.writelines(data) |
|
136 | return fp.writelines(data) | |
@@ -362,7 +366,9 class abstractvfs(abc.ABC): | |||||
362 | def utime(self, path: Optional[bytes] = None, t=None) -> None: |
|
366 | def utime(self, path: Optional[bytes] = None, t=None) -> None: | |
363 | return os.utime(self.join(path), t) |
|
367 | return os.utime(self.join(path), t) | |
364 |
|
368 | |||
365 | def walk(self, path: Optional[bytes] = None, onerror=None): |
|
369 | def walk( | |
|
370 | self, path: Optional[bytes] = None, onerror=None | |||
|
371 | ) -> Iterator[Tuple[bytes, List[bytes], List[bytes]]]: | |||
366 | """Yield (dirpath, dirs, files) tuple for each directory under path |
|
372 | """Yield (dirpath, dirs, files) tuple for each directory under path | |
367 |
|
373 | |||
368 | ``dirpath`` is relative one from the root of this vfs. This |
|
374 | ``dirpath`` is relative one from the root of this vfs. This | |
@@ -379,7 +385,9 class abstractvfs(abc.ABC): | |||||
379 | yield (dirpath[prefixlen:], dirs, files) |
|
385 | yield (dirpath[prefixlen:], dirs, files) | |
380 |
|
386 | |||
381 | @contextlib.contextmanager |
|
387 | @contextlib.contextmanager | |
382 |
def backgroundclosing( |
|
388 | def backgroundclosing( | |
|
389 | self, ui, expectedcount=-1 | |||
|
390 | ) -> Iterator[Optional[backgroundfilecloser]]: | |||
383 | """Allow files to be closed asynchronously. |
|
391 | """Allow files to be closed asynchronously. | |
384 |
|
392 | |||
385 | When this context manager is active, ``backgroundclose`` can be passed |
|
393 | When this context manager is active, ``backgroundclose`` can be passed | |
@@ -723,11 +731,11 class closewrapbase(abc.ABC): | |||||
723 | return self |
|
731 | return self | |
724 |
|
732 | |||
725 | @abc.abstractmethod |
|
733 | @abc.abstractmethod | |
726 | def __exit__(self, exc_type, exc_value, exc_tb): |
|
734 | def __exit__(self, exc_type, exc_value, exc_tb) -> None: | |
727 | ... |
|
735 | ... | |
728 |
|
736 | |||
729 | @abc.abstractmethod |
|
737 | @abc.abstractmethod | |
730 | def close(self): |
|
738 | def close(self) -> None: | |
731 | ... |
|
739 | ... | |
732 |
|
740 | |||
733 |
|
741 | |||
@@ -741,7 +749,7 class delayclosedfile(closewrapbase): | |||||
741 | super(delayclosedfile, self).__init__(fh) |
|
749 | super(delayclosedfile, self).__init__(fh) | |
742 | object.__setattr__(self, '_closer', closer) |
|
750 | object.__setattr__(self, '_closer', closer) | |
743 |
|
751 | |||
744 | def __exit__(self, exc_type, exc_value, exc_tb): |
|
752 | def __exit__(self, exc_type, exc_value, exc_tb) -> None: | |
745 | self._closer.close(self._origfh) |
|
753 | self._closer.close(self._origfh) | |
746 |
|
754 | |||
747 | def close(self) -> None: |
|
755 | def close(self) -> None: | |
@@ -793,7 +801,7 class backgroundfilecloser: | |||||
793 | self._entered = True |
|
801 | self._entered = True | |
794 | return self |
|
802 | return self | |
795 |
|
803 | |||
796 |
def __exit__(self, exc_type, exc_value, exc_tb) -> None: |
|
804 | def __exit__(self, exc_type, exc_value, exc_tb) -> None: | |
797 | self._running = False |
|
805 | self._running = False | |
798 |
|
806 | |||
799 | # Wait for threads to finish closing so open files don't linger for |
|
807 | # Wait for threads to finish closing so open files don't linger for | |
@@ -860,7 +868,7 class checkambigatclosing(closewrapbase) | |||||
860 | if oldstat.stat: |
|
868 | if oldstat.stat: | |
861 | _avoidambig(self._origfh.name, oldstat) |
|
869 | _avoidambig(self._origfh.name, oldstat) | |
862 |
|
870 | |||
863 |
def __exit__(self, exc_type, exc_value, exc_tb) -> None: |
|
871 | def __exit__(self, exc_type, exc_value, exc_tb) -> None: | |
864 | self._origfh.__exit__(exc_type, exc_value, exc_tb) |
|
872 | self._origfh.__exit__(exc_type, exc_value, exc_tb) | |
865 | self._checkambig() |
|
873 | self._checkambig() | |
866 |
|
874 |
General Comments 0
You need to be logged in to leave comments.
Login now