Skip to content

Commit c68dcf1

Browse files
mxrJelleZijlstra
authored andcommitted
Add definitions for boto/utils.py (#1579)
1 parent 355f30c commit c68dcf1

File tree

1 file changed

+239
-0
lines changed

1 file changed

+239
-0
lines changed

third_party/2and3/boto/utils.pyi

+239
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
import datetime
2+
import logging.handlers
3+
import subprocess
4+
import sys
5+
import time
6+
7+
import boto.connection
8+
from typing import (
9+
Any,
10+
Callable,
11+
ContextManager,
12+
Dict,
13+
IO,
14+
Iterable,
15+
List,
16+
Mapping,
17+
Optional,
18+
Sequence,
19+
Tuple,
20+
Type,
21+
TypeVar,
22+
Union,
23+
)
24+
25+
_KT = TypeVar('_KT')
26+
_VT = TypeVar('_VT')
27+
28+
if sys.version_info[0] >= 3:
29+
# TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO
30+
import io
31+
_StringIO = io.StringIO
32+
33+
from hashlib import _Hash
34+
_HashType = _Hash
35+
36+
from email.message import Message as _Message
37+
else:
38+
# TODO move _StringIO definition into boto.compat once stubs exist and rename to StringIO
39+
import StringIO
40+
_StringIO = StringIO.StringIO
41+
42+
from hashlib import _hash
43+
_HashType = _hash
44+
45+
# TODO use email.message.Message once stubs exist
46+
_Message = Any
47+
48+
_Provider = Any # TODO replace this with boto.provider.Provider once stubs exist
49+
_LockType = Any # TODO replace this with _thread.LockType once stubs exist
50+
51+
52+
JSONDecodeError = ... # type: Type[ValueError]
53+
qsa_of_interest = ... # type: List[str]
54+
55+
56+
def unquote_v(nv: str) -> Union[str, Tuple[str, str]]: ...
57+
def canonical_string(
58+
method: str,
59+
path: str,
60+
headers: Mapping[str, Optional[str]],
61+
expires: Optional[int] = ...,
62+
provider: Optional[_Provider] = ...,
63+
) -> str: ...
64+
def merge_meta(
65+
headers: Mapping[str, str],
66+
metadata: Mapping[str, str],
67+
provider: Optional[_Provider] = ...,
68+
) -> Mapping[str, str]: ...
69+
def get_aws_metadata(
70+
headers: Mapping[str, str],
71+
provider: Optional[_Provider] = ...,
72+
) -> Mapping[str, str]: ...
73+
def retry_url(
74+
url: str,
75+
retry_on_404: bool = ...,
76+
num_retries: int = ...,
77+
timeout: Optional[int] = ...,
78+
) -> str: ...
79+
80+
class LazyLoadMetadata(Dict[_KT, _VT]):
81+
def __init__(
82+
self,
83+
url: str,
84+
num_retries: int,
85+
timeout: Optional[int] = ...,
86+
) -> None: ...
87+
88+
def get_instance_metadata(
89+
version: str = ...,
90+
url: str = ...,
91+
data: str = ...,
92+
timeout: Optional[int] = ...,
93+
num_retries: int = ...,
94+
) -> Optional[LazyLoadMetadata]: ...
95+
def get_instance_identity(
96+
version: str = ...,
97+
url: str = ...,
98+
timeout: Optional[int] = ...,
99+
num_retries: int = ...,
100+
) -> Optional[Mapping[str, Any]]: ...
101+
def get_instance_userdata(
102+
version: str = ...,
103+
sep: Optional[str] = ...,
104+
url: str = ...,
105+
timeout: Optional[int] = ...,
106+
num_retries: int = ...,
107+
) -> Mapping[str, str]: ...
108+
109+
ISO8601 = ... # type: str
110+
ISO8601_MS = ... # type: str
111+
RFC1123 = ... # type: str
112+
LOCALE_LOCK = ... # type: _LockType
113+
114+
def setlocale(name: Union[str, Tuple[str, str]]) -> ContextManager[str]: ...
115+
def get_ts(ts: Optional[time.struct_time] = ...) -> str: ...
116+
def parse_ts(ts: str) -> datetime.datetime: ...
117+
def find_class(module_name: str, class_name: Optional[str] = ...) -> Optional[Type[Any]]: ...
118+
def update_dme(username: str, password: str, dme_id: str, ip_address: str) -> str: ...
119+
def fetch_file(
120+
uri: str,
121+
file: Optional[IO[str]] = ...,
122+
username: Optional[str] = ...,
123+
password: Optional[str] = ...,
124+
) -> Optional[IO[str]]: ...
125+
126+
class ShellCommand:
127+
exit_code = ... # type: int
128+
command = ... # type: subprocess._CMD
129+
log_fp = ... # type: _StringIO
130+
wait = ... # type: bool
131+
fail_fast = ... # type: bool
132+
133+
def __init__(
134+
self,
135+
command: subprocess._CMD,
136+
wait: bool = ...,
137+
fail_fast: bool = ...,
138+
cwd: Optional[subprocess._TXT] = ...,
139+
) -> None: ...
140+
141+
process = ... # type: subprocess.Popen
142+
143+
def run(self, cwd: Optional[subprocess._CMD] = ...) -> Optional[int]: ...
144+
def setReadOnly(self, value) -> None: ...
145+
def getStatus(self) -> Optional[int]: ...
146+
147+
status = ... # type: Optional[int]
148+
149+
def getOutput(self) -> str: ...
150+
151+
output = ... # type: str
152+
153+
class AuthSMTPHandler(logging.handlers.SMTPHandler):
154+
username = ... # type: str
155+
password = ... # type: str
156+
def __init__(
157+
self,
158+
mailhost: str,
159+
username: str,
160+
password: str,
161+
fromaddr: str,
162+
toaddrs: Sequence[str],
163+
subject: str,
164+
) -> None: ...
165+
166+
class LRUCache(Dict[_KT, _VT]):
167+
class _Item:
168+
previous = ... # type: Optional[LRUCache._Item]
169+
next = ... # type: Optional[LRUCache._Item]
170+
key = ...
171+
value = ...
172+
def __init__(self, key, value) -> None: ...
173+
174+
_dict = ... # type: Dict[_KT, LRUCache._Item]
175+
capacity = ... # type: int
176+
head = ... # type: Optional[LRUCache._Item]
177+
tail = ... # type: Optional[LRUCache._Item]
178+
179+
def __init__(self, capacity: int) -> None: ...
180+
181+
182+
# This exists to work around Password.str's name shadowing the str type
183+
_str = str
184+
185+
class Password:
186+
hashfunc = ... # type: Callable[[bytes], _HashType]
187+
str = ... # type: Optional[_str]
188+
189+
def __init__(
190+
self,
191+
str: Optional[_str] = ...,
192+
hashfunc: Optional[Callable[[bytes], _HashType]] = ...,
193+
) -> None: ...
194+
def set(self, value: Union[bytes, _str]) -> None: ...
195+
def __eq__(self, other: Any) -> bool: ...
196+
def __len__(self) -> int: ...
197+
198+
def notify(
199+
subject: str,
200+
body: Optional[str] = ...,
201+
html_body: Optional[Union[Sequence[str], str]] = ...,
202+
to_string: Optional[str] = ...,
203+
attachments: Optional[Iterable[_Message]] = ...,
204+
append_instance_id: bool = ...,
205+
) -> None: ...
206+
def get_utf8_value(value: str) -> bytes: ...
207+
def mklist(value: Any) -> List: ...
208+
def pythonize_name(name: str) -> str: ...
209+
def write_mime_multipart(
210+
content: List[Tuple[str, str]],
211+
compress: bool = ...,
212+
deftype: str = ...,
213+
delimiter: str = ...,
214+
) -> str: ...
215+
def guess_mime_type(content: str, deftype: str) -> str: ...
216+
def compute_md5(
217+
fp: IO[Any],
218+
buf_size: int = ...,
219+
size: Optional[int] = ...,
220+
) -> Tuple[str, str, int]: ...
221+
def compute_hash(
222+
fp: IO[Any],
223+
buf_size: int = ...,
224+
size: Optional[int] = ...,
225+
hash_algorithm: Any = ...,
226+
) -> Tuple[str, str, int]: ...
227+
def find_matching_headers(name: str, headers: Mapping[str, Optional[str]]) -> List[str]: ...
228+
def merge_headers_by_name(name: str, headers: Mapping[str, Optional[str]]) -> str: ...
229+
230+
class RequestHook:
231+
def handle_request_data(
232+
self,
233+
request: boto.connection.HTTPRequest,
234+
response: boto.connection.HTTPResponse,
235+
error: bool = ...,
236+
) -> Any: ...
237+
238+
def host_is_ipv6(hostname: str) -> bool: ...
239+
def parse_host(hostname: str) -> str: ...

0 commit comments

Comments
 (0)