partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | WebSocket.shutdown | close socket, immediately. | websocket/_core.py | def shutdown(self):
"""close socket, immediately."""
if self.sock:
self.sock.close()
self.sock = None
self.connected = False | def shutdown(self):
"""close socket, immediately."""
if self.sock:
self.sock.close()
self.sock = None
self.connected = False | [
"close",
"socket",
"immediately",
"."
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_core.py#L440-L445 | [
"def",
"shutdown",
"(",
"self",
")",
":",
"if",
"self",
".",
"sock",
":",
"self",
".",
"sock",
".",
"close",
"(",
")",
"self",
".",
"sock",
"=",
"None",
"self",
".",
"connected",
"=",
"False"
] | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | enableTrace | turn on/off the traceability.
traceable: boolean value. if set True, traceability is enabled. | websocket/_logging.py | def enableTrace(traceable, handler = logging.StreamHandler()):
"""
turn on/off the traceability.
traceable: boolean value. if set True, traceability is enabled.
"""
global _traceEnabled
_traceEnabled = traceable
if traceable:
_logger.addHandler(handler)
_logger.setLevel(logg... | def enableTrace(traceable, handler = logging.StreamHandler()):
"""
turn on/off the traceability.
traceable: boolean value. if set True, traceability is enabled.
"""
global _traceEnabled
_traceEnabled = traceable
if traceable:
_logger.addHandler(handler)
_logger.setLevel(logg... | [
"turn",
"on",
"/",
"off",
"the",
"traceability",
"."
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_logging.py#L40-L50 | [
"def",
"enableTrace",
"(",
"traceable",
",",
"handler",
"=",
"logging",
".",
"StreamHandler",
"(",
")",
")",
":",
"global",
"_traceEnabled",
"_traceEnabled",
"=",
"traceable",
"if",
"traceable",
":",
"_logger",
".",
"addHandler",
"(",
"handler",
")",
"_logger"... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | ABNF.validate | validate the ABNF frame.
skip_utf8_validation: skip utf8 validation. | websocket/_abnf.py | def validate(self, skip_utf8_validation=False):
"""
validate the ABNF frame.
skip_utf8_validation: skip utf8 validation.
"""
if self.rsv1 or self.rsv2 or self.rsv3:
raise WebSocketProtocolException("rsv is not implemented, yet")
if self.opcode not in ABNF.OPC... | def validate(self, skip_utf8_validation=False):
"""
validate the ABNF frame.
skip_utf8_validation: skip utf8 validation.
"""
if self.rsv1 or self.rsv2 or self.rsv3:
raise WebSocketProtocolException("rsv is not implemented, yet")
if self.opcode not in ABNF.OPC... | [
"validate",
"the",
"ABNF",
"frame",
".",
"skip_utf8_validation",
":",
"skip",
"utf8",
"validation",
"."
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_abnf.py#L156-L182 | [
"def",
"validate",
"(",
"self",
",",
"skip_utf8_validation",
"=",
"False",
")",
":",
"if",
"self",
".",
"rsv1",
"or",
"self",
".",
"rsv2",
"or",
"self",
".",
"rsv3",
":",
"raise",
"WebSocketProtocolException",
"(",
"\"rsv is not implemented, yet\"",
")",
"if",... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | ABNF.create_frame | create frame to send text, binary and other data.
data: data to send. This is string value(byte array).
if opcode is OPCODE_TEXT and this value is unicode,
data value is converted into unicode string, automatically.
opcode: operation code. please see OPCODE_XXX.
fin: f... | websocket/_abnf.py | def create_frame(data, opcode, fin=1):
"""
create frame to send text, binary and other data.
data: data to send. This is string value(byte array).
if opcode is OPCODE_TEXT and this value is unicode,
data value is converted into unicode string, automatically.
opc... | def create_frame(data, opcode, fin=1):
"""
create frame to send text, binary and other data.
data: data to send. This is string value(byte array).
if opcode is OPCODE_TEXT and this value is unicode,
data value is converted into unicode string, automatically.
opc... | [
"create",
"frame",
"to",
"send",
"text",
"binary",
"and",
"other",
"data",
"."
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_abnf.py#L194-L209 | [
"def",
"create_frame",
"(",
"data",
",",
"opcode",
",",
"fin",
"=",
"1",
")",
":",
"if",
"opcode",
"==",
"ABNF",
".",
"OPCODE_TEXT",
"and",
"isinstance",
"(",
"data",
",",
"six",
".",
"text_type",
")",
":",
"data",
"=",
"data",
".",
"encode",
"(",
... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | ABNF.format | format this object to string(byte array) to send data to server. | websocket/_abnf.py | def format(self):
"""
format this object to string(byte array) to send data to server.
"""
if any(x not in (0, 1) for x in [self.fin, self.rsv1, self.rsv2, self.rsv3]):
raise ValueError("not 0 or 1")
if self.opcode not in ABNF.OPCODES:
raise ValueError("In... | def format(self):
"""
format this object to string(byte array) to send data to server.
"""
if any(x not in (0, 1) for x in [self.fin, self.rsv1, self.rsv2, self.rsv3]):
raise ValueError("not 0 or 1")
if self.opcode not in ABNF.OPCODES:
raise ValueError("In... | [
"format",
"this",
"object",
"to",
"string",
"(",
"byte",
"array",
")",
"to",
"send",
"data",
"to",
"server",
"."
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_abnf.py#L211-L242 | [
"def",
"format",
"(",
"self",
")",
":",
"if",
"any",
"(",
"x",
"not",
"in",
"(",
"0",
",",
"1",
")",
"for",
"x",
"in",
"[",
"self",
".",
"fin",
",",
"self",
".",
"rsv1",
",",
"self",
".",
"rsv2",
",",
"self",
".",
"rsv3",
"]",
")",
":",
"... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | ABNF.mask | mask or unmask data. Just do xor for each byte
mask_key: 4 byte string(byte).
data: data to mask/unmask. | websocket/_abnf.py | def mask(mask_key, data):
"""
mask or unmask data. Just do xor for each byte
mask_key: 4 byte string(byte).
data: data to mask/unmask.
"""
if data is None:
data = ""
if isinstance(mask_key, six.text_type):
mask_key = six.b(mask_key)
... | def mask(mask_key, data):
"""
mask or unmask data. Just do xor for each byte
mask_key: 4 byte string(byte).
data: data to mask/unmask.
"""
if data is None:
data = ""
if isinstance(mask_key, six.text_type):
mask_key = six.b(mask_key)
... | [
"mask",
"or",
"unmask",
"data",
".",
"Just",
"do",
"xor",
"for",
"each",
"byte"
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_abnf.py#L253-L284 | [
"def",
"mask",
"(",
"mask_key",
",",
"data",
")",
":",
"if",
"data",
"is",
"None",
":",
"data",
"=",
"\"\"",
"if",
"isinstance",
"(",
"mask_key",
",",
"six",
".",
"text_type",
")",
":",
"mask_key",
"=",
"six",
".",
"b",
"(",
"mask_key",
")",
"if",
... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | WebSocketApp.send | send message.
data: message to send. If you set opcode to OPCODE_TEXT,
data must be utf-8 string or unicode.
opcode: operation code of data. default is OPCODE_TEXT. | websocket/_app.py | def send(self, data, opcode=ABNF.OPCODE_TEXT):
"""
send message.
data: message to send. If you set opcode to OPCODE_TEXT,
data must be utf-8 string or unicode.
opcode: operation code of data. default is OPCODE_TEXT.
"""
if not self.sock or self.sock.send(da... | def send(self, data, opcode=ABNF.OPCODE_TEXT):
"""
send message.
data: message to send. If you set opcode to OPCODE_TEXT,
data must be utf-8 string or unicode.
opcode: operation code of data. default is OPCODE_TEXT.
"""
if not self.sock or self.sock.send(da... | [
"send",
"message",
".",
"data",
":",
"message",
"to",
"send",
".",
"If",
"you",
"set",
"opcode",
"to",
"OPCODE_TEXT",
"data",
"must",
"be",
"utf",
"-",
"8",
"string",
"or",
"unicode",
".",
"opcode",
":",
"operation",
"code",
"of",
"data",
".",
"default... | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_app.py#L145-L155 | [
"def",
"send",
"(",
"self",
",",
"data",
",",
"opcode",
"=",
"ABNF",
".",
"OPCODE_TEXT",
")",
":",
"if",
"not",
"self",
".",
"sock",
"or",
"self",
".",
"sock",
".",
"send",
"(",
"data",
",",
"opcode",
")",
"==",
"0",
":",
"raise",
"WebSocketConnect... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | WebSocketApp.close | close websocket connection. | websocket/_app.py | def close(self, **kwargs):
"""
close websocket connection.
"""
self.keep_running = False
if self.sock:
self.sock.close(**kwargs)
self.sock = None | def close(self, **kwargs):
"""
close websocket connection.
"""
self.keep_running = False
if self.sock:
self.sock.close(**kwargs)
self.sock = None | [
"close",
"websocket",
"connection",
"."
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_app.py#L157-L164 | [
"def",
"close",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"keep_running",
"=",
"False",
"if",
"self",
".",
"sock",
":",
"self",
".",
"sock",
".",
"close",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"sock",
"=",
"None"
] | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | WebSocketApp.run_forever | run event loop for WebSocket framework.
This loop is infinite loop and is alive during websocket is available.
sockopt: values for socket.setsockopt.
sockopt must be tuple
and each element is argument of sock.setsockopt.
sslopt: ssl socket optional dict.
ping_inte... | websocket/_app.py | def run_forever(self, sockopt=None, sslopt=None,
ping_interval=0, ping_timeout=None,
http_proxy_host=None, http_proxy_port=None,
http_no_proxy=None, http_proxy_auth=None,
skip_utf8_validation=False,
host=None, origin=Non... | def run_forever(self, sockopt=None, sslopt=None,
ping_interval=0, ping_timeout=None,
http_proxy_host=None, http_proxy_port=None,
http_no_proxy=None, http_proxy_auth=None,
skip_utf8_validation=False,
host=None, origin=Non... | [
"run",
"event",
"loop",
"for",
"WebSocket",
"framework",
".",
"This",
"loop",
"is",
"infinite",
"loop",
"and",
"is",
"alive",
"during",
"websocket",
"is",
"available",
".",
"sockopt",
":",
"values",
"for",
"socket",
".",
"setsockopt",
".",
"sockopt",
"must",... | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_app.py#L176-L312 | [
"def",
"run_forever",
"(",
"self",
",",
"sockopt",
"=",
"None",
",",
"sslopt",
"=",
"None",
",",
"ping_interval",
"=",
"0",
",",
"ping_timeout",
"=",
"None",
",",
"http_proxy_host",
"=",
"None",
",",
"http_proxy_port",
"=",
"None",
",",
"http_no_proxy",
"=... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | WebSocketApp._get_close_args | this functions extracts the code, reason from the close body
if they exists, and if the self.on_close except three arguments | websocket/_app.py | def _get_close_args(self, data):
""" this functions extracts the code, reason from the close body
if they exists, and if the self.on_close except three arguments """
# if the on_close callback is "old", just return empty list
if sys.version_info < (3, 0):
if not self.on_close... | def _get_close_args(self, data):
""" this functions extracts the code, reason from the close body
if they exists, and if the self.on_close except three arguments """
# if the on_close callback is "old", just return empty list
if sys.version_info < (3, 0):
if not self.on_close... | [
"this",
"functions",
"extracts",
"the",
"code",
"reason",
"from",
"the",
"close",
"body",
"if",
"they",
"exists",
"and",
"if",
"the",
"self",
".",
"on_close",
"except",
"three",
"arguments"
] | websocket-client/websocket-client | python | https://github.com/websocket-client/websocket-client/blob/3c25814664fef5b78716ed8841123ed1c0d17824/websocket/_app.py#L321-L337 | [
"def",
"_get_close_args",
"(",
"self",
",",
"data",
")",
":",
"# if the on_close callback is \"old\", just return empty list",
"if",
"sys",
".",
"version_info",
"<",
"(",
"3",
",",
"0",
")",
":",
"if",
"not",
"self",
".",
"on_close",
"or",
"len",
"(",
"inspect... | 3c25814664fef5b78716ed8841123ed1c0d17824 |
train | RequestsHttpClient.get | GET request.
:param str url: Request url
:param dict headers: (optional) Request headers
:param dict params: (optional) Request query parameter
:param bool stream: (optional) get content as stream
:param timeout: (optional), How long to wait for the server
to send da... | linebot/http_client.py | def get(self, url, headers=None, params=None, stream=False, timeout=None):
"""GET request.
:param str url: Request url
:param dict headers: (optional) Request headers
:param dict params: (optional) Request query parameter
:param bool stream: (optional) get content as stream
... | def get(self, url, headers=None, params=None, stream=False, timeout=None):
"""GET request.
:param str url: Request url
:param dict headers: (optional) Request headers
:param dict params: (optional) Request query parameter
:param bool stream: (optional) get content as stream
... | [
"GET",
"request",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/http_client.py#L110-L132 | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"self",
".",
"timeout",
"respons... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | RequestsHttpClient.post | POST request.
:param str url: Request url
:param dict headers: (optional) Request headers
:param data: (optional) Dictionary, bytes, or file-like object to send in the body
:param timeout: (optional), How long to wait for the server
to send data before giving up, as a float,... | linebot/http_client.py | def post(self, url, headers=None, data=None, timeout=None):
"""POST request.
:param str url: Request url
:param dict headers: (optional) Request headers
:param data: (optional) Dictionary, bytes, or file-like object to send in the body
:param timeout: (optional), How long to wai... | def post(self, url, headers=None, data=None, timeout=None):
"""POST request.
:param str url: Request url
:param dict headers: (optional) Request headers
:param data: (optional) Dictionary, bytes, or file-like object to send in the body
:param timeout: (optional), How long to wai... | [
"POST",
"request",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/http_client.py#L134-L155 | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"None",
",",
"data",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"self",
".",
"timeout",
"response",
"=",
"requests",
".",
"pos... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | RequestsHttpResponse.iter_content | Get request body as iterator content (stream).
:param int chunk_size:
:param bool decode_unicode: | linebot/http_client.py | def iter_content(self, chunk_size=1024, decode_unicode=False):
"""Get request body as iterator content (stream).
:param int chunk_size:
:param bool decode_unicode:
"""
return self.response.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode) | def iter_content(self, chunk_size=1024, decode_unicode=False):
"""Get request body as iterator content (stream).
:param int chunk_size:
:param bool decode_unicode:
"""
return self.response.iter_content(chunk_size=chunk_size, decode_unicode=decode_unicode) | [
"Get",
"request",
"body",
"as",
"iterator",
"content",
"(",
"stream",
")",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/http_client.py#L254-L260 | [
"def",
"iter_content",
"(",
"self",
",",
"chunk_size",
"=",
"1024",
",",
"decode_unicode",
"=",
"False",
")",
":",
"return",
"self",
".",
"response",
".",
"iter_content",
"(",
"chunk_size",
"=",
"chunk_size",
",",
"decode_unicode",
"=",
"decode_unicode",
")"
] | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | to_snake_case | Convert to snake case.
:param str text:
:rtype: str
:return: | linebot/utils.py | def to_snake_case(text):
"""Convert to snake case.
:param str text:
:rtype: str
:return:
"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | def to_snake_case(text):
"""Convert to snake case.
:param str text:
:rtype: str
:return:
"""
s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() | [
"Convert",
"to",
"snake",
"case",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/utils.py#L28-L36 | [
"def",
"to_snake_case",
"(",
"text",
")",
":",
"s1",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"text",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s1",
")",
".",
"lower",
"(",
")... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | to_camel_case | Convert to camel case.
:param str text:
:rtype: str
:return: | linebot/utils.py | def to_camel_case(text):
"""Convert to camel case.
:param str text:
:rtype: str
:return:
"""
split = text.split('_')
return split[0] + "".join(x.title() for x in split[1:]) | def to_camel_case(text):
"""Convert to camel case.
:param str text:
:rtype: str
:return:
"""
split = text.split('_')
return split[0] + "".join(x.title() for x in split[1:]) | [
"Convert",
"to",
"camel",
"case",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/utils.py#L39-L47 | [
"def",
"to_camel_case",
"(",
"text",
")",
":",
"split",
"=",
"text",
".",
"split",
"(",
"'_'",
")",
"return",
"split",
"[",
"0",
"]",
"+",
"\"\"",
".",
"join",
"(",
"x",
".",
"title",
"(",
")",
"for",
"x",
"in",
"split",
"[",
"1",
":",
"]",
"... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | safe_compare_digest | safe_compare_digest method.
:param val1: string or bytes for compare
:type val1: str | bytes
:param val2: string or bytes for compare
:type val2: str | bytes | linebot/utils.py | def safe_compare_digest(val1, val2):
"""safe_compare_digest method.
:param val1: string or bytes for compare
:type val1: str | bytes
:param val2: string or bytes for compare
:type val2: str | bytes
"""
if len(val1) != len(val2):
return False
result = 0
if PY3 and isinstance... | def safe_compare_digest(val1, val2):
"""safe_compare_digest method.
:param val1: string or bytes for compare
:type val1: str | bytes
:param val2: string or bytes for compare
:type val2: str | bytes
"""
if len(val1) != len(val2):
return False
result = 0
if PY3 and isinstance... | [
"safe_compare_digest",
"method",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/utils.py#L50-L69 | [
"def",
"safe_compare_digest",
"(",
"val1",
",",
"val2",
")",
":",
"if",
"len",
"(",
"val1",
")",
"!=",
"len",
"(",
"val2",
")",
":",
"return",
"False",
"result",
"=",
"0",
"if",
"PY3",
"and",
"isinstance",
"(",
"val1",
",",
"bytes",
")",
"and",
"is... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | Base.as_json_dict | Return dictionary from this object.
:return: dict | linebot/models/base.py | def as_json_dict(self):
"""Return dictionary from this object.
:return: dict
"""
data = {}
for key, value in self.__dict__.items():
camel_key = utils.to_camel_case(key)
if isinstance(value, (list, tuple, set)):
data[camel_key] = list()
... | def as_json_dict(self):
"""Return dictionary from this object.
:return: dict
"""
data = {}
for key, value in self.__dict__.items():
camel_key = utils.to_camel_case(key)
if isinstance(value, (list, tuple, set)):
data[camel_key] = list()
... | [
"Return",
"dictionary",
"from",
"this",
"object",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/models/base.py#L75-L96 | [
"def",
"as_json_dict",
"(",
"self",
")",
":",
"data",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"camel_key",
"=",
"utils",
".",
"to_camel_case",
"(",
"key",
")",
"if",
"isinstance",
"(",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | Base.new_from_json_dict | Create a new instance from a dict.
:param data: JSON dict
:rtype:
:return: | linebot/models/base.py | def new_from_json_dict(cls, data):
"""Create a new instance from a dict.
:param data: JSON dict
:rtype:
:return:
"""
new_data = {utils.to_snake_case(key): value
for key, value in data.items()}
return cls(**new_data) | def new_from_json_dict(cls, data):
"""Create a new instance from a dict.
:param data: JSON dict
:rtype:
:return:
"""
new_data = {utils.to_snake_case(key): value
for key, value in data.items()}
return cls(**new_data) | [
"Create",
"a",
"new",
"instance",
"from",
"a",
"dict",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/models/base.py#L99-L109 | [
"def",
"new_from_json_dict",
"(",
"cls",
",",
"data",
")",
":",
"new_data",
"=",
"{",
"utils",
".",
"to_snake_case",
"(",
"key",
")",
":",
"value",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
"}",
"return",
"cls",
"(",
"*",
"*... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | Base.get_or_new_from_json_dict | Get `cls` object w/ deserialization from json if needed.
If data is instance of cls, return data.
Else if data is instance of dict, create instance from dict.
Else, return None.
:param data:
:param cls:
:rtype: object
:return: | linebot/models/base.py | def get_or_new_from_json_dict(data, cls):
"""Get `cls` object w/ deserialization from json if needed.
If data is instance of cls, return data.
Else if data is instance of dict, create instance from dict.
Else, return None.
:param data:
:param cls:
:rtype: object... | def get_or_new_from_json_dict(data, cls):
"""Get `cls` object w/ deserialization from json if needed.
If data is instance of cls, return data.
Else if data is instance of dict, create instance from dict.
Else, return None.
:param data:
:param cls:
:rtype: object... | [
"Get",
"cls",
"object",
"w",
"/",
"deserialization",
"from",
"json",
"if",
"needed",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/models/base.py#L112-L129 | [
"def",
"get_or_new_from_json_dict",
"(",
"data",
",",
"cls",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"cls",
")",
":",
"return",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"dict",
")",
":",
"return",
"cls",
".",
"new_from_json_dict",
"(",
"da... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | Base.get_or_new_from_json_dict_with_types | Get `cls` object w/ deserialization from json by using type key hint if needed.
If data is instance of one of cls, return data.
Else if data is instance of dict, create instance from dict.
Else, return None.
:param data:
:param cls_map:
:param type_key:
:rtype: ... | linebot/models/base.py | def get_or_new_from_json_dict_with_types(
data, cls_map, type_key='type'
):
"""Get `cls` object w/ deserialization from json by using type key hint if needed.
If data is instance of one of cls, return data.
Else if data is instance of dict, create instance from dict.
Els... | def get_or_new_from_json_dict_with_types(
data, cls_map, type_key='type'
):
"""Get `cls` object w/ deserialization from json by using type key hint if needed.
If data is instance of one of cls, return data.
Else if data is instance of dict, create instance from dict.
Els... | [
"Get",
"cls",
"object",
"w",
"/",
"deserialization",
"from",
"json",
"by",
"using",
"type",
"key",
"hint",
"if",
"needed",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/models/base.py#L132-L154 | [
"def",
"get_or_new_from_json_dict_with_types",
"(",
"data",
",",
"cls_map",
",",
"type_key",
"=",
"'type'",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"tuple",
"(",
"cls_map",
".",
"values",
"(",
")",
")",
")",
":",
"return",
"data",
"elif",
"isinstan... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.reply_message | Call reply message API.
https://devdocs.line.me/en/#reply-message
Respond to events from users, groups, and rooms.
Webhooks are used to notify you when an event occurs.
For events that you can respond to, a replyToken is issued for replying to messages.
Because the replyToken... | linebot/api.py | def reply_message(self, reply_token, messages, timeout=None):
"""Call reply message API.
https://devdocs.line.me/en/#reply-message
Respond to events from users, groups, and rooms.
Webhooks are used to notify you when an event occurs.
For events that you can respond to, a reply... | def reply_message(self, reply_token, messages, timeout=None):
"""Call reply message API.
https://devdocs.line.me/en/#reply-message
Respond to events from users, groups, and rooms.
Webhooks are used to notify you when an event occurs.
For events that you can respond to, a reply... | [
"Call",
"reply",
"message",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L60-L96 | [
"def",
"reply_message",
"(",
"self",
",",
"reply_token",
",",
"messages",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"messages",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"messages",
"=",
"[",
"messages",
"]",
"data",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.push_message | Call push message API.
https://devdocs.line.me/en/#push-message
Send messages to users, groups, and rooms at any time.
:param str to: ID of the receiver
:param messages: Messages.
Max: 5
:type messages: T <= :py:class:`linebot.models.send_messages.SendMessage` |
... | linebot/api.py | def push_message(self, to, messages, timeout=None):
"""Call push message API.
https://devdocs.line.me/en/#push-message
Send messages to users, groups, and rooms at any time.
:param str to: ID of the receiver
:param messages: Messages.
Max: 5
:type messages:... | def push_message(self, to, messages, timeout=None):
"""Call push message API.
https://devdocs.line.me/en/#push-message
Send messages to users, groups, and rooms at any time.
:param str to: ID of the receiver
:param messages: Messages.
Max: 5
:type messages:... | [
"Call",
"push",
"message",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L98-L126 | [
"def",
"push_message",
"(",
"self",
",",
"to",
",",
"messages",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"messages",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"messages",
"=",
"[",
"messages",
"]",
"data",
"=",
"{... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_profile | Call get profile API.
https://devdocs.line.me/en/#bot-api-get-profile
Get user profile information.
:param str user_id: User ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect timeout, read tim... | linebot/api.py | def get_profile(self, user_id, timeout=None):
"""Call get profile API.
https://devdocs.line.me/en/#bot-api-get-profile
Get user profile information.
:param str user_id: User ID
:param timeout: (optional) How long to wait for the server
to send data before giving up... | def get_profile(self, user_id, timeout=None):
"""Call get profile API.
https://devdocs.line.me/en/#bot-api-get-profile
Get user profile information.
:param str user_id: User ID
:param timeout: (optional) How long to wait for the server
to send data before giving up... | [
"Call",
"get",
"profile",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L160-L181 | [
"def",
"get_profile",
"(",
"self",
",",
"user_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/profile/{user_id}'",
".",
"format",
"(",
"user_id",
"=",
"user_id",
")",
",",
"timeout",
"=",
"timeout",
")",
"... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_group_member_profile | Call get group member profile API.
https://devdocs.line.me/en/#get-group-room-member-profile
Gets the user profile of a member of a group that
the bot is in. This can be the user ID of a user who has
not added the bot as a friend or has blocked the bot.
:param str group_id: Gr... | linebot/api.py | def get_group_member_profile(self, group_id, user_id, timeout=None):
"""Call get group member profile API.
https://devdocs.line.me/en/#get-group-room-member-profile
Gets the user profile of a member of a group that
the bot is in. This can be the user ID of a user who has
not ad... | def get_group_member_profile(self, group_id, user_id, timeout=None):
"""Call get group member profile API.
https://devdocs.line.me/en/#get-group-room-member-profile
Gets the user profile of a member of a group that
the bot is in. This can be the user ID of a user who has
not ad... | [
"Call",
"get",
"group",
"member",
"profile",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L183-L207 | [
"def",
"get_group_member_profile",
"(",
"self",
",",
"group_id",
",",
"user_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/group/{group_id}/member/{user_id}'",
".",
"format",
"(",
"group_id",
"=",
"group_id",
","... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_room_member_profile | Call get room member profile API.
https://devdocs.line.me/en/#get-group-room-member-profile
Gets the user profile of a member of a room that
the bot is in. This can be the user ID of a user who has
not added the bot as a friend or has blocked the bot.
:param str room_id: Room ... | linebot/api.py | def get_room_member_profile(self, room_id, user_id, timeout=None):
"""Call get room member profile API.
https://devdocs.line.me/en/#get-group-room-member-profile
Gets the user profile of a member of a room that
the bot is in. This can be the user ID of a user who has
not added ... | def get_room_member_profile(self, room_id, user_id, timeout=None):
"""Call get room member profile API.
https://devdocs.line.me/en/#get-group-room-member-profile
Gets the user profile of a member of a room that
the bot is in. This can be the user ID of a user who has
not added ... | [
"Call",
"get",
"room",
"member",
"profile",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L209-L233 | [
"def",
"get_room_member_profile",
"(",
"self",
",",
"room_id",
",",
"user_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/room/{room_id}/member/{user_id}'",
".",
"format",
"(",
"room_id",
"=",
"room_id",
",",
"u... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_group_member_ids | Call get group member IDs API.
https://devdocs.line.me/en/#get-group-room-member-ids
Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as a friend
or has blocked the bot.
:param str group_id: Group ID... | linebot/api.py | def get_group_member_ids(self, group_id, start=None, timeout=None):
"""Call get group member IDs API.
https://devdocs.line.me/en/#get-group-room-member-ids
Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as ... | def get_group_member_ids(self, group_id, start=None, timeout=None):
"""Call get group member IDs API.
https://devdocs.line.me/en/#get-group-room-member-ids
Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as ... | [
"Call",
"get",
"group",
"member",
"IDs",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L235-L262 | [
"def",
"get_group_member_ids",
"(",
"self",
",",
"group_id",
",",
"start",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"params",
"=",
"None",
"if",
"start",
"is",
"None",
"else",
"{",
"'start'",
":",
"start",
"}",
"response",
"=",
"self",
".",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_room_member_ids | Call get room member IDs API.
https://devdocs.line.me/en/#get-group-room-member-ids
Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as a friend
or has blocked the bot.
:param str room_id: Room ID
... | linebot/api.py | def get_room_member_ids(self, room_id, start=None, timeout=None):
"""Call get room member IDs API.
https://devdocs.line.me/en/#get-group-room-member-ids
Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as a f... | def get_room_member_ids(self, room_id, start=None, timeout=None):
"""Call get room member IDs API.
https://devdocs.line.me/en/#get-group-room-member-ids
Gets the user IDs of the members of a group that the bot is in.
This includes the user IDs of users who have not added the bot as a f... | [
"Call",
"get",
"room",
"member",
"IDs",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L264-L291 | [
"def",
"get_room_member_ids",
"(",
"self",
",",
"room_id",
",",
"start",
"=",
"None",
",",
"timeout",
"=",
"None",
")",
":",
"params",
"=",
"None",
"if",
"start",
"is",
"None",
"else",
"{",
"'start'",
":",
"start",
"}",
"response",
"=",
"self",
".",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_message_content | Call get content API.
https://devdocs.line.me/en/#get-content
Retrieve image, video, and audio data sent by users.
:param str message_id: Message ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (conn... | linebot/api.py | def get_message_content(self, message_id, timeout=None):
"""Call get content API.
https://devdocs.line.me/en/#get-content
Retrieve image, video, and audio data sent by users.
:param str message_id: Message ID
:param timeout: (optional) How long to wait for the server
... | def get_message_content(self, message_id, timeout=None):
"""Call get content API.
https://devdocs.line.me/en/#get-content
Retrieve image, video, and audio data sent by users.
:param str message_id: Message ID
:param timeout: (optional) How long to wait for the server
... | [
"Call",
"get",
"content",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L293-L314 | [
"def",
"get_message_content",
"(",
"self",
",",
"message_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/message/{message_id}/content'",
".",
"format",
"(",
"message_id",
"=",
"message_id",
")",
",",
"stream",
"... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.leave_group | Call leave group API.
https://devdocs.line.me/en/#leave
Leave a group.
:param str group_id: Group ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect timeout, read timeout) float tuple.
... | linebot/api.py | def leave_group(self, group_id, timeout=None):
"""Call leave group API.
https://devdocs.line.me/en/#leave
Leave a group.
:param str group_id: Group ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
... | def leave_group(self, group_id, timeout=None):
"""Call leave group API.
https://devdocs.line.me/en/#leave
Leave a group.
:param str group_id: Group ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
... | [
"Call",
"leave",
"group",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L316-L333 | [
"def",
"leave_group",
"(",
"self",
",",
"group_id",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_post",
"(",
"'/v2/bot/group/{group_id}/leave'",
".",
"format",
"(",
"group_id",
"=",
"group_id",
")",
",",
"timeout",
"=",
"timeout",
")"
] | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.leave_room | Call leave room API.
https://devdocs.line.me/en/#leave
Leave a room.
:param str room_id: Room ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect timeout, read timeout) float tuple.
... | linebot/api.py | def leave_room(self, room_id, timeout=None):
"""Call leave room API.
https://devdocs.line.me/en/#leave
Leave a room.
:param str room_id: Room ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (... | def leave_room(self, room_id, timeout=None):
"""Call leave room API.
https://devdocs.line.me/en/#leave
Leave a room.
:param str room_id: Room ID
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (... | [
"Call",
"leave",
"room",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L335-L352 | [
"def",
"leave_room",
"(",
"self",
",",
"room_id",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_post",
"(",
"'/v2/bot/room/{room_id}/leave'",
".",
"format",
"(",
"room_id",
"=",
"room_id",
")",
",",
"timeout",
"=",
"timeout",
")"
] | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_rich_menu | Call get rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu
:param str rich_menu_id: ID of the rich menu
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect timeout, re... | linebot/api.py | def get_rich_menu(self, rich_menu_id, timeout=None):
"""Call get rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu
:param str rich_menu_id: ID of the rich menu
:param timeout: (optional) How long to wait for the server
to send data bef... | def get_rich_menu(self, rich_menu_id, timeout=None):
"""Call get rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu
:param str rich_menu_id: ID of the rich menu
:param timeout: (optional) How long to wait for the server
to send data bef... | [
"Call",
"get",
"rich",
"menu",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L354-L373 | [
"def",
"get_rich_menu",
"(",
"self",
",",
"rich_menu_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/richmenu/{rich_menu_id}'",
".",
"format",
"(",
"rich_menu_id",
"=",
"rich_menu_id",
")",
",",
"timeout",
"=",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.create_rich_menu | Call create rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu
:param rich_menu: Inquired to create a rich menu object.
:type rich_menu: T <= :py:class:`linebot.models.rich_menu.RichMenu`
:param timeout: (optional) How long to wait for the serve... | linebot/api.py | def create_rich_menu(self, rich_menu, timeout=None):
"""Call create rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu
:param rich_menu: Inquired to create a rich menu object.
:type rich_menu: T <= :py:class:`linebot.models.rich_menu.RichMenu`
... | def create_rich_menu(self, rich_menu, timeout=None):
"""Call create rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#create-rich-menu
:param rich_menu: Inquired to create a rich menu object.
:type rich_menu: T <= :py:class:`linebot.models.rich_menu.RichMenu`
... | [
"Call",
"create",
"rich",
"menu",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L375-L394 | [
"def",
"create_rich_menu",
"(",
"self",
",",
"rich_menu",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_post",
"(",
"'/v2/bot/richmenu'",
",",
"data",
"=",
"rich_menu",
".",
"as_json_string",
"(",
")",
",",
"timeout",
"=",
"timeout... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.delete_rich_menu | Call delete rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#delete-rich-menu
:param str rich_menu_id: ID of an uploaded rich menu
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (conne... | linebot/api.py | def delete_rich_menu(self, rich_menu_id, timeout=None):
"""Call delete rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#delete-rich-menu
:param str rich_menu_id: ID of an uploaded rich menu
:param timeout: (optional) How long to wait for the server
... | def delete_rich_menu(self, rich_menu_id, timeout=None):
"""Call delete rich menu API.
https://developers.line.me/en/docs/messaging-api/reference/#delete-rich-menu
:param str rich_menu_id: ID of an uploaded rich menu
:param timeout: (optional) How long to wait for the server
... | [
"Call",
"delete",
"rich",
"menu",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L396-L411 | [
"def",
"delete_rich_menu",
"(",
"self",
",",
"rich_menu_id",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_delete",
"(",
"'/v2/bot/richmenu/{rich_menu_id}'",
".",
"format",
"(",
"rich_menu_id",
"=",
"rich_menu_id",
")",
",",
"timeout",
"=",
"timeout",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_rich_menu_id_of_user | Call get rich menu ID of user API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-id-of-user
:param str user_id: IDs of the user
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connec... | linebot/api.py | def get_rich_menu_id_of_user(self, user_id, timeout=None):
"""Call get rich menu ID of user API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-id-of-user
:param str user_id: IDs of the user
:param timeout: (optional) How long to wait for the server
... | def get_rich_menu_id_of_user(self, user_id, timeout=None):
"""Call get rich menu ID of user API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-id-of-user
:param str user_id: IDs of the user
:param timeout: (optional) How long to wait for the server
... | [
"Call",
"get",
"rich",
"menu",
"ID",
"of",
"user",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L413-L432 | [
"def",
"get_rich_menu_id_of_user",
"(",
"self",
",",
"user_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/user/{user_id}/richmenu'",
".",
"format",
"(",
"user_id",
"=",
"user_id",
")",
",",
"timeout",
"=",
"t... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.link_rich_menu_to_user | Call link rich menu to user API.
https://developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-user
:param str user_id: ID of an uploaded rich menu
:param str rich_menu_id: ID of the user
:type timeout: float | tuple(float, float) | linebot/api.py | def link_rich_menu_to_user(self, user_id, rich_menu_id, timeout=None):
"""Call link rich menu to user API.
https://developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-user
:param str user_id: ID of an uploaded rich menu
:param str rich_menu_id: ID of the user
... | def link_rich_menu_to_user(self, user_id, rich_menu_id, timeout=None):
"""Call link rich menu to user API.
https://developers.line.me/en/docs/messaging-api/reference/#link-rich-menu-to-user
:param str user_id: ID of an uploaded rich menu
:param str rich_menu_id: ID of the user
... | [
"Call",
"link",
"rich",
"menu",
"to",
"user",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L434-L449 | [
"def",
"link_rich_menu_to_user",
"(",
"self",
",",
"user_id",
",",
"rich_menu_id",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_post",
"(",
"'/v2/bot/user/{user_id}/richmenu/{rich_menu_id}'",
".",
"format",
"(",
"user_id",
"=",
"user_id",
",",
"rich_menu_... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.unlink_rich_menu_from_user | Call unlink rich menu from user API.
https://developers.line.me/en/docs/messaging-api/reference/#unlink-rich-menu-from-user
:param str user_id: ID of the user
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (con... | linebot/api.py | def unlink_rich_menu_from_user(self, user_id, timeout=None):
"""Call unlink rich menu from user API.
https://developers.line.me/en/docs/messaging-api/reference/#unlink-rich-menu-from-user
:param str user_id: ID of the user
:param timeout: (optional) How long to wait for the server
... | def unlink_rich_menu_from_user(self, user_id, timeout=None):
"""Call unlink rich menu from user API.
https://developers.line.me/en/docs/messaging-api/reference/#unlink-rich-menu-from-user
:param str user_id: ID of the user
:param timeout: (optional) How long to wait for the server
... | [
"Call",
"unlink",
"rich",
"menu",
"from",
"user",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L451-L466 | [
"def",
"unlink_rich_menu_from_user",
"(",
"self",
",",
"user_id",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_delete",
"(",
"'/v2/bot/user/{user_id}/richmenu'",
".",
"format",
"(",
"user_id",
"=",
"user_id",
")",
",",
"timeout",
"=",
"timeout",
")"
] | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_rich_menu_image | Call download rich menu image API.
https://developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image
:param str rich_menu_id: ID of the rich menu with the image to be downloaded
:param timeout: (optional) How long to wait for the server
to send data before giving... | linebot/api.py | def get_rich_menu_image(self, rich_menu_id, timeout=None):
"""Call download rich menu image API.
https://developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image
:param str rich_menu_id: ID of the rich menu with the image to be downloaded
:param timeout: (optional) ... | def get_rich_menu_image(self, rich_menu_id, timeout=None):
"""Call download rich menu image API.
https://developers.line.me/en/docs/messaging-api/reference/#download-rich-menu-image
:param str rich_menu_id: ID of the rich menu with the image to be downloaded
:param timeout: (optional) ... | [
"Call",
"download",
"rich",
"menu",
"image",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L468-L487 | [
"def",
"get_rich_menu_image",
"(",
"self",
",",
"rich_menu_id",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/richmenu/{rich_menu_id}/content'",
".",
"format",
"(",
"rich_menu_id",
"=",
"rich_menu_id",
")",
",",
"tim... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.set_rich_menu_image | Call upload rich menu image API.
https://developers.line.me/en/docs/messaging-api/reference/#upload-rich-menu-image
Uploads and attaches an image to a rich menu.
:param str rich_menu_id: IDs of the richmenu
:param str content_type: image/jpeg or image/png
:param content: image... | linebot/api.py | def set_rich_menu_image(self, rich_menu_id, content_type, content, timeout=None):
"""Call upload rich menu image API.
https://developers.line.me/en/docs/messaging-api/reference/#upload-rich-menu-image
Uploads and attaches an image to a rich menu.
:param str rich_menu_id: IDs of the ri... | def set_rich_menu_image(self, rich_menu_id, content_type, content, timeout=None):
"""Call upload rich menu image API.
https://developers.line.me/en/docs/messaging-api/reference/#upload-rich-menu-image
Uploads and attaches an image to a rich menu.
:param str rich_menu_id: IDs of the ri... | [
"Call",
"upload",
"rich",
"menu",
"image",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L489-L510 | [
"def",
"set_rich_menu_image",
"(",
"self",
",",
"rich_menu_id",
",",
"content_type",
",",
"content",
",",
"timeout",
"=",
"None",
")",
":",
"self",
".",
"_post",
"(",
"'/v2/bot/richmenu/{rich_menu_id}/content'",
".",
"format",
"(",
"rich_menu_id",
"=",
"rich_menu_... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | LineBotApi.get_rich_menu_list | Call get rich menu list API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect timeout, read timeout) float tuple.
Defaul... | linebot/api.py | def get_rich_menu_list(self, timeout=None):
"""Call get rich menu list API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect... | def get_rich_menu_list(self, timeout=None):
"""Call get rich menu list API.
https://developers.line.me/en/docs/messaging-api/reference/#get-rich-menu-list
:param timeout: (optional) How long to wait for the server
to send data before giving up, as a float,
or a (connect... | [
"Call",
"get",
"rich",
"menu",
"list",
"API",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/api.py#L512-L534 | [
"def",
"get_rich_menu_list",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"'/v2/bot/richmenu/list'",
",",
"timeout",
"=",
"timeout",
")",
"result",
"=",
"[",
"]",
"for",
"richmenu",
"in",
"response",
".",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | SignatureValidator.validate | Check signature.
https://devdocs.line.me/en/#webhook-authentication
:param str body: Request body (as text)
:param str signature: X-Line-Signature value (as text)
:rtype: bool
:return: result | linebot/webhook.py | def validate(self, body, signature):
"""Check signature.
https://devdocs.line.me/en/#webhook-authentication
:param str body: Request body (as text)
:param str signature: X-Line-Signature value (as text)
:rtype: bool
:return: result
"""
gen_signature = hm... | def validate(self, body, signature):
"""Check signature.
https://devdocs.line.me/en/#webhook-authentication
:param str body: Request body (as text)
:param str signature: X-Line-Signature value (as text)
:rtype: bool
:return: result
"""
gen_signature = hm... | [
"Check",
"signature",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/webhook.py#L84-L102 | [
"def",
"validate",
"(",
"self",
",",
"body",
",",
"signature",
")",
":",
"gen_signature",
"=",
"hmac",
".",
"new",
"(",
"self",
".",
"channel_secret",
",",
"body",
".",
"encode",
"(",
"'utf-8'",
")",
",",
"hashlib",
".",
"sha256",
")",
".",
"digest",
... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | WebhookParser.parse | Parse webhook request body as text.
:param str body: Webhook request body (as text)
:param str signature: X-Line-Signature value (as text)
:rtype: list[T <= :py:class:`linebot.models.events.Event`]
:return: | linebot/webhook.py | def parse(self, body, signature):
"""Parse webhook request body as text.
:param str body: Webhook request body (as text)
:param str signature: X-Line-Signature value (as text)
:rtype: list[T <= :py:class:`linebot.models.events.Event`]
:return:
"""
if not self.sig... | def parse(self, body, signature):
"""Parse webhook request body as text.
:param str body: Webhook request body (as text)
:param str signature: X-Line-Signature value (as text)
:rtype: list[T <= :py:class:`linebot.models.events.Event`]
:return:
"""
if not self.sig... | [
"Parse",
"webhook",
"request",
"body",
"as",
"text",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/webhook.py#L115-L150 | [
"def",
"parse",
"(",
"self",
",",
"body",
",",
"signature",
")",
":",
"if",
"not",
"self",
".",
"signature_validator",
".",
"validate",
"(",
"body",
",",
"signature",
")",
":",
"raise",
"InvalidSignatureError",
"(",
"'Invalid signature. signature='",
"+",
"sig... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | WebhookHandler.add | [Decorator] Add handler method.
:param event: Specify a kind of Event which you want to handle
:type event: T <= :py:class:`linebot.models.events.Event` class
:param message: (optional) If event is MessageEvent,
specify kind of Messages which you want to handle
:type: messag... | linebot/webhook.py | def add(self, event, message=None):
"""[Decorator] Add handler method.
:param event: Specify a kind of Event which you want to handle
:type event: T <= :py:class:`linebot.models.events.Event` class
:param message: (optional) If event is MessageEvent,
specify kind of Messages... | def add(self, event, message=None):
"""[Decorator] Add handler method.
:param event: Specify a kind of Event which you want to handle
:type event: T <= :py:class:`linebot.models.events.Event` class
:param message: (optional) If event is MessageEvent,
specify kind of Messages... | [
"[",
"Decorator",
"]",
"Add",
"handler",
"method",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/webhook.py#L165-L185 | [
"def",
"add",
"(",
"self",
",",
"event",
",",
"message",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"it",
"in",
"message",
":",
"self... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | WebhookHandler.handle | Handle webhook.
:param str body: Webhook request body (as text)
:param str signature: X-Line-Signature value (as text) | linebot/webhook.py | def handle(self, body, signature):
"""Handle webhook.
:param str body: Webhook request body (as text)
:param str signature: X-Line-Signature value (as text)
"""
events = self.parser.parse(body, signature)
for event in events:
func = None
key = No... | def handle(self, body, signature):
"""Handle webhook.
:param str body: Webhook request body (as text)
:param str signature: X-Line-Signature value (as text)
"""
events = self.parser.parse(body, signature)
for event in events:
func = None
key = No... | [
"Handle",
"webhook",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/webhook.py#L199-L230 | [
"def",
"handle",
"(",
"self",
",",
"body",
",",
"signature",
")",
":",
"events",
"=",
"self",
".",
"parser",
".",
"parse",
"(",
"body",
",",
"signature",
")",
"for",
"event",
"in",
"events",
":",
"func",
"=",
"None",
"key",
"=",
"None",
"if",
"isin... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | get_action | Get action. | linebot/models/actions.py | def get_action(action):
"""Get action."""
action_obj = Base.get_or_new_from_json_dict_with_types(
action, {
'postback': PostbackAction,
'message': MessageAction,
'uri': URIAction,
'datetimepicker': DatetimePickerAction,
'camera': CameraAction,
... | def get_action(action):
"""Get action."""
action_obj = Base.get_or_new_from_json_dict_with_types(
action, {
'postback': PostbackAction,
'message': MessageAction,
'uri': URIAction,
'datetimepicker': DatetimePickerAction,
'camera': CameraAction,
... | [
"Get",
"action",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/models/actions.py#L26-L39 | [
"def",
"get_action",
"(",
"action",
")",
":",
"action_obj",
"=",
"Base",
".",
"get_or_new_from_json_dict_with_types",
"(",
"action",
",",
"{",
"'postback'",
":",
"PostbackAction",
",",
"'message'",
":",
"MessageAction",
",",
"'uri'",
":",
"URIAction",
",",
"'dat... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | get_actions | Get actions. | linebot/models/actions.py | def get_actions(actions):
"""Get actions."""
new_actions = []
if actions:
for action in actions:
action_obj = get_action(action)
if action_obj:
new_actions.append(action_obj)
return new_actions | def get_actions(actions):
"""Get actions."""
new_actions = []
if actions:
for action in actions:
action_obj = get_action(action)
if action_obj:
new_actions.append(action_obj)
return new_actions | [
"Get",
"actions",
"."
] | line/line-bot-sdk-python | python | https://github.com/line/line-bot-sdk-python/blob/1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0/linebot/models/actions.py#L42-L51 | [
"def",
"get_actions",
"(",
"actions",
")",
":",
"new_actions",
"=",
"[",
"]",
"if",
"actions",
":",
"for",
"action",
"in",
"actions",
":",
"action_obj",
"=",
"get_action",
"(",
"action",
")",
"if",
"action_obj",
":",
"new_actions",
".",
"append",
"(",
"a... | 1b38bfc2497ff3e3c75be4b50e0f1b7425a07ce0 |
train | save_structure_to_file | Saves a :class:`Post`, :class:`Profile` or :class:`StoryItem` to a '.json' or '.json.xz' file such that it can
later be loaded by :func:`load_structure_from_file`.
If the specified filename ends in '.xz', the file will be LZMA compressed. Otherwise, a pretty-printed JSON file
will be created.
:param s... | instaloader/structures.py | def save_structure_to_file(structure: JsonExportable, filename: str) -> None:
"""Saves a :class:`Post`, :class:`Profile` or :class:`StoryItem` to a '.json' or '.json.xz' file such that it can
later be loaded by :func:`load_structure_from_file`.
If the specified filename ends in '.xz', the file will be LZMA... | def save_structure_to_file(structure: JsonExportable, filename: str) -> None:
"""Saves a :class:`Post`, :class:`Profile` or :class:`StoryItem` to a '.json' or '.json.xz' file such that it can
later be loaded by :func:`load_structure_from_file`.
If the specified filename ends in '.xz', the file will be LZMA... | [
"Saves",
"a",
":",
"class",
":",
"Post",
":",
"class",
":",
"Profile",
"or",
":",
"class",
":",
"StoryItem",
"to",
"a",
".",
"json",
"or",
".",
"json",
".",
"xz",
"file",
"such",
"that",
"it",
"can",
"later",
"be",
"loaded",
"by",
":",
"func",
":... | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L1008-L1026 | [
"def",
"save_structure_to_file",
"(",
"structure",
":",
"JsonExportable",
",",
"filename",
":",
"str",
")",
"->",
"None",
":",
"json_structure",
"=",
"{",
"'node'",
":",
"structure",
".",
"_asdict",
"(",
")",
",",
"'instaloader'",
":",
"{",
"'version'",
":",... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | load_structure_from_file | Loads a :class:`Post`, :class:`Profile` or :class:`StoryItem` from a '.json' or '.json.xz' file that
has been saved by :func:`save_structure_to_file`.
:param context: :attr:`Instaloader.context` linked to the new object, used for additional queries if neccessary.
:param filename: Filename, ends in '.json' ... | instaloader/structures.py | def load_structure_from_file(context: InstaloaderContext, filename: str) -> JsonExportable:
"""Loads a :class:`Post`, :class:`Profile` or :class:`StoryItem` from a '.json' or '.json.xz' file that
has been saved by :func:`save_structure_to_file`.
:param context: :attr:`Instaloader.context` linked to the new... | def load_structure_from_file(context: InstaloaderContext, filename: str) -> JsonExportable:
"""Loads a :class:`Post`, :class:`Profile` or :class:`StoryItem` from a '.json' or '.json.xz' file that
has been saved by :func:`save_structure_to_file`.
:param context: :attr:`Instaloader.context` linked to the new... | [
"Loads",
"a",
":",
"class",
":",
"Post",
":",
"class",
":",
"Profile",
"or",
":",
"class",
":",
"StoryItem",
"from",
"a",
".",
"json",
"or",
".",
"json",
".",
"xz",
"file",
"that",
"has",
"been",
"saved",
"by",
":",
"func",
":",
"save_structure_to_fi... | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L1029-L1058 | [
"def",
"load_structure_from_file",
"(",
"context",
":",
"InstaloaderContext",
",",
"filename",
":",
"str",
")",
"->",
"JsonExportable",
":",
"compressed",
"=",
"filename",
".",
"endswith",
"(",
"'.xz'",
")",
"if",
"compressed",
":",
"fp",
"=",
"lzma",
".",
"... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.from_shortcode | Create a post object from a given shortcode | instaloader/structures.py | def from_shortcode(cls, context: InstaloaderContext, shortcode: str):
"""Create a post object from a given shortcode"""
# pylint:disable=protected-access
post = cls(context, {'shortcode': shortcode})
post._node = post._full_metadata
return post | def from_shortcode(cls, context: InstaloaderContext, shortcode: str):
"""Create a post object from a given shortcode"""
# pylint:disable=protected-access
post = cls(context, {'shortcode': shortcode})
post._node = post._full_metadata
return post | [
"Create",
"a",
"post",
"object",
"from",
"a",
"given",
"shortcode"
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L75-L80 | [
"def",
"from_shortcode",
"(",
"cls",
",",
"context",
":",
"InstaloaderContext",
",",
"shortcode",
":",
"str",
")",
":",
"# pylint:disable=protected-access",
"post",
"=",
"cls",
"(",
"context",
",",
"{",
"'shortcode'",
":",
"shortcode",
"}",
")",
"post",
".",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.from_mediaid | Create a post object from a given mediaid | instaloader/structures.py | def from_mediaid(cls, context: InstaloaderContext, mediaid: int):
"""Create a post object from a given mediaid"""
return cls.from_shortcode(context, Post.mediaid_to_shortcode(mediaid)) | def from_mediaid(cls, context: InstaloaderContext, mediaid: int):
"""Create a post object from a given mediaid"""
return cls.from_shortcode(context, Post.mediaid_to_shortcode(mediaid)) | [
"Create",
"a",
"post",
"object",
"from",
"a",
"given",
"mediaid"
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L83-L85 | [
"def",
"from_mediaid",
"(",
"cls",
",",
"context",
":",
"InstaloaderContext",
",",
"mediaid",
":",
"int",
")",
":",
"return",
"cls",
".",
"from_shortcode",
"(",
"context",
",",
"Post",
".",
"mediaid_to_shortcode",
"(",
"mediaid",
")",
")"
] | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post._field | Lookups given fields in _node, and if not found in _full_metadata. Raises KeyError if not found anywhere. | instaloader/structures.py | def _field(self, *keys) -> Any:
"""Lookups given fields in _node, and if not found in _full_metadata. Raises KeyError if not found anywhere."""
try:
d = self._node
for key in keys:
d = d[key]
return d
except KeyError:
d = self._full... | def _field(self, *keys) -> Any:
"""Lookups given fields in _node, and if not found in _full_metadata. Raises KeyError if not found anywhere."""
try:
d = self._node
for key in keys:
d = d[key]
return d
except KeyError:
d = self._full... | [
"Lookups",
"given",
"fields",
"in",
"_node",
"and",
"if",
"not",
"found",
"in",
"_full_metadata",
".",
"Raises",
"KeyError",
"if",
"not",
"found",
"anywhere",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L150-L161 | [
"def",
"_field",
"(",
"self",
",",
"*",
"keys",
")",
"->",
"Any",
":",
"try",
":",
"d",
"=",
"self",
".",
"_node",
"for",
"key",
"in",
"keys",
":",
"d",
"=",
"d",
"[",
"key",
"]",
"return",
"d",
"except",
"KeyError",
":",
"d",
"=",
"self",
".... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.owner_profile | :class:`Profile` instance of the Post's owner. | instaloader/structures.py | def owner_profile(self) -> 'Profile':
""":class:`Profile` instance of the Post's owner."""
if not self._owner_profile:
if 'username' in self._node['owner']:
owner_struct = self._node['owner']
else:
# Sometimes, the 'owner' structure does not contai... | def owner_profile(self) -> 'Profile':
""":class:`Profile` instance of the Post's owner."""
if not self._owner_profile:
if 'username' in self._node['owner']:
owner_struct = self._node['owner']
else:
# Sometimes, the 'owner' structure does not contai... | [
":",
"class",
":",
"Profile",
"instance",
"of",
"the",
"Post",
"s",
"owner",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L164-L176 | [
"def",
"owner_profile",
"(",
"self",
")",
"->",
"'Profile'",
":",
"if",
"not",
"self",
".",
"_owner_profile",
":",
"if",
"'username'",
"in",
"self",
".",
"_node",
"[",
"'owner'",
"]",
":",
"owner_struct",
"=",
"self",
".",
"_node",
"[",
"'owner'",
"]",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.date_local | Timestamp when the post was created (local time zone). | instaloader/structures.py | def date_local(self) -> datetime:
"""Timestamp when the post was created (local time zone)."""
return datetime.fromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) | def date_local(self) -> datetime:
"""Timestamp when the post was created (local time zone)."""
return datetime.fromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) | [
"Timestamp",
"when",
"the",
"post",
"was",
"created",
"(",
"local",
"time",
"zone",
")",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L189-L191 | [
"def",
"date_local",
"(",
"self",
")",
"->",
"datetime",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"_node",
"[",
"\"date\"",
"]",
"if",
"\"date\"",
"in",
"self",
".",
"_node",
"else",
"self",
".",
"_node",
"[",
"\"taken_at_timestam... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.date_utc | Timestamp when the post was created (UTC). | instaloader/structures.py | def date_utc(self) -> datetime:
"""Timestamp when the post was created (UTC)."""
return datetime.utcfromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) | def date_utc(self) -> datetime:
"""Timestamp when the post was created (UTC)."""
return datetime.utcfromtimestamp(self._node["date"] if "date" in self._node else self._node["taken_at_timestamp"]) | [
"Timestamp",
"when",
"the",
"post",
"was",
"created",
"(",
"UTC",
")",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L194-L196 | [
"def",
"date_utc",
"(",
"self",
")",
"->",
"datetime",
":",
"return",
"datetime",
".",
"utcfromtimestamp",
"(",
"self",
".",
"_node",
"[",
"\"date\"",
"]",
"if",
"\"date\"",
"in",
"self",
".",
"_node",
"else",
"self",
".",
"_node",
"[",
"\"taken_at_timesta... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.get_sidecar_nodes | Sidecar nodes of a Post with typename==GraphSidecar. | instaloader/structures.py | def get_sidecar_nodes(self) -> Iterator[PostSidecarNode]:
"""Sidecar nodes of a Post with typename==GraphSidecar."""
if self.typename == 'GraphSidecar':
for edge in self._field('edge_sidecar_to_children', 'edges'):
node = edge['node']
is_video = node['is_video... | def get_sidecar_nodes(self) -> Iterator[PostSidecarNode]:
"""Sidecar nodes of a Post with typename==GraphSidecar."""
if self.typename == 'GraphSidecar':
for edge in self._field('edge_sidecar_to_children', 'edges'):
node = edge['node']
is_video = node['is_video... | [
"Sidecar",
"nodes",
"of",
"a",
"Post",
"with",
"typename",
"==",
"GraphSidecar",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L218-L225 | [
"def",
"get_sidecar_nodes",
"(",
"self",
")",
"->",
"Iterator",
"[",
"PostSidecarNode",
"]",
":",
"if",
"self",
".",
"typename",
"==",
"'GraphSidecar'",
":",
"for",
"edge",
"in",
"self",
".",
"_field",
"(",
"'edge_sidecar_to_children'",
",",
"'edges'",
")",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.caption | Caption. | instaloader/structures.py | def caption(self) -> Optional[str]:
"""Caption."""
if "edge_media_to_caption" in self._node and self._node["edge_media_to_caption"]["edges"]:
return self._node["edge_media_to_caption"]["edges"][0]["node"]["text"]
elif "caption" in self._node:
return self._node["caption"] | def caption(self) -> Optional[str]:
"""Caption."""
if "edge_media_to_caption" in self._node and self._node["edge_media_to_caption"]["edges"]:
return self._node["edge_media_to_caption"]["edges"][0]["node"]["text"]
elif "caption" in self._node:
return self._node["caption"] | [
"Caption",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L228-L233 | [
"def",
"caption",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"\"edge_media_to_caption\"",
"in",
"self",
".",
"_node",
"and",
"self",
".",
"_node",
"[",
"\"edge_media_to_caption\"",
"]",
"[",
"\"edges\"",
"]",
":",
"return",
"self",
"."... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.caption_hashtags | List of all lowercased hashtags (without preceeding #) that occur in the Post's caption. | instaloader/structures.py | def caption_hashtags(self) -> List[str]:
"""List of all lowercased hashtags (without preceeding #) that occur in the Post's caption."""
if not self.caption:
return []
# This regular expression is from jStassen, adjusted to use Python's \w to support Unicode
# http://blog.jsta... | def caption_hashtags(self) -> List[str]:
"""List of all lowercased hashtags (without preceeding #) that occur in the Post's caption."""
if not self.caption:
return []
# This regular expression is from jStassen, adjusted to use Python's \w to support Unicode
# http://blog.jsta... | [
"List",
"of",
"all",
"lowercased",
"hashtags",
"(",
"without",
"preceeding",
"#",
")",
"that",
"occur",
"in",
"the",
"Post",
"s",
"caption",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L236-L243 | [
"def",
"caption_hashtags",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"caption",
":",
"return",
"[",
"]",
"# This regular expression is from jStassen, adjusted to use Python's \\w to support Unicode",
"# http://blog.jstassen.com/2016/03/... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.caption_mentions | List of all lowercased profiles that are mentioned in the Post's caption, without preceeding @. | instaloader/structures.py | def caption_mentions(self) -> List[str]:
"""List of all lowercased profiles that are mentioned in the Post's caption, without preceeding @."""
if not self.caption:
return []
# This regular expression is from jStassen, adjusted to use Python's \w to support Unicode
# http://bl... | def caption_mentions(self) -> List[str]:
"""List of all lowercased profiles that are mentioned in the Post's caption, without preceeding @."""
if not self.caption:
return []
# This regular expression is from jStassen, adjusted to use Python's \w to support Unicode
# http://bl... | [
"List",
"of",
"all",
"lowercased",
"profiles",
"that",
"are",
"mentioned",
"in",
"the",
"Post",
"s",
"caption",
"without",
"preceeding"
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L246-L253 | [
"def",
"caption_mentions",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"if",
"not",
"self",
".",
"caption",
":",
"return",
"[",
"]",
"# This regular expression is from jStassen, adjusted to use Python's \\w to support Unicode",
"# http://blog.jstassen.com/2016/03/... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.tagged_users | List of all lowercased users that are tagged in the Post. | instaloader/structures.py | def tagged_users(self) -> List[str]:
"""List of all lowercased users that are tagged in the Post."""
try:
return [edge['node']['user']['username'].lower() for edge in self._field('edge_media_to_tagged_user',
... | def tagged_users(self) -> List[str]:
"""List of all lowercased users that are tagged in the Post."""
try:
return [edge['node']['user']['username'].lower() for edge in self._field('edge_media_to_tagged_user',
... | [
"List",
"of",
"all",
"lowercased",
"users",
"that",
"are",
"tagged",
"in",
"the",
"Post",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L256-L262 | [
"def",
"tagged_users",
"(",
"self",
")",
"->",
"List",
"[",
"str",
"]",
":",
"try",
":",
"return",
"[",
"edge",
"[",
"'node'",
"]",
"[",
"'user'",
"]",
"[",
"'username'",
"]",
".",
"lower",
"(",
")",
"for",
"edge",
"in",
"self",
".",
"_field",
"(... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.viewer_has_liked | Whether the viewer has liked the post, or None if not logged in. | instaloader/structures.py | def viewer_has_liked(self) -> Optional[bool]:
"""Whether the viewer has liked the post, or None if not logged in."""
if not self._context.is_logged_in:
return None
if 'likes' in self._node and 'viewer_has_liked' in self._node['likes']:
return self._node['likes']['viewer_h... | def viewer_has_liked(self) -> Optional[bool]:
"""Whether the viewer has liked the post, or None if not logged in."""
if not self._context.is_logged_in:
return None
if 'likes' in self._node and 'viewer_has_liked' in self._node['likes']:
return self._node['likes']['viewer_h... | [
"Whether",
"the",
"viewer",
"has",
"liked",
"the",
"post",
"or",
"None",
"if",
"not",
"logged",
"in",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L276-L282 | [
"def",
"viewer_has_liked",
"(",
"self",
")",
"->",
"Optional",
"[",
"bool",
"]",
":",
"if",
"not",
"self",
".",
"_context",
".",
"is_logged_in",
":",
"return",
"None",
"if",
"'likes'",
"in",
"self",
".",
"_node",
"and",
"'viewer_has_liked'",
"in",
"self",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.get_comments | r"""Iterate over all comments of the post.
Each comment is represented by a PostComment namedtuple with fields text (string), created_at (datetime),
id (int), owner (:class:`Profile`) and answers (:class:`~typing.Iterator`\ [:class:`PostCommentAnswer`])
if available. | instaloader/structures.py | def get_comments(self) -> Iterator[PostComment]:
r"""Iterate over all comments of the post.
Each comment is represented by a PostComment namedtuple with fields text (string), created_at (datetime),
id (int), owner (:class:`Profile`) and answers (:class:`~typing.Iterator`\ [:class:`PostCommentAn... | def get_comments(self) -> Iterator[PostComment]:
r"""Iterate over all comments of the post.
Each comment is represented by a PostComment namedtuple with fields text (string), created_at (datetime),
id (int), owner (:class:`Profile`) and answers (:class:`~typing.Iterator`\ [:class:`PostCommentAn... | [
"r",
"Iterate",
"over",
"all",
"comments",
"of",
"the",
"post",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L297-L356 | [
"def",
"get_comments",
"(",
"self",
")",
"->",
"Iterator",
"[",
"PostComment",
"]",
":",
"def",
"_postcommentanswer",
"(",
"node",
")",
":",
"return",
"PostCommentAnswer",
"(",
"id",
"=",
"int",
"(",
"node",
"[",
"'id'",
"]",
")",
",",
"created_at_utc",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.get_likes | Iterate over all likes of the post. A :class:`Profile` instance of each likee is yielded. | instaloader/structures.py | def get_likes(self) -> Iterator['Profile']:
"""Iterate over all likes of the post. A :class:`Profile` instance of each likee is yielded."""
if self.likes == 0:
# Avoid doing additional requests if there are no comments
return
likes_edges = self._field('edge_media_preview_... | def get_likes(self) -> Iterator['Profile']:
"""Iterate over all likes of the post. A :class:`Profile` instance of each likee is yielded."""
if self.likes == 0:
# Avoid doing additional requests if there are no comments
return
likes_edges = self._field('edge_media_preview_... | [
"Iterate",
"over",
"all",
"likes",
"of",
"the",
"post",
".",
"A",
":",
"class",
":",
"Profile",
"instance",
"of",
"each",
"likee",
"is",
"yielded",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L358-L372 | [
"def",
"get_likes",
"(",
"self",
")",
"->",
"Iterator",
"[",
"'Profile'",
"]",
":",
"if",
"self",
".",
"likes",
"==",
"0",
":",
"# Avoid doing additional requests if there are no comments",
"return",
"likes_edges",
"=",
"self",
".",
"_field",
"(",
"'edge_media_pre... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Post.location | If the Post has a location, returns PostLocation namedtuple with fields 'id', 'lat' and 'lng' and 'name'. | instaloader/structures.py | def location(self) -> Optional[PostLocation]:
"""If the Post has a location, returns PostLocation namedtuple with fields 'id', 'lat' and 'lng' and 'name'."""
loc = self._field("location")
if self._location or not loc:
return self._location
location_id = int(loc['id'])
... | def location(self) -> Optional[PostLocation]:
"""If the Post has a location, returns PostLocation namedtuple with fields 'id', 'lat' and 'lng' and 'name'."""
loc = self._field("location")
if self._location or not loc:
return self._location
location_id = int(loc['id'])
... | [
"If",
"the",
"Post",
"has",
"a",
"location",
"returns",
"PostLocation",
"namedtuple",
"with",
"fields",
"id",
"lat",
"and",
"lng",
"and",
"name",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L375-L386 | [
"def",
"location",
"(",
"self",
")",
"->",
"Optional",
"[",
"PostLocation",
"]",
":",
"loc",
"=",
"self",
".",
"_field",
"(",
"\"location\"",
")",
"if",
"self",
".",
"_location",
"or",
"not",
"loc",
":",
"return",
"self",
".",
"_location",
"location_id",... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Profile.from_username | Create a Profile instance from a given username, raise exception if it does not exist.
See also :meth:`Instaloader.check_profile_id`.
:param context: :attr:`Instaloader.context`
:param username: Username
:raises: :class:`ProfileNotExistsException` | instaloader/structures.py | def from_username(cls, context: InstaloaderContext, username: str):
"""Create a Profile instance from a given username, raise exception if it does not exist.
See also :meth:`Instaloader.check_profile_id`.
:param context: :attr:`Instaloader.context`
:param username: Username
:ra... | def from_username(cls, context: InstaloaderContext, username: str):
"""Create a Profile instance from a given username, raise exception if it does not exist.
See also :meth:`Instaloader.check_profile_id`.
:param context: :attr:`Instaloader.context`
:param username: Username
:ra... | [
"Create",
"a",
"Profile",
"instance",
"from",
"a",
"given",
"username",
"raise",
"exception",
"if",
"it",
"does",
"not",
"exist",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L428-L440 | [
"def",
"from_username",
"(",
"cls",
",",
"context",
":",
"InstaloaderContext",
",",
"username",
":",
"str",
")",
":",
"# pylint:disable=protected-access",
"profile",
"=",
"cls",
"(",
"context",
",",
"{",
"'username'",
":",
"username",
".",
"lower",
"(",
")",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Profile.from_id | Create a Profile instance from a given userid. If possible, use :meth:`Profile.from_username`
or constructor directly rather than this method, since it requires more requests.
:param context: :attr:`Instaloader.context`
:param profile_id: userid
:raises: :class:`ProfileNotExistsExceptio... | instaloader/structures.py | def from_id(cls, context: InstaloaderContext, profile_id: int):
"""Create a Profile instance from a given userid. If possible, use :meth:`Profile.from_username`
or constructor directly rather than this method, since it requires more requests.
:param context: :attr:`Instaloader.context`
... | def from_id(cls, context: InstaloaderContext, profile_id: int):
"""Create a Profile instance from a given userid. If possible, use :meth:`Profile.from_username`
or constructor directly rather than this method, since it requires more requests.
:param context: :attr:`Instaloader.context`
... | [
"Create",
"a",
"Profile",
"instance",
"from",
"a",
"given",
"userid",
".",
"If",
"possible",
"use",
":",
"meth",
":",
"Profile",
".",
"from_username",
"or",
"constructor",
"directly",
"rather",
"than",
"this",
"method",
"since",
"it",
"requires",
"more",
"re... | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L443-L467 | [
"def",
"from_id",
"(",
"cls",
",",
"context",
":",
"InstaloaderContext",
",",
"profile_id",
":",
"int",
")",
":",
"if",
"profile_id",
"in",
"context",
".",
"profile_id_cache",
":",
"return",
"context",
".",
"profile_id_cache",
"[",
"profile_id",
"]",
"data",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Profile.profile_pic_url | Return URL of profile picture. If logged in, the HD version is returned, otherwise a lower-quality version.
.. versionadded:: 4.0.3
.. versionchanged:: 4.2.1
Require being logged in for HD version (as required by Instagram). | instaloader/structures.py | def profile_pic_url(self) -> str:
"""Return URL of profile picture. If logged in, the HD version is returned, otherwise a lower-quality version.
.. versionadded:: 4.0.3
.. versionchanged:: 4.2.1
Require being logged in for HD version (as required by Instagram)."""
if self._c... | def profile_pic_url(self) -> str:
"""Return URL of profile picture. If logged in, the HD version is returned, otherwise a lower-quality version.
.. versionadded:: 4.0.3
.. versionchanged:: 4.2.1
Require being logged in for HD version (as required by Instagram)."""
if self._c... | [
"Return",
"URL",
"of",
"profile",
"picture",
".",
"If",
"logged",
"in",
"the",
"HD",
"version",
"is",
"returned",
"otherwise",
"a",
"lower",
"-",
"quality",
"version",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L625-L639 | [
"def",
"profile_pic_url",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"_context",
".",
"is_logged_in",
":",
"try",
":",
"return",
"self",
".",
"_iphone_struct",
"[",
"'hd_profile_pic_url_info'",
"]",
"[",
"'url'",
"]",
"except",
"(",
"InstaloaderE... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Profile.get_posts | Retrieve all posts from a profile. | instaloader/structures.py | def get_posts(self) -> Iterator[Post]:
"""Retrieve all posts from a profile."""
self._obtain_metadata()
yield from (Post(self._context, node, self) for node in
self._context.graphql_node_list("472f257a40c653c64c666ce877d59d2b",
... | def get_posts(self) -> Iterator[Post]:
"""Retrieve all posts from a profile."""
self._obtain_metadata()
yield from (Post(self._context, node, self) for node in
self._context.graphql_node_list("472f257a40c653c64c666ce877d59d2b",
... | [
"Retrieve",
"all",
"posts",
"from",
"a",
"profile",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L647-L656 | [
"def",
"get_posts",
"(",
"self",
")",
"->",
"Iterator",
"[",
"Post",
"]",
":",
"self",
".",
"_obtain_metadata",
"(",
")",
"yield",
"from",
"(",
"Post",
"(",
"self",
".",
"_context",
",",
"node",
",",
"self",
")",
"for",
"node",
"in",
"self",
".",
"... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Profile.get_tagged_posts | Retrieve all posts where a profile is tagged.
.. versionadded:: 4.0.7 | instaloader/structures.py | def get_tagged_posts(self) -> Iterator[Post]:
"""Retrieve all posts where a profile is tagged.
.. versionadded:: 4.0.7"""
self._obtain_metadata()
yield from (Post(self._context, node, self if int(node['owner']['id']) == self.userid else None) for node in
self._contex... | def get_tagged_posts(self) -> Iterator[Post]:
"""Retrieve all posts where a profile is tagged.
.. versionadded:: 4.0.7"""
self._obtain_metadata()
yield from (Post(self._context, node, self if int(node['owner']['id']) == self.userid else None) for node in
self._contex... | [
"Retrieve",
"all",
"posts",
"where",
"a",
"profile",
"is",
"tagged",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L673-L683 | [
"def",
"get_tagged_posts",
"(",
"self",
")",
"->",
"Iterator",
"[",
"Post",
"]",
":",
"self",
".",
"_obtain_metadata",
"(",
")",
"yield",
"from",
"(",
"Post",
"(",
"self",
".",
"_context",
",",
"node",
",",
"self",
"if",
"int",
"(",
"node",
"[",
"'ow... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Profile.get_followers | Retrieve list of followers of given profile.
To use this, one needs to be logged in and private profiles has to be followed. | instaloader/structures.py | def get_followers(self) -> Iterator['Profile']:
"""
Retrieve list of followers of given profile.
To use this, one needs to be logged in and private profiles has to be followed.
"""
if not self._context.is_logged_in:
raise LoginRequiredException("--login required to ge... | def get_followers(self) -> Iterator['Profile']:
"""
Retrieve list of followers of given profile.
To use this, one needs to be logged in and private profiles has to be followed.
"""
if not self._context.is_logged_in:
raise LoginRequiredException("--login required to ge... | [
"Retrieve",
"list",
"of",
"followers",
"of",
"given",
"profile",
".",
"To",
"use",
"this",
"one",
"needs",
"to",
"be",
"logged",
"in",
"and",
"private",
"profiles",
"has",
"to",
"be",
"followed",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L685-L698 | [
"def",
"get_followers",
"(",
"self",
")",
"->",
"Iterator",
"[",
"'Profile'",
"]",
":",
"if",
"not",
"self",
".",
"_context",
".",
"is_logged_in",
":",
"raise",
"LoginRequiredException",
"(",
"\"--login required to get a profile's followers.\"",
")",
"self",
".",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | StoryItem.owner_profile | :class:`Profile` instance of the story item's owner. | instaloader/structures.py | def owner_profile(self) -> Profile:
""":class:`Profile` instance of the story item's owner."""
if not self._owner_profile:
self._owner_profile = Profile.from_id(self._context, self._node['owner']['id'])
return self._owner_profile | def owner_profile(self) -> Profile:
""":class:`Profile` instance of the story item's owner."""
if not self._owner_profile:
self._owner_profile = Profile.from_id(self._context, self._node['owner']['id'])
return self._owner_profile | [
":",
"class",
":",
"Profile",
"instance",
"of",
"the",
"story",
"item",
"s",
"owner",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L761-L765 | [
"def",
"owner_profile",
"(",
"self",
")",
"->",
"Profile",
":",
"if",
"not",
"self",
".",
"_owner_profile",
":",
"self",
".",
"_owner_profile",
"=",
"Profile",
".",
"from_id",
"(",
"self",
".",
"_context",
",",
"self",
".",
"_node",
"[",
"'owner'",
"]",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Story.unique_id | This ID only equals amongst :class:`Story` instances which have the same owner and the same set of
:class:`StoryItem`. For all other :class:`Story` instances this ID is different. | instaloader/structures.py | def unique_id(self) -> str:
"""
This ID only equals amongst :class:`Story` instances which have the same owner and the same set of
:class:`StoryItem`. For all other :class:`Story` instances this ID is different.
"""
if not self._unique_id:
id_list = [item.mediaid for ... | def unique_id(self) -> str:
"""
This ID only equals amongst :class:`Story` instances which have the same owner and the same set of
:class:`StoryItem`. For all other :class:`Story` instances this ID is different.
"""
if not self._unique_id:
id_list = [item.mediaid for ... | [
"This",
"ID",
"only",
"equals",
"amongst",
":",
"class",
":",
"Story",
"instances",
"which",
"have",
"the",
"same",
"owner",
"and",
"the",
"same",
"set",
"of",
":",
"class",
":",
"StoryItem",
".",
"For",
"all",
"other",
":",
"class",
":",
"Story",
"ins... | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L868-L877 | [
"def",
"unique_id",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"_unique_id",
":",
"id_list",
"=",
"[",
"item",
".",
"mediaid",
"for",
"item",
"in",
"self",
".",
"get_items",
"(",
")",
"]",
"id_list",
".",
"sort",
"(",
")",
"self"... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Story.last_seen_local | Timestamp when the story has last been watched or None (local time zone). | instaloader/structures.py | def last_seen_local(self) -> Optional[datetime]:
"""Timestamp when the story has last been watched or None (local time zone)."""
if self._node['seen']:
return datetime.fromtimestamp(self._node['seen']) | def last_seen_local(self) -> Optional[datetime]:
"""Timestamp when the story has last been watched or None (local time zone)."""
if self._node['seen']:
return datetime.fromtimestamp(self._node['seen']) | [
"Timestamp",
"when",
"the",
"story",
"has",
"last",
"been",
"watched",
"or",
"None",
"(",
"local",
"time",
"zone",
")",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L880-L883 | [
"def",
"last_seen_local",
"(",
"self",
")",
"->",
"Optional",
"[",
"datetime",
"]",
":",
"if",
"self",
".",
"_node",
"[",
"'seen'",
"]",
":",
"return",
"datetime",
".",
"fromtimestamp",
"(",
"self",
".",
"_node",
"[",
"'seen'",
"]",
")"
] | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Story.last_seen_utc | Timestamp when the story has last been watched or None (UTC). | instaloader/structures.py | def last_seen_utc(self) -> Optional[datetime]:
"""Timestamp when the story has last been watched or None (UTC)."""
if self._node['seen']:
return datetime.utcfromtimestamp(self._node['seen']) | def last_seen_utc(self) -> Optional[datetime]:
"""Timestamp when the story has last been watched or None (UTC)."""
if self._node['seen']:
return datetime.utcfromtimestamp(self._node['seen']) | [
"Timestamp",
"when",
"the",
"story",
"has",
"last",
"been",
"watched",
"or",
"None",
"(",
"UTC",
")",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L886-L889 | [
"def",
"last_seen_utc",
"(",
"self",
")",
"->",
"Optional",
"[",
"datetime",
"]",
":",
"if",
"self",
".",
"_node",
"[",
"'seen'",
"]",
":",
"return",
"datetime",
".",
"utcfromtimestamp",
"(",
"self",
".",
"_node",
"[",
"'seen'",
"]",
")"
] | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Story.get_items | Retrieve all items from a story. | instaloader/structures.py | def get_items(self) -> Iterator[StoryItem]:
"""Retrieve all items from a story."""
yield from (StoryItem(self._context, item, self.owner_profile) for item in reversed(self._node['items'])) | def get_items(self) -> Iterator[StoryItem]:
"""Retrieve all items from a story."""
yield from (StoryItem(self._context, item, self.owner_profile) for item in reversed(self._node['items'])) | [
"Retrieve",
"all",
"items",
"from",
"a",
"story",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L923-L925 | [
"def",
"get_items",
"(",
"self",
")",
"->",
"Iterator",
"[",
"StoryItem",
"]",
":",
"yield",
"from",
"(",
"StoryItem",
"(",
"self",
".",
"_context",
",",
"item",
",",
"self",
".",
"owner_profile",
")",
"for",
"item",
"in",
"reversed",
"(",
"self",
".",... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | Highlight.get_items | Retrieve all associated highlight items. | instaloader/structures.py | def get_items(self) -> Iterator[StoryItem]:
"""Retrieve all associated highlight items."""
self._fetch_items()
yield from (StoryItem(self._context, item, self.owner_profile) for item in self._items) | def get_items(self) -> Iterator[StoryItem]:
"""Retrieve all associated highlight items."""
self._fetch_items()
yield from (StoryItem(self._context, item, self.owner_profile) for item in self._items) | [
"Retrieve",
"all",
"associated",
"highlight",
"items",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/structures.py#L999-L1002 | [
"def",
"get_items",
"(",
"self",
")",
"->",
"Iterator",
"[",
"StoryItem",
"]",
":",
"self",
".",
"_fetch_items",
"(",
")",
"yield",
"from",
"(",
"StoryItem",
"(",
"self",
".",
"_context",
",",
"item",
",",
"self",
".",
"owner_profile",
")",
"for",
"ite... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | copy_session | Duplicates a requests.Session. | instaloader/instaloadercontext.py | def copy_session(session: requests.Session) -> requests.Session:
"""Duplicates a requests.Session."""
new = requests.Session()
new.cookies = requests.utils.cookiejar_from_dict(requests.utils.dict_from_cookiejar(session.cookies))
new.headers = session.headers.copy()
return new | def copy_session(session: requests.Session) -> requests.Session:
"""Duplicates a requests.Session."""
new = requests.Session()
new.cookies = requests.utils.cookiejar_from_dict(requests.utils.dict_from_cookiejar(session.cookies))
new.headers = session.headers.copy()
return new | [
"Duplicates",
"a",
"requests",
".",
"Session",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L21-L26 | [
"def",
"copy_session",
"(",
"session",
":",
"requests",
".",
"Session",
")",
"->",
"requests",
".",
"Session",
":",
"new",
"=",
"requests",
".",
"Session",
"(",
")",
"new",
".",
"cookies",
"=",
"requests",
".",
"utils",
".",
"cookiejar_from_dict",
"(",
"... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.log | Log a message to stdout that can be suppressed with --quiet. | instaloader/instaloadercontext.py | def log(self, *msg, sep='', end='\n', flush=False):
"""Log a message to stdout that can be suppressed with --quiet."""
if not self.quiet:
print(*msg, sep=sep, end=end, flush=flush) | def log(self, *msg, sep='', end='\n', flush=False):
"""Log a message to stdout that can be suppressed with --quiet."""
if not self.quiet:
print(*msg, sep=sep, end=end, flush=flush) | [
"Log",
"a",
"message",
"to",
"stdout",
"that",
"can",
"be",
"suppressed",
"with",
"--",
"quiet",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L93-L96 | [
"def",
"log",
"(",
"self",
",",
"*",
"msg",
",",
"sep",
"=",
"''",
",",
"end",
"=",
"'\\n'",
",",
"flush",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"quiet",
":",
"print",
"(",
"*",
"msg",
",",
"sep",
"=",
"sep",
",",
"end",
"=",
"e... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.error | Log a non-fatal error message to stderr, which is repeated at program termination.
:param msg: Message to be printed.
:param repeat_at_end: Set to false if the message should be printed, but not repeated at program termination. | instaloader/instaloadercontext.py | def error(self, msg, repeat_at_end=True):
"""Log a non-fatal error message to stderr, which is repeated at program termination.
:param msg: Message to be printed.
:param repeat_at_end: Set to false if the message should be printed, but not repeated at program termination."""
print(msg, ... | def error(self, msg, repeat_at_end=True):
"""Log a non-fatal error message to stderr, which is repeated at program termination.
:param msg: Message to be printed.
:param repeat_at_end: Set to false if the message should be printed, but not repeated at program termination."""
print(msg, ... | [
"Log",
"a",
"non",
"-",
"fatal",
"error",
"message",
"to",
"stderr",
"which",
"is",
"repeated",
"at",
"program",
"termination",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L98-L105 | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"repeat_at_end",
"=",
"True",
")",
":",
"print",
"(",
"msg",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"if",
"repeat_at_end",
":",
"self",
".",
"error_log",
".",
"append",
"(",
"msg",
")"
] | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.close | Print error log and close session | instaloader/instaloadercontext.py | def close(self):
"""Print error log and close session"""
if self.error_log and not self.quiet:
print("\nErrors occured:", file=sys.stderr)
for err in self.error_log:
print(err, file=sys.stderr)
self._session.close() | def close(self):
"""Print error log and close session"""
if self.error_log and not self.quiet:
print("\nErrors occured:", file=sys.stderr)
for err in self.error_log:
print(err, file=sys.stderr)
self._session.close() | [
"Print",
"error",
"log",
"and",
"close",
"session"
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L107-L113 | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"error_log",
"and",
"not",
"self",
".",
"quiet",
":",
"print",
"(",
"\"\\nErrors occured:\"",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"for",
"err",
"in",
"self",
".",
"error_log",
":",
"p... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.error_catcher | Context manager to catch, print and record InstaloaderExceptions.
:param extra_info: String to prefix error message with. | instaloader/instaloadercontext.py | def error_catcher(self, extra_info: Optional[str] = None):
"""
Context manager to catch, print and record InstaloaderExceptions.
:param extra_info: String to prefix error message with."""
try:
yield
except InstaloaderException as err:
if extra_info:
... | def error_catcher(self, extra_info: Optional[str] = None):
"""
Context manager to catch, print and record InstaloaderExceptions.
:param extra_info: String to prefix error message with."""
try:
yield
except InstaloaderException as err:
if extra_info:
... | [
"Context",
"manager",
"to",
"catch",
"print",
"and",
"record",
"InstaloaderExceptions",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L116-L129 | [
"def",
"error_catcher",
"(",
"self",
",",
"extra_info",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
":",
"try",
":",
"yield",
"except",
"InstaloaderException",
"as",
"err",
":",
"if",
"extra_info",
":",
"self",
".",
"error",
"(",
"'{}: {}'",
".",... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext._default_http_header | Returns default HTTP header we use for requests. | instaloader/instaloadercontext.py | def _default_http_header(self, empty_session_only: bool = False) -> Dict[str, str]:
"""Returns default HTTP header we use for requests."""
header = {'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive',
... | def _default_http_header(self, empty_session_only: bool = False) -> Dict[str, str]:
"""Returns default HTTP header we use for requests."""
header = {'Accept-Encoding': 'gzip, deflate',
'Accept-Language': 'en-US,en;q=0.8',
'Connection': 'keep-alive',
... | [
"Returns",
"default",
"HTTP",
"header",
"we",
"use",
"for",
"requests",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L131-L149 | [
"def",
"_default_http_header",
"(",
"self",
",",
"empty_session_only",
":",
"bool",
"=",
"False",
")",
"->",
"Dict",
"[",
"str",
",",
"str",
"]",
":",
"header",
"=",
"{",
"'Accept-Encoding'",
":",
"'gzip, deflate'",
",",
"'Accept-Language'",
":",
"'en-US,en;q=... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.get_anonymous_session | Returns our default anonymous requests.Session object. | instaloader/instaloadercontext.py | def get_anonymous_session(self) -> requests.Session:
"""Returns our default anonymous requests.Session object."""
session = requests.Session()
session.cookies.update({'sessionid': '', 'mid': '', 'ig_pr': '1',
'ig_vw': '1920', 'csrftoken': '',
... | def get_anonymous_session(self) -> requests.Session:
"""Returns our default anonymous requests.Session object."""
session = requests.Session()
session.cookies.update({'sessionid': '', 'mid': '', 'ig_pr': '1',
'ig_vw': '1920', 'csrftoken': '',
... | [
"Returns",
"our",
"default",
"anonymous",
"requests",
".",
"Session",
"object",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L151-L158 | [
"def",
"get_anonymous_session",
"(",
"self",
")",
"->",
"requests",
".",
"Session",
":",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"session",
".",
"cookies",
".",
"update",
"(",
"{",
"'sessionid'",
":",
"''",
",",
"'mid'",
":",
"''",
",",
"... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.save_session_to_file | Not meant to be used directly, use :meth:`Instaloader.save_session_to_file`. | instaloader/instaloadercontext.py | def save_session_to_file(self, sessionfile):
"""Not meant to be used directly, use :meth:`Instaloader.save_session_to_file`."""
pickle.dump(requests.utils.dict_from_cookiejar(self._session.cookies), sessionfile) | def save_session_to_file(self, sessionfile):
"""Not meant to be used directly, use :meth:`Instaloader.save_session_to_file`."""
pickle.dump(requests.utils.dict_from_cookiejar(self._session.cookies), sessionfile) | [
"Not",
"meant",
"to",
"be",
"used",
"directly",
"use",
":",
"meth",
":",
"Instaloader",
".",
"save_session_to_file",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L160-L162 | [
"def",
"save_session_to_file",
"(",
"self",
",",
"sessionfile",
")",
":",
"pickle",
".",
"dump",
"(",
"requests",
".",
"utils",
".",
"dict_from_cookiejar",
"(",
"self",
".",
"_session",
".",
"cookies",
")",
",",
"sessionfile",
")"
] | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.load_session_from_file | Not meant to be used directly, use :meth:`Instaloader.load_session_from_file`. | instaloader/instaloadercontext.py | def load_session_from_file(self, username, sessionfile):
"""Not meant to be used directly, use :meth:`Instaloader.load_session_from_file`."""
session = requests.Session()
session.cookies = requests.utils.cookiejar_from_dict(pickle.load(sessionfile))
session.headers.update(self._default_h... | def load_session_from_file(self, username, sessionfile):
"""Not meant to be used directly, use :meth:`Instaloader.load_session_from_file`."""
session = requests.Session()
session.cookies = requests.utils.cookiejar_from_dict(pickle.load(sessionfile))
session.headers.update(self._default_h... | [
"Not",
"meant",
"to",
"be",
"used",
"directly",
"use",
":",
"meth",
":",
"Instaloader",
".",
"load_session_from_file",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L164-L171 | [
"def",
"load_session_from_file",
"(",
"self",
",",
"username",
",",
"sessionfile",
")",
":",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"session",
".",
"cookies",
"=",
"requests",
".",
"utils",
".",
"cookiejar_from_dict",
"(",
"pickle",
".",
"load... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.login | Not meant to be used directly, use :meth:`Instaloader.login`.
:raises InvalidArgumentException: If the provided username does not exist.
:raises BadCredentialsException: If the provided password is wrong.
:raises ConnectionException: If connection to Instagram failed.
:raises TwoFactorA... | instaloader/instaloadercontext.py | def login(self, user, passwd):
"""Not meant to be used directly, use :meth:`Instaloader.login`.
:raises InvalidArgumentException: If the provided username does not exist.
:raises BadCredentialsException: If the provided password is wrong.
:raises ConnectionException: If connection to In... | def login(self, user, passwd):
"""Not meant to be used directly, use :meth:`Instaloader.login`.
:raises InvalidArgumentException: If the provided username does not exist.
:raises BadCredentialsException: If the provided password is wrong.
:raises ConnectionException: If connection to In... | [
"Not",
"meant",
"to",
"be",
"used",
"directly",
"use",
":",
"meth",
":",
"Instaloader",
".",
"login",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L178-L235 | [
"def",
"login",
"(",
"self",
",",
"user",
",",
"passwd",
")",
":",
"import",
"http",
".",
"client",
"# pylint:disable=protected-access",
"http",
".",
"client",
".",
"_MAXHEADERS",
"=",
"200",
"session",
"=",
"requests",
".",
"Session",
"(",
")",
"session",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.two_factor_login | Second step of login if 2FA is enabled.
Not meant to be used directly, use :meth:`Instaloader.two_factor_login`.
:raises InvalidArgumentException: No two-factor authentication pending.
:raises BadCredentialsException: 2FA verification code invalid.
.. versionadded:: 4.2 | instaloader/instaloadercontext.py | def two_factor_login(self, two_factor_code):
"""Second step of login if 2FA is enabled.
Not meant to be used directly, use :meth:`Instaloader.two_factor_login`.
:raises InvalidArgumentException: No two-factor authentication pending.
:raises BadCredentialsException: 2FA verification code... | def two_factor_login(self, two_factor_code):
"""Second step of login if 2FA is enabled.
Not meant to be used directly, use :meth:`Instaloader.two_factor_login`.
:raises InvalidArgumentException: No two-factor authentication pending.
:raises BadCredentialsException: 2FA verification code... | [
"Second",
"step",
"of",
"login",
"if",
"2FA",
"is",
"enabled",
".",
"Not",
"meant",
"to",
"be",
"used",
"directly",
"use",
":",
"meth",
":",
"Instaloader",
".",
"two_factor_login",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L237-L261 | [
"def",
"two_factor_login",
"(",
"self",
",",
"two_factor_code",
")",
":",
"if",
"not",
"self",
".",
"two_factor_auth_pending",
":",
"raise",
"InvalidArgumentException",
"(",
"\"No two-factor authentication pending.\"",
")",
"(",
"session",
",",
"user",
",",
"two_facto... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext._dump_query_timestamps | Output the number of GraphQL queries grouped by their query_hash within the last time. | instaloader/instaloadercontext.py | def _dump_query_timestamps(self, current_time: float):
"""Output the number of GraphQL queries grouped by their query_hash within the last time."""
windows = [10, 11, 15, 20, 30, 60]
print("GraphQL requests:", file=sys.stderr)
for query_hash, times in self._graphql_query_timestamps.items... | def _dump_query_timestamps(self, current_time: float):
"""Output the number of GraphQL queries grouped by their query_hash within the last time."""
windows = [10, 11, 15, 20, 30, 60]
print("GraphQL requests:", file=sys.stderr)
for query_hash, times in self._graphql_query_timestamps.items... | [
"Output",
"the",
"number",
"of",
"GraphQL",
"queries",
"grouped",
"by",
"their",
"query_hash",
"within",
"the",
"last",
"time",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L268-L276 | [
"def",
"_dump_query_timestamps",
"(",
"self",
",",
"current_time",
":",
"float",
")",
":",
"windows",
"=",
"[",
"10",
",",
"11",
",",
"15",
",",
"20",
",",
"30",
",",
"60",
"]",
"print",
"(",
"\"GraphQL requests:\"",
",",
"file",
"=",
"sys",
".",
"st... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext._graphql_request_count_per_sliding_window | Return how many GraphQL requests can be done within the sliding window. | instaloader/instaloadercontext.py | def _graphql_request_count_per_sliding_window(self, query_hash: str) -> int:
"""Return how many GraphQL requests can be done within the sliding window."""
if self.is_logged_in:
max_reqs = {'1cb6ec562846122743b61e492c85999f': 20, '33ba35852cb50da46f5b5e889df7d159': 20}
else:
... | def _graphql_request_count_per_sliding_window(self, query_hash: str) -> int:
"""Return how many GraphQL requests can be done within the sliding window."""
if self.is_logged_in:
max_reqs = {'1cb6ec562846122743b61e492c85999f': 20, '33ba35852cb50da46f5b5e889df7d159': 20}
else:
... | [
"Return",
"how",
"many",
"GraphQL",
"requests",
"can",
"be",
"done",
"within",
"the",
"sliding",
"window",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L278-L284 | [
"def",
"_graphql_request_count_per_sliding_window",
"(",
"self",
",",
"query_hash",
":",
"str",
")",
"->",
"int",
":",
"if",
"self",
".",
"is_logged_in",
":",
"max_reqs",
"=",
"{",
"'1cb6ec562846122743b61e492c85999f'",
":",
"20",
",",
"'33ba35852cb50da46f5b5e889df7d15... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext._graphql_query_waittime | Calculate time needed to wait before GraphQL query can be executed. | instaloader/instaloadercontext.py | def _graphql_query_waittime(self, query_hash: str, current_time: float, untracked_queries: bool = False) -> int:
"""Calculate time needed to wait before GraphQL query can be executed."""
sliding_window = 660
if query_hash not in self._graphql_query_timestamps:
self._graphql_query_tim... | def _graphql_query_waittime(self, query_hash: str, current_time: float, untracked_queries: bool = False) -> int:
"""Calculate time needed to wait before GraphQL query can be executed."""
sliding_window = 660
if query_hash not in self._graphql_query_timestamps:
self._graphql_query_tim... | [
"Calculate",
"time",
"needed",
"to",
"wait",
"before",
"GraphQL",
"query",
"can",
"be",
"executed",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L286-L301 | [
"def",
"_graphql_query_waittime",
"(",
"self",
",",
"query_hash",
":",
"str",
",",
"current_time",
":",
"float",
",",
"untracked_queries",
":",
"bool",
"=",
"False",
")",
"->",
"int",
":",
"sliding_window",
"=",
"660",
"if",
"query_hash",
"not",
"in",
"self"... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext._ratecontrol_graphql_query | Called before a GraphQL query is made in order to stay within Instagram's rate limits.
:param query_hash: The query_hash parameter of the query.
:param untracked_queries: True, if 429 has been returned to apply 429 logic. | instaloader/instaloadercontext.py | def _ratecontrol_graphql_query(self, query_hash: str, untracked_queries: bool = False):
"""Called before a GraphQL query is made in order to stay within Instagram's rate limits.
:param query_hash: The query_hash parameter of the query.
:param untracked_queries: True, if 429 has been returned to... | def _ratecontrol_graphql_query(self, query_hash: str, untracked_queries: bool = False):
"""Called before a GraphQL query is made in order to stay within Instagram's rate limits.
:param query_hash: The query_hash parameter of the query.
:param untracked_queries: True, if 429 has been returned to... | [
"Called",
"before",
"a",
"GraphQL",
"query",
"is",
"made",
"in",
"order",
"to",
"stay",
"within",
"Instagram",
"s",
"rate",
"limits",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L303-L332 | [
"def",
"_ratecontrol_graphql_query",
"(",
"self",
",",
"query_hash",
":",
"str",
",",
"untracked_queries",
":",
"bool",
"=",
"False",
")",
":",
"if",
"not",
"untracked_queries",
":",
"waittime",
"=",
"self",
".",
"_graphql_query_waittime",
"(",
"query_hash",
","... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.get_json | JSON request to Instagram.
:param path: URL, relative to the given domain which defaults to www.instagram.com/
:param params: GET parameters
:param host: Domain part of the URL from where to download the requested JSON; defaults to www.instagram.com
:param session: Session to use, or No... | instaloader/instaloadercontext.py | def get_json(self, path: str, params: Dict[str, Any], host: str = 'www.instagram.com',
session: Optional[requests.Session] = None, _attempt=1) -> Dict[str, Any]:
"""JSON request to Instagram.
:param path: URL, relative to the given domain which defaults to www.instagram.com/
:p... | def get_json(self, path: str, params: Dict[str, Any], host: str = 'www.instagram.com',
session: Optional[requests.Session] = None, _attempt=1) -> Dict[str, Any]:
"""JSON request to Instagram.
:param path: URL, relative to the given domain which defaults to www.instagram.com/
:p... | [
"JSON",
"request",
"to",
"Instagram",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L334-L396 | [
"def",
"get_json",
"(",
"self",
",",
"path",
":",
"str",
",",
"params",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"host",
":",
"str",
"=",
"'www.instagram.com'",
",",
"session",
":",
"Optional",
"[",
"requests",
".",
"Session",
"]",
"=",
"None",... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.graphql_query | Do a GraphQL Query.
:param query_hash: Query identifying hash.
:param variables: Variables for the Query.
:param referer: HTTP Referer, or None.
:param rhx_gis: 'rhx_gis' variable as somewhere returned by Instagram, needed to 'sign' request
:return: The server's response diction... | instaloader/instaloadercontext.py | def graphql_query(self, query_hash: str, variables: Dict[str, Any],
referer: Optional[str] = None, rhx_gis: Optional[str] = None) -> Dict[str, Any]:
"""
Do a GraphQL Query.
:param query_hash: Query identifying hash.
:param variables: Variables for the Query.
... | def graphql_query(self, query_hash: str, variables: Dict[str, Any],
referer: Optional[str] = None, rhx_gis: Optional[str] = None) -> Dict[str, Any]:
"""
Do a GraphQL Query.
:param query_hash: Query identifying hash.
:param variables: Variables for the Query.
... | [
"Do",
"a",
"GraphQL",
"Query",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L398-L433 | [
"def",
"graphql_query",
"(",
"self",
",",
"query_hash",
":",
"str",
",",
"variables",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"referer",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"rhx_gis",
":",
"Optional",
"[",
"str",
"]",
"=",
"N... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.graphql_node_list | Retrieve a list of GraphQL nodes. | instaloader/instaloadercontext.py | def graphql_node_list(self, query_hash: str, query_variables: Dict[str, Any],
query_referer: Optional[str],
edge_extractor: Callable[[Dict[str, Any]], Dict[str, Any]],
rhx_gis: Optional[str] = None,
first_data: Optio... | def graphql_node_list(self, query_hash: str, query_variables: Dict[str, Any],
query_referer: Optional[str],
edge_extractor: Callable[[Dict[str, Any]], Dict[str, Any]],
rhx_gis: Optional[str] = None,
first_data: Optio... | [
"Retrieve",
"a",
"list",
"of",
"GraphQL",
"nodes",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L435-L464 | [
"def",
"graphql_node_list",
"(",
"self",
",",
"query_hash",
":",
"str",
",",
"query_variables",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"query_referer",
":",
"Optional",
"[",
"str",
"]",
",",
"edge_extractor",
":",
"Callable",
"[",
"[",
"Dict",
"[... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.get_iphone_json | JSON request to ``i.instagram.com``.
:param path: URL, relative to ``i.instagram.com/``
:param params: GET parameters
:return: Decoded response dictionary
:raises QueryReturnedBadRequestException: When the server responds with a 400.
:raises QueryReturnedNotFoundException: When ... | instaloader/instaloadercontext.py | def get_iphone_json(self, path: str, params: Dict[str, Any]) -> Dict[str, Any]:
"""JSON request to ``i.instagram.com``.
:param path: URL, relative to ``i.instagram.com/``
:param params: GET parameters
:return: Decoded response dictionary
:raises QueryReturnedBadRequestException:... | def get_iphone_json(self, path: str, params: Dict[str, Any]) -> Dict[str, Any]:
"""JSON request to ``i.instagram.com``.
:param path: URL, relative to ``i.instagram.com/``
:param params: GET parameters
:return: Decoded response dictionary
:raises QueryReturnedBadRequestException:... | [
"JSON",
"request",
"to",
"i",
".",
"instagram",
".",
"com",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L466-L482 | [
"def",
"get_iphone_json",
"(",
"self",
",",
"path",
":",
"str",
",",
"params",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"with",
"copy_session",
"(",
"self",
".",
"_session",
")",
"as",
"tempsess... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.write_raw | Write raw response data into a file.
.. versionadded:: 4.2.1 | instaloader/instaloadercontext.py | def write_raw(self, resp: Union[bytes, requests.Response], filename: str) -> None:
"""Write raw response data into a file.
.. versionadded:: 4.2.1"""
self.log(filename, end=' ', flush=True)
with open(filename, 'wb') as file:
if isinstance(resp, requests.Response):
... | def write_raw(self, resp: Union[bytes, requests.Response], filename: str) -> None:
"""Write raw response data into a file.
.. versionadded:: 4.2.1"""
self.log(filename, end=' ', flush=True)
with open(filename, 'wb') as file:
if isinstance(resp, requests.Response):
... | [
"Write",
"raw",
"response",
"data",
"into",
"a",
"file",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L484-L493 | [
"def",
"write_raw",
"(",
"self",
",",
"resp",
":",
"Union",
"[",
"bytes",
",",
"requests",
".",
"Response",
"]",
",",
"filename",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"log",
"(",
"filename",
",",
"end",
"=",
"' '",
",",
"flush",
"=",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.get_raw | Downloads a file anonymously.
:raises QueryReturnedNotFoundException: When the server responds with a 404.
:raises QueryReturnedForbiddenException: When the server responds with a 403.
:raises ConnectionException: When download failed.
.. versionadded:: 4.2.1 | instaloader/instaloadercontext.py | def get_raw(self, url: str, _attempt=1) -> requests.Response:
"""Downloads a file anonymously.
:raises QueryReturnedNotFoundException: When the server responds with a 404.
:raises QueryReturnedForbiddenException: When the server responds with a 403.
:raises ConnectionException: When dow... | def get_raw(self, url: str, _attempt=1) -> requests.Response:
"""Downloads a file anonymously.
:raises QueryReturnedNotFoundException: When the server responds with a 404.
:raises QueryReturnedForbiddenException: When the server responds with a 403.
:raises ConnectionException: When dow... | [
"Downloads",
"a",
"file",
"anonymously",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L495-L515 | [
"def",
"get_raw",
"(",
"self",
",",
"url",
":",
"str",
",",
"_attempt",
"=",
"1",
")",
"->",
"requests",
".",
"Response",
":",
"with",
"self",
".",
"get_anonymous_session",
"(",
")",
"as",
"anonymous_session",
":",
"resp",
"=",
"anonymous_session",
".",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.get_and_write_raw | Downloads and writes anonymously-requested raw data into a file.
:raises QueryReturnedNotFoundException: When the server responds with a 404.
:raises QueryReturnedForbiddenException: When the server responds with a 403.
:raises ConnectionException: When download repeatedly failed. | instaloader/instaloadercontext.py | def get_and_write_raw(self, url: str, filename: str) -> None:
"""Downloads and writes anonymously-requested raw data into a file.
:raises QueryReturnedNotFoundException: When the server responds with a 404.
:raises QueryReturnedForbiddenException: When the server responds with a 403.
:r... | def get_and_write_raw(self, url: str, filename: str) -> None:
"""Downloads and writes anonymously-requested raw data into a file.
:raises QueryReturnedNotFoundException: When the server responds with a 404.
:raises QueryReturnedForbiddenException: When the server responds with a 403.
:r... | [
"Downloads",
"and",
"writes",
"anonymously",
"-",
"requested",
"raw",
"data",
"into",
"a",
"file",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L517-L523 | [
"def",
"get_and_write_raw",
"(",
"self",
",",
"url",
":",
"str",
",",
"filename",
":",
"str",
")",
"->",
"None",
":",
"self",
".",
"write_raw",
"(",
"self",
".",
"get_raw",
"(",
"url",
")",
",",
"filename",
")"
] | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | InstaloaderContext.root_rhx_gis | rhx_gis string returned in the / query. | instaloader/instaloadercontext.py | def root_rhx_gis(self) -> Optional[str]:
"""rhx_gis string returned in the / query."""
if self.is_logged_in:
# At the moment, rhx_gis seems to be required for anonymous requests only. By returning None when logged
# in, we can save the root_rhx_gis lookup query.
retur... | def root_rhx_gis(self) -> Optional[str]:
"""rhx_gis string returned in the / query."""
if self.is_logged_in:
# At the moment, rhx_gis seems to be required for anonymous requests only. By returning None when logged
# in, we can save the root_rhx_gis lookup query.
retur... | [
"rhx_gis",
"string",
"returned",
"in",
"the",
"/",
"query",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloadercontext.py#L526-L534 | [
"def",
"root_rhx_gis",
"(",
"self",
")",
"->",
"Optional",
"[",
"str",
"]",
":",
"if",
"self",
".",
"is_logged_in",
":",
"# At the moment, rhx_gis seems to be required for anonymous requests only. By returning None when logged",
"# in, we can save the root_rhx_gis lookup query.",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | get_default_session_filename | Returns default session filename for given username. | instaloader/instaloader.py | def get_default_session_filename(username: str) -> str:
"""Returns default session filename for given username."""
dirname = tempfile.gettempdir() + "/" + ".instaloader-" + getpass.getuser()
filename = dirname + "/" + "session-" + username
return filename.lower() | def get_default_session_filename(username: str) -> str:
"""Returns default session filename for given username."""
dirname = tempfile.gettempdir() + "/" + ".instaloader-" + getpass.getuser()
filename = dirname + "/" + "session-" + username
return filename.lower() | [
"Returns",
"default",
"session",
"filename",
"for",
"given",
"username",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloader.py#L26-L30 | [
"def",
"get_default_session_filename",
"(",
"username",
":",
"str",
")",
"->",
"str",
":",
"dirname",
"=",
"tempfile",
".",
"gettempdir",
"(",
")",
"+",
"\"/\"",
"+",
"\".instaloader-\"",
"+",
"getpass",
".",
"getuser",
"(",
")",
"filename",
"=",
"dirname",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | _requires_login | Decorator to raise an exception if herewith-decorated function is called without being logged in | instaloader/instaloader.py | def _requires_login(func: Callable) -> Callable:
"""Decorator to raise an exception if herewith-decorated function is called without being logged in"""
@wraps(func)
def call(instaloader, *args, **kwargs):
if not instaloader.context.is_logged_in:
raise LoginRequiredException("--login=USER... | def _requires_login(func: Callable) -> Callable:
"""Decorator to raise an exception if herewith-decorated function is called without being logged in"""
@wraps(func)
def call(instaloader, *args, **kwargs):
if not instaloader.context.is_logged_in:
raise LoginRequiredException("--login=USER... | [
"Decorator",
"to",
"raise",
"an",
"exception",
"if",
"herewith",
"-",
"decorated",
"function",
"is",
"called",
"without",
"being",
"logged",
"in"
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloader.py#L41-L50 | [
"def",
"_requires_login",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"call",
"(",
"instaloader",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"instaloader",
".",
"context",
".... | 87d877e650cd8020b04b8b51be120599a441fd5b |
train | _retry_on_connection_error | Decorator to retry the function max_connection_attemps number of times.
Herewith-decorated functions need an ``_attempt`` keyword argument.
This is to decorate functions that do network requests that may fail. Note that
:meth:`.get_json`, :meth:`.get_iphone_json`, :meth:`.graphql_query` and :meth:`.graphq... | instaloader/instaloader.py | def _retry_on_connection_error(func: Callable) -> Callable:
"""Decorator to retry the function max_connection_attemps number of times.
Herewith-decorated functions need an ``_attempt`` keyword argument.
This is to decorate functions that do network requests that may fail. Note that
:meth:`.get_json`, ... | def _retry_on_connection_error(func: Callable) -> Callable:
"""Decorator to retry the function max_connection_attemps number of times.
Herewith-decorated functions need an ``_attempt`` keyword argument.
This is to decorate functions that do network requests that may fail. Note that
:meth:`.get_json`, ... | [
"Decorator",
"to",
"retry",
"the",
"function",
"max_connection_attemps",
"number",
"of",
"times",
"."
] | instaloader/instaloader | python | https://github.com/instaloader/instaloader/blob/87d877e650cd8020b04b8b51be120599a441fd5b/instaloader/instaloader.py#L53-L81 | [
"def",
"_retry_on_connection_error",
"(",
"func",
":",
"Callable",
")",
"->",
"Callable",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"call",
"(",
"instaloader",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"return",
"func",
"(",
... | 87d877e650cd8020b04b8b51be120599a441fd5b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.