id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
26,900
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar._is_domain_match
def _is_domain_match(domain: str, hostname: str) -> bool: """Implements domain matching adhering to RFC 6265.""" if hostname == domain: return True if not hostname.endswith(domain): return False non_matching = hostname[:-len(domain)] if not non_matching...
python
def _is_domain_match(domain: str, hostname: str) -> bool: """Implements domain matching adhering to RFC 6265.""" if hostname == domain: return True if not hostname.endswith(domain): return False non_matching = hostname[:-len(domain)] if not non_matching...
[ "def", "_is_domain_match", "(", "domain", ":", "str", ",", "hostname", ":", "str", ")", "->", "bool", ":", "if", "hostname", "==", "domain", ":", "return", "True", "if", "not", "hostname", ".", "endswith", "(", "domain", ")", ":", "return", "False", "n...
Implements domain matching adhering to RFC 6265.
[ "Implements", "domain", "matching", "adhering", "to", "RFC", "6265", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L229-L242
26,901
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar._is_path_match
def _is_path_match(req_path: str, cookie_path: str) -> bool: """Implements path matching adhering to RFC 6265.""" if not req_path.startswith("/"): req_path = "/" if req_path == cookie_path: return True if not req_path.startswith(cookie_path): return ...
python
def _is_path_match(req_path: str, cookie_path: str) -> bool: """Implements path matching adhering to RFC 6265.""" if not req_path.startswith("/"): req_path = "/" if req_path == cookie_path: return True if not req_path.startswith(cookie_path): return ...
[ "def", "_is_path_match", "(", "req_path", ":", "str", ",", "cookie_path", ":", "str", ")", "->", "bool", ":", "if", "not", "req_path", ".", "startswith", "(", "\"/\"", ")", ":", "req_path", "=", "\"/\"", "if", "req_path", "==", "cookie_path", ":", "retur...
Implements path matching adhering to RFC 6265.
[ "Implements", "path", "matching", "adhering", "to", "RFC", "6265", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L245-L261
26,902
aio-libs/aiohttp
aiohttp/cookiejar.py
CookieJar._parse_date
def _parse_date(cls, date_str: str) -> Optional[datetime.datetime]: """Implements date string parsing adhering to RFC 6265.""" if not date_str: return None found_time = False found_day = False found_month = False found_year = False hour = minute = se...
python
def _parse_date(cls, date_str: str) -> Optional[datetime.datetime]: """Implements date string parsing adhering to RFC 6265.""" if not date_str: return None found_time = False found_day = False found_month = False found_year = False hour = minute = se...
[ "def", "_parse_date", "(", "cls", ",", "date_str", ":", "str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "if", "not", "date_str", ":", "return", "None", "found_time", "=", "False", "found_day", "=", "False", "found_month", "=", "...
Implements date string parsing adhering to RFC 6265.
[ "Implements", "date", "string", "parsing", "adhering", "to", "RFC", "6265", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/cookiejar.py#L264-L327
26,903
aio-libs/aiohttp
examples/legacy/tcp_protocol_parser.py
my_protocol_parser
def my_protocol_parser(out, buf): """Parser is used with StreamParser for incremental protocol parsing. Parser is a generator function, but it is not a coroutine. Usually parsers are implemented as a state machine. more details in asyncio/parsers.py existing parsers: * HTTP protocol parsers a...
python
def my_protocol_parser(out, buf): """Parser is used with StreamParser for incremental protocol parsing. Parser is a generator function, but it is not a coroutine. Usually parsers are implemented as a state machine. more details in asyncio/parsers.py existing parsers: * HTTP protocol parsers a...
[ "def", "my_protocol_parser", "(", "out", ",", "buf", ")", ":", "while", "True", ":", "tp", "=", "yield", "from", "buf", ".", "read", "(", "5", ")", "if", "tp", "in", "(", "MSG_PING", ",", "MSG_PONG", ")", ":", "# skip line", "yield", "from", "buf", ...
Parser is used with StreamParser for incremental protocol parsing. Parser is a generator function, but it is not a coroutine. Usually parsers are implemented as a state machine. more details in asyncio/parsers.py existing parsers: * HTTP protocol parsers asyncio/http/protocol.py * websocket...
[ "Parser", "is", "used", "with", "StreamParser", "for", "incremental", "protocol", "parsing", ".", "Parser", "is", "a", "generator", "function", "but", "it", "is", "not", "a", "coroutine", ".", "Usually", "parsers", "are", "implemented", "as", "a", "state", "...
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/examples/legacy/tcp_protocol_parser.py#L23-L46
26,904
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.clone
def clone(self, *, method: str=sentinel, rel_url: StrOrURL=sentinel, headers: LooseHeaders=sentinel, scheme: str=sentinel, host: str=sentinel, remote: str=sentinel) -> 'BaseRequest': """Clone itself with replacement some attributes. Creates and returns a new in...
python
def clone(self, *, method: str=sentinel, rel_url: StrOrURL=sentinel, headers: LooseHeaders=sentinel, scheme: str=sentinel, host: str=sentinel, remote: str=sentinel) -> 'BaseRequest': """Clone itself with replacement some attributes. Creates and returns a new in...
[ "def", "clone", "(", "self", ",", "*", ",", "method", ":", "str", "=", "sentinel", ",", "rel_url", ":", "StrOrURL", "=", "sentinel", ",", "headers", ":", "LooseHeaders", "=", "sentinel", ",", "scheme", ":", "str", "=", "sentinel", ",", "host", ":", "...
Clone itself with replacement some attributes. Creates and returns a new instance of Request object. If no parameters are given, an exact copy is returned. If a parameter is not passed, it will reuse the one from the current request object.
[ "Clone", "itself", "with", "replacement", "some", "attributes", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L148-L196
26,905
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.host
def host(self) -> str: """Hostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value """ host = self._message.headers.get(hdrs.HOST) if host is not None: ...
python
def host(self) -> str: """Hostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value """ host = self._message.headers.get(hdrs.HOST) if host is not None: ...
[ "def", "host", "(", "self", ")", "->", "str", ":", "host", "=", "self", ".", "_message", ".", "headers", ".", "get", "(", "hdrs", ".", "HOST", ")", "if", "host", "is", "not", "None", ":", "return", "host", "else", ":", "return", "socket", ".", "g...
Hostname of the request. Hostname is resolved in this order: - overridden value by .clone(host=new_host) call. - HOST HTTP header - socket.getfqdn() value
[ "Hostname", "of", "the", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L353-L366
26,906
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.remote
def remote(self) -> Optional[str]: """Remote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket """ if isinstance(self._transport_peername, (list, tuple)): ...
python
def remote(self) -> Optional[str]: """Remote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket """ if isinstance(self._transport_peername, (list, tuple)): ...
[ "def", "remote", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "if", "isinstance", "(", "self", ".", "_transport_peername", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "self", ".", "_transport_peername", "[", "0", "]", "else", ...
Remote IP of client initiated HTTP request. The IP is resolved in this order: - overridden value by .clone(remote=new_remote) call. - peername of opened socket
[ "Remote", "IP", "of", "client", "initiated", "HTTP", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L369-L380
26,907
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest._http_date
def _http_date(_date_str: str) -> Optional[datetime.datetime]: """Process a date string, return a datetime object """ if _date_str is not None: timetuple = parsedate(_date_str) if timetuple is not None: return datetime.datetime(*timetuple[:6], ...
python
def _http_date(_date_str: str) -> Optional[datetime.datetime]: """Process a date string, return a datetime object """ if _date_str is not None: timetuple = parsedate(_date_str) if timetuple is not None: return datetime.datetime(*timetuple[:6], ...
[ "def", "_http_date", "(", "_date_str", ":", "str", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "if", "_date_str", "is", "not", "None", ":", "timetuple", "=", "parsedate", "(", "_date_str", ")", "if", "timetuple", "is", "not", "None...
Process a date string, return a datetime object
[ "Process", "a", "date", "string", "return", "a", "datetime", "object" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L436-L444
26,908
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.if_modified_since
def if_modified_since(self) -> Optional[datetime.datetime]: """The value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_MODIFIED_SINCE))
python
def if_modified_since(self) -> Optional[datetime.datetime]: """The value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_MODIFIED_SINCE))
[ "def", "if_modified_since", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "return", "self", ".", "_http_date", "(", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "IF_MODIFIED_SINCE", ")", ")" ]
The value of If-Modified-Since HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "If", "-", "Modified", "-", "Since", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L447-L452
26,909
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.if_unmodified_since
def if_unmodified_since(self) -> Optional[datetime.datetime]: """The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_UNMODIFIED_SINCE))
python
def if_unmodified_since(self) -> Optional[datetime.datetime]: """The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_UNMODIFIED_SINCE))
[ "def", "if_unmodified_since", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "return", "self", ".", "_http_date", "(", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "IF_UNMODIFIED_SINCE", ")", ")" ]
The value of If-Unmodified-Since HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "If", "-", "Unmodified", "-", "Since", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L455-L460
26,910
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.if_range
def if_range(self) -> Optional[datetime.datetime]: """The value of If-Range HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_RANGE))
python
def if_range(self) -> Optional[datetime.datetime]: """The value of If-Range HTTP header, or None. This header is represented as a `datetime` object. """ return self._http_date(self.headers.get(hdrs.IF_RANGE))
[ "def", "if_range", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "return", "self", ".", "_http_date", "(", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "IF_RANGE", ")", ")" ]
The value of If-Range HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "If", "-", "Range", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L463-L468
26,911
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.cookies
def cookies(self) -> Mapping[str, str]: """Return request cookies. A read-only dictionary-like object. """ raw = self.headers.get(hdrs.COOKIE, '') parsed = SimpleCookie(raw) return MappingProxyType( {key: val.value for key, val in parsed.items()})
python
def cookies(self) -> Mapping[str, str]: """Return request cookies. A read-only dictionary-like object. """ raw = self.headers.get(hdrs.COOKIE, '') parsed = SimpleCookie(raw) return MappingProxyType( {key: val.value for key, val in parsed.items()})
[ "def", "cookies", "(", "self", ")", "->", "Mapping", "[", "str", ",", "str", "]", ":", "raw", "=", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "COOKIE", ",", "''", ")", "parsed", "=", "SimpleCookie", "(", "raw", ")", "return", "MappingPro...
Return request cookies. A read-only dictionary-like object.
[ "Return", "request", "cookies", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L476-L484
26,912
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.http_range
def http_range(self) -> slice: """The content of Range HTTP header. Return a slice instance. """ rng = self._headers.get(hdrs.RANGE) start, end = None, None if rng is not None: try: pattern = r'^bytes=(\d*)-(\d*)$' start, end ...
python
def http_range(self) -> slice: """The content of Range HTTP header. Return a slice instance. """ rng = self._headers.get(hdrs.RANGE) start, end = None, None if rng is not None: try: pattern = r'^bytes=(\d*)-(\d*)$' start, end ...
[ "def", "http_range", "(", "self", ")", "->", "slice", ":", "rng", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "RANGE", ")", "start", ",", "end", "=", "None", ",", "None", "if", "rng", "is", "not", "None", ":", "try", ":", "pattern...
The content of Range HTTP header. Return a slice instance.
[ "The", "content", "of", "Range", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L487-L520
26,913
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.has_body
def has_body(self) -> bool: """Return True if request's HTTP BODY can be read, False otherwise.""" warnings.warn( "Deprecated, use .can_read_body #2005", DeprecationWarning, stacklevel=2) return not self._payload.at_eof()
python
def has_body(self) -> bool: """Return True if request's HTTP BODY can be read, False otherwise.""" warnings.warn( "Deprecated, use .can_read_body #2005", DeprecationWarning, stacklevel=2) return not self._payload.at_eof()
[ "def", "has_body", "(", "self", ")", "->", "bool", ":", "warnings", ".", "warn", "(", "\"Deprecated, use .can_read_body #2005\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "return", "not", "self", ".", "_payload", ".", "at_eof", "(", ")" ]
Return True if request's HTTP BODY can be read, False otherwise.
[ "Return", "True", "if", "request", "s", "HTTP", "BODY", "can", "be", "read", "False", "otherwise", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L528-L533
26,914
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.read
async def read(self) -> bytes: """Read request body if present. Returns bytes object with full request content. """ if self._read_bytes is None: body = bytearray() while True: chunk = await self._payload.readany() body.extend(chunk...
python
async def read(self) -> bytes: """Read request body if present. Returns bytes object with full request content. """ if self._read_bytes is None: body = bytearray() while True: chunk = await self._payload.readany() body.extend(chunk...
[ "async", "def", "read", "(", "self", ")", "->", "bytes", ":", "if", "self", ".", "_read_bytes", "is", "None", ":", "body", "=", "bytearray", "(", ")", "while", "True", ":", "chunk", "=", "await", "self", ".", "_payload", ".", "readany", "(", ")", "...
Read request body if present. Returns bytes object with full request content.
[ "Read", "request", "body", "if", "present", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L553-L573
26,915
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.text
async def text(self) -> str: """Return BODY as text using encoding from .charset.""" bytes_body = await self.read() encoding = self.charset or 'utf-8' return bytes_body.decode(encoding)
python
async def text(self) -> str: """Return BODY as text using encoding from .charset.""" bytes_body = await self.read() encoding = self.charset or 'utf-8' return bytes_body.decode(encoding)
[ "async", "def", "text", "(", "self", ")", "->", "str", ":", "bytes_body", "=", "await", "self", ".", "read", "(", ")", "encoding", "=", "self", ".", "charset", "or", "'utf-8'", "return", "bytes_body", ".", "decode", "(", "encoding", ")" ]
Return BODY as text using encoding from .charset.
[ "Return", "BODY", "as", "text", "using", "encoding", "from", ".", "charset", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L575-L579
26,916
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.json
async def json(self, *, loads: JSONDecoder=DEFAULT_JSON_DECODER) -> Any: """Return BODY as JSON.""" body = await self.text() return loads(body)
python
async def json(self, *, loads: JSONDecoder=DEFAULT_JSON_DECODER) -> Any: """Return BODY as JSON.""" body = await self.text() return loads(body)
[ "async", "def", "json", "(", "self", ",", "*", ",", "loads", ":", "JSONDecoder", "=", "DEFAULT_JSON_DECODER", ")", "->", "Any", ":", "body", "=", "await", "self", ".", "text", "(", ")", "return", "loads", "(", "body", ")" ]
Return BODY as JSON.
[ "Return", "BODY", "as", "JSON", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L581-L584
26,917
aio-libs/aiohttp
aiohttp/web_request.py
BaseRequest.post
async def post(self) -> 'MultiDictProxy[Union[str, bytes, FileField]]': """Return POST parameters.""" if self._post is not None: return self._post if self._method not in self.POST_METHODS: self._post = MultiDictProxy(MultiDict()) return self._post con...
python
async def post(self) -> 'MultiDictProxy[Union[str, bytes, FileField]]': """Return POST parameters.""" if self._post is not None: return self._post if self._method not in self.POST_METHODS: self._post = MultiDictProxy(MultiDict()) return self._post con...
[ "async", "def", "post", "(", "self", ")", "->", "'MultiDictProxy[Union[str, bytes, FileField]]'", ":", "if", "self", ".", "_post", "is", "not", "None", ":", "return", "self", ".", "_post", "if", "self", ".", "_method", "not", "in", "self", ".", "POST_METHODS...
Return POST parameters.
[ "Return", "POST", "parameters", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_request.py#L590-L662
26,918
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.shutdown
async def shutdown(self, timeout: Optional[float]=15.0) -> None: """Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.""" self._force_close = True if self._keepalive_handle is not None: ...
python
async def shutdown(self, timeout: Optional[float]=15.0) -> None: """Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.""" self._force_close = True if self._keepalive_handle is not None: ...
[ "async", "def", "shutdown", "(", "self", ",", "timeout", ":", "Optional", "[", "float", "]", "=", "15.0", ")", "->", "None", ":", "self", ".", "_force_close", "=", "True", "if", "self", ".", "_keepalive_handle", "is", "not", "None", ":", "self", ".", ...
Worker process is about to exit, we need cleanup everything and stop accepting requests. It is especially important for keep-alive connections.
[ "Worker", "process", "is", "about", "to", "exit", "we", "need", "cleanup", "everything", "and", "stop", "accepting", "requests", ".", "It", "is", "especially", "important", "for", "keep", "-", "alive", "connections", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L184-L213
26,919
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.keep_alive
def keep_alive(self, val: bool) -> None: """Set keep-alive connection mode. :param bool val: new state. """ self._keepalive = val if self._keepalive_handle: self._keepalive_handle.cancel() self._keepalive_handle = None
python
def keep_alive(self, val: bool) -> None: """Set keep-alive connection mode. :param bool val: new state. """ self._keepalive = val if self._keepalive_handle: self._keepalive_handle.cancel() self._keepalive_handle = None
[ "def", "keep_alive", "(", "self", ",", "val", ":", "bool", ")", "->", "None", ":", "self", ".", "_keepalive", "=", "val", "if", "self", ".", "_keepalive_handle", ":", "self", ".", "_keepalive_handle", ".", "cancel", "(", ")", "self", ".", "_keepalive_han...
Set keep-alive connection mode. :param bool val: new state.
[ "Set", "keep", "-", "alive", "connection", "mode", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L316-L324
26,920
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.close
def close(self) -> None: """Stop accepting new pipelinig messages and close connection when handlers done processing messages""" self._close = True if self._waiter: self._waiter.cancel()
python
def close(self) -> None: """Stop accepting new pipelinig messages and close connection when handlers done processing messages""" self._close = True if self._waiter: self._waiter.cancel()
[ "def", "close", "(", "self", ")", "->", "None", ":", "self", ".", "_close", "=", "True", "if", "self", ".", "_waiter", ":", "self", ".", "_waiter", ".", "cancel", "(", ")" ]
Stop accepting new pipelinig messages and close connection when handlers done processing messages
[ "Stop", "accepting", "new", "pipelinig", "messages", "and", "close", "connection", "when", "handlers", "done", "processing", "messages" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L326-L331
26,921
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.force_close
def force_close(self) -> None: """Force close connection""" self._force_close = True if self._waiter: self._waiter.cancel() if self.transport is not None: self.transport.close() self.transport = None
python
def force_close(self) -> None: """Force close connection""" self._force_close = True if self._waiter: self._waiter.cancel() if self.transport is not None: self.transport.close() self.transport = None
[ "def", "force_close", "(", "self", ")", "->", "None", ":", "self", ".", "_force_close", "=", "True", "if", "self", ".", "_waiter", ":", "self", ".", "_waiter", ".", "cancel", "(", ")", "if", "self", ".", "transport", "is", "not", "None", ":", "self",...
Force close connection
[ "Force", "close", "connection" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L333-L340
26,922
aio-libs/aiohttp
aiohttp/web.py
run_app
def run_app(app: Union[Application, Awaitable[Application]], *, host: Optional[str]=None, port: Optional[int]=None, path: Optional[str]=None, sock: Optional[socket.socket]=None, shutdown_timeout: float=60.0, ssl_context: Optional[SSLContext]=None, ...
python
def run_app(app: Union[Application, Awaitable[Application]], *, host: Optional[str]=None, port: Optional[int]=None, path: Optional[str]=None, sock: Optional[socket.socket]=None, shutdown_timeout: float=60.0, ssl_context: Optional[SSLContext]=None, ...
[ "def", "run_app", "(", "app", ":", "Union", "[", "Application", ",", "Awaitable", "[", "Application", "]", "]", ",", "*", ",", "host", ":", "Optional", "[", "str", "]", "=", "None", ",", "port", ":", "Optional", "[", "int", "]", "=", "None", ",", ...
Run an app locally
[ "Run", "an", "app", "locally" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web.py#L375-L422
26,923
aio-libs/aiohttp
aiohttp/streams.py
AsyncStreamReaderMixin.iter_chunked
def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]: """Returns an asynchronous iterator that yields chunks of size n. Python-3.5 available for Python 3.5+ only """ return AsyncStreamIterator(lambda: self.read(n))
python
def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]: """Returns an asynchronous iterator that yields chunks of size n. Python-3.5 available for Python 3.5+ only """ return AsyncStreamIterator(lambda: self.read(n))
[ "def", "iter_chunked", "(", "self", ",", "n", ":", "int", ")", "->", "AsyncStreamIterator", "[", "bytes", "]", ":", "return", "AsyncStreamIterator", "(", "lambda", ":", "self", ".", "read", "(", "n", ")", ")" ]
Returns an asynchronous iterator that yields chunks of size n. Python-3.5 available for Python 3.5+ only
[ "Returns", "an", "asynchronous", "iterator", "that", "yields", "chunks", "of", "size", "n", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L68-L73
26,924
aio-libs/aiohttp
aiohttp/streams.py
StreamReader.unread_data
def unread_data(self, data: bytes) -> None: """ rollback reading some data from stream, inserting it to buffer head. """ warnings.warn("unread_data() is deprecated " "and will be removed in future releases (#3260)", DeprecationWarning, ...
python
def unread_data(self, data: bytes) -> None: """ rollback reading some data from stream, inserting it to buffer head. """ warnings.warn("unread_data() is deprecated " "and will be removed in future releases (#3260)", DeprecationWarning, ...
[ "def", "unread_data", "(", "self", ",", "data", ":", "bytes", ")", "->", "None", ":", "warnings", ".", "warn", "(", "\"unread_data() is deprecated \"", "\"and will be removed in future releases (#3260)\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", ...
rollback reading some data from stream, inserting it to buffer head.
[ "rollback", "reading", "some", "data", "from", "stream", "inserting", "it", "to", "buffer", "head", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L211-L227
26,925
aio-libs/aiohttp
aiohttp/streams.py
StreamReader._read_nowait
def _read_nowait(self, n: int) -> bytes: """ Read not more than n bytes, or whole buffer is n == -1 """ chunks = [] while self._buffer: chunk = self._read_nowait_chunk(n) chunks.append(chunk) if n != -1: n -= len(chunk) if n ==...
python
def _read_nowait(self, n: int) -> bytes: """ Read not more than n bytes, or whole buffer is n == -1 """ chunks = [] while self._buffer: chunk = self._read_nowait_chunk(n) chunks.append(chunk) if n != -1: n -= len(chunk) if n ==...
[ "def", "_read_nowait", "(", "self", ",", "n", ":", "int", ")", "->", "bytes", ":", "chunks", "=", "[", "]", "while", "self", ".", "_buffer", ":", "chunk", "=", "self", ".", "_read_nowait_chunk", "(", "n", ")", "chunks", ".", "append", "(", "chunk", ...
Read not more than n bytes, or whole buffer is n == -1
[ "Read", "not", "more", "than", "n", "bytes", "or", "whole", "buffer", "is", "n", "==", "-", "1" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/streams.py#L472-L484
26,926
aio-libs/aiohttp
aiohttp/signals.py
Signal.send
async def send(self, *args, **kwargs): """ Sends data to all registered receivers. """ if not self.frozen: raise RuntimeError("Cannot send non-frozen signal.") for receiver in self: await receiver(*args, **kwargs)
python
async def send(self, *args, **kwargs): """ Sends data to all registered receivers. """ if not self.frozen: raise RuntimeError("Cannot send non-frozen signal.") for receiver in self: await receiver(*args, **kwargs)
[ "async", "def", "send", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "frozen", ":", "raise", "RuntimeError", "(", "\"Cannot send non-frozen signal.\"", ")", "for", "receiver", "in", "self", ":", "await", "re...
Sends data to all registered receivers.
[ "Sends", "data", "to", "all", "registered", "receivers", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/signals.py#L26-L34
26,927
aio-libs/aiohttp
aiohttp/web_log.py
AccessLogger.compile_format
def compile_format(self, log_format: str) -> Tuple[str, List[KeyMethod]]: """Translate log_format into form usable by modulo formatting All known atoms will be replaced with %s Also methods for formatting of those atoms will be added to _methods in appropriate order For example...
python
def compile_format(self, log_format: str) -> Tuple[str, List[KeyMethod]]: """Translate log_format into form usable by modulo formatting All known atoms will be replaced with %s Also methods for formatting of those atoms will be added to _methods in appropriate order For example...
[ "def", "compile_format", "(", "self", ",", "log_format", ":", "str", ")", "->", "Tuple", "[", "str", ",", "List", "[", "KeyMethod", "]", "]", ":", "# list of (key, method) tuples, we don't use an OrderedDict as users", "# can repeat the same key more than once", "methods"...
Translate log_format into form usable by modulo formatting All known atoms will be replaced with %s Also methods for formatting of those atoms will be added to _methods in appropriate order For example we have log_format = "%a %t" This format will be translated to "%s %s" ...
[ "Translate", "log_format", "into", "form", "usable", "by", "modulo", "formatting" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_log.py#L78-L118
26,928
aio-libs/aiohttp
aiohttp/http_writer.py
StreamWriter.write
async def write(self, chunk: bytes, *, drain: bool=True, LIMIT: int=0x10000) -> None: """Writes chunk of data to a stream. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future. """ ...
python
async def write(self, chunk: bytes, *, drain: bool=True, LIMIT: int=0x10000) -> None: """Writes chunk of data to a stream. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future. """ ...
[ "async", "def", "write", "(", "self", ",", "chunk", ":", "bytes", ",", "*", ",", "drain", ":", "bool", "=", "True", ",", "LIMIT", ":", "int", "=", "0x10000", ")", "->", "None", ":", "if", "self", ".", "_on_chunk_sent", "is", "not", "None", ":", "...
Writes chunk of data to a stream. write_eof() indicates end of stream. writer can't be used after write_eof() method being called. write() return drain future.
[ "Writes", "chunk", "of", "data", "to", "a", "stream", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_writer.py#L70-L105
26,929
aio-libs/aiohttp
aiohttp/helpers.py
netrc_from_env
def netrc_from_env() -> Optional[netrc.netrc]: """Attempt to load the netrc file from the path specified by the env-var NETRC or in the default location in the user's home directory. Returns None if it couldn't be found or fails to parse. """ netrc_env = os.environ.get('NETRC') if netrc_env is...
python
def netrc_from_env() -> Optional[netrc.netrc]: """Attempt to load the netrc file from the path specified by the env-var NETRC or in the default location in the user's home directory. Returns None if it couldn't be found or fails to parse. """ netrc_env = os.environ.get('NETRC') if netrc_env is...
[ "def", "netrc_from_env", "(", ")", "->", "Optional", "[", "netrc", ".", "netrc", "]", ":", "netrc_env", "=", "os", ".", "environ", ".", "get", "(", "'NETRC'", ")", "if", "netrc_env", "is", "not", "None", ":", "netrc_path", "=", "Path", "(", "netrc_env"...
Attempt to load the netrc file from the path specified by the env-var NETRC or in the default location in the user's home directory. Returns None if it couldn't be found or fails to parse.
[ "Attempt", "to", "load", "the", "netrc", "file", "from", "the", "path", "specified", "by", "the", "env", "-", "var", "NETRC", "or", "in", "the", "default", "location", "in", "the", "user", "s", "home", "directory", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L186-L219
26,930
aio-libs/aiohttp
aiohttp/helpers.py
parse_mimetype
def parse_mimetype(mimetype: str) -> MimeType: """Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'u...
python
def parse_mimetype(mimetype: str) -> MimeType: """Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'u...
[ "def", "parse_mimetype", "(", "mimetype", ":", "str", ")", "->", "MimeType", ":", "if", "not", "mimetype", ":", "return", "MimeType", "(", "type", "=", "''", ",", "subtype", "=", "''", ",", "suffix", "=", "''", ",", "parameters", "=", "MultiDictProxy", ...
Parses a MIME type into its components. mimetype is a MIME type string. Returns a MimeType object. Example: >>> parse_mimetype('text/html; charset=utf-8') MimeType(type='text', subtype='html', suffix='', parameters={'charset': 'utf-8'})
[ "Parses", "a", "MIME", "type", "into", "its", "components", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L291-L328
26,931
aio-libs/aiohttp
aiohttp/helpers.py
BasicAuth.decode
def decode(cls, auth_header: str, encoding: str='latin1') -> 'BasicAuth': """Create a BasicAuth object from an Authorization HTTP header.""" try: auth_type, encoded_credentials = auth_header.split(' ', 1) except ValueError: raise ValueError('Could not parse authorization ...
python
def decode(cls, auth_header: str, encoding: str='latin1') -> 'BasicAuth': """Create a BasicAuth object from an Authorization HTTP header.""" try: auth_type, encoded_credentials = auth_header.split(' ', 1) except ValueError: raise ValueError('Could not parse authorization ...
[ "def", "decode", "(", "cls", ",", "auth_header", ":", "str", ",", "encoding", ":", "str", "=", "'latin1'", ")", "->", "'BasicAuth'", ":", "try", ":", "auth_type", ",", "encoded_credentials", "=", "auth_header", ".", "split", "(", "' '", ",", "1", ")", ...
Create a BasicAuth object from an Authorization HTTP header.
[ "Create", "a", "BasicAuth", "object", "from", "an", "Authorization", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L134-L160
26,932
aio-libs/aiohttp
aiohttp/helpers.py
BasicAuth.from_url
def from_url(cls, url: URL, *, encoding: str='latin1') -> Optional['BasicAuth']: """Create BasicAuth from url.""" if not isinstance(url, URL): raise TypeError("url should be yarl.URL instance") if url.user is None: return None return cls(url.user,...
python
def from_url(cls, url: URL, *, encoding: str='latin1') -> Optional['BasicAuth']: """Create BasicAuth from url.""" if not isinstance(url, URL): raise TypeError("url should be yarl.URL instance") if url.user is None: return None return cls(url.user,...
[ "def", "from_url", "(", "cls", ",", "url", ":", "URL", ",", "*", ",", "encoding", ":", "str", "=", "'latin1'", ")", "->", "Optional", "[", "'BasicAuth'", "]", ":", "if", "not", "isinstance", "(", "url", ",", "URL", ")", ":", "raise", "TypeError", "...
Create BasicAuth from url.
[ "Create", "BasicAuth", "from", "url", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L163-L170
26,933
aio-libs/aiohttp
aiohttp/helpers.py
BasicAuth.encode
def encode(self) -> str: """Encode credentials.""" creds = ('%s:%s' % (self.login, self.password)).encode(self.encoding) return 'Basic %s' % base64.b64encode(creds).decode(self.encoding)
python
def encode(self) -> str: """Encode credentials.""" creds = ('%s:%s' % (self.login, self.password)).encode(self.encoding) return 'Basic %s' % base64.b64encode(creds).decode(self.encoding)
[ "def", "encode", "(", "self", ")", "->", "str", ":", "creds", "=", "(", "'%s:%s'", "%", "(", "self", ".", "login", ",", "self", ".", "password", ")", ")", ".", "encode", "(", "self", ".", "encoding", ")", "return", "'Basic %s'", "%", "base64", ".",...
Encode credentials.
[ "Encode", "credentials", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L172-L175
26,934
aio-libs/aiohttp
aiohttp/helpers.py
HeadersMixin.content_type
def content_type(self) -> str: """The value of content part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_type
python
def content_type(self) -> str: """The value of content part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_type
[ "def", "content_type", "(", "self", ")", "->", "str", ":", "raw", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "CONTENT_TYPE", ")", "# type: ignore", "if", "self", ".", "_stored_content_type", "!=", "raw", ":", "self", ".", "_parse_content_t...
The value of content part for Content-Type HTTP header.
[ "The", "value", "of", "content", "part", "for", "Content", "-", "Type", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L624-L629
26,935
aio-libs/aiohttp
aiohttp/helpers.py
HeadersMixin.charset
def charset(self) -> Optional[str]: """The value of charset part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_dict.get('charset')
python
def charset(self) -> Optional[str]: """The value of charset part for Content-Type HTTP header.""" raw = self._headers.get(hdrs.CONTENT_TYPE) # type: ignore if self._stored_content_type != raw: self._parse_content_type(raw) return self._content_dict.get('charset')
[ "def", "charset", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "raw", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "CONTENT_TYPE", ")", "# type: ignore", "if", "self", ".", "_stored_content_type", "!=", "raw", ":", "self", "...
The value of charset part for Content-Type HTTP header.
[ "The", "value", "of", "charset", "part", "for", "Content", "-", "Type", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L632-L637
26,936
aio-libs/aiohttp
aiohttp/helpers.py
HeadersMixin.content_length
def content_length(self) -> Optional[int]: """The value of Content-Length HTTP header.""" content_length = self._headers.get(hdrs.CONTENT_LENGTH) # type: ignore if content_length is not None: return int(content_length) else: return None
python
def content_length(self) -> Optional[int]: """The value of Content-Length HTTP header.""" content_length = self._headers.get(hdrs.CONTENT_LENGTH) # type: ignore if content_length is not None: return int(content_length) else: return None
[ "def", "content_length", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "content_length", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "CONTENT_LENGTH", ")", "# type: ignore", "if", "content_length", "is", "not", "None", ":", "ret...
The value of Content-Length HTTP header.
[ "The", "value", "of", "Content", "-", "Length", "HTTP", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/helpers.py#L640-L647
26,937
aio-libs/aiohttp
aiohttp/client.py
ClientSession.request
def request(self, method: str, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP request.""" return _RequestContextManager(self._request(method, url, **kwargs))
python
def request(self, method: str, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP request.""" return _RequestContextManager(self._request(method, url, **kwargs))
[ "def", "request", "(", "self", ",", "method", ":", "str", ",", "url", ":", "StrOrURL", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", "(", "method", ",", ...
Perform HTTP request.
[ "Perform", "HTTP", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L297-L302
26,938
aio-libs/aiohttp
aiohttp/client.py
ClientSession.ws_connect
def ws_connect( self, url: StrOrURL, *, method: str=hdrs.METH_GET, protocols: Iterable[str]=(), timeout: float=10.0, receive_timeout: Optional[float]=None, autoclose: bool=True, autoping: bool=True, heartbeat: Op...
python
def ws_connect( self, url: StrOrURL, *, method: str=hdrs.METH_GET, protocols: Iterable[str]=(), timeout: float=10.0, receive_timeout: Optional[float]=None, autoclose: bool=True, autoping: bool=True, heartbeat: Op...
[ "def", "ws_connect", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "method", ":", "str", "=", "hdrs", ".", "METH_GET", ",", "protocols", ":", "Iterable", "[", "str", "]", "=", "(", ")", ",", "timeout", ":", "float", "=", "10.0", ",", "...
Initiate websocket connection.
[ "Initiate", "websocket", "connection", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L604-L641
26,939
aio-libs/aiohttp
aiohttp/client.py
ClientSession._prepare_headers
def _prepare_headers( self, headers: Optional[LooseHeaders]) -> 'CIMultiDict[str]': """ Add default headers and transform it to CIMultiDict """ # Convert headers to MultiDict result = CIMultiDict(self._default_headers) if headers: if not isinst...
python
def _prepare_headers( self, headers: Optional[LooseHeaders]) -> 'CIMultiDict[str]': """ Add default headers and transform it to CIMultiDict """ # Convert headers to MultiDict result = CIMultiDict(self._default_headers) if headers: if not isinst...
[ "def", "_prepare_headers", "(", "self", ",", "headers", ":", "Optional", "[", "LooseHeaders", "]", ")", "->", "'CIMultiDict[str]'", ":", "# Convert headers to MultiDict", "result", "=", "CIMultiDict", "(", "self", ".", "_default_headers", ")", "if", "headers", ":"...
Add default headers and transform it to CIMultiDict
[ "Add", "default", "headers", "and", "transform", "it", "to", "CIMultiDict" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L800-L817
26,940
aio-libs/aiohttp
aiohttp/client.py
ClientSession.get
def get(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP GET request.""" return _RequestContextManager( self._request(hdrs.METH_GET, url, allow_redirects=allow_redirects, ...
python
def get(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP GET request.""" return _RequestContextManager( self._request(hdrs.METH_GET, url, allow_redirects=allow_redirects, ...
[ "def", "get", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "allow_redirects", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_r...
Perform HTTP GET request.
[ "Perform", "HTTP", "GET", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L819-L825
26,941
aio-libs/aiohttp
aiohttp/client.py
ClientSession.options
def options(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP OPTIONS request.""" return _RequestContextManager( self._request(hdrs.METH_OPTIONS, url, allow_redirects=allow_redirects, ...
python
def options(self, url: StrOrURL, *, allow_redirects: bool=True, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP OPTIONS request.""" return _RequestContextManager( self._request(hdrs.METH_OPTIONS, url, allow_redirects=allow_redirects, ...
[ "def", "options", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "allow_redirects", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", ...
Perform HTTP OPTIONS request.
[ "Perform", "HTTP", "OPTIONS", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L827-L833
26,942
aio-libs/aiohttp
aiohttp/client.py
ClientSession.head
def head(self, url: StrOrURL, *, allow_redirects: bool=False, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP HEAD request.""" return _RequestContextManager( self._request(hdrs.METH_HEAD, url, allow_redirects=allow_redirects, ...
python
def head(self, url: StrOrURL, *, allow_redirects: bool=False, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP HEAD request.""" return _RequestContextManager( self._request(hdrs.METH_HEAD, url, allow_redirects=allow_redirects, ...
[ "def", "head", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "allow_redirects", ":", "bool", "=", "False", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "...
Perform HTTP HEAD request.
[ "Perform", "HTTP", "HEAD", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L835-L841
26,943
aio-libs/aiohttp
aiohttp/client.py
ClientSession.post
def post(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP POST request.""" return _RequestContextManager( self._request(hdrs.METH_POST, url, data=data, **kwargs))
python
def post(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP POST request.""" return _RequestContextManager( self._request(hdrs.METH_POST, url, data=data, **kwargs))
[ "def", "post", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "data", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", ...
Perform HTTP POST request.
[ "Perform", "HTTP", "POST", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L843-L849
26,944
aio-libs/aiohttp
aiohttp/client.py
ClientSession.put
def put(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PUT request.""" return _RequestContextManager( self._request(hdrs.METH_PUT, url, data=data, **kwargs))
python
def put(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PUT request.""" return _RequestContextManager( self._request(hdrs.METH_PUT, url, data=data, **kwargs))
[ "def", "put", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "data", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", "...
Perform HTTP PUT request.
[ "Perform", "HTTP", "PUT", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L851-L857
26,945
aio-libs/aiohttp
aiohttp/client.py
ClientSession.patch
def patch(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PATCH request.""" return _RequestContextManager( self._request(hdrs.METH_PATCH, url, data=data, **kwargs))
python
def patch(self, url: StrOrURL, *, data: Any=None, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP PATCH request.""" return _RequestContextManager( self._request(hdrs.METH_PATCH, url, data=data, **kwargs))
[ "def", "patch", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", ",", "data", ":", "Any", "=", "None", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", ...
Perform HTTP PATCH request.
[ "Perform", "HTTP", "PATCH", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L859-L865
26,946
aio-libs/aiohttp
aiohttp/client.py
ClientSession.delete
def delete(self, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP DELETE request.""" return _RequestContextManager( self._request(hdrs.METH_DELETE, url, **kwargs))
python
def delete(self, url: StrOrURL, **kwargs: Any) -> '_RequestContextManager': """Perform HTTP DELETE request.""" return _RequestContextManager( self._request(hdrs.METH_DELETE, url, **kwargs))
[ "def", "delete", "(", "self", ",", "url", ":", "StrOrURL", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "'_RequestContextManager'", ":", "return", "_RequestContextManager", "(", "self", ".", "_request", "(", "hdrs", ".", "METH_DELETE", ",", "url", ",", ...
Perform HTTP DELETE request.
[ "Perform", "HTTP", "DELETE", "request", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L867-L871
26,947
aio-libs/aiohttp
aiohttp/client.py
ClientSession.close
async def close(self) -> None: """Close underlying connector. Release all acquired resources. """ if not self.closed: if self._connector is not None and self._connector_owner: await self._connector.close() self._connector = None
python
async def close(self) -> None: """Close underlying connector. Release all acquired resources. """ if not self.closed: if self._connector is not None and self._connector_owner: await self._connector.close() self._connector = None
[ "async", "def", "close", "(", "self", ")", "->", "None", ":", "if", "not", "self", ".", "closed", ":", "if", "self", ".", "_connector", "is", "not", "None", "and", "self", ".", "_connector_owner", ":", "await", "self", ".", "_connector", ".", "close", ...
Close underlying connector. Release all acquired resources.
[ "Close", "underlying", "connector", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L873-L881
26,948
aio-libs/aiohttp
aiohttp/client.py
ClientSession.requote_redirect_url
def requote_redirect_url(self, val: bool) -> None: """Do URL requoting on redirection handling.""" warnings.warn("session.requote_redirect_url modification " "is deprecated #2778", DeprecationWarning, stacklevel=2) self._requote_r...
python
def requote_redirect_url(self, val: bool) -> None: """Do URL requoting on redirection handling.""" warnings.warn("session.requote_redirect_url modification " "is deprecated #2778", DeprecationWarning, stacklevel=2) self._requote_r...
[ "def", "requote_redirect_url", "(", "self", ",", "val", ":", "bool", ")", "->", "None", ":", "warnings", ".", "warn", "(", "\"session.requote_redirect_url modification \"", "\"is deprecated #2778\"", ",", "DeprecationWarning", ",", "stacklevel", "=", "2", ")", "self...
Do URL requoting on redirection handling.
[ "Do", "URL", "requoting", "on", "redirection", "handling", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client.py#L912-L918
26,949
aio-libs/aiohttp
aiohttp/multipart.py
MultipartResponseWrapper.next
async def next(self) -> Any: """Emits next multipart reader object.""" item = await self.stream.next() if self.stream.at_eof(): await self.release() return item
python
async def next(self) -> Any: """Emits next multipart reader object.""" item = await self.stream.next() if self.stream.at_eof(): await self.release() return item
[ "async", "def", "next", "(", "self", ")", "->", "Any", ":", "item", "=", "await", "self", ".", "stream", ".", "next", "(", ")", "if", "self", ".", "stream", ".", "at_eof", "(", ")", ":", "await", "self", ".", "release", "(", ")", "return", "item"...
Emits next multipart reader object.
[ "Emits", "next", "multipart", "reader", "object", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L222-L227
26,950
aio-libs/aiohttp
aiohttp/multipart.py
BodyPartReader.read
async def read(self, *, decode: bool=False) -> Any: """Reads body part data. decode: Decodes data following by encoding method from Content-Encoding header. If it missed data remains untouched """ if self._at_eof: return b'' data = byt...
python
async def read(self, *, decode: bool=False) -> Any: """Reads body part data. decode: Decodes data following by encoding method from Content-Encoding header. If it missed data remains untouched """ if self._at_eof: return b'' data = byt...
[ "async", "def", "read", "(", "self", ",", "*", ",", "decode", ":", "bool", "=", "False", ")", "->", "Any", ":", "if", "self", ".", "_at_eof", ":", "return", "b''", "data", "=", "bytearray", "(", ")", "while", "not", "self", ".", "_at_eof", ":", "...
Reads body part data. decode: Decodes data following by encoding method from Content-Encoding header. If it missed data remains untouched
[ "Reads", "body", "part", "data", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L277-L291
26,951
aio-libs/aiohttp
aiohttp/multipart.py
BodyPartReader.read_chunk
async def read_chunk(self, size: int=chunk_size) -> bytes: """Reads body part content chunk of the specified size. size: chunk size """ if self._at_eof: return b'' if self._length: chunk = await self._read_chunk_from_length(size) else: ...
python
async def read_chunk(self, size: int=chunk_size) -> bytes: """Reads body part content chunk of the specified size. size: chunk size """ if self._at_eof: return b'' if self._length: chunk = await self._read_chunk_from_length(size) else: ...
[ "async", "def", "read_chunk", "(", "self", ",", "size", ":", "int", "=", "chunk_size", ")", "->", "bytes", ":", "if", "self", ".", "_at_eof", ":", "return", "b''", "if", "self", ".", "_length", ":", "chunk", "=", "await", "self", ".", "_read_chunk_from...
Reads body part content chunk of the specified size. size: chunk size
[ "Reads", "body", "part", "content", "chunk", "of", "the", "specified", "size", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L293-L312
26,952
aio-libs/aiohttp
aiohttp/multipart.py
BodyPartReader.readline
async def readline(self) -> bytes: """Reads body part by line by line.""" if self._at_eof: return b'' if self._unread: line = self._unread.popleft() else: line = await self._content.readline() if line.startswith(self._boundary): #...
python
async def readline(self) -> bytes: """Reads body part by line by line.""" if self._at_eof: return b'' if self._unread: line = self._unread.popleft() else: line = await self._content.readline() if line.startswith(self._boundary): #...
[ "async", "def", "readline", "(", "self", ")", "->", "bytes", ":", "if", "self", ".", "_at_eof", ":", "return", "b''", "if", "self", ".", "_unread", ":", "line", "=", "self", ".", "_unread", ".", "popleft", "(", ")", "else", ":", "line", "=", "await...
Reads body part by line by line.
[ "Reads", "body", "part", "by", "line", "by", "line", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L362-L390
26,953
aio-libs/aiohttp
aiohttp/multipart.py
BodyPartReader.decode
def decode(self, data: bytes) -> bytes: """Decodes data according the specified Content-Encoding or Content-Transfer-Encoding headers value. """ if CONTENT_TRANSFER_ENCODING in self.headers: data = self._decode_content_transfer(data) if CONTENT_ENCODING in self.header...
python
def decode(self, data: bytes) -> bytes: """Decodes data according the specified Content-Encoding or Content-Transfer-Encoding headers value. """ if CONTENT_TRANSFER_ENCODING in self.headers: data = self._decode_content_transfer(data) if CONTENT_ENCODING in self.header...
[ "def", "decode", "(", "self", ",", "data", ":", "bytes", ")", "->", "bytes", ":", "if", "CONTENT_TRANSFER_ENCODING", "in", "self", ".", "headers", ":", "data", "=", "self", ".", "_decode_content_transfer", "(", "data", ")", "if", "CONTENT_ENCODING", "in", ...
Decodes data according the specified Content-Encoding or Content-Transfer-Encoding headers value.
[ "Decodes", "data", "according", "the", "specified", "Content", "-", "Encoding", "or", "Content", "-", "Transfer", "-", "Encoding", "headers", "value", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L435-L443
26,954
aio-libs/aiohttp
aiohttp/multipart.py
BodyPartReader.get_charset
def get_charset(self, default: str) -> str: """Returns charset parameter from Content-Type header or default.""" ctype = self.headers.get(CONTENT_TYPE, '') mimetype = parse_mimetype(ctype) return mimetype.parameters.get('charset', default)
python
def get_charset(self, default: str) -> str: """Returns charset parameter from Content-Type header or default.""" ctype = self.headers.get(CONTENT_TYPE, '') mimetype = parse_mimetype(ctype) return mimetype.parameters.get('charset', default)
[ "def", "get_charset", "(", "self", ",", "default", ":", "str", ")", "->", "str", ":", "ctype", "=", "self", ".", "headers", ".", "get", "(", "CONTENT_TYPE", ",", "''", ")", "mimetype", "=", "parse_mimetype", "(", "ctype", ")", "return", "mimetype", "."...
Returns charset parameter from Content-Type header or default.
[ "Returns", "charset", "parameter", "from", "Content", "-", "Type", "header", "or", "default", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L470-L474
26,955
aio-libs/aiohttp
aiohttp/multipart.py
BodyPartReader.name
def name(self) -> Optional[str]: """Returns name specified in Content-Disposition header or None if missed or header is malformed. """ _, params = parse_content_disposition( self.headers.get(CONTENT_DISPOSITION)) return content_disposition_filename(params, 'name')
python
def name(self) -> Optional[str]: """Returns name specified in Content-Disposition header or None if missed or header is malformed. """ _, params = parse_content_disposition( self.headers.get(CONTENT_DISPOSITION)) return content_disposition_filename(params, 'name')
[ "def", "name", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "_", ",", "params", "=", "parse_content_disposition", "(", "self", ".", "headers", ".", "get", "(", "CONTENT_DISPOSITION", ")", ")", "return", "content_disposition_filename", "(", "para...
Returns name specified in Content-Disposition header or None if missed or header is malformed.
[ "Returns", "name", "specified", "in", "Content", "-", "Disposition", "header", "or", "None", "if", "missed", "or", "header", "is", "malformed", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L477-L484
26,956
aio-libs/aiohttp
aiohttp/multipart.py
MultipartReader.from_response
def from_response(cls, response: 'ClientResponse') -> Any: """Constructs reader instance from HTTP response. :param response: :class:`~aiohttp.client.ClientResponse` instance """ obj = cls.response_wrapper_cls(response, cls(response.headers, ...
python
def from_response(cls, response: 'ClientResponse') -> Any: """Constructs reader instance from HTTP response. :param response: :class:`~aiohttp.client.ClientResponse` instance """ obj = cls.response_wrapper_cls(response, cls(response.headers, ...
[ "def", "from_response", "(", "cls", ",", "response", ":", "'ClientResponse'", ")", "->", "Any", ":", "obj", "=", "cls", ".", "response_wrapper_cls", "(", "response", ",", "cls", "(", "response", ".", "headers", ",", "response", ".", "content", ")", ")", ...
Constructs reader instance from HTTP response. :param response: :class:`~aiohttp.client.ClientResponse` instance
[ "Constructs", "reader", "instance", "from", "HTTP", "response", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L557-L564
26,957
aio-libs/aiohttp
aiohttp/multipart.py
MultipartReader.next
async def next(self) -> Any: """Emits the next multipart body part.""" # So, if we're at BOF, we need to skip till the boundary. if self._at_eof: return await self._maybe_release_last_part() if self._at_bof: await self._read_until_first_boundary() ...
python
async def next(self) -> Any: """Emits the next multipart body part.""" # So, if we're at BOF, we need to skip till the boundary. if self._at_eof: return await self._maybe_release_last_part() if self._at_bof: await self._read_until_first_boundary() ...
[ "async", "def", "next", "(", "self", ")", "->", "Any", ":", "# So, if we're at BOF, we need to skip till the boundary.", "if", "self", ".", "_at_eof", ":", "return", "await", "self", ".", "_maybe_release_last_part", "(", ")", "if", "self", ".", "_at_bof", ":", "...
Emits the next multipart body part.
[ "Emits", "the", "next", "multipart", "body", "part", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L572-L586
26,958
aio-libs/aiohttp
aiohttp/multipart.py
MultipartReader.release
async def release(self) -> None: """Reads all the body parts to the void till the final boundary.""" while not self._at_eof: item = await self.next() if item is None: break await item.release()
python
async def release(self) -> None: """Reads all the body parts to the void till the final boundary.""" while not self._at_eof: item = await self.next() if item is None: break await item.release()
[ "async", "def", "release", "(", "self", ")", "->", "None", ":", "while", "not", "self", ".", "_at_eof", ":", "item", "=", "await", "self", ".", "next", "(", ")", "if", "item", "is", "None", ":", "break", "await", "item", ".", "release", "(", ")" ]
Reads all the body parts to the void till the final boundary.
[ "Reads", "all", "the", "body", "parts", "to", "the", "void", "till", "the", "final", "boundary", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L588-L594
26,959
aio-libs/aiohttp
aiohttp/multipart.py
MultipartReader._get_part_reader
def _get_part_reader(self, headers: 'CIMultiDictProxy[str]') -> Any: """Dispatches the response by the `Content-Type` header, returning suitable reader instance. :param dict headers: Response headers """ ctype = headers.get(CONTENT_TYPE, '') mimetype = parse_mimetype(cty...
python
def _get_part_reader(self, headers: 'CIMultiDictProxy[str]') -> Any: """Dispatches the response by the `Content-Type` header, returning suitable reader instance. :param dict headers: Response headers """ ctype = headers.get(CONTENT_TYPE, '') mimetype = parse_mimetype(cty...
[ "def", "_get_part_reader", "(", "self", ",", "headers", ":", "'CIMultiDictProxy[str]'", ")", "->", "Any", ":", "ctype", "=", "headers", ".", "get", "(", "CONTENT_TYPE", ",", "''", ")", "mimetype", "=", "parse_mimetype", "(", "ctype", ")", "if", "mimetype", ...
Dispatches the response by the `Content-Type` header, returning suitable reader instance. :param dict headers: Response headers
[ "Dispatches", "the", "response", "by", "the", "Content", "-", "Type", "header", "returning", "suitable", "reader", "instance", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L601-L619
26,960
aio-libs/aiohttp
aiohttp/multipart.py
MultipartReader._maybe_release_last_part
async def _maybe_release_last_part(self) -> None: """Ensures that the last read body part is read completely.""" if self._last_part is not None: if not self._last_part.at_eof(): await self._last_part.release() self._unread.extend(self._last_part._unread) ...
python
async def _maybe_release_last_part(self) -> None: """Ensures that the last read body part is read completely.""" if self._last_part is not None: if not self._last_part.at_eof(): await self._last_part.release() self._unread.extend(self._last_part._unread) ...
[ "async", "def", "_maybe_release_last_part", "(", "self", ")", "->", "None", ":", "if", "self", ".", "_last_part", "is", "not", "None", ":", "if", "not", "self", ".", "_last_part", ".", "at_eof", "(", ")", ":", "await", "self", ".", "_last_part", ".", "...
Ensures that the last read body part is read completely.
[ "Ensures", "that", "the", "last", "read", "body", "part", "is", "read", "completely", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L698-L704
26,961
aio-libs/aiohttp
aiohttp/multipart.py
MultipartWriter._boundary_value
def _boundary_value(self) -> str: """Wrap boundary parameter value in quotes, if necessary. Reads self.boundary and returns a unicode sting. """ # Refer to RFCs 7231, 7230, 5234. # # parameter = token "=" ( token / quoted-string ) # token = 1*tchar ...
python
def _boundary_value(self) -> str: """Wrap boundary parameter value in quotes, if necessary. Reads self.boundary and returns a unicode sting. """ # Refer to RFCs 7231, 7230, 5234. # # parameter = token "=" ( token / quoted-string ) # token = 1*tchar ...
[ "def", "_boundary_value", "(", "self", ")", "->", "str", ":", "# Refer to RFCs 7231, 7230, 5234.", "#", "# parameter = token \"=\" ( token / quoted-string )", "# token = 1*tchar", "# quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE", "# qdtext = HTAB / SP / %x...
Wrap boundary parameter value in quotes, if necessary. Reads self.boundary and returns a unicode sting.
[ "Wrap", "boundary", "parameter", "value", "in", "quotes", "if", "necessary", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L752-L781
26,962
aio-libs/aiohttp
aiohttp/multipart.py
MultipartWriter.append_payload
def append_payload(self, payload: Payload) -> Payload: """Adds a new body part to multipart writer.""" # compression encoding = payload.headers.get(CONTENT_ENCODING, '').lower() # type: Optional[str] # noqa if encoding and encoding not in ('deflate', 'gzip', 'identity'): ra...
python
def append_payload(self, payload: Payload) -> Payload: """Adds a new body part to multipart writer.""" # compression encoding = payload.headers.get(CONTENT_ENCODING, '').lower() # type: Optional[str] # noqa if encoding and encoding not in ('deflate', 'gzip', 'identity'): ra...
[ "def", "append_payload", "(", "self", ",", "payload", ":", "Payload", ")", "->", "Payload", ":", "# compression", "encoding", "=", "payload", ".", "headers", ".", "get", "(", "CONTENT_ENCODING", ",", "''", ")", ".", "lower", "(", ")", "# type: Optional[str] ...
Adds a new body part to multipart writer.
[ "Adds", "a", "new", "body", "part", "to", "multipart", "writer", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L806-L830
26,963
aio-libs/aiohttp
aiohttp/multipart.py
MultipartWriter.append_json
def append_json( self, obj: Any, headers: Optional['MultiMapping[str]']=None ) -> Payload: """Helper to append JSON part.""" if headers is None: headers = CIMultiDict() return self.append_payload(JsonPayload(obj, headers=headers))
python
def append_json( self, obj: Any, headers: Optional['MultiMapping[str]']=None ) -> Payload: """Helper to append JSON part.""" if headers is None: headers = CIMultiDict() return self.append_payload(JsonPayload(obj, headers=headers))
[ "def", "append_json", "(", "self", ",", "obj", ":", "Any", ",", "headers", ":", "Optional", "[", "'MultiMapping[str]'", "]", "=", "None", ")", "->", "Payload", ":", "if", "headers", "is", "None", ":", "headers", "=", "CIMultiDict", "(", ")", "return", ...
Helper to append JSON part.
[ "Helper", "to", "append", "JSON", "part", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L832-L841
26,964
aio-libs/aiohttp
aiohttp/multipart.py
MultipartWriter.append_form
def append_form( self, obj: Union[Sequence[Tuple[str, str]], Mapping[str, str]], headers: Optional['MultiMapping[str]']=None ) -> Payload: """Helper to append form urlencoded part.""" assert isinstance(obj, (Sequence, Mapping)) if h...
python
def append_form( self, obj: Union[Sequence[Tuple[str, str]], Mapping[str, str]], headers: Optional['MultiMapping[str]']=None ) -> Payload: """Helper to append form urlencoded part.""" assert isinstance(obj, (Sequence, Mapping)) if h...
[ "def", "append_form", "(", "self", ",", "obj", ":", "Union", "[", "Sequence", "[", "Tuple", "[", "str", ",", "str", "]", "]", ",", "Mapping", "[", "str", ",", "str", "]", "]", ",", "headers", ":", "Optional", "[", "'MultiMapping[str]'", "]", "=", "...
Helper to append form urlencoded part.
[ "Helper", "to", "append", "form", "urlencoded", "part", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L843-L861
26,965
aio-libs/aiohttp
aiohttp/multipart.py
MultipartWriter.size
def size(self) -> Optional[int]: """Size of the payload.""" if not self._parts: return 0 total = 0 for part, encoding, te_encoding in self._parts: if encoding or te_encoding or part.size is None: return None total += int( ...
python
def size(self) -> Optional[int]: """Size of the payload.""" if not self._parts: return 0 total = 0 for part, encoding, te_encoding in self._parts: if encoding or te_encoding or part.size is None: return None total += int( ...
[ "def", "size", "(", "self", ")", "->", "Optional", "[", "int", "]", ":", "if", "not", "self", ".", "_parts", ":", "return", "0", "total", "=", "0", "for", "part", ",", "encoding", ",", "te_encoding", "in", "self", ".", "_parts", ":", "if", "encodin...
Size of the payload.
[ "Size", "of", "the", "payload", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L864-L881
26,966
aio-libs/aiohttp
aiohttp/multipart.py
MultipartWriter.write
async def write(self, writer: Any, close_boundary: bool=True) -> None: """Write body.""" if not self._parts: return for part, encoding, te_encoding in self._parts: await writer.write(b'--' + self._boundary + b'\r\n') await writer.write(par...
python
async def write(self, writer: Any, close_boundary: bool=True) -> None: """Write body.""" if not self._parts: return for part, encoding, te_encoding in self._parts: await writer.write(b'--' + self._boundary + b'\r\n') await writer.write(par...
[ "async", "def", "write", "(", "self", ",", "writer", ":", "Any", ",", "close_boundary", ":", "bool", "=", "True", ")", "->", "None", ":", "if", "not", "self", ".", "_parts", ":", "return", "for", "part", ",", "encoding", ",", "te_encoding", "in", "se...
Write body.
[ "Write", "body", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/multipart.py#L883-L907
26,967
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.update_version
def update_version(self, version: Union[http.HttpVersion, str]) -> None: """Convert request version to two elements tuple. parser HTTP version '1.1' => (1, 1) """ if isinstance(version, str): v = [l.strip() for l in version.split('.', 1)] try: ver...
python
def update_version(self, version: Union[http.HttpVersion, str]) -> None: """Convert request version to two elements tuple. parser HTTP version '1.1' => (1, 1) """ if isinstance(version, str): v = [l.strip() for l in version.split('.', 1)] try: ver...
[ "def", "update_version", "(", "self", ",", "version", ":", "Union", "[", "http", ".", "HttpVersion", ",", "str", "]", ")", "->", "None", ":", "if", "isinstance", "(", "version", ",", "str", ")", ":", "v", "=", "[", "l", ".", "strip", "(", ")", "f...
Convert request version to two elements tuple. parser HTTP version '1.1' => (1, 1)
[ "Convert", "request", "version", "to", "two", "elements", "tuple", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L307-L320
26,968
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.update_headers
def update_headers(self, headers: Optional[LooseHeaders]) -> None: """Update request headers.""" self.headers = CIMultiDict() # type: CIMultiDict[str] # add host netloc = cast(str, self.url.raw_host) if helpers.is_ipv6_address(netloc): netloc = '[{}]'.format(netloc)...
python
def update_headers(self, headers: Optional[LooseHeaders]) -> None: """Update request headers.""" self.headers = CIMultiDict() # type: CIMultiDict[str] # add host netloc = cast(str, self.url.raw_host) if helpers.is_ipv6_address(netloc): netloc = '[{}]'.format(netloc)...
[ "def", "update_headers", "(", "self", ",", "headers", ":", "Optional", "[", "LooseHeaders", "]", ")", "->", "None", ":", "self", ".", "headers", "=", "CIMultiDict", "(", ")", "# type: CIMultiDict[str]", "# add host", "netloc", "=", "cast", "(", "str", ",", ...
Update request headers.
[ "Update", "request", "headers", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L322-L343
26,969
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.update_cookies
def update_cookies(self, cookies: Optional[LooseCookies]) -> None: """Update request cookies header.""" if not cookies: return c = SimpleCookie() if hdrs.COOKIE in self.headers: c.load(self.headers.get(hdrs.COOKIE, '')) del self.headers[hdrs.COOKIE] ...
python
def update_cookies(self, cookies: Optional[LooseCookies]) -> None: """Update request cookies header.""" if not cookies: return c = SimpleCookie() if hdrs.COOKIE in self.headers: c.load(self.headers.get(hdrs.COOKIE, '')) del self.headers[hdrs.COOKIE] ...
[ "def", "update_cookies", "(", "self", ",", "cookies", ":", "Optional", "[", "LooseCookies", "]", ")", "->", "None", ":", "if", "not", "cookies", ":", "return", "c", "=", "SimpleCookie", "(", ")", "if", "hdrs", ".", "COOKIE", "in", "self", ".", "headers...
Update request cookies header.
[ "Update", "request", "cookies", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L358-L381
26,970
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.update_content_encoding
def update_content_encoding(self, data: Any) -> None: """Set request content encoding.""" if not data: return enc = self.headers.get(hdrs.CONTENT_ENCODING, '').lower() if enc: if self.compress: raise ValueError( 'compress can n...
python
def update_content_encoding(self, data: Any) -> None: """Set request content encoding.""" if not data: return enc = self.headers.get(hdrs.CONTENT_ENCODING, '').lower() if enc: if self.compress: raise ValueError( 'compress can n...
[ "def", "update_content_encoding", "(", "self", ",", "data", ":", "Any", ")", "->", "None", ":", "if", "not", "data", ":", "return", "enc", "=", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "CONTENT_ENCODING", ",", "''", ")", ".", "lower", "(...
Set request content encoding.
[ "Set", "request", "content", "encoding", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L383-L398
26,971
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.update_transfer_encoding
def update_transfer_encoding(self) -> None: """Analyze transfer-encoding header.""" te = self.headers.get(hdrs.TRANSFER_ENCODING, '').lower() if 'chunked' in te: if self.chunked: raise ValueError( 'chunked can not be set ' 'if ...
python
def update_transfer_encoding(self) -> None: """Analyze transfer-encoding header.""" te = self.headers.get(hdrs.TRANSFER_ENCODING, '').lower() if 'chunked' in te: if self.chunked: raise ValueError( 'chunked can not be set ' 'if ...
[ "def", "update_transfer_encoding", "(", "self", ")", "->", "None", ":", "te", "=", "self", ".", "headers", ".", "get", "(", "hdrs", ".", "TRANSFER_ENCODING", ",", "''", ")", ".", "lower", "(", ")", "if", "'chunked'", "in", "te", ":", "if", "self", "....
Analyze transfer-encoding header.
[ "Analyze", "transfer", "-", "encoding", "header", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L400-L419
26,972
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.update_auth
def update_auth(self, auth: Optional[BasicAuth]) -> None: """Set basic auth.""" if auth is None: auth = self.auth if auth is None: return if not isinstance(auth, helpers.BasicAuth): raise TypeError('BasicAuth() tuple is required instead') sel...
python
def update_auth(self, auth: Optional[BasicAuth]) -> None: """Set basic auth.""" if auth is None: auth = self.auth if auth is None: return if not isinstance(auth, helpers.BasicAuth): raise TypeError('BasicAuth() tuple is required instead') sel...
[ "def", "update_auth", "(", "self", ",", "auth", ":", "Optional", "[", "BasicAuth", "]", ")", "->", "None", ":", "if", "auth", "is", "None", ":", "auth", "=", "self", ".", "auth", "if", "auth", "is", "None", ":", "return", "if", "not", "isinstance", ...
Set basic auth.
[ "Set", "basic", "auth", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L421-L431
26,973
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientRequest.write_bytes
async def write_bytes(self, writer: AbstractStreamWriter, conn: 'Connection') -> None: """Support coroutines that yields bytes objects.""" # 100 response if self._continue is not None: await writer.drain() await self._continue protocol =...
python
async def write_bytes(self, writer: AbstractStreamWriter, conn: 'Connection') -> None: """Support coroutines that yields bytes objects.""" # 100 response if self._continue is not None: await writer.drain() await self._continue protocol =...
[ "async", "def", "write_bytes", "(", "self", ",", "writer", ":", "AbstractStreamWriter", ",", "conn", ":", "'Connection'", ")", "->", "None", ":", "# 100 response", "if", "self", ".", "_continue", "is", "not", "None", ":", "await", "writer", ".", "drain", "...
Support coroutines that yields bytes objects.
[ "Support", "coroutines", "that", "yields", "bytes", "objects", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L501-L535
26,974
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientResponse.start
async def start(self, connection: 'Connection') -> 'ClientResponse': """Start response processing.""" self._closed = False self._protocol = connection.protocol self._connection = connection with self._timer: while True: # read response ...
python
async def start(self, connection: 'Connection') -> 'ClientResponse': """Start response processing.""" self._closed = False self._protocol = connection.protocol self._connection = connection with self._timer: while True: # read response ...
[ "async", "def", "start", "(", "self", ",", "connection", ":", "'Connection'", ")", "->", "'ClientResponse'", ":", "self", ".", "_closed", "=", "False", "self", ".", "_protocol", "=", "connection", ".", "protocol", "self", ".", "_connection", "=", "connection...
Start response processing.
[ "Start", "response", "processing", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L788-L835
26,975
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientResponse.read
async def read(self) -> bytes: """Read response payload.""" if self._body is None: try: self._body = await self.content.read() for trace in self._traces: await trace.send_response_chunk_received(self._body) except BaseException:...
python
async def read(self) -> bytes: """Read response payload.""" if self._body is None: try: self._body = await self.content.read() for trace in self._traces: await trace.send_response_chunk_received(self._body) except BaseException:...
[ "async", "def", "read", "(", "self", ")", "->", "bytes", ":", "if", "self", ".", "_body", "is", "None", ":", "try", ":", "self", ".", "_body", "=", "await", "self", ".", "content", ".", "read", "(", ")", "for", "trace", "in", "self", ".", "_trace...
Read response payload.
[ "Read", "response", "payload", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L920-L933
26,976
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientResponse.text
async def text(self, encoding: Optional[str]=None, errors: str='strict') -> str: """Read response payload and decode.""" if self._body is None: await self.read() if encoding is None: encoding = self.get_encoding() return self._body.decode(enco...
python
async def text(self, encoding: Optional[str]=None, errors: str='strict') -> str: """Read response payload and decode.""" if self._body is None: await self.read() if encoding is None: encoding = self.get_encoding() return self._body.decode(enco...
[ "async", "def", "text", "(", "self", ",", "encoding", ":", "Optional", "[", "str", "]", "=", "None", ",", "errors", ":", "str", "=", "'strict'", ")", "->", "str", ":", "if", "self", ".", "_body", "is", "None", ":", "await", "self", ".", "read", "...
Read response payload and decode.
[ "Read", "response", "payload", "and", "decode", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L956-L965
26,977
aio-libs/aiohttp
aiohttp/client_reqrep.py
ClientResponse.json
async def json(self, *, encoding: str=None, loads: JSONDecoder=DEFAULT_JSON_DECODER, content_type: Optional[str]='application/json') -> Any: """Read and decodes JSON response.""" if self._body is None: await self.read() if content_type: ...
python
async def json(self, *, encoding: str=None, loads: JSONDecoder=DEFAULT_JSON_DECODER, content_type: Optional[str]='application/json') -> Any: """Read and decodes JSON response.""" if self._body is None: await self.read() if content_type: ...
[ "async", "def", "json", "(", "self", ",", "*", ",", "encoding", ":", "str", "=", "None", ",", "loads", ":", "JSONDecoder", "=", "DEFAULT_JSON_DECODER", ",", "content_type", ":", "Optional", "[", "str", "]", "=", "'application/json'", ")", "->", "Any", ":...
Read and decodes JSON response.
[ "Read", "and", "decodes", "JSON", "response", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_reqrep.py#L967-L987
26,978
aio-libs/aiohttp
aiohttp/web_response.py
StreamResponse.enable_chunked_encoding
def enable_chunked_encoding(self, chunk_size: Optional[int]=None) -> None: """Enables automatic chunked transfer encoding.""" self._chunked = True if hdrs.CONTENT_LENGTH in self._headers: raise RuntimeError("You can't enable chunked encoding when " "a ...
python
def enable_chunked_encoding(self, chunk_size: Optional[int]=None) -> None: """Enables automatic chunked transfer encoding.""" self._chunked = True if hdrs.CONTENT_LENGTH in self._headers: raise RuntimeError("You can't enable chunked encoding when " "a ...
[ "def", "enable_chunked_encoding", "(", "self", ",", "chunk_size", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "self", ".", "_chunked", "=", "True", "if", "hdrs", ".", "CONTENT_LENGTH", "in", "self", ".", "_headers", ":", "raise...
Enables automatic chunked transfer encoding.
[ "Enables", "automatic", "chunked", "transfer", "encoding", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_response.py#L144-L152
26,979
aio-libs/aiohttp
aiohttp/web_response.py
StreamResponse.enable_compression
def enable_compression(self, force: Optional[Union[bool, ContentCoding]]=None ) -> None: """Enables response compression encoding.""" # Backwards compatibility for when force was a bool <0.17. if type(force) == bool: force = Conte...
python
def enable_compression(self, force: Optional[Union[bool, ContentCoding]]=None ) -> None: """Enables response compression encoding.""" # Backwards compatibility for when force was a bool <0.17. if type(force) == bool: force = Conte...
[ "def", "enable_compression", "(", "self", ",", "force", ":", "Optional", "[", "Union", "[", "bool", ",", "ContentCoding", "]", "]", "=", "None", ")", "->", "None", ":", "# Backwards compatibility for when force was a bool <0.17.", "if", "type", "(", "force", ")"...
Enables response compression encoding.
[ "Enables", "response", "compression", "encoding", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_response.py#L154-L169
26,980
aio-libs/aiohttp
aiohttp/web_response.py
StreamResponse.set_cookie
def set_cookie(self, name: str, value: str, *, expires: Optional[str]=None, domain: Optional[str]=None, max_age: Optional[Union[int, str]]=None, path: str='/', secure: Optional[str]=None, httponly: Optional...
python
def set_cookie(self, name: str, value: str, *, expires: Optional[str]=None, domain: Optional[str]=None, max_age: Optional[Union[int, str]]=None, path: str='/', secure: Optional[str]=None, httponly: Optional...
[ "def", "set_cookie", "(", "self", ",", "name", ":", "str", ",", "value", ":", "str", ",", "*", ",", "expires", ":", "Optional", "[", "str", "]", "=", "None", ",", "domain", ":", "Optional", "[", "str", "]", "=", "None", ",", "max_age", ":", "Opti...
Set or update response cookie. Sets new cookie or updates existent with new value. Also updates only those params which are not None.
[ "Set", "or", "update", "response", "cookie", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_response.py#L179-L221
26,981
aio-libs/aiohttp
aiohttp/web_response.py
StreamResponse.del_cookie
def del_cookie(self, name: str, *, domain: Optional[str]=None, path: str='/') -> None: """Delete cookie. Creates new empty expired cookie. """ # TODO: do we need domain/path here? self._cookies.pop(name, None) self.set_cookie(name, '...
python
def del_cookie(self, name: str, *, domain: Optional[str]=None, path: str='/') -> None: """Delete cookie. Creates new empty expired cookie. """ # TODO: do we need domain/path here? self._cookies.pop(name, None) self.set_cookie(name, '...
[ "def", "del_cookie", "(", "self", ",", "name", ":", "str", ",", "*", ",", "domain", ":", "Optional", "[", "str", "]", "=", "None", ",", "path", ":", "str", "=", "'/'", ")", "->", "None", ":", "# TODO: do we need domain/path here?", "self", ".", "_cooki...
Delete cookie. Creates new empty expired cookie.
[ "Delete", "cookie", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_response.py#L223-L234
26,982
aio-libs/aiohttp
aiohttp/web_response.py
StreamResponse.last_modified
def last_modified(self) -> Optional[datetime.datetime]: """The value of Last-Modified HTTP header, or None. This header is represented as a `datetime` object. """ httpdate = self._headers.get(hdrs.LAST_MODIFIED) if httpdate is not None: timetuple = parsedate(httpdate...
python
def last_modified(self) -> Optional[datetime.datetime]: """The value of Last-Modified HTTP header, or None. This header is represented as a `datetime` object. """ httpdate = self._headers.get(hdrs.LAST_MODIFIED) if httpdate is not None: timetuple = parsedate(httpdate...
[ "def", "last_modified", "(", "self", ")", "->", "Optional", "[", "datetime", ".", "datetime", "]", ":", "httpdate", "=", "self", ".", "_headers", ".", "get", "(", "hdrs", ".", "LAST_MODIFIED", ")", "if", "httpdate", "is", "not", "None", ":", "timetuple",...
The value of Last-Modified HTTP header, or None. This header is represented as a `datetime` object.
[ "The", "value", "of", "Last", "-", "Modified", "HTTP", "header", "or", "None", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_response.py#L282-L293
26,983
aio-libs/aiohttp
aiohttp/web_urldispatcher.py
UrlDispatcher.add_static
def add_static(self, prefix: str, path: PathLike, *, name: Optional[str]=None, expect_handler: Optional[_ExpectHandler]=None, chunk_size: int=256 * 1024, show_index: bool=False, follow_symlinks: bool=False, append_version: bo...
python
def add_static(self, prefix: str, path: PathLike, *, name: Optional[str]=None, expect_handler: Optional[_ExpectHandler]=None, chunk_size: int=256 * 1024, show_index: bool=False, follow_symlinks: bool=False, append_version: bo...
[ "def", "add_static", "(", "self", ",", "prefix", ":", "str", ",", "path", ":", "PathLike", ",", "*", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ",", "expect_handler", ":", "Optional", "[", "_ExpectHandler", "]", "=", "None", ",", "ch...
Add static files view. prefix - url prefix path - folder with files
[ "Add", "static", "files", "view", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_urldispatcher.py#L1036-L1059
26,984
aio-libs/aiohttp
aiohttp/web_urldispatcher.py
UrlDispatcher.add_options
def add_options(self, path: str, handler: _WebHandler, **kwargs: Any) -> AbstractRoute: """ Shortcut for add_route with method OPTIONS """ return self.add_route(hdrs.METH_OPTIONS, path, handler, **kwargs)
python
def add_options(self, path: str, handler: _WebHandler, **kwargs: Any) -> AbstractRoute: """ Shortcut for add_route with method OPTIONS """ return self.add_route(hdrs.METH_OPTIONS, path, handler, **kwargs)
[ "def", "add_options", "(", "self", ",", "path", ":", "str", ",", "handler", ":", "_WebHandler", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "AbstractRoute", ":", "return", "self", ".", "add_route", "(", "hdrs", ".", "METH_OPTIONS", ",", "path", ","...
Shortcut for add_route with method OPTIONS
[ "Shortcut", "for", "add_route", "with", "method", "OPTIONS" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_urldispatcher.py#L1068-L1073
26,985
aio-libs/aiohttp
aiohttp/web_urldispatcher.py
UrlDispatcher.add_get
def add_get(self, path: str, handler: _WebHandler, *, name: Optional[str]=None, allow_head: bool=True, **kwargs: Any) -> AbstractRoute: """ Shortcut for add_route with method GET, if allow_head is true another route is added allowing head requests to the same endp...
python
def add_get(self, path: str, handler: _WebHandler, *, name: Optional[str]=None, allow_head: bool=True, **kwargs: Any) -> AbstractRoute: """ Shortcut for add_route with method GET, if allow_head is true another route is added allowing head requests to the same endp...
[ "def", "add_get", "(", "self", ",", "path", ":", "str", ",", "handler", ":", "_WebHandler", ",", "*", ",", "name", ":", "Optional", "[", "str", "]", "=", "None", ",", "allow_head", ":", "bool", "=", "True", ",", "*", "*", "kwargs", ":", "Any", ")...
Shortcut for add_route with method GET, if allow_head is true another route is added allowing head requests to the same endpoint
[ "Shortcut", "for", "add_route", "with", "method", "GET", "if", "allow_head", "is", "true", "another", "route", "is", "added", "allowing", "head", "requests", "to", "the", "same", "endpoint" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_urldispatcher.py#L1075-L1085
26,986
aio-libs/aiohttp
aiohttp/web_urldispatcher.py
UrlDispatcher.add_view
def add_view(self, path: str, handler: AbstractView, **kwargs: Any) -> AbstractRoute: """ Shortcut for add_route with ANY methods for a class-based view """ return self.add_route(hdrs.METH_ANY, path, handler, **kwargs)
python
def add_view(self, path: str, handler: AbstractView, **kwargs: Any) -> AbstractRoute: """ Shortcut for add_route with ANY methods for a class-based view """ return self.add_route(hdrs.METH_ANY, path, handler, **kwargs)
[ "def", "add_view", "(", "self", ",", "path", ":", "str", ",", "handler", ":", "AbstractView", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "AbstractRoute", ":", "return", "self", ".", "add_route", "(", "hdrs", ".", "METH_ANY", ",", "path", ",", "h...
Shortcut for add_route with ANY methods for a class-based view
[ "Shortcut", "for", "add_route", "with", "ANY", "methods", "for", "a", "class", "-", "based", "view" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_urldispatcher.py#L1115-L1120
26,987
aio-libs/aiohttp
aiohttp/web_urldispatcher.py
UrlDispatcher.add_routes
def add_routes(self, routes: Iterable[AbstractRouteDef]) -> None: """Append routes to route table. Parameter should be a sequence of RouteDef objects. """ for route_def in routes: route_def.register(self)
python
def add_routes(self, routes: Iterable[AbstractRouteDef]) -> None: """Append routes to route table. Parameter should be a sequence of RouteDef objects. """ for route_def in routes: route_def.register(self)
[ "def", "add_routes", "(", "self", ",", "routes", ":", "Iterable", "[", "AbstractRouteDef", "]", ")", "->", "None", ":", "for", "route_def", "in", "routes", ":", "route_def", ".", "register", "(", "self", ")" ]
Append routes to route table. Parameter should be a sequence of RouteDef objects.
[ "Append", "routes", "to", "route", "table", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_urldispatcher.py#L1127-L1133
26,988
aio-libs/aiohttp
aiohttp/http_parser.py
HttpParser.parse_headers
def parse_headers( self, lines: List[bytes] ) -> Tuple['CIMultiDictProxy[str]', RawHeaders, Optional[bool], Optional[str], bool, bool]: """Parses RFC 5322 headers from a stream. Line continuations are...
python
def parse_headers( self, lines: List[bytes] ) -> Tuple['CIMultiDictProxy[str]', RawHeaders, Optional[bool], Optional[str], bool, bool]: """Parses RFC 5322 headers from a stream. Line continuations are...
[ "def", "parse_headers", "(", "self", ",", "lines", ":", "List", "[", "bytes", "]", ")", "->", "Tuple", "[", "'CIMultiDictProxy[str]'", ",", "RawHeaders", ",", "Optional", "[", "bool", "]", ",", "Optional", "[", "str", "]", ",", "bool", ",", "bool", "]"...
Parses RFC 5322 headers from a stream. Line continuations are supported. Returns list of header name and value pairs. Header name is in upper case.
[ "Parses", "RFC", "5322", "headers", "from", "a", "stream", "." ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/http_parser.py#L369-L412
26,989
aio-libs/aiohttp
aiohttp/client_ws.py
ClientWebSocketResponse.get_extra_info
def get_extra_info(self, name: str, default: Any=None) -> Any: """extra info from connection transport""" conn = self._response.connection if conn is None: return default transport = conn.transport if transport is None: return default return transp...
python
def get_extra_info(self, name: str, default: Any=None) -> Any: """extra info from connection transport""" conn = self._response.connection if conn is None: return default transport = conn.transport if transport is None: return default return transp...
[ "def", "get_extra_info", "(", "self", ",", "name", ":", "str", ",", "default", ":", "Any", "=", "None", ")", "->", "Any", ":", "conn", "=", "self", ".", "_response", ".", "connection", "if", "conn", "is", "None", ":", "return", "default", "transport", ...
extra info from connection transport
[ "extra", "info", "from", "connection", "transport" ]
9504fe2affaaff673fa4f3754c1c44221f8ba47d
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/client_ws.py#L125-L133
26,990
kennethreitz/requests-html
requests_html.py
user_agent
def user_agent(style=None) -> _UserAgent: """Returns an apparently legit user-agent, if not requested one of a specific style. Defaults to a Chrome-style User-Agent. """ global useragent if (not useragent) and style: useragent = UserAgent() return useragent[style] if style else DEFAULT_...
python
def user_agent(style=None) -> _UserAgent: """Returns an apparently legit user-agent, if not requested one of a specific style. Defaults to a Chrome-style User-Agent. """ global useragent if (not useragent) and style: useragent = UserAgent() return useragent[style] if style else DEFAULT_...
[ "def", "user_agent", "(", "style", "=", "None", ")", "->", "_UserAgent", ":", "global", "useragent", "if", "(", "not", "useragent", ")", "and", "style", ":", "useragent", "=", "UserAgent", "(", ")", "return", "useragent", "[", "style", "]", "if", "style"...
Returns an apparently legit user-agent, if not requested one of a specific style. Defaults to a Chrome-style User-Agent.
[ "Returns", "an", "apparently", "legit", "user", "-", "agent", "if", "not", "requested", "one", "of", "a", "specific", "style", ".", "Defaults", "to", "a", "Chrome", "-", "style", "User", "-", "Agent", "." ]
b59a9f2fb9333d7d467154a0fd82978efdb9d23b
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L665-L673
26,991
kennethreitz/requests-html
requests_html.py
BaseParser._make_absolute
def _make_absolute(self, link): """Makes a given link absolute.""" # Parse the link with stdlib. parsed = urlparse(link)._asdict() # If link is relative, then join it with base_url. if not parsed['netloc']: return urljoin(self.base_url, link) # Link is abso...
python
def _make_absolute(self, link): """Makes a given link absolute.""" # Parse the link with stdlib. parsed = urlparse(link)._asdict() # If link is relative, then join it with base_url. if not parsed['netloc']: return urljoin(self.base_url, link) # Link is abso...
[ "def", "_make_absolute", "(", "self", ",", "link", ")", ":", "# Parse the link with stdlib.", "parsed", "=", "urlparse", "(", "link", ")", ".", "_asdict", "(", ")", "# If link is relative, then join it with base_url.", "if", "not", "parsed", "[", "'netloc'", "]", ...
Makes a given link absolute.
[ "Makes", "a", "given", "link", "absolute", "." ]
b59a9f2fb9333d7d467154a0fd82978efdb9d23b
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L306-L325
26,992
kennethreitz/requests-html
requests_html.py
HTML.render
def render(self, retries: int = 8, script: str = None, wait: float = 0.2, scrolldown=False, sleep: int = 0, reload: bool = True, timeout: Union[float, int] = 8.0, keep_page: bool = False): """Reloads the response in Chromium, and replaces HTML content with an updated version, with JavaScript executed. ...
python
def render(self, retries: int = 8, script: str = None, wait: float = 0.2, scrolldown=False, sleep: int = 0, reload: bool = True, timeout: Union[float, int] = 8.0, keep_page: bool = False): """Reloads the response in Chromium, and replaces HTML content with an updated version, with JavaScript executed. ...
[ "def", "render", "(", "self", ",", "retries", ":", "int", "=", "8", ",", "script", ":", "str", "=", "None", ",", "wait", ":", "float", "=", "0.2", ",", "scrolldown", "=", "False", ",", "sleep", ":", "int", "=", "0", ",", "reload", ":", "bool", ...
Reloads the response in Chromium, and replaces HTML content with an updated version, with JavaScript executed. :param retries: The number of times to retry loading the page in Chromium. :param script: JavaScript to execute upon page load (optional). :param wait: The number of seconds to...
[ "Reloads", "the", "response", "in", "Chromium", "and", "replaces", "HTML", "content", "with", "an", "updated", "version", "with", "JavaScript", "executed", "." ]
b59a9f2fb9333d7d467154a0fd82978efdb9d23b
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L541-L610
26,993
kennethreitz/requests-html
requests_html.py
HTMLSession.close
def close(self): """ If a browser was created close it first. """ if hasattr(self, "_browser"): self.loop.run_until_complete(self._browser.close()) super().close()
python
def close(self): """ If a browser was created close it first. """ if hasattr(self, "_browser"): self.loop.run_until_complete(self._browser.close()) super().close()
[ "def", "close", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "\"_browser\"", ")", ":", "self", ".", "loop", ".", "run_until_complete", "(", "self", ".", "_browser", ".", "close", "(", ")", ")", "super", "(", ")", ".", "close", "(", ")"...
If a browser was created close it first.
[ "If", "a", "browser", "was", "created", "close", "it", "first", "." ]
b59a9f2fb9333d7d467154a0fd82978efdb9d23b
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L733-L737
26,994
kennethreitz/requests-html
requests_html.py
AsyncHTMLSession.request
def request(self, *args, **kwargs): """ Partial original request func and run it in a thread. """ func = partial(super().request, *args, **kwargs) return self.loop.run_in_executor(self.thread_pool, func)
python
def request(self, *args, **kwargs): """ Partial original request func and run it in a thread. """ func = partial(super().request, *args, **kwargs) return self.loop.run_in_executor(self.thread_pool, func)
[ "def", "request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "func", "=", "partial", "(", "super", "(", ")", ".", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "self", ".", "loop", ".", "run_in_execut...
Partial original request func and run it in a thread.
[ "Partial", "original", "request", "func", "and", "run", "it", "in", "a", "thread", "." ]
b59a9f2fb9333d7d467154a0fd82978efdb9d23b
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L756-L759
26,995
kennethreitz/requests-html
requests_html.py
AsyncHTMLSession.run
def run(self, *coros): """ Pass in all the coroutines you want to run, it will wrap each one in a task, run it and wait for the result. Return a list with all results, this is returned in the same order coros are passed in. """ tasks = [ asyncio.ensure_future(coro()) ...
python
def run(self, *coros): """ Pass in all the coroutines you want to run, it will wrap each one in a task, run it and wait for the result. Return a list with all results, this is returned in the same order coros are passed in. """ tasks = [ asyncio.ensure_future(coro()) ...
[ "def", "run", "(", "self", ",", "*", "coros", ")", ":", "tasks", "=", "[", "asyncio", ".", "ensure_future", "(", "coro", "(", ")", ")", "for", "coro", "in", "coros", "]", "done", ",", "_", "=", "self", ".", "loop", ".", "run_until_complete", "(", ...
Pass in all the coroutines you want to run, it will wrap each one in a task, run it and wait for the result. Return a list with all results, this is returned in the same order coros are passed in.
[ "Pass", "in", "all", "the", "coroutines", "you", "want", "to", "run", "it", "will", "wrap", "each", "one", "in", "a", "task", "run", "it", "and", "wait", "for", "the", "result", ".", "Return", "a", "list", "with", "all", "results", "this", "is", "ret...
b59a9f2fb9333d7d467154a0fd82978efdb9d23b
https://github.com/kennethreitz/requests-html/blob/b59a9f2fb9333d7d467154a0fd82978efdb9d23b/requests_html.py#L767-L775
26,996
Microsoft/nni
examples/trials/weight_sharing/ga_squad/util.py
shape
def shape(tensor): ''' Get shape of variable. Return type is tuple. ''' temp_s = tensor.get_shape() return tuple([temp_s[i].value for i in range(0, len(temp_s))])
python
def shape(tensor): ''' Get shape of variable. Return type is tuple. ''' temp_s = tensor.get_shape() return tuple([temp_s[i].value for i in range(0, len(temp_s))])
[ "def", "shape", "(", "tensor", ")", ":", "temp_s", "=", "tensor", ".", "get_shape", "(", ")", "return", "tuple", "(", "[", "temp_s", "[", "i", "]", ".", "value", "for", "i", "in", "range", "(", "0", ",", "len", "(", "temp_s", ")", ")", "]", ")"...
Get shape of variable. Return type is tuple.
[ "Get", "shape", "of", "variable", ".", "Return", "type", "is", "tuple", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/util.py#L30-L36
26,997
Microsoft/nni
examples/trials/weight_sharing/ga_squad/util.py
get_variable
def get_variable(name, temp_s): ''' Get variable by name. ''' return tf.Variable(tf.zeros(temp_s), name=name)
python
def get_variable(name, temp_s): ''' Get variable by name. ''' return tf.Variable(tf.zeros(temp_s), name=name)
[ "def", "get_variable", "(", "name", ",", "temp_s", ")", ":", "return", "tf", ".", "Variable", "(", "tf", ".", "zeros", "(", "temp_s", ")", ",", "name", "=", "name", ")" ]
Get variable by name.
[ "Get", "variable", "by", "name", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/util.py#L39-L43
26,998
Microsoft/nni
examples/trials/weight_sharing/ga_squad/util.py
dropout
def dropout(tensor, drop_prob, is_training): ''' Dropout except test. ''' if not is_training: return tensor return tf.nn.dropout(tensor, 1.0 - drop_prob)
python
def dropout(tensor, drop_prob, is_training): ''' Dropout except test. ''' if not is_training: return tensor return tf.nn.dropout(tensor, 1.0 - drop_prob)
[ "def", "dropout", "(", "tensor", ",", "drop_prob", ",", "is_training", ")", ":", "if", "not", "is_training", ":", "return", "tensor", "return", "tf", ".", "nn", ".", "dropout", "(", "tensor", ",", "1.0", "-", "drop_prob", ")" ]
Dropout except test.
[ "Dropout", "except", "test", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/util.py#L46-L52
26,999
Microsoft/nni
examples/trials/weight_sharing/ga_squad/util.py
Timer.get_elapsed
def get_elapsed(self, restart=True): ''' Calculate time span. ''' end = time.time() span = end - self.__start if restart: self.__start = end return span
python
def get_elapsed(self, restart=True): ''' Calculate time span. ''' end = time.time() span = end - self.__start if restart: self.__start = end return span
[ "def", "get_elapsed", "(", "self", ",", "restart", "=", "True", ")", ":", "end", "=", "time", ".", "time", "(", ")", "span", "=", "end", "-", "self", ".", "__start", "if", "restart", ":", "self", ".", "__start", "=", "end", "return", "span" ]
Calculate time span.
[ "Calculate", "time", "span", "." ]
c7cc8db32da8d2ec77a382a55089f4e17247ce41
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/util.py#L68-L76