Show More
@@ -139,6 +139,9 def build_opener(ui, authinfo): | |||
|
139 | 139 | f = b"/".join((self.base, urlreq.quote(path))) |
|
140 | 140 | return httprangereader(f, urlopener) |
|
141 | 141 | |
|
142 | def _auditpath(self, path: bytes, mode: bytes) -> None: | |
|
143 | raise NotImplementedError | |
|
144 | ||
|
142 | 145 | def join(self, path, *insidef): |
|
143 | 146 | if path: |
|
144 | 147 | return pathutil.join(self.base, path, *insidef) |
@@ -7,6 +7,7 | |||
|
7 | 7 | |
|
8 | 8 | from __future__ import annotations |
|
9 | 9 | |
|
10 | import abc | |
|
10 | 11 | import contextlib |
|
11 | 12 | import os |
|
12 | 13 | import shutil |
@@ -46,7 +47,7 def _avoidambig(path: bytes, oldstat): | |||
|
46 | 47 | checkandavoid() |
|
47 | 48 | |
|
48 | 49 | |
|
49 | class abstractvfs: | |
|
50 | class abstractvfs(abc.ABC): | |
|
50 | 51 | """Abstract base class; cannot be instantiated""" |
|
51 | 52 | |
|
52 | 53 | # default directory separator for vfs |
@@ -57,19 +58,18 class abstractvfs: | |||
|
57 | 58 | # encoded vfs (see issue6546) |
|
58 | 59 | _dir_sep = b'/' |
|
59 | 60 | |
|
60 | def __init__(self, *args, **kwargs): | |
|
61 | '''Prevent instantiation; don't call this from subclasses.''' | |
|
62 | raise NotImplementedError('attempted instantiating ' + str(type(self))) | |
|
63 | ||
|
64 | 61 | # TODO: type return, which is util.posixfile wrapped by a proxy |
|
62 | @abc.abstractmethod | |
|
65 | 63 | def __call__(self, path: bytes, mode: bytes = b'rb', **kwargs): |
|
66 | raise NotImplementedError | |
|
64 | ... | |
|
67 | 65 | |
|
66 | @abc.abstractmethod | |
|
68 | 67 | def _auditpath(self, path: bytes, mode: bytes): |
|
69 | raise NotImplementedError | |
|
68 | ... | |
|
70 | 69 | |
|
70 | @abc.abstractmethod | |
|
71 | 71 | def join(self, path: Optional[bytes], *insidef: bytes) -> bytes: |
|
72 | raise NotImplementedError | |
|
72 | ... | |
|
73 | 73 | |
|
74 | 74 | def tryread(self, path: bytes) -> bytes: |
|
75 | 75 | '''gracefully return an empty string for missing files''' |
@@ -625,7 +625,7 class vfs(abstractvfs): | |||
|
625 | 625 | opener = vfs |
|
626 | 626 | |
|
627 | 627 | |
|
628 | class proxyvfs(abstractvfs): | |
|
628 | class proxyvfs(abstractvfs, abc.ABC): | |
|
629 | 629 | def __init__(self, vfs: "vfs"): |
|
630 | 630 | self.vfs = vfs |
|
631 | 631 | |
@@ -684,7 +684,7 class readonlyvfs(proxyvfs): | |||
|
684 | 684 | return self.vfs.join(path, *insidef) |
|
685 | 685 | |
|
686 | 686 | |
|
687 | class closewrapbase: | |
|
687 | class closewrapbase(abc.ABC): | |
|
688 | 688 | """Base class of wrapper, which hooks closing |
|
689 | 689 | |
|
690 | 690 | Do not instantiate outside of the vfs layer. |
@@ -706,11 +706,13 class closewrapbase: | |||
|
706 | 706 | self._origfh.__enter__() |
|
707 | 707 | return self |
|
708 | 708 | |
|
709 | @abc.abstractmethod | |
|
709 | 710 | def __exit__(self, exc_type, exc_value, exc_tb): |
|
710 | raise NotImplementedError('attempted instantiating ' + str(type(self))) | |
|
711 | ... | |
|
711 | 712 | |
|
713 | @abc.abstractmethod | |
|
712 | 714 | def close(self): |
|
713 | raise NotImplementedError('attempted instantiating ' + str(type(self))) | |
|
715 | ... | |
|
714 | 716 | |
|
715 | 717 | |
|
716 | 718 | class delayclosedfile(closewrapbase): |
General Comments 0
You need to be logged in to leave comments.
Login now