Mercurial > public > mercurial-scm > hg-stable
annotate mercurial/interfaces/misc.py @ 52908:180591a9a6a1
typing: add a protocol for `urlutil.path`
That is the last external import for the repository interface module.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 10 Feb 2025 00:16:22 +0100 |
parents | ba343f763595 |
children |
rev | line source |
---|---|
52905
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 # misc.py - Various Interface that did not deserve a dedicated module (yet) |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 # |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 # Copyright 2025 Octobus, contact@octobus.net |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 from __future__ import annotations |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 import abc |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 from typing import ( |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 Callable, |
52908
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
10 Dict, |
52906
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
11 Iterator, |
52905
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 List, |
52907
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
13 Optional, |
52905
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 Protocol, |
52907
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
15 Tuple, |
52905
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 ) |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 class IHooks(Protocol): |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 """A collection of hook functions that can be used to extend a |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 function's behavior. Hooks are called in lexicographic order, |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 based on the names of their sources.""" |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
24 @abc.abstractmethod |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
25 def add(self, source: bytes, hook: Callable): |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 ... |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
28 @abc.abstractmethod |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
29 def __call__(self, *args) -> List: |
483b0bb23085
typing: use a protocol to annotate `hooks` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
30 ... |
52906
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
31 |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
32 |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
33 class IDirs(Protocol): |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
34 '''a multiset of directory names from a set of file paths''' |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
35 |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
36 @abc.abstractmethod |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
37 def addpath(self, path: bytes) -> None: |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
38 ... |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
39 |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
40 @abc.abstractmethod |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
41 def delpath(self, path: bytes) -> None: |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
42 ... |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
43 |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
44 @abc.abstractmethod |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
45 def __iter__(self) -> Iterator[bytes]: |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
46 ... |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
47 |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
48 @abc.abstractmethod |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
49 def __contains__(self, d: bytes) -> bool: |
bde94bd8e8a2
typing: use a protocol to annotate `pathutil.dirs` in repository.py
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52905
diff
changeset
|
50 ... |
52907
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
51 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
52 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
53 AuthInfoT = Tuple[ |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
54 bytes, |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
55 Optional[ |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
56 Tuple[ |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
57 None, |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
58 Tuple[bytes, bytes], |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
59 bytes, |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
60 bytes, |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
61 ] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
62 ], |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
63 ] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
64 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
65 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
66 class IUrl(Protocol): |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
67 r"""Reliable URL parser. |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
68 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
69 This parses URLs and provides attributes for the following |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
70 components: |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
71 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
72 <scheme>://<user>:<passwd>@<host>:<port>/<path>?<query>#<fragment> |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
73 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
74 Missing components are set to None. The only exception is |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
75 fragment, which is set to '' if present but empty. |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
76 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
77 If parsefragment is False, fragment is included in query. If |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
78 parsequery is False, query is included in path. If both are |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
79 False, both fragment and query are included in path. |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
80 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
81 See http://www.ietf.org/rfc/rfc2396.txt for more information. |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
82 """ |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
83 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
84 path: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
85 scheme: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
86 user: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
87 passwd: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
88 host: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
89 port: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
90 query: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
91 fragment: Optional[bytes] |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
92 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
93 @abc.abstractmethod |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
94 def copy(self) -> IUrl: |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
95 ... |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
96 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
97 @abc.abstractmethod |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
98 def authinfo(self) -> AuthInfoT: |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
99 ... |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
100 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
101 @abc.abstractmethod |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
102 def isabs(self) -> bool: |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
103 ... |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
104 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
105 @abc.abstractmethod |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
106 def localpath(self) -> bytes: |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
107 ... |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
108 |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
109 @abc.abstractmethod |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
110 def islocal(self) -> bool: |
ba343f763595
typing: add an interface for url
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52906
diff
changeset
|
111 ... |
52908
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
112 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
113 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
114 class IPath(Protocol): |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
115 """Represents an individual path and its configuration.""" |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
116 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
117 name: bytes |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
118 main_path: Optional[IPath] |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
119 url: IUrl |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
120 raw_url: IUrl |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
121 branch: bytes |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
122 rawloc: bytes |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
123 loc: bytes |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
124 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
125 @abc.abstractmethod |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
126 def copy(self, new_raw_location: Optional[bytes] = None) -> IPath: |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
127 ... |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
128 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
129 @property |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
130 @abc.abstractmethod |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
131 def is_push_variant(self) -> bool: |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
132 """is this a path variant to be used for pushing""" |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
133 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
134 @abc.abstractmethod |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
135 def get_push_variant(self) -> IPath: |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
136 """get a "copy" of the path, but suitable for pushing |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
137 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
138 This means using the value of the `pushurl` option (if any) as the url. |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
139 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
140 The original path is available in the `main_path` attribute. |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
141 """ |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
142 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
143 @property |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
144 @abc.abstractmethod |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
145 def suboptions(self) -> Dict[bytes, bytes]: |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
146 """Return sub-options and their values for this path. |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
147 |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
148 This is intended to be used for presentation purposes. |
180591a9a6a1
typing: add a protocol for `urlutil.path`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
52907
diff
changeset
|
149 """ |