repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
palantir/python-language-server | pyls/plugins/jedi_completion.py | _sort_text | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
# If its 'hidden', put it next last
prefix = 'z{}' if definition.name.startswith('_') else 'a{}'
return prefix.format(definition.name) | python | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
# If its 'hidden', put it next last
prefix = 'z{}' if definition.name.startswith('_') else 'a{}'
return prefix.format(definition.name) | [
"def",
"_sort_text",
"(",
"definition",
")",
":",
"# If its 'hidden', put it next last",
"prefix",
"=",
"'z{}'",
"if",
"definition",
".",
"name",
".",
"startswith",
"(",
"'_'",
")",
"else",
"'a{}'",
"return",
"prefix",
".",
"format",
"(",
"definition",
".",
"n... | Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item> | [
"Ensure",
"builtins",
"appear",
"at",
"the",
"bottom",
".",
"Description",
"is",
"of",
"format",
"<type",
">",
":",
"<module",
">",
".",
"<item",
">"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/jedi_completion.py#L95-L102 | train |
palantir/python-language-server | pyls/config/config.py | Config.settings | def settings(self, document_path=None):
"""Settings are constructed from a few sources:
1. User settings, found in user's home directory
2. Plugin settings, reported by PyLS plugins
3. LSP settings, given to us from didChangeConfiguration
4. Project settings, fou... | python | def settings(self, document_path=None):
"""Settings are constructed from a few sources:
1. User settings, found in user's home directory
2. Plugin settings, reported by PyLS plugins
3. LSP settings, given to us from didChangeConfiguration
4. Project settings, fou... | [
"def",
"settings",
"(",
"self",
",",
"document_path",
"=",
"None",
")",
":",
"settings",
"=",
"{",
"}",
"sources",
"=",
"self",
".",
"_settings",
".",
"get",
"(",
"'configurationSources'",
",",
"DEFAULT_CONFIG_SOURCES",
")",
"for",
"source_name",
"in",
"reve... | Settings are constructed from a few sources:
1. User settings, found in user's home directory
2. Plugin settings, reported by PyLS plugins
3. LSP settings, given to us from didChangeConfiguration
4. Project settings, found in config files in the current project.
... | [
"Settings",
"are",
"constructed",
"from",
"a",
"few",
"sources",
":"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/config.py#L95-L133 | train |
palantir/python-language-server | pyls/config/config.py | Config.update | def update(self, settings):
"""Recursively merge the given settings into the current settings."""
self.settings.cache_clear()
self._settings = settings
log.info("Updated settings to %s", self._settings)
self._update_disabled_plugins() | python | def update(self, settings):
"""Recursively merge the given settings into the current settings."""
self.settings.cache_clear()
self._settings = settings
log.info("Updated settings to %s", self._settings)
self._update_disabled_plugins() | [
"def",
"update",
"(",
"self",
",",
"settings",
")",
":",
"self",
".",
"settings",
".",
"cache_clear",
"(",
")",
"self",
".",
"_settings",
"=",
"settings",
"log",
".",
"info",
"(",
"\"Updated settings to %s\"",
",",
"self",
".",
"_settings",
")",
"self",
... | Recursively merge the given settings into the current settings. | [
"Recursively",
"merge",
"the",
"given",
"settings",
"into",
"the",
"current",
"settings",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/config.py#L142-L147 | train |
palantir/python-language-server | pyls/workspace.py | Workspace.get_document | def get_document(self, doc_uri):
"""Return a managed document if-present, else create one pointing at disk.
See https://github.com/Microsoft/language-server-protocol/issues/177
"""
return self._docs.get(doc_uri) or self._create_document(doc_uri) | python | def get_document(self, doc_uri):
"""Return a managed document if-present, else create one pointing at disk.
See https://github.com/Microsoft/language-server-protocol/issues/177
"""
return self._docs.get(doc_uri) or self._create_document(doc_uri) | [
"def",
"get_document",
"(",
"self",
",",
"doc_uri",
")",
":",
"return",
"self",
".",
"_docs",
".",
"get",
"(",
"doc_uri",
")",
"or",
"self",
".",
"_create_document",
"(",
"doc_uri",
")"
] | Return a managed document if-present, else create one pointing at disk.
See https://github.com/Microsoft/language-server-protocol/issues/177 | [
"Return",
"a",
"managed",
"document",
"if",
"-",
"present",
"else",
"create",
"one",
"pointing",
"at",
"disk",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L63-L68 | train |
palantir/python-language-server | pyls/workspace.py | Workspace.source_roots | def source_roots(self, document_path):
"""Return the source roots for the given document."""
files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
return [os.path.dirname(setup_py) for setup_py in files] | python | def source_roots(self, document_path):
"""Return the source roots for the given document."""
files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
return [os.path.dirname(setup_py) for setup_py in files] | [
"def",
"source_roots",
"(",
"self",
",",
"document_path",
")",
":",
"files",
"=",
"_utils",
".",
"find_parents",
"(",
"self",
".",
"_root_path",
",",
"document_path",
",",
"[",
"'setup.py'",
"]",
")",
"or",
"[",
"]",
"return",
"[",
"os",
".",
"path",
"... | Return the source roots for the given document. | [
"Return",
"the",
"source",
"roots",
"for",
"the",
"given",
"document",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L89-L92 | train |
palantir/python-language-server | pyls/workspace.py | Document.apply_change | def apply_change(self, change):
"""Apply a change to the document."""
text = change['text']
change_range = change.get('range')
if not change_range:
# The whole file has changed
self._source = text
return
start_line = change_range['start']['li... | python | def apply_change(self, change):
"""Apply a change to the document."""
text = change['text']
change_range = change.get('range')
if not change_range:
# The whole file has changed
self._source = text
return
start_line = change_range['start']['li... | [
"def",
"apply_change",
"(",
"self",
",",
"change",
")",
":",
"text",
"=",
"change",
"[",
"'text'",
"]",
"change_range",
"=",
"change",
".",
"get",
"(",
"'range'",
")",
"if",
"not",
"change_range",
":",
"# The whole file has changed",
"self",
".",
"_source",
... | Apply a change to the document. | [
"Apply",
"a",
"change",
"to",
"the",
"document",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L134-L175 | train |
palantir/python-language-server | pyls/workspace.py | Document.word_at_position | def word_at_position(self, position):
"""Get the word under the cursor returning the start and end positions."""
if position['line'] >= len(self.lines):
return ''
line = self.lines[position['line']]
i = position['character']
# Split word in two
start = line[:... | python | def word_at_position(self, position):
"""Get the word under the cursor returning the start and end positions."""
if position['line'] >= len(self.lines):
return ''
line = self.lines[position['line']]
i = position['character']
# Split word in two
start = line[:... | [
"def",
"word_at_position",
"(",
"self",
",",
"position",
")",
":",
"if",
"position",
"[",
"'line'",
"]",
">=",
"len",
"(",
"self",
".",
"lines",
")",
":",
"return",
"''",
"line",
"=",
"self",
".",
"lines",
"[",
"position",
"[",
"'line'",
"]",
"]",
... | Get the word under the cursor returning the start and end positions. | [
"Get",
"the",
"word",
"under",
"the",
"cursor",
"returning",
"the",
"start",
"and",
"end",
"positions",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L181-L197 | train |
palantir/python-language-server | pyls/_utils.py | debounce | def debounce(interval_s, keyed_by=None):
"""Debounce calls to this function until interval_s seconds have passed."""
def wrapper(func):
timers = {}
lock = threading.Lock()
@functools.wraps(func)
def debounced(*args, **kwargs):
call_args = inspect.getcallargs(func, *a... | python | def debounce(interval_s, keyed_by=None):
"""Debounce calls to this function until interval_s seconds have passed."""
def wrapper(func):
timers = {}
lock = threading.Lock()
@functools.wraps(func)
def debounced(*args, **kwargs):
call_args = inspect.getcallargs(func, *a... | [
"def",
"debounce",
"(",
"interval_s",
",",
"keyed_by",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"timers",
"=",
"{",
"}",
"lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def"... | Debounce calls to this function until interval_s seconds have passed. | [
"Debounce",
"calls",
"to",
"this",
"function",
"until",
"interval_s",
"seconds",
"have",
"passed",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L11-L36 | train |
palantir/python-language-server | pyls/_utils.py | find_parents | def find_parents(root, path, names):
"""Find files matching the given names relative to the given path.
Args:
path (str): The file path to start searching up from.
names (List[str]): The file/directory names to look for.
root (str): The directory at which to stop recursing upwards.
... | python | def find_parents(root, path, names):
"""Find files matching the given names relative to the given path.
Args:
path (str): The file path to start searching up from.
names (List[str]): The file/directory names to look for.
root (str): The directory at which to stop recursing upwards.
... | [
"def",
"find_parents",
"(",
"root",
",",
"path",
",",
"names",
")",
":",
"if",
"not",
"root",
":",
"return",
"[",
"]",
"if",
"not",
"os",
".",
"path",
".",
"commonprefix",
"(",
"(",
"root",
",",
"path",
")",
")",
":",
"log",
".",
"warning",
"(",
... | Find files matching the given names relative to the given path.
Args:
path (str): The file path to start searching up from.
names (List[str]): The file/directory names to look for.
root (str): The directory at which to stop recursing upwards.
Note:
The path MUST be within the r... | [
"Find",
"files",
"matching",
"the",
"given",
"names",
"relative",
"to",
"the",
"given",
"path",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L39-L71 | train |
palantir/python-language-server | pyls/_utils.py | merge_dicts | def merge_dicts(dict_a, dict_b):
"""Recursively merge dictionary b into dictionary a.
If override_nones is True, then
"""
def _merge_dicts_(a, b):
for key in set(a.keys()).union(b.keys()):
if key in a and key in b:
if isinstance(a[key], dict) and isinstance(b[key], d... | python | def merge_dicts(dict_a, dict_b):
"""Recursively merge dictionary b into dictionary a.
If override_nones is True, then
"""
def _merge_dicts_(a, b):
for key in set(a.keys()).union(b.keys()):
if key in a and key in b:
if isinstance(a[key], dict) and isinstance(b[key], d... | [
"def",
"merge_dicts",
"(",
"dict_a",
",",
"dict_b",
")",
":",
"def",
"_merge_dicts_",
"(",
"a",
",",
"b",
")",
":",
"for",
"key",
"in",
"set",
"(",
"a",
".",
"keys",
"(",
")",
")",
".",
"union",
"(",
"b",
".",
"keys",
"(",
")",
")",
":",
"if"... | Recursively merge dictionary b into dictionary a.
If override_nones is True, then | [
"Recursively",
"merge",
"dictionary",
"b",
"into",
"dictionary",
"a",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L78-L96 | train |
palantir/python-language-server | pyls/_utils.py | format_docstring | def format_docstring(contents):
"""Python doc strings come in a number of formats, but LSP wants markdown.
Until we can find a fast enough way of discovering and parsing each format,
we can do a little better by at least preserving indentation.
"""
contents = contents.replace('\t', u'\u00A0' * 4)
... | python | def format_docstring(contents):
"""Python doc strings come in a number of formats, but LSP wants markdown.
Until we can find a fast enough way of discovering and parsing each format,
we can do a little better by at least preserving indentation.
"""
contents = contents.replace('\t', u'\u00A0' * 4)
... | [
"def",
"format_docstring",
"(",
"contents",
")",
":",
"contents",
"=",
"contents",
".",
"replace",
"(",
"'\\t'",
",",
"u'\\u00A0'",
"*",
"4",
")",
"contents",
"=",
"contents",
".",
"replace",
"(",
"' '",
",",
"u'\\u00A0'",
"*",
"2",
")",
"contents",
"="... | Python doc strings come in a number of formats, but LSP wants markdown.
Until we can find a fast enough way of discovering and parsing each format,
we can do a little better by at least preserving indentation. | [
"Python",
"doc",
"strings",
"come",
"in",
"a",
"number",
"of",
"formats",
"but",
"LSP",
"wants",
"markdown",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L99-L108 | train |
palantir/python-language-server | pyls/uris.py | urlparse | def urlparse(uri):
"""Parse and decode the parts of a URI."""
scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
return (
parse.unquote(scheme),
parse.unquote(netloc),
parse.unquote(path),
parse.unquote(params),
parse.unquote(query),
parse.unq... | python | def urlparse(uri):
"""Parse and decode the parts of a URI."""
scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
return (
parse.unquote(scheme),
parse.unquote(netloc),
parse.unquote(path),
parse.unquote(params),
parse.unquote(query),
parse.unq... | [
"def",
"urlparse",
"(",
"uri",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"parse",
".",
"urlparse",
"(",
"uri",
")",
"return",
"(",
"parse",
".",
"unquote",
"(",
"scheme",
")",
",",
"parse",
"... | Parse and decode the parts of a URI. | [
"Parse",
"and",
"decode",
"the",
"parts",
"of",
"a",
"URI",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L13-L23 | train |
palantir/python-language-server | pyls/uris.py | urlunparse | def urlunparse(parts):
"""Unparse and encode parts of a URI."""
scheme, netloc, path, params, query, fragment = parts
# Avoid encoding the windows drive letter colon
if RE_DRIVE_LETTER_PATH.match(path):
quoted_path = path[:3] + parse.quote(path[3:])
else:
quoted_path = parse.quote(p... | python | def urlunparse(parts):
"""Unparse and encode parts of a URI."""
scheme, netloc, path, params, query, fragment = parts
# Avoid encoding the windows drive letter colon
if RE_DRIVE_LETTER_PATH.match(path):
quoted_path = path[:3] + parse.quote(path[3:])
else:
quoted_path = parse.quote(p... | [
"def",
"urlunparse",
"(",
"parts",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"parts",
"# Avoid encoding the windows drive letter colon",
"if",
"RE_DRIVE_LETTER_PATH",
".",
"match",
"(",
"path",
")",
":",
... | Unparse and encode parts of a URI. | [
"Unparse",
"and",
"encode",
"parts",
"of",
"a",
"URI",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L26-L43 | train |
palantir/python-language-server | pyls/uris.py | to_fs_path | def to_fs_path(uri):
"""Returns the filesystem path of the given URI.
Will handle UNC paths and normalize windows drive letters to lower-case. Also
uses the platform specific path separator. Will *not* validate the path for
invalid characters and semantics. Will *not* look at the scheme of this URI.
... | python | def to_fs_path(uri):
"""Returns the filesystem path of the given URI.
Will handle UNC paths and normalize windows drive letters to lower-case. Also
uses the platform specific path separator. Will *not* validate the path for
invalid characters and semantics. Will *not* look at the scheme of this URI.
... | [
"def",
"to_fs_path",
"(",
"uri",
")",
":",
"# scheme://netloc/path;parameters?query#fragment",
"scheme",
",",
"netloc",
",",
"path",
",",
"_params",
",",
"_query",
",",
"_fragment",
"=",
"urlparse",
"(",
"uri",
")",
"if",
"netloc",
"and",
"path",
"and",
"schem... | Returns the filesystem path of the given URI.
Will handle UNC paths and normalize windows drive letters to lower-case. Also
uses the platform specific path separator. Will *not* validate the path for
invalid characters and semantics. Will *not* look at the scheme of this URI. | [
"Returns",
"the",
"filesystem",
"path",
"of",
"the",
"given",
"URI",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L46-L71 | train |
palantir/python-language-server | pyls/uris.py | from_fs_path | def from_fs_path(path):
"""Returns a URI for the given filesystem path."""
scheme = 'file'
params, query, fragment = '', '', ''
path, netloc = _normalize_win_path(path)
return urlunparse((scheme, netloc, path, params, query, fragment)) | python | def from_fs_path(path):
"""Returns a URI for the given filesystem path."""
scheme = 'file'
params, query, fragment = '', '', ''
path, netloc = _normalize_win_path(path)
return urlunparse((scheme, netloc, path, params, query, fragment)) | [
"def",
"from_fs_path",
"(",
"path",
")",
":",
"scheme",
"=",
"'file'",
"params",
",",
"query",
",",
"fragment",
"=",
"''",
",",
"''",
",",
"''",
"path",
",",
"netloc",
"=",
"_normalize_win_path",
"(",
"path",
")",
"return",
"urlunparse",
"(",
"(",
"sch... | Returns a URI for the given filesystem path. | [
"Returns",
"a",
"URI",
"for",
"the",
"given",
"filesystem",
"path",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L74-L79 | train |
palantir/python-language-server | pyls/uris.py | uri_with | def uri_with(uri, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None):
"""Return a URI with the given part(s) replaced.
Parts are decoded / encoded.
"""
old_scheme, old_netloc, old_path, old_params, old_query, old_fragment = urlparse(uri)
path, _netloc = _normalize_win_path... | python | def uri_with(uri, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None):
"""Return a URI with the given part(s) replaced.
Parts are decoded / encoded.
"""
old_scheme, old_netloc, old_path, old_params, old_query, old_fragment = urlparse(uri)
path, _netloc = _normalize_win_path... | [
"def",
"uri_with",
"(",
"uri",
",",
"scheme",
"=",
"None",
",",
"netloc",
"=",
"None",
",",
"path",
"=",
"None",
",",
"params",
"=",
"None",
",",
"query",
"=",
"None",
",",
"fragment",
"=",
"None",
")",
":",
"old_scheme",
",",
"old_netloc",
",",
"o... | Return a URI with the given part(s) replaced.
Parts are decoded / encoded. | [
"Return",
"a",
"URI",
"with",
"the",
"given",
"part",
"(",
"s",
")",
"replaced",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L82-L96 | train |
palantir/python-language-server | pyls/plugins/pyflakes_lint.py | PyflakesDiagnosticReport.flake | def flake(self, message):
""" Get message like <filename>:<lineno>: <msg> """
err_range = {
'start': {'line': message.lineno - 1, 'character': message.col},
'end': {'line': message.lineno - 1, 'character': len(self.lines[message.lineno - 1])},
}
severity = lsp.Di... | python | def flake(self, message):
""" Get message like <filename>:<lineno>: <msg> """
err_range = {
'start': {'line': message.lineno - 1, 'character': message.col},
'end': {'line': message.lineno - 1, 'character': len(self.lines[message.lineno - 1])},
}
severity = lsp.Di... | [
"def",
"flake",
"(",
"self",
",",
"message",
")",
":",
"err_range",
"=",
"{",
"'start'",
":",
"{",
"'line'",
":",
"message",
".",
"lineno",
"-",
"1",
",",
"'character'",
":",
"message",
".",
"col",
"}",
",",
"'end'",
":",
"{",
"'line'",
":",
"messa... | Get message like <filename>:<lineno>: <msg> | [
"Get",
"message",
"like",
"<filename",
">",
":",
"<lineno",
">",
":",
"<msg",
">"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/pyflakes_lint.py#L62-L80 | train |
palantir/python-language-server | pyls/python_ls.py | PythonLanguageServer._hook | def _hook(self, hook_name, doc_uri=None, **kwargs):
"""Calls hook_name and returns a list of results from all registered handlers"""
doc = self.workspace.get_document(doc_uri) if doc_uri else None
hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugi... | python | def _hook(self, hook_name, doc_uri=None, **kwargs):
"""Calls hook_name and returns a list of results from all registered handlers"""
doc = self.workspace.get_document(doc_uri) if doc_uri else None
hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugi... | [
"def",
"_hook",
"(",
"self",
",",
"hook_name",
",",
"doc_uri",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"doc",
"=",
"self",
".",
"workspace",
".",
"get_document",
"(",
"doc_uri",
")",
"if",
"doc_uri",
"else",
"None",
"hook_handlers",
"=",
"self"... | Calls hook_name and returns a list of results from all registered handlers | [
"Calls",
"hook_name",
"and",
"returns",
"a",
"list",
"of",
"results",
"from",
"all",
"registered",
"handlers"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/python_ls.py#L118-L122 | train |
palantir/python-language-server | pyls/plugins/rope_completion.py | _sort_text | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
if definition.name.startswith("_"):
# It's a 'hidden' func, put it next last
return 'z' + definition.name
elif definition.scope == 'builtin':
return 'y' ... | python | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
if definition.name.startswith("_"):
# It's a 'hidden' func, put it next last
return 'z' + definition.name
elif definition.scope == 'builtin':
return 'y' ... | [
"def",
"_sort_text",
"(",
"definition",
")",
":",
"if",
"definition",
".",
"name",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"# It's a 'hidden' func, put it next last",
"return",
"'z'",
"+",
"definition",
".",
"name",
"elif",
"definition",
".",
"scope",
"==",
... | Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item> | [
"Ensure",
"builtins",
"appear",
"at",
"the",
"bottom",
".",
"Description",
"is",
"of",
"format",
"<type",
">",
":",
"<module",
">",
".",
"<item",
">"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/rope_completion.py#L58-L69 | train |
palantir/python-language-server | pyls/plugins/rope_completion.py | _kind | def _kind(d):
""" Return the VSCode type """
MAP = {
'none': lsp.CompletionItemKind.Value,
'type': lsp.CompletionItemKind.Class,
'tuple': lsp.CompletionItemKind.Class,
'dict': lsp.CompletionItemKind.Class,
'dictionary': lsp.CompletionItemKind.Class,
'function': ls... | python | def _kind(d):
""" Return the VSCode type """
MAP = {
'none': lsp.CompletionItemKind.Value,
'type': lsp.CompletionItemKind.Class,
'tuple': lsp.CompletionItemKind.Class,
'dict': lsp.CompletionItemKind.Class,
'dictionary': lsp.CompletionItemKind.Class,
'function': ls... | [
"def",
"_kind",
"(",
"d",
")",
":",
"MAP",
"=",
"{",
"'none'",
":",
"lsp",
".",
"CompletionItemKind",
".",
"Value",
",",
"'type'",
":",
"lsp",
".",
"CompletionItemKind",
".",
"Class",
",",
"'tuple'",
":",
"lsp",
".",
"CompletionItemKind",
".",
"Class",
... | Return the VSCode type | [
"Return",
"the",
"VSCode",
"type"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/rope_completion.py#L72-L107 | train |
palantir/python-language-server | pyls/config/source.py | _get_opt | def _get_opt(config, key, option, opt_type):
"""Get an option from a configparser with the given type."""
for opt_key in [option, option.replace('-', '_')]:
if not config.has_option(key, opt_key):
continue
if opt_type == bool:
return config.getbool(key, opt_key)
... | python | def _get_opt(config, key, option, opt_type):
"""Get an option from a configparser with the given type."""
for opt_key in [option, option.replace('-', '_')]:
if not config.has_option(key, opt_key):
continue
if opt_type == bool:
return config.getbool(key, opt_key)
... | [
"def",
"_get_opt",
"(",
"config",
",",
"key",
",",
"option",
",",
"opt_type",
")",
":",
"for",
"opt_key",
"in",
"[",
"option",
",",
"option",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"]",
":",
"if",
"not",
"config",
".",
"has_option",
"(",
"key... | Get an option from a configparser with the given type. | [
"Get",
"an",
"option",
"from",
"a",
"configparser",
"with",
"the",
"given",
"type",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/source.py#L48-L66 | train |
palantir/python-language-server | pyls/config/source.py | _set_opt | def _set_opt(config_dict, path, value):
"""Set the value in the dictionary at the given path if the value is not None."""
if value is None:
return
if '.' not in path:
config_dict[path] = value
return
key, rest = path.split(".", 1)
if key not in config_dict:
config_d... | python | def _set_opt(config_dict, path, value):
"""Set the value in the dictionary at the given path if the value is not None."""
if value is None:
return
if '.' not in path:
config_dict[path] = value
return
key, rest = path.split(".", 1)
if key not in config_dict:
config_d... | [
"def",
"_set_opt",
"(",
"config_dict",
",",
"path",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"if",
"'.'",
"not",
"in",
"path",
":",
"config_dict",
"[",
"path",
"]",
"=",
"value",
"return",
"key",
",",
"rest",
"=",
"path",
... | Set the value in the dictionary at the given path if the value is not None. | [
"Set",
"the",
"value",
"in",
"the",
"dictionary",
"at",
"the",
"given",
"path",
"if",
"the",
"value",
"is",
"not",
"None",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/source.py#L73-L86 | train |
palantir/python-language-server | pyls/config/source.py | ConfigSource.parse_config | def parse_config(config, key, options):
"""Parse the config with the given options."""
conf = {}
for source, destination, opt_type in options:
opt_value = _get_opt(config, key, source, opt_type)
if opt_value is not None:
_set_opt(conf, destination, opt_val... | python | def parse_config(config, key, options):
"""Parse the config with the given options."""
conf = {}
for source, destination, opt_type in options:
opt_value = _get_opt(config, key, source, opt_type)
if opt_value is not None:
_set_opt(conf, destination, opt_val... | [
"def",
"parse_config",
"(",
"config",
",",
"key",
",",
"options",
")",
":",
"conf",
"=",
"{",
"}",
"for",
"source",
",",
"destination",
",",
"opt_type",
"in",
"options",
":",
"opt_value",
"=",
"_get_opt",
"(",
"config",
",",
"key",
",",
"source",
",",
... | Parse the config with the given options. | [
"Parse",
"the",
"config",
"with",
"the",
"given",
"options",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/source.py#L38-L45 | train |
palantir/python-language-server | pyls/__main__.py | _binary_stdio | def _binary_stdio():
"""Construct binary stdio streams (not text mode).
This seems to be different for Window/Unix Python2/3, so going by:
https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin
"""
PY3K = sys.version_info >= (3, 0)
if PY3K:
# pylint: disable=no-... | python | def _binary_stdio():
"""Construct binary stdio streams (not text mode).
This seems to be different for Window/Unix Python2/3, so going by:
https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin
"""
PY3K = sys.version_info >= (3, 0)
if PY3K:
# pylint: disable=no-... | [
"def",
"_binary_stdio",
"(",
")",
":",
"PY3K",
"=",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"0",
")",
"if",
"PY3K",
":",
"# pylint: disable=no-member",
"stdin",
",",
"stdout",
"=",
"sys",
".",
"stdin",
".",
"buffer",
",",
"sys",
".",
"stdout",... | Construct binary stdio streams (not text mode).
This seems to be different for Window/Unix Python2/3, so going by:
https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin | [
"Construct",
"binary",
"stdio",
"streams",
"(",
"not",
"text",
"mode",
")",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/__main__.py#L64-L87 | train |
openai/retro | retro/examples/interactive.py | Interactive.run | def run(self):
"""
Run the interactive window until the user quits
"""
# pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet
# and also involves inverting your code to run inside the pyglet framework
# avoid... | python | def run(self):
"""
Run the interactive window until the user quits
"""
# pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet
# and also involves inverting your code to run inside the pyglet framework
# avoid... | [
"def",
"run",
"(",
"self",
")",
":",
"# pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet",
"# and also involves inverting your code to run inside the pyglet framework",
"# avoid both by using a while loop",
"prev_frame_time",
"=... | Run the interactive window until the user quits | [
"Run",
"the",
"interactive",
"window",
"until",
"the",
"user",
"quits"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/interactive.py#L179-L194 | train |
openai/retro | retro/data/__init__.py | get_file_path | def get_file_path(game, file, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's directory
"""
base = path()
for t in inttype.paths:
possible_path = os.path.join(base, t, game, file)
if os.path.exists(possible_path):
return possible_path
return None | python | def get_file_path(game, file, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's directory
"""
base = path()
for t in inttype.paths:
possible_path = os.path.join(base, t, game, file)
if os.path.exists(possible_path):
return possible_path
return None | [
"def",
"get_file_path",
"(",
"game",
",",
"file",
",",
"inttype",
"=",
"Integrations",
".",
"DEFAULT",
")",
":",
"base",
"=",
"path",
"(",
")",
"for",
"t",
"in",
"inttype",
".",
"paths",
":",
"possible_path",
"=",
"os",
".",
"path",
".",
"join",
"(",... | Return the path to a given game's directory | [
"Return",
"the",
"path",
"to",
"a",
"given",
"game",
"s",
"directory"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/data/__init__.py#L266-L276 | train |
openai/retro | retro/data/__init__.py | get_romfile_path | def get_romfile_path(game, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's romfile
"""
for extension in EMU_EXTENSIONS.keys():
possible_path = get_file_path(game, "rom" + extension, inttype)
if possible_path:
return possible_path
raise FileNotFoundEr... | python | def get_romfile_path(game, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's romfile
"""
for extension in EMU_EXTENSIONS.keys():
possible_path = get_file_path(game, "rom" + extension, inttype)
if possible_path:
return possible_path
raise FileNotFoundEr... | [
"def",
"get_romfile_path",
"(",
"game",
",",
"inttype",
"=",
"Integrations",
".",
"DEFAULT",
")",
":",
"for",
"extension",
"in",
"EMU_EXTENSIONS",
".",
"keys",
"(",
")",
":",
"possible_path",
"=",
"get_file_path",
"(",
"game",
",",
"\"rom\"",
"+",
"extension... | Return the path to a given game's romfile | [
"Return",
"the",
"path",
"to",
"a",
"given",
"game",
"s",
"romfile"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/data/__init__.py#L279-L288 | train |
openai/retro | retro/__init__.py | make | def make(game, state=State.DEFAULT, inttype=retro.data.Integrations.DEFAULT, **kwargs):
"""
Create a Gym environment for the specified game
"""
try:
retro.data.get_romfile_path(game, inttype)
except FileNotFoundError:
if not retro.data.get_file_path(game, "rom.sha", inttype):
... | python | def make(game, state=State.DEFAULT, inttype=retro.data.Integrations.DEFAULT, **kwargs):
"""
Create a Gym environment for the specified game
"""
try:
retro.data.get_romfile_path(game, inttype)
except FileNotFoundError:
if not retro.data.get_file_path(game, "rom.sha", inttype):
... | [
"def",
"make",
"(",
"game",
",",
"state",
"=",
"State",
".",
"DEFAULT",
",",
"inttype",
"=",
"retro",
".",
"data",
".",
"Integrations",
".",
"DEFAULT",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"retro",
".",
"data",
".",
"get_romfile_path",
"(",... | Create a Gym environment for the specified game | [
"Create",
"a",
"Gym",
"environment",
"for",
"the",
"specified",
"game"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/__init__.py#L44-L55 | train |
openai/retro | retro/examples/brute.py | select_actions | def select_actions(root, action_space, max_episode_steps):
"""
Select actions from the tree
Normally we select the greedy action that has the highest reward
associated with that subtree. We have a small chance to select a
random action based on the exploration param and visit count of the
curr... | python | def select_actions(root, action_space, max_episode_steps):
"""
Select actions from the tree
Normally we select the greedy action that has the highest reward
associated with that subtree. We have a small chance to select a
random action based on the exploration param and visit count of the
curr... | [
"def",
"select_actions",
"(",
"root",
",",
"action_space",
",",
"max_episode_steps",
")",
":",
"node",
"=",
"root",
"acts",
"=",
"[",
"]",
"steps",
"=",
"0",
"while",
"steps",
"<",
"max_episode_steps",
":",
"if",
"node",
"is",
"None",
":",
"# we've fallen ... | Select actions from the tree
Normally we select the greedy action that has the highest reward
associated with that subtree. We have a small chance to select a
random action based on the exploration param and visit count of the
current node at each step.
We select actions for the longest possible ... | [
"Select",
"actions",
"from",
"the",
"tree"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L76-L124 | train |
openai/retro | retro/examples/brute.py | rollout | def rollout(env, acts):
"""
Perform a rollout using a preset collection of actions
"""
total_rew = 0
env.reset()
steps = 0
for act in acts:
_obs, rew, done, _info = env.step(act)
steps += 1
total_rew += rew
if done:
break
return steps, total_r... | python | def rollout(env, acts):
"""
Perform a rollout using a preset collection of actions
"""
total_rew = 0
env.reset()
steps = 0
for act in acts:
_obs, rew, done, _info = env.step(act)
steps += 1
total_rew += rew
if done:
break
return steps, total_r... | [
"def",
"rollout",
"(",
"env",
",",
"acts",
")",
":",
"total_rew",
"=",
"0",
"env",
".",
"reset",
"(",
")",
"steps",
"=",
"0",
"for",
"act",
"in",
"acts",
":",
"_obs",
",",
"rew",
",",
"done",
",",
"_info",
"=",
"env",
".",
"step",
"(",
"act",
... | Perform a rollout using a preset collection of actions | [
"Perform",
"a",
"rollout",
"using",
"a",
"preset",
"collection",
"of",
"actions"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L127-L141 | train |
openai/retro | retro/examples/brute.py | update_tree | def update_tree(root, executed_acts, total_rew):
"""
Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree
so that the path formed by the executed actions are all updated to the new reward.
"""
root.value = max(total_rew, root.value)
root.visit... | python | def update_tree(root, executed_acts, total_rew):
"""
Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree
so that the path formed by the executed actions are all updated to the new reward.
"""
root.value = max(total_rew, root.value)
root.visit... | [
"def",
"update_tree",
"(",
"root",
",",
"executed_acts",
",",
"total_rew",
")",
":",
"root",
".",
"value",
"=",
"max",
"(",
"total_rew",
",",
"root",
".",
"value",
")",
"root",
".",
"visits",
"+=",
"1",
"new_nodes",
"=",
"0",
"node",
"=",
"root",
"fo... | Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree
so that the path formed by the executed actions are all updated to the new reward. | [
"Given",
"the",
"tree",
"a",
"list",
"of",
"actions",
"that",
"were",
"executed",
"before",
"the",
"game",
"ended",
"and",
"a",
"reward",
"update",
"the",
"tree",
"so",
"that",
"the",
"path",
"formed",
"by",
"the",
"executed",
"actions",
"are",
"all",
"u... | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L144-L162 | train |
tweepy/tweepy | tweepy/auth.py | OAuthHandler.get_authorization_url | def get_authorization_url(self,
signin_with_twitter=False,
access_type=None):
"""Get the authorization URL to redirect the user"""
try:
if signin_with_twitter:
url = self._get_oauth_url('authenticate')
... | python | def get_authorization_url(self,
signin_with_twitter=False,
access_type=None):
"""Get the authorization URL to redirect the user"""
try:
if signin_with_twitter:
url = self._get_oauth_url('authenticate')
... | [
"def",
"get_authorization_url",
"(",
"self",
",",
"signin_with_twitter",
"=",
"False",
",",
"access_type",
"=",
"None",
")",
":",
"try",
":",
"if",
"signin_with_twitter",
":",
"url",
"=",
"self",
".",
"_get_oauth_url",
"(",
"'authenticate'",
")",
"if",
"access... | Get the authorization URL to redirect the user | [
"Get",
"the",
"authorization",
"URL",
"to",
"redirect",
"the",
"user"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/auth.py#L75-L89 | train |
tweepy/tweepy | tweepy/auth.py | OAuthHandler.get_access_token | def get_access_token(self, verifier=None):
"""
After user has authorized the request token, get access token
with user supplied verifier.
"""
try:
url = self._get_oauth_url('access_token')
self.oauth = OAuth1Session(self.consumer_key,
... | python | def get_access_token(self, verifier=None):
"""
After user has authorized the request token, get access token
with user supplied verifier.
"""
try:
url = self._get_oauth_url('access_token')
self.oauth = OAuth1Session(self.consumer_key,
... | [
"def",
"get_access_token",
"(",
"self",
",",
"verifier",
"=",
"None",
")",
":",
"try",
":",
"url",
"=",
"self",
".",
"_get_oauth_url",
"(",
"'access_token'",
")",
"self",
".",
"oauth",
"=",
"OAuth1Session",
"(",
"self",
".",
"consumer_key",
",",
"client_se... | After user has authorized the request token, get access token
with user supplied verifier. | [
"After",
"user",
"has",
"authorized",
"the",
"request",
"token",
"get",
"access",
"token",
"with",
"user",
"supplied",
"verifier",
"."
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/auth.py#L91-L108 | train |
tweepy/tweepy | tweepy/auth.py | OAuthHandler.get_xauth_access_token | def get_xauth_access_token(self, username, password):
"""
Get an access token from an username and password combination.
In order to get this working you need to create an app at
http://twitter.com/apps, after that send a mail to api@twitter.com
and request activation of xAuth fo... | python | def get_xauth_access_token(self, username, password):
"""
Get an access token from an username and password combination.
In order to get this working you need to create an app at
http://twitter.com/apps, after that send a mail to api@twitter.com
and request activation of xAuth fo... | [
"def",
"get_xauth_access_token",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"try",
":",
"url",
"=",
"self",
".",
"_get_oauth_url",
"(",
"'access_token'",
")",
"oauth",
"=",
"OAuth1",
"(",
"self",
".",
"consumer_key",
",",
"client_secret",
"=",
... | Get an access token from an username and password combination.
In order to get this working you need to create an app at
http://twitter.com/apps, after that send a mail to api@twitter.com
and request activation of xAuth for it. | [
"Get",
"an",
"access",
"token",
"from",
"an",
"username",
"and",
"password",
"combination",
".",
"In",
"order",
"to",
"get",
"this",
"working",
"you",
"need",
"to",
"create",
"an",
"app",
"at",
"http",
":",
"//",
"twitter",
".",
"com",
"/",
"apps",
"af... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/auth.py#L110-L130 | train |
tweepy/tweepy | tweepy/cache.py | MemCacheCache.store | def store(self, key, value):
"""Add new record to cache
key: entry key
value: data of entry
"""
self.client.set(key, value, time=self.timeout) | python | def store(self, key, value):
"""Add new record to cache
key: entry key
value: data of entry
"""
self.client.set(key, value, time=self.timeout) | [
"def",
"store",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"client",
".",
"set",
"(",
"key",
",",
"value",
",",
"time",
"=",
"self",
".",
"timeout",
")"
] | Add new record to cache
key: entry key
value: data of entry | [
"Add",
"new",
"record",
"to",
"cache",
"key",
":",
"entry",
"key",
"value",
":",
"data",
"of",
"entry"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L282-L287 | train |
tweepy/tweepy | tweepy/cache.py | RedisCache.store | def store(self, key, value):
"""Store the key, value pair in our redis server"""
# Prepend tweepy to our key,
# this makes it easier to identify tweepy keys in our redis server
key = self.pre_identifier + key
# Get a pipe (to execute several redis commands in one step)
pi... | python | def store(self, key, value):
"""Store the key, value pair in our redis server"""
# Prepend tweepy to our key,
# this makes it easier to identify tweepy keys in our redis server
key = self.pre_identifier + key
# Get a pipe (to execute several redis commands in one step)
pi... | [
"def",
"store",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# Prepend tweepy to our key,",
"# this makes it easier to identify tweepy keys in our redis server",
"key",
"=",
"self",
".",
"pre_identifier",
"+",
"key",
"# Get a pipe (to execute several redis commands in one ... | Store the key, value pair in our redis server | [
"Store",
"the",
"key",
"value",
"pair",
"in",
"our",
"redis",
"server"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L326-L340 | train |
tweepy/tweepy | tweepy/cache.py | RedisCache.get | def get(self, key, timeout=None):
"""Given a key, returns an element from the redis table"""
key = self.pre_identifier + key
# Check to see if we have this key
unpickled_entry = self.client.get(key)
if not unpickled_entry:
# No hit, return nothing
return N... | python | def get(self, key, timeout=None):
"""Given a key, returns an element from the redis table"""
key = self.pre_identifier + key
# Check to see if we have this key
unpickled_entry = self.client.get(key)
if not unpickled_entry:
# No hit, return nothing
return N... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"timeout",
"=",
"None",
")",
":",
"key",
"=",
"self",
".",
"pre_identifier",
"+",
"key",
"# Check to see if we have this key",
"unpickled_entry",
"=",
"self",
".",
"client",
".",
"get",
"(",
"key",
")",
"if",
"... | Given a key, returns an element from the redis table | [
"Given",
"a",
"key",
"returns",
"an",
"element",
"from",
"the",
"redis",
"table"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L342-L363 | train |
tweepy/tweepy | tweepy/cache.py | RedisCache.delete_entry | def delete_entry(self, key):
"""Delete an object from the redis table"""
pipe = self.client.pipeline()
pipe.srem(self.keys_container, key)
pipe.delete(key)
pipe.execute() | python | def delete_entry(self, key):
"""Delete an object from the redis table"""
pipe = self.client.pipeline()
pipe.srem(self.keys_container, key)
pipe.delete(key)
pipe.execute() | [
"def",
"delete_entry",
"(",
"self",
",",
"key",
")",
":",
"pipe",
"=",
"self",
".",
"client",
".",
"pipeline",
"(",
")",
"pipe",
".",
"srem",
"(",
"self",
".",
"keys_container",
",",
"key",
")",
"pipe",
".",
"delete",
"(",
"key",
")",
"pipe",
".",
... | Delete an object from the redis table | [
"Delete",
"an",
"object",
"from",
"the",
"redis",
"table"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L371-L376 | train |
tweepy/tweepy | tweepy/cache.py | RedisCache.cleanup | def cleanup(self):
"""Cleanup all the expired keys"""
keys = self.client.smembers(self.keys_container)
for key in keys:
entry = self.client.get(key)
if entry:
entry = pickle.loads(entry)
if self._is_expired(entry, self.timeout):
... | python | def cleanup(self):
"""Cleanup all the expired keys"""
keys = self.client.smembers(self.keys_container)
for key in keys:
entry = self.client.get(key)
if entry:
entry = pickle.loads(entry)
if self._is_expired(entry, self.timeout):
... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"client",
".",
"smembers",
"(",
"self",
".",
"keys_container",
")",
"for",
"key",
"in",
"keys",
":",
"entry",
"=",
"self",
".",
"client",
".",
"get",
"(",
"key",
")",
"if",
"entry",... | Cleanup all the expired keys | [
"Cleanup",
"all",
"the",
"expired",
"keys"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L378-L386 | train |
tweepy/tweepy | tweepy/cache.py | RedisCache.flush | def flush(self):
"""Delete all entries from the cache"""
keys = self.client.smembers(self.keys_container)
for key in keys:
self.delete_entry(key) | python | def flush(self):
"""Delete all entries from the cache"""
keys = self.client.smembers(self.keys_container)
for key in keys:
self.delete_entry(key) | [
"def",
"flush",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"client",
".",
"smembers",
"(",
"self",
".",
"keys_container",
")",
"for",
"key",
"in",
"keys",
":",
"self",
".",
"delete_entry",
"(",
"key",
")"
] | Delete all entries from the cache | [
"Delete",
"all",
"entries",
"from",
"the",
"cache"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L388-L392 | train |
tweepy/tweepy | tweepy/api.py | API.related_results | def related_results(self):
""" :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/related_results/show/{id}.json',
payload_type='relation', payload_list=Tr... | python | def related_results(self):
""" :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/related_results/show/{id}.json',
payload_type='relation', payload_list=Tr... | [
"def",
"related_results",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/related_results/show/{id}.json'",
",",
"payload_type",
"=",
"'relation'",
",",
"payload_list",
"=",
"True",
",",
"allowed_param",
"=",
"[",
"'i... | :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format
:allowed_param:'id' | [
":",
"reference",
":",
"https",
":",
"//",
"dev",
".",
"twitter",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"1",
".",
"1",
"/",
"get",
"/",
"related_results",
"/",
"show",
"/",
"%3id",
".",
"format",
":",
"allowed_param",
":",
"id"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L142-L152 | train |
tweepy/tweepy | tweepy/api.py | API.media_upload | def media_upload(self, filename, *args, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
:allowed_param:
"""
f = kwargs.pop('file', None)
headers, post_data = API._pack_image(filename, 4883, form_field='media'... | python | def media_upload(self, filename, *args, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
:allowed_param:
"""
f = kwargs.pop('file', None)
headers, post_data = API._pack_image(filename, 4883, form_field='media'... | [
"def",
"media_upload",
"(",
"self",
",",
"filename",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"f",
"=",
"kwargs",
".",
"pop",
"(",
"'file'",
",",
"None",
")",
"headers",
",",
"post_data",
"=",
"API",
".",
"_pack_image",
"(",
"filename",
... | :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
:allowed_param: | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"media",
"/",
"upload",
"-",
"media",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"media",
"-",
"upload",
":",
"allowed_param",
":"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L197-L213 | train |
tweepy/tweepy | tweepy/api.py | API.destroy_status | def destroy_status(self):
""" :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/statuses/destroy/{id}.json',
method='POST',
... | python | def destroy_status(self):
""" :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/statuses/destroy/{id}.json',
method='POST',
... | [
"def",
"destroy_status",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/statuses/destroy/{id}.json'",
",",
"method",
"=",
"'POST'",
",",
"payload_type",
"=",
"'status'",
",",
"allowed_param",
"=",
"[",
"'id'",
"]",... | :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id
:allowed_param:'id' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"tweets",
"/",
"post",
"-",
"and",
"-",
"engage",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"statuses",
"-",
"destroy",
"-",
"id"... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L236-L247 | train |
tweepy/tweepy | tweepy/api.py | API.lookup_users | def lookup_users(self, user_ids=None, screen_names=None, include_entities=None, tweet_mode=None):
""" Perform bulk look up of users from user ID or screen_name """
post_data = {}
if include_entities is not None:
include_entities = 'true' if include_entities else 'false'
p... | python | def lookup_users(self, user_ids=None, screen_names=None, include_entities=None, tweet_mode=None):
""" Perform bulk look up of users from user ID or screen_name """
post_data = {}
if include_entities is not None:
include_entities = 'true' if include_entities else 'false'
p... | [
"def",
"lookup_users",
"(",
"self",
",",
"user_ids",
"=",
"None",
",",
"screen_names",
"=",
"None",
",",
"include_entities",
"=",
"None",
",",
"tweet_mode",
"=",
"None",
")",
":",
"post_data",
"=",
"{",
"}",
"if",
"include_entities",
"is",
"not",
"None",
... | Perform bulk look up of users from user ID or screen_name | [
"Perform",
"bulk",
"look",
"up",
"of",
"users",
"from",
"user",
"ID",
"or",
"screen_name"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L326-L339 | train |
tweepy/tweepy | tweepy/api.py | API._lookup_users | def _lookup_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup
allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode'
"""
return bind_api(
api=self,
pat... | python | def _lookup_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup
allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode'
"""
return bind_api(
api=self,
pat... | [
"def",
"_lookup_users",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/users/lookup.json'",
",",
"payload_type",
"=",
"'user'",
",",
"payload_list",
"=",
"True",
",",
"method",
"=",
"'POST'",
",",
"allowed_param",
... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup
allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"follow",
"-",
"search",
"-",
"get",
"-",
"users",
"/",
"api",
"-",
"reference",
"/",
"get",... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L342-L352 | train |
tweepy/tweepy | tweepy/api.py | API.search_users | def search_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search
:allowed_param:'q', 'count', 'page'
"""
return bind_api(
api=self,
path='/users/search.json',
pa... | python | def search_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search
:allowed_param:'q', 'count', 'page'
"""
return bind_api(
api=self,
path='/users/search.json',
pa... | [
"def",
"search_users",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/users/search.json'",
",",
"payload_type",
"=",
"'user'",
",",
"payload_list",
"=",
"True",
",",
"require_auth",
"=",
"True",
",",
"allowed_param... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search
:allowed_param:'q', 'count', 'page' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"follow",
"-",
"search",
"-",
"get",
"-",
"users",
"/",
"api",
"-",
"reference",
"/",
"get",... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L359-L369 | train |
tweepy/tweepy | tweepy/api.py | API.get_direct_message | def get_direct_message(self):
""" :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
:allowed_param:'id', 'full_text'
"""
return bind_api(
api=self,
path='/direct_messages/show/{id}.json',
... | python | def get_direct_message(self):
""" :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
:allowed_param:'id', 'full_text'
"""
return bind_api(
api=self,
path='/direct_messages/show/{id}.json',
... | [
"def",
"get_direct_message",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/direct_messages/show/{id}.json'",
",",
"payload_type",
"=",
"'direct_message'",
",",
"allowed_param",
"=",
"[",
"'id'",
",",
"'full_text'",
"]... | :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
:allowed_param:'id', 'full_text' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"direct",
"-",
"messages",
"/",
"sending",
"-",
"and",
"-",
"receiving",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"message",
":",
... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L424-L434 | train |
tweepy/tweepy | tweepy/api.py | API.lookup_friendships | def lookup_friendships(self, user_ids=None, screen_names=None):
""" Perform bulk look up of friendships from user ID or screenname """
return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names)) | python | def lookup_friendships(self, user_ids=None, screen_names=None):
""" Perform bulk look up of friendships from user ID or screenname """
return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names)) | [
"def",
"lookup_friendships",
"(",
"self",
",",
"user_ids",
"=",
"None",
",",
"screen_names",
"=",
"None",
")",
":",
"return",
"self",
".",
"_lookup_friendships",
"(",
"list_to_csv",
"(",
"user_ids",
")",
",",
"list_to_csv",
"(",
"screen_names",
")",
")"
] | Perform bulk look up of friendships from user ID or screenname | [
"Perform",
"bulk",
"look",
"up",
"of",
"friendships",
"from",
"user",
"ID",
"or",
"screenname"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L518-L520 | train |
tweepy/tweepy | tweepy/api.py | API.set_settings | def set_settings(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings
:allowed_param:'sleep_time_enabled', 'start_sleep_time',
'end_sleep_time', 'time_zone', 'trend_location_woeid',
'allow_... | python | def set_settings(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings
:allowed_param:'sleep_time_enabled', 'start_sleep_time',
'end_sleep_time', 'time_zone', 'trend_location_woeid',
'allow_... | [
"def",
"set_settings",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/account/settings.json'",
",",
"method",
"=",
"'POST'",
",",
"payload_type",
"=",
"'json'",
",",
"allowed_param",
"=",
"[",
"'sleep_time_enabled'",... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings
:allowed_param:'sleep_time_enabled', 'start_sleep_time',
'end_sleep_time', 'time_zone', 'trend_location_woeid',
'allow_contributor_request', 'lang' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L619-L635 | train |
tweepy/tweepy | tweepy/api.py | API.verify_credentials | def verify_credentials(self, **kargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email'
"""
try:
return bind_api(... | python | def verify_credentials(self, **kargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email'
"""
try:
return bind_api(... | [
"def",
"verify_credentials",
"(",
"self",
",",
"*",
"*",
"kargs",
")",
":",
"try",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/account/verify_credentials.json'",
",",
"payload_type",
"=",
"'user'",
",",
"require_auth",
"=",
"True... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"a... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L637-L652 | train |
tweepy/tweepy | tweepy/api.py | API.rate_limit_status | def rate_limit_status(self):
""" :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
:allowed_param:'resources'
"""
return bind_api(
api=self,
path='/application/rate_limit_sta... | python | def rate_limit_status(self):
""" :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
:allowed_param:'resources'
"""
return bind_api(
api=self,
path='/application/rate_limit_sta... | [
"def",
"rate_limit_status",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/application/rate_limit_status.json'",
",",
"payload_type",
"=",
"'json'",
",",
"allowed_param",
"=",
"[",
"'resources'",
"]",
",",
"use_cache",... | :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
:allowed_param:'resources' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"developer",
"-",
"utilities",
"/",
"rate",
"-",
"limit",
"-",
"status",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"application",
"-... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L655-L665 | train |
tweepy/tweepy | tweepy/api.py | API.update_profile_image | def update_profile_image(self, filename, file_=None):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
:allowed_param:'include_entities', 'skip_status'
"""
headers, post_data = API._pack_i... | python | def update_profile_image(self, filename, file_=None):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
:allowed_param:'include_entities', 'skip_status'
"""
headers, post_data = API._pack_i... | [
"def",
"update_profile_image",
"(",
"self",
",",
"filename",
",",
"file_",
"=",
"None",
")",
":",
"headers",
",",
"post_data",
"=",
"API",
".",
"_pack_image",
"(",
"filename",
",",
"700",
",",
"f",
"=",
"file_",
")",
"return",
"bind_api",
"(",
"api",
"... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
:allowed_param:'include_entities', 'skip_status' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L681-L693 | train |
tweepy/tweepy | tweepy/api.py | API.favorites | def favorites(self):
""" :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list
:allowed_param:'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id'
"""
return bind_api(
api=self,
path='/favorites/... | python | def favorites(self):
""" :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list
:allowed_param:'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id'
"""
return bind_api(
api=self,
path='/favorites/... | [
"def",
"favorites",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/favorites/list.json'",
",",
"payload_type",
"=",
"'status'",
",",
"payload_list",
"=",
"True",
",",
"allowed_param",
"=",
"[",
"'screen_name'",
","... | :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/get-favorites-list
:allowed_param:'screen_name', 'user_id', 'max_id', 'count', 'since_id', 'max_id' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"tweets",
"/",
"post",
"-",
"and",
"-",
"engage",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"favorites",
"-",
"list",
":",
"allowe... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L739-L748 | train |
tweepy/tweepy | tweepy/api.py | API.saved_searches | def saved_searches(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list """
return bind_api(
api=self,
path='/saved_searches/list.json',
payload_type='saved_search', payload_list=... | python | def saved_searches(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list """
return bind_api(
api=self,
path='/saved_searches/list.json',
payload_type='saved_search', payload_list=... | [
"def",
"saved_searches",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/saved_searches/list.json'",
",",
"payload_type",
"=",
"'saved_search'",
",",
"payload_list",
"=",
"True",
",",
"require_auth",
"=",
"True",
")"
... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"s... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L882-L889 | train |
tweepy/tweepy | tweepy/api.py | API.add_list_members | def add_list_members(self, screen_name=None, user_id=None, slug=None,
list_id=None, owner_id=None, owner_screen_name=None):
""" Perform bulk add of list members from user ID or screenname """
return self._add_list_members(list_to_csv(screen_name),
... | python | def add_list_members(self, screen_name=None, user_id=None, slug=None,
list_id=None, owner_id=None, owner_screen_name=None):
""" Perform bulk add of list members from user ID or screenname """
return self._add_list_members(list_to_csv(screen_name),
... | [
"def",
"add_list_members",
"(",
"self",
",",
"screen_name",
"=",
"None",
",",
"user_id",
"=",
"None",
",",
"slug",
"=",
"None",
",",
"list_id",
"=",
"None",
",",
"owner_id",
"=",
"None",
",",
"owner_screen_name",
"=",
"None",
")",
":",
"return",
"self",
... | Perform bulk add of list members from user ID or screenname | [
"Perform",
"bulk",
"add",
"of",
"list",
"members",
"from",
"user",
"ID",
"or",
"screenname"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L1072-L1078 | train |
tweepy/tweepy | tweepy/api.py | API.remove_list_members | def remove_list_members(self, screen_name=None, user_id=None, slug=None,
list_id=None, owner_id=None, owner_screen_name=None):
""" Perform bulk remove of list members from user ID or screenname """
return self._remove_list_members(list_to_csv(screen_name),
... | python | def remove_list_members(self, screen_name=None, user_id=None, slug=None,
list_id=None, owner_id=None, owner_screen_name=None):
""" Perform bulk remove of list members from user ID or screenname """
return self._remove_list_members(list_to_csv(screen_name),
... | [
"def",
"remove_list_members",
"(",
"self",
",",
"screen_name",
"=",
"None",
",",
"user_id",
"=",
"None",
",",
"slug",
"=",
"None",
",",
"list_id",
"=",
"None",
",",
"owner_id",
"=",
"None",
",",
"owner_screen_name",
"=",
"None",
")",
":",
"return",
"self... | Perform bulk remove of list members from user ID or screenname | [
"Perform",
"bulk",
"remove",
"of",
"list",
"members",
"from",
"user",
"ID",
"or",
"screenname"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L1097-L1103 | train |
tweepy/tweepy | tweepy/streaming.py | StreamListener.on_data | def on_data(self, raw_data):
"""Called when raw data is received from connection.
Override this method if you wish to manually handle
the stream data. Return False to stop stream and close connection.
"""
data = json.loads(raw_data)
if 'in_reply_to_status_id' in data:
... | python | def on_data(self, raw_data):
"""Called when raw data is received from connection.
Override this method if you wish to manually handle
the stream data. Return False to stop stream and close connection.
"""
data = json.loads(raw_data)
if 'in_reply_to_status_id' in data:
... | [
"def",
"on_data",
"(",
"self",
",",
"raw_data",
")",
":",
"data",
"=",
"json",
".",
"loads",
"(",
"raw_data",
")",
"if",
"'in_reply_to_status_id'",
"in",
"data",
":",
"status",
"=",
"Status",
".",
"parse",
"(",
"self",
".",
"api",
",",
"data",
")",
"... | Called when raw data is received from connection.
Override this method if you wish to manually handle
the stream data. Return False to stop stream and close connection. | [
"Called",
"when",
"raw",
"data",
"is",
"received",
"from",
"connection",
"."
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/streaming.py#L45-L82 | train |
tweepy/tweepy | tweepy/streaming.py | ReadBuffer.read_line | def read_line(self, sep=six.b('\n')):
"""Read the data stream until a given separator is found (default \n)
:param sep: Separator to read until. Must by of the bytes type (str in python 2,
bytes in python 3)
:return: The str of the data read until sep
"""
start = 0
... | python | def read_line(self, sep=six.b('\n')):
"""Read the data stream until a given separator is found (default \n)
:param sep: Separator to read until. Must by of the bytes type (str in python 2,
bytes in python 3)
:return: The str of the data read until sep
"""
start = 0
... | [
"def",
"read_line",
"(",
"self",
",",
"sep",
"=",
"six",
".",
"b",
"(",
"'\\n'",
")",
")",
":",
"start",
"=",
"0",
"while",
"not",
"self",
".",
"_stream",
".",
"closed",
":",
"loc",
"=",
"self",
".",
"_buffer",
".",
"find",
"(",
"sep",
",",
"st... | Read the data stream until a given separator is found (default \n)
:param sep: Separator to read until. Must by of the bytes type (str in python 2,
bytes in python 3)
:return: The str of the data read until sep | [
"Read",
"the",
"data",
"stream",
"until",
"a",
"given",
"separator",
"is",
"found",
"(",
"default",
"\\",
"n",
")"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/streaming.py#L167-L182 | train |
tweepy/tweepy | tweepy/cursor.py | Cursor.pages | def pages(self, limit=0):
"""Return iterator for pages"""
if limit > 0:
self.iterator.limit = limit
return self.iterator | python | def pages(self, limit=0):
"""Return iterator for pages"""
if limit > 0:
self.iterator.limit = limit
return self.iterator | [
"def",
"pages",
"(",
"self",
",",
"limit",
"=",
"0",
")",
":",
"if",
"limit",
">",
"0",
":",
"self",
".",
"iterator",
".",
"limit",
"=",
"limit",
"return",
"self",
".",
"iterator"
] | Return iterator for pages | [
"Return",
"iterator",
"for",
"pages"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cursor.py#L27-L31 | train |
tweepy/tweepy | tweepy/cursor.py | Cursor.items | def items(self, limit=0):
"""Return iterator for items in each page"""
i = ItemIterator(self.iterator)
i.limit = limit
return i | python | def items(self, limit=0):
"""Return iterator for items in each page"""
i = ItemIterator(self.iterator)
i.limit = limit
return i | [
"def",
"items",
"(",
"self",
",",
"limit",
"=",
"0",
")",
":",
"i",
"=",
"ItemIterator",
"(",
"self",
".",
"iterator",
")",
"i",
".",
"limit",
"=",
"limit",
"return",
"i"
] | Return iterator for items in each page | [
"Return",
"iterator",
"for",
"items",
"in",
"each",
"page"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cursor.py#L33-L37 | train |
tweepy/tweepy | tweepy/cursor.py | IdIterator.next | def next(self):
"""Fetch a set of items with IDs less than current set."""
if self.limit and self.limit == self.num_tweets:
raise StopIteration
if self.index >= len(self.results) - 1:
data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs)
... | python | def next(self):
"""Fetch a set of items with IDs less than current set."""
if self.limit and self.limit == self.num_tweets:
raise StopIteration
if self.index >= len(self.results) - 1:
data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs)
... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"limit",
"and",
"self",
".",
"limit",
"==",
"self",
".",
"num_tweets",
":",
"raise",
"StopIteration",
"if",
"self",
".",
"index",
">=",
"len",
"(",
"self",
".",
"results",
")",
"-",
"1",
":",... | Fetch a set of items with IDs less than current set. | [
"Fetch",
"a",
"set",
"of",
"items",
"with",
"IDs",
"less",
"than",
"current",
"set",
"."
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cursor.py#L102-L139 | train |
tweepy/tweepy | tweepy/cursor.py | IdIterator.prev | def prev(self):
"""Fetch a set of items with IDs greater than current set."""
if self.limit and self.limit == self.num_tweets:
raise StopIteration
self.index -= 1
if self.index < 0:
# There's no way to fetch a set of tweets directly 'above' the
# curr... | python | def prev(self):
"""Fetch a set of items with IDs greater than current set."""
if self.limit and self.limit == self.num_tweets:
raise StopIteration
self.index -= 1
if self.index < 0:
# There's no way to fetch a set of tweets directly 'above' the
# curr... | [
"def",
"prev",
"(",
"self",
")",
":",
"if",
"self",
".",
"limit",
"and",
"self",
".",
"limit",
"==",
"self",
".",
"num_tweets",
":",
"raise",
"StopIteration",
"self",
".",
"index",
"-=",
"1",
"if",
"self",
".",
"index",
"<",
"0",
":",
"# There's no w... | Fetch a set of items with IDs greater than current set. | [
"Fetch",
"a",
"set",
"of",
"items",
"with",
"IDs",
"greater",
"than",
"current",
"set",
"."
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cursor.py#L141-L155 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCache.add_bid | def add_bid(self, bid):
"""Add a bid to the cache
:param bid:
:return:
"""
self._bids[bid[0]] = float(bid[1])
if bid[1] == "0.00000000":
del self._bids[bid[0]] | python | def add_bid(self, bid):
"""Add a bid to the cache
:param bid:
:return:
"""
self._bids[bid[0]] = float(bid[1])
if bid[1] == "0.00000000":
del self._bids[bid[0]] | [
"def",
"add_bid",
"(",
"self",
",",
"bid",
")",
":",
"self",
".",
"_bids",
"[",
"bid",
"[",
"0",
"]",
"]",
"=",
"float",
"(",
"bid",
"[",
"1",
"]",
")",
"if",
"bid",
"[",
"1",
"]",
"==",
"\"0.00000000\"",
":",
"del",
"self",
".",
"_bids",
"["... | Add a bid to the cache
:param bid:
:return: | [
"Add",
"a",
"bid",
"to",
"the",
"cache"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L23-L32 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCache.add_ask | def add_ask(self, ask):
"""Add an ask to the cache
:param ask:
:return:
"""
self._asks[ask[0]] = float(ask[1])
if ask[1] == "0.00000000":
del self._asks[ask[0]] | python | def add_ask(self, ask):
"""Add an ask to the cache
:param ask:
:return:
"""
self._asks[ask[0]] = float(ask[1])
if ask[1] == "0.00000000":
del self._asks[ask[0]] | [
"def",
"add_ask",
"(",
"self",
",",
"ask",
")",
":",
"self",
".",
"_asks",
"[",
"ask",
"[",
"0",
"]",
"]",
"=",
"float",
"(",
"ask",
"[",
"1",
"]",
")",
"if",
"ask",
"[",
"1",
"]",
"==",
"\"0.00000000\"",
":",
"del",
"self",
".",
"_asks",
"["... | Add an ask to the cache
:param ask:
:return: | [
"Add",
"an",
"ask",
"to",
"the",
"cache"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L34-L43 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCache.sort_depth | def sort_depth(vals, reverse=False):
"""Sort bids or asks by price
"""
lst = [[float(price), quantity] for price, quantity in vals.items()]
lst = sorted(lst, key=itemgetter(0), reverse=reverse)
return lst | python | def sort_depth(vals, reverse=False):
"""Sort bids or asks by price
"""
lst = [[float(price), quantity] for price, quantity in vals.items()]
lst = sorted(lst, key=itemgetter(0), reverse=reverse)
return lst | [
"def",
"sort_depth",
"(",
"vals",
",",
"reverse",
"=",
"False",
")",
":",
"lst",
"=",
"[",
"[",
"float",
"(",
"price",
")",
",",
"quantity",
"]",
"for",
"price",
",",
"quantity",
"in",
"vals",
".",
"items",
"(",
")",
"]",
"lst",
"=",
"sorted",
"(... | Sort bids or asks by price | [
"Sort",
"bids",
"or",
"asks",
"by",
"price"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L112-L117 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCacheManager._init_cache | def _init_cache(self):
"""Initialise the depth cache calling REST endpoint
:return:
"""
self._last_update_id = None
self._depth_message_buffer = []
res = self._client.get_order_book(symbol=self._symbol, limit=self._limit)
# process bid and asks from the order b... | python | def _init_cache(self):
"""Initialise the depth cache calling REST endpoint
:return:
"""
self._last_update_id = None
self._depth_message_buffer = []
res = self._client.get_order_book(symbol=self._symbol, limit=self._limit)
# process bid and asks from the order b... | [
"def",
"_init_cache",
"(",
"self",
")",
":",
"self",
".",
"_last_update_id",
"=",
"None",
"self",
".",
"_depth_message_buffer",
"=",
"[",
"]",
"res",
"=",
"self",
".",
"_client",
".",
"get_order_book",
"(",
"symbol",
"=",
"self",
".",
"_symbol",
",",
"li... | Initialise the depth cache calling REST endpoint
:return: | [
"Initialise",
"the",
"depth",
"cache",
"calling",
"REST",
"endpoint"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L153-L181 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCacheManager._start_socket | def _start_socket(self):
"""Start the depth cache socket
:return:
"""
if self._bm is None:
self._bm = BinanceSocketManager(self._client)
self._conn_key = self._bm.start_depth_socket(self._symbol, self._depth_event)
if not self._bm.is_alive():
sel... | python | def _start_socket(self):
"""Start the depth cache socket
:return:
"""
if self._bm is None:
self._bm = BinanceSocketManager(self._client)
self._conn_key = self._bm.start_depth_socket(self._symbol, self._depth_event)
if not self._bm.is_alive():
sel... | [
"def",
"_start_socket",
"(",
"self",
")",
":",
"if",
"self",
".",
"_bm",
"is",
"None",
":",
"self",
".",
"_bm",
"=",
"BinanceSocketManager",
"(",
"self",
".",
"_client",
")",
"self",
".",
"_conn_key",
"=",
"self",
".",
"_bm",
".",
"start_depth_socket",
... | Start the depth cache socket
:return: | [
"Start",
"the",
"depth",
"cache",
"socket"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L183-L197 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCacheManager._depth_event | def _depth_event(self, msg):
"""Handle a depth event
:param msg:
:return:
"""
if 'e' in msg and msg['e'] == 'error':
# close the socket
self.close()
# notify the user by returning a None value
if self._callback:
... | python | def _depth_event(self, msg):
"""Handle a depth event
:param msg:
:return:
"""
if 'e' in msg and msg['e'] == 'error':
# close the socket
self.close()
# notify the user by returning a None value
if self._callback:
... | [
"def",
"_depth_event",
"(",
"self",
",",
"msg",
")",
":",
"if",
"'e'",
"in",
"msg",
"and",
"msg",
"[",
"'e'",
"]",
"==",
"'error'",
":",
"# close the socket",
"self",
".",
"close",
"(",
")",
"# notify the user by returning a None value",
"if",
"self",
".",
... | Handle a depth event
:param msg:
:return: | [
"Handle",
"a",
"depth",
"event"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L199-L219 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCacheManager._process_depth_message | def _process_depth_message(self, msg, buffer=False):
"""Process a depth event message.
:param msg: Depth event message.
:return:
"""
if buffer and msg['u'] <= self._last_update_id:
# ignore any updates before the initial update id
return
elif ms... | python | def _process_depth_message(self, msg, buffer=False):
"""Process a depth event message.
:param msg: Depth event message.
:return:
"""
if buffer and msg['u'] <= self._last_update_id:
# ignore any updates before the initial update id
return
elif ms... | [
"def",
"_process_depth_message",
"(",
"self",
",",
"msg",
",",
"buffer",
"=",
"False",
")",
":",
"if",
"buffer",
"and",
"msg",
"[",
"'u'",
"]",
"<=",
"self",
".",
"_last_update_id",
":",
"# ignore any updates before the initial update id",
"return",
"elif",
"msg... | Process a depth event message.
:param msg: Depth event message.
:return: | [
"Process",
"a",
"depth",
"event",
"message",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L221-L254 | train |
sammchardy/python-binance | binance/depthcache.py | DepthCacheManager.close | def close(self, close_socket=False):
"""Close the open socket for this manager
:return:
"""
self._bm.stop_socket(self._conn_key)
if close_socket:
self._bm.close()
time.sleep(1)
self._depth_cache = None | python | def close(self, close_socket=False):
"""Close the open socket for this manager
:return:
"""
self._bm.stop_socket(self._conn_key)
if close_socket:
self._bm.close()
time.sleep(1)
self._depth_cache = None | [
"def",
"close",
"(",
"self",
",",
"close_socket",
"=",
"False",
")",
":",
"self",
".",
"_bm",
".",
"stop_socket",
"(",
"self",
".",
"_conn_key",
")",
"if",
"close_socket",
":",
"self",
".",
"_bm",
".",
"close",
"(",
")",
"time",
".",
"sleep",
"(",
... | Close the open socket for this manager
:return: | [
"Close",
"the",
"open",
"socket",
"for",
"this",
"manager"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/depthcache.py#L264-L273 | train |
sammchardy/python-binance | examples/save_historical_data.py | date_to_milliseconds | def date_to_milliseconds(date_str):
"""Convert UTC date to milliseconds
If using offset strings add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
See dateparse docs for formats http://dateparser.readthedocs.io/en/latest/
:param date_str: date in readable format, i.e. "January 01, 2018", "11... | python | def date_to_milliseconds(date_str):
"""Convert UTC date to milliseconds
If using offset strings add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
See dateparse docs for formats http://dateparser.readthedocs.io/en/latest/
:param date_str: date in readable format, i.e. "January 01, 2018", "11... | [
"def",
"date_to_milliseconds",
"(",
"date_str",
")",
":",
"# get epoch value in UTC",
"epoch",
"=",
"datetime",
".",
"utcfromtimestamp",
"(",
"0",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"utc",
")",
"# parse our date string",
"d",
"=",
"dateparser"... | Convert UTC date to milliseconds
If using offset strings add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
See dateparse docs for formats http://dateparser.readthedocs.io/en/latest/
:param date_str: date in readable format, i.e. "January 01, 2018", "11 hours ago UTC", "now UTC"
:type date_s... | [
"Convert",
"UTC",
"date",
"to",
"milliseconds"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/examples/save_historical_data.py#L10-L29 | train |
sammchardy/python-binance | examples/save_historical_data.py | interval_to_milliseconds | def interval_to_milliseconds(interval):
"""Convert a Binance interval string to milliseconds
:param interval: Binance interval string 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w
:type interval: str
:return:
None if unit not one of m, h, d or w
None if string not in corr... | python | def interval_to_milliseconds(interval):
"""Convert a Binance interval string to milliseconds
:param interval: Binance interval string 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w
:type interval: str
:return:
None if unit not one of m, h, d or w
None if string not in corr... | [
"def",
"interval_to_milliseconds",
"(",
"interval",
")",
":",
"ms",
"=",
"None",
"seconds_per_unit",
"=",
"{",
"\"m\"",
":",
"60",
",",
"\"h\"",
":",
"60",
"*",
"60",
",",
"\"d\"",
":",
"24",
"*",
"60",
"*",
"60",
",",
"\"w\"",
":",
"7",
"*",
"24",... | Convert a Binance interval string to milliseconds
:param interval: Binance interval string 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w
:type interval: str
:return:
None if unit not one of m, h, d or w
None if string not in correct format
int value of interval in mi... | [
"Convert",
"a",
"Binance",
"interval",
"string",
"to",
"milliseconds"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/examples/save_historical_data.py#L32-L57 | train |
sammchardy/python-binance | examples/save_historical_data.py | get_historical_klines | def get_historical_klines(symbol, interval, start_str, end_str=None):
"""Get Historical Klines from Binance
See dateparse docs for valid start and end string formats http://dateparser.readthedocs.io/en/latest/
If using offset strings for dates add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
... | python | def get_historical_klines(symbol, interval, start_str, end_str=None):
"""Get Historical Klines from Binance
See dateparse docs for valid start and end string formats http://dateparser.readthedocs.io/en/latest/
If using offset strings for dates add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
... | [
"def",
"get_historical_klines",
"(",
"symbol",
",",
"interval",
",",
"start_str",
",",
"end_str",
"=",
"None",
")",
":",
"# create the Binance client, no need for api key",
"client",
"=",
"Client",
"(",
"\"\"",
",",
"\"\"",
")",
"# init our list",
"output_data",
"="... | Get Historical Klines from Binance
See dateparse docs for valid start and end string formats http://dateparser.readthedocs.io/en/latest/
If using offset strings for dates add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
:param symbol: Name of symbol pair e.g BNBBTC
:type symbol: str
:p... | [
"Get",
"Historical",
"Klines",
"from",
"Binance"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/examples/save_historical_data.py#L60-L136 | train |
sammchardy/python-binance | binance/client.py | Client._order_params | def _order_params(self, data):
"""Convert params to list with signature as last element
:param data:
:return:
"""
has_signature = False
params = []
for key, value in data.items():
if key == 'signature':
has_signature = True
... | python | def _order_params(self, data):
"""Convert params to list with signature as last element
:param data:
:return:
"""
has_signature = False
params = []
for key, value in data.items():
if key == 'signature':
has_signature = True
... | [
"def",
"_order_params",
"(",
"self",
",",
"data",
")",
":",
"has_signature",
"=",
"False",
"params",
"=",
"[",
"]",
"for",
"key",
",",
"value",
"in",
"data",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"'signature'",
":",
"has_signature",
"=",
"T... | Convert params to list with signature as last element
:param data:
:return: | [
"Convert",
"params",
"to",
"list",
"with",
"signature",
"as",
"last",
"element"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L121-L139 | train |
sammchardy/python-binance | binance/client.py | Client._handle_response | def _handle_response(self, response):
"""Internal helper for handling API responses from the Binance server.
Raises the appropriate exceptions when necessary; otherwise, returns the
response.
"""
if not str(response.status_code).startswith('2'):
raise BinanceAPIExcept... | python | def _handle_response(self, response):
"""Internal helper for handling API responses from the Binance server.
Raises the appropriate exceptions when necessary; otherwise, returns the
response.
"""
if not str(response.status_code).startswith('2'):
raise BinanceAPIExcept... | [
"def",
"_handle_response",
"(",
"self",
",",
"response",
")",
":",
"if",
"not",
"str",
"(",
"response",
".",
"status_code",
")",
".",
"startswith",
"(",
"'2'",
")",
":",
"raise",
"BinanceAPIException",
"(",
"response",
")",
"try",
":",
"return",
"response"... | Internal helper for handling API responses from the Binance server.
Raises the appropriate exceptions when necessary; otherwise, returns the
response. | [
"Internal",
"helper",
"for",
"handling",
"API",
"responses",
"from",
"the",
"Binance",
"server",
".",
"Raises",
"the",
"appropriate",
"exceptions",
"when",
"necessary",
";",
"otherwise",
"returns",
"the",
"response",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L194-L204 | train |
sammchardy/python-binance | binance/client.py | Client.get_symbol_info | def get_symbol_info(self, symbol):
"""Return information about a symbol
:param symbol: required e.g BNBBTC
:type symbol: str
:returns: Dict if found, None if not
.. code-block:: python
{
"symbol": "ETHBTC",
"status": "TRADING",
... | python | def get_symbol_info(self, symbol):
"""Return information about a symbol
:param symbol: required e.g BNBBTC
:type symbol: str
:returns: Dict if found, None if not
.. code-block:: python
{
"symbol": "ETHBTC",
"status": "TRADING",
... | [
"def",
"get_symbol_info",
"(",
"self",
",",
"symbol",
")",
":",
"res",
"=",
"self",
".",
"_get",
"(",
"'exchangeInfo'",
")",
"for",
"item",
"in",
"res",
"[",
"'symbols'",
"]",
":",
"if",
"item",
"[",
"'symbol'",
"]",
"==",
"symbol",
".",
"upper",
"("... | Return information about a symbol
:param symbol: required e.g BNBBTC
:type symbol: str
:returns: Dict if found, None if not
.. code-block:: python
{
"symbol": "ETHBTC",
"status": "TRADING",
"baseAsset": "ETH",
... | [
"Return",
"information",
"about",
"a",
"symbol"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L298-L345 | train |
sammchardy/python-binance | binance/client.py | Client.aggregate_trade_iter | def aggregate_trade_iter(self, symbol, start_str=None, last_id=None):
"""Iterate over aggregate trade data from (start_time or last_id) to
the end of the history so far.
If start_time is specified, start with the first trade after
start_time. Meant to initialise a local cache of trade d... | python | def aggregate_trade_iter(self, symbol, start_str=None, last_id=None):
"""Iterate over aggregate trade data from (start_time or last_id) to
the end of the history so far.
If start_time is specified, start with the first trade after
start_time. Meant to initialise a local cache of trade d... | [
"def",
"aggregate_trade_iter",
"(",
"self",
",",
"symbol",
",",
"start_str",
"=",
"None",
",",
"last_id",
"=",
"None",
")",
":",
"if",
"start_str",
"is",
"not",
"None",
"and",
"last_id",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'start_time an... | Iterate over aggregate trade data from (start_time or last_id) to
the end of the history so far.
If start_time is specified, start with the first trade after
start_time. Meant to initialise a local cache of trade data.
If last_id is specified, start with the trade after it. This is mea... | [
"Iterate",
"over",
"aggregate",
"trade",
"data",
"from",
"(",
"start_time",
"or",
"last_id",
")",
"to",
"the",
"end",
"of",
"the",
"history",
"so",
"far",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L579-L663 | train |
sammchardy/python-binance | binance/client.py | Client._get_earliest_valid_timestamp | def _get_earliest_valid_timestamp(self, symbol, interval):
"""Get earliest valid open timestamp from Binance
:param symbol: Name of symbol pair e.g BNBBTC
:type symbol: str
:param interval: Binance Kline interval
:type interval: str
:return: first valid timestamp
... | python | def _get_earliest_valid_timestamp(self, symbol, interval):
"""Get earliest valid open timestamp from Binance
:param symbol: Name of symbol pair e.g BNBBTC
:type symbol: str
:param interval: Binance Kline interval
:type interval: str
:return: first valid timestamp
... | [
"def",
"_get_earliest_valid_timestamp",
"(",
"self",
",",
"symbol",
",",
"interval",
")",
":",
"kline",
"=",
"self",
".",
"get_klines",
"(",
"symbol",
"=",
"symbol",
",",
"interval",
"=",
"interval",
",",
"limit",
"=",
"1",
",",
"startTime",
"=",
"0",
",... | Get earliest valid open timestamp from Binance
:param symbol: Name of symbol pair e.g BNBBTC
:type symbol: str
:param interval: Binance Kline interval
:type interval: str
:return: first valid timestamp | [
"Get",
"earliest",
"valid",
"open",
"timestamp",
"from",
"Binance"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L707-L725 | train |
sammchardy/python-binance | binance/client.py | Client.get_historical_klines | def get_historical_klines(self, symbol, interval, start_str, end_str=None,
limit=500):
"""Get Historical Klines from Binance
See dateparser docs for valid start and end string formats http://dateparser.readthedocs.io/en/latest/
If using offset strings for dates ad... | python | def get_historical_klines(self, symbol, interval, start_str, end_str=None,
limit=500):
"""Get Historical Klines from Binance
See dateparser docs for valid start and end string formats http://dateparser.readthedocs.io/en/latest/
If using offset strings for dates ad... | [
"def",
"get_historical_klines",
"(",
"self",
",",
"symbol",
",",
"interval",
",",
"start_str",
",",
"end_str",
"=",
"None",
",",
"limit",
"=",
"500",
")",
":",
"# init our list",
"output_data",
"=",
"[",
"]",
"# setup the max limit",
"limit",
"=",
"limit",
"... | Get Historical Klines from Binance
See dateparser docs for valid start and end string formats http://dateparser.readthedocs.io/en/latest/
If using offset strings for dates add "UTC" to date string e.g. "now UTC", "11 hours ago UTC"
:param symbol: Name of symbol pair e.g BNBBTC
:type s... | [
"Get",
"Historical",
"Klines",
"from",
"Binance"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L727-L810 | train |
sammchardy/python-binance | binance/client.py | Client.get_symbol_ticker | def get_symbol_ticker(self, **params):
"""Latest price for a symbol or symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics
:param symbol:
:type symbol: str
:returns: API response
.. code-bl... | python | def get_symbol_ticker(self, **params):
"""Latest price for a symbol or symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics
:param symbol:
:type symbol: str
:returns: API response
.. code-bl... | [
"def",
"get_symbol_ticker",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"_get",
"(",
"'ticker/price'",
",",
"data",
"=",
"params",
",",
"version",
"=",
"self",
".",
"PRIVATE_API_VERSION",
")"
] | Latest price for a symbol or symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#24hr-ticker-price-change-statistics
:param symbol:
:type symbol: str
:returns: API response
.. code-block:: python
{
"symbo... | [
"Latest",
"price",
"for",
"a",
"symbol",
"or",
"symbols",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L952-L987 | train |
sammchardy/python-binance | binance/client.py | Client.get_orderbook_ticker | def get_orderbook_ticker(self, **params):
"""Latest price for a symbol or symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#symbol-order-book-ticker
:param symbol:
:type symbol: str
:returns: API response
.. code-block:: py... | python | def get_orderbook_ticker(self, **params):
"""Latest price for a symbol or symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#symbol-order-book-ticker
:param symbol:
:type symbol: str
:returns: API response
.. code-block:: py... | [
"def",
"get_orderbook_ticker",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"return",
"self",
".",
"_get",
"(",
"'ticker/bookTicker'",
",",
"data",
"=",
"params",
",",
"version",
"=",
"self",
".",
"PRIVATE_API_VERSION",
")"
] | Latest price for a symbol or symbols.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#symbol-order-book-ticker
:param symbol:
:type symbol: str
:returns: API response
.. code-block:: python
{
"symbol": "LTCBTC... | [
"Latest",
"price",
"for",
"a",
"symbol",
"or",
"symbols",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L989-L1033 | train |
sammchardy/python-binance | binance/client.py | Client.order_limit | def order_limit(self, timeInForce=TIME_IN_FORCE_GTC, **params):
"""Send in a new limit order
Any order with an icebergQty MUST have timeInForce set to GTC.
:param symbol: required
:type symbol: str
:param side: required
:type side: str
:param quantity: required
... | python | def order_limit(self, timeInForce=TIME_IN_FORCE_GTC, **params):
"""Send in a new limit order
Any order with an icebergQty MUST have timeInForce set to GTC.
:param symbol: required
:type symbol: str
:param side: required
:type side: str
:param quantity: required
... | [
"def",
"order_limit",
"(",
"self",
",",
"timeInForce",
"=",
"TIME_IN_FORCE_GTC",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'type'",
":",
"self",
".",
"ORDER_TYPE_LIMIT",
",",
"'timeInForce'",
":",
"timeInForce",
"}",
")",
"retu... | Send in a new limit order
Any order with an icebergQty MUST have timeInForce set to GTC.
:param symbol: required
:type symbol: str
:param side: required
:type side: str
:param quantity: required
:type quantity: decimal
:param price: required
:typ... | [
"Send",
"in",
"a",
"new",
"limit",
"order"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1151-L1186 | train |
sammchardy/python-binance | binance/client.py | Client.order_limit_buy | def order_limit_buy(self, timeInForce=TIME_IN_FORCE_GTC, **params):
"""Send in a new limit buy order
Any order with an icebergQty MUST have timeInForce set to GTC.
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param... | python | def order_limit_buy(self, timeInForce=TIME_IN_FORCE_GTC, **params):
"""Send in a new limit buy order
Any order with an icebergQty MUST have timeInForce set to GTC.
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param... | [
"def",
"order_limit_buy",
"(",
"self",
",",
"timeInForce",
"=",
"TIME_IN_FORCE_GTC",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'side'",
":",
"self",
".",
"SIDE_BUY",
",",
"}",
")",
"return",
"self",
".",
"order_limit",
"(",
... | Send in a new limit buy order
Any order with an icebergQty MUST have timeInForce set to GTC.
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param price: required
:type price: str
:param timeInForce: default G... | [
"Send",
"in",
"a",
"new",
"limit",
"buy",
"order"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1188-L1222 | train |
sammchardy/python-binance | binance/client.py | Client.order_limit_sell | def order_limit_sell(self, timeInForce=TIME_IN_FORCE_GTC, **params):
"""Send in a new limit sell order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param price: required
:type price: str
:param timeInForce: ... | python | def order_limit_sell(self, timeInForce=TIME_IN_FORCE_GTC, **params):
"""Send in a new limit sell order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param price: required
:type price: str
:param timeInForce: ... | [
"def",
"order_limit_sell",
"(",
"self",
",",
"timeInForce",
"=",
"TIME_IN_FORCE_GTC",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'side'",
":",
"self",
".",
"SIDE_SELL",
"}",
")",
"return",
"self",
".",
"order_limit",
"(",
"tim... | Send in a new limit sell order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param price: required
:type price: str
:param timeInForce: default Good till cancelled
:type timeInForce: str
:param newCli... | [
"Send",
"in",
"a",
"new",
"limit",
"sell",
"order"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1224-L1256 | train |
sammchardy/python-binance | binance/client.py | Client.order_market | def order_market(self, **params):
"""Send in a new market order
:param symbol: required
:type symbol: str
:param side: required
:type side: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatic... | python | def order_market(self, **params):
"""Send in a new market order
:param symbol: required
:type symbol: str
:param side: required
:type side: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatic... | [
"def",
"order_market",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'type'",
":",
"self",
".",
"ORDER_TYPE_MARKET",
"}",
")",
"return",
"self",
".",
"create_order",
"(",
"*",
"*",
"params",
")"
] | Send in a new market order
:param symbol: required
:type symbol: str
:param side: required
:type side: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type new... | [
"Send",
"in",
"a",
"new",
"market",
"order"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1258-L1284 | train |
sammchardy/python-binance | binance/client.py | Client.order_market_buy | def order_market_buy(self, **params):
"""Send in a new market buy order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type newC... | python | def order_market_buy(self, **params):
"""Send in a new market buy order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type newC... | [
"def",
"order_market_buy",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'side'",
":",
"self",
".",
"SIDE_BUY",
"}",
")",
"return",
"self",
".",
"order_market",
"(",
"*",
"*",
"params",
")"
] | Send in a new market buy order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type newClientOrderId: str
:param newOrderRespType... | [
"Send",
"in",
"a",
"new",
"market",
"buy",
"order"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1286-L1310 | train |
sammchardy/python-binance | binance/client.py | Client.order_market_sell | def order_market_sell(self, **params):
"""Send in a new market sell order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type ne... | python | def order_market_sell(self, **params):
"""Send in a new market sell order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type ne... | [
"def",
"order_market_sell",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"params",
".",
"update",
"(",
"{",
"'side'",
":",
"self",
".",
"SIDE_SELL",
"}",
")",
"return",
"self",
".",
"order_market",
"(",
"*",
"*",
"params",
")"
] | Send in a new market sell order
:param symbol: required
:type symbol: str
:param quantity: required
:type quantity: decimal
:param newClientOrderId: A unique id for the order. Automatically generated if not sent.
:type newClientOrderId: str
:param newOrderRespTyp... | [
"Send",
"in",
"a",
"new",
"market",
"sell",
"order"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1312-L1336 | train |
sammchardy/python-binance | binance/client.py | Client.get_asset_balance | def get_asset_balance(self, asset, **params):
"""Get current asset balance.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data
:param asset: required
:type asset: str
:param recvWindow: the number of milliseconds ... | python | def get_asset_balance(self, asset, **params):
"""Get current asset balance.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data
:param asset: required
:type asset: str
:param recvWindow: the number of milliseconds ... | [
"def",
"get_asset_balance",
"(",
"self",
",",
"asset",
",",
"*",
"*",
"params",
")",
":",
"res",
"=",
"self",
".",
"get_account",
"(",
"*",
"*",
"params",
")",
"# find asset balance in list of balances",
"if",
"\"balances\"",
"in",
"res",
":",
"for",
"bal",
... | Get current asset balance.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#account-information-user_data
:param asset: required
:type asset: str
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
... | [
"Get",
"current",
"asset",
"balance",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1565-L1594 | train |
sammchardy/python-binance | binance/client.py | Client.get_account_status | def get_account_status(self, **params):
"""Get account status detail.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#account-status-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:re... | python | def get_account_status(self, **params):
"""Get account status detail.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#account-status-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:re... | [
"def",
"get_account_status",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"res",
"=",
"self",
".",
"_request_withdraw_api",
"(",
"'get'",
",",
"'accountStatus.html'",
",",
"True",
",",
"data",
"=",
"params",
")",
"if",
"not",
"res",
"[",
"'success'",
... | Get account status detail.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#account-status-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:returns: API response
.. code-block:: python... | [
"Get",
"account",
"status",
"detail",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1652-L1678 | train |
sammchardy/python-binance | binance/client.py | Client.get_dust_log | def get_dust_log(self, **params):
"""Get log of small amounts exchanged for BNB.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#dustlog-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
... | python | def get_dust_log(self, **params):
"""Get log of small amounts exchanged for BNB.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#dustlog-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
... | [
"def",
"get_dust_log",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"res",
"=",
"self",
".",
"_request_withdraw_api",
"(",
"'get'",
",",
"'userAssetDribbletLog.html'",
",",
"True",
",",
"data",
"=",
"params",
")",
"if",
"not",
"res",
"[",
"'success'",
... | Get log of small amounts exchanged for BNB.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#dustlog-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:returns: API response
.. code-bloc... | [
"Get",
"log",
"of",
"small",
"amounts",
"exchanged",
"for",
"BNB",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1680-L1759 | train |
sammchardy/python-binance | binance/client.py | Client.get_trade_fee | def get_trade_fee(self, **params):
"""Get trade fee.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#trade-fee-user_data
:param symbol: optional
:type symbol: str
:param recvWindow: the number of milliseconds the request is valid for
... | python | def get_trade_fee(self, **params):
"""Get trade fee.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#trade-fee-user_data
:param symbol: optional
:type symbol: str
:param recvWindow: the number of milliseconds the request is valid for
... | [
"def",
"get_trade_fee",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"res",
"=",
"self",
".",
"_request_withdraw_api",
"(",
"'get'",
",",
"'tradeFee.html'",
",",
"True",
",",
"data",
"=",
"params",
")",
"if",
"not",
"res",
"[",
"'success'",
"]",
":"... | Get trade fee.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#trade-fee-user_data
:param symbol: optional
:type symbol: str
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:returns: API... | [
"Get",
"trade",
"fee",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1761-L1796 | train |
sammchardy/python-binance | binance/client.py | Client.get_asset_details | def get_asset_details(self, **params):
"""Fetch details on assets.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#asset-detail-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:returns... | python | def get_asset_details(self, **params):
"""Fetch details on assets.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#asset-detail-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:returns... | [
"def",
"get_asset_details",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"res",
"=",
"self",
".",
"_request_withdraw_api",
"(",
"'get'",
",",
"'assetDetail.html'",
",",
"True",
",",
"data",
"=",
"params",
")",
"if",
"not",
"res",
"[",
"'success'",
"]"... | Fetch details on assets.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/wapi-api.md#asset-detail-user_data
:param recvWindow: the number of milliseconds the request is valid for
:type recvWindow: int
:returns: API response
.. code-block:: python
... | [
"Fetch",
"details",
"on",
"assets",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1798-L1835 | train |
sammchardy/python-binance | binance/client.py | Client.withdraw | def withdraw(self, **params):
"""Submit a withdraw request.
https://www.binance.com/restapipub.html
Assumptions:
- You must have Withdraw permissions enabled on your API key
- You must have withdrawn to the address specified through the website and approved the transaction via... | python | def withdraw(self, **params):
"""Submit a withdraw request.
https://www.binance.com/restapipub.html
Assumptions:
- You must have Withdraw permissions enabled on your API key
- You must have withdrawn to the address specified through the website and approved the transaction via... | [
"def",
"withdraw",
"(",
"self",
",",
"*",
"*",
"params",
")",
":",
"# force a name for the withdrawal if one not set",
"if",
"'asset'",
"in",
"params",
"and",
"'name'",
"not",
"in",
"params",
":",
"params",
"[",
"'name'",
"]",
"=",
"params",
"[",
"'asset'",
... | Submit a withdraw request.
https://www.binance.com/restapipub.html
Assumptions:
- You must have Withdraw permissions enabled on your API key
- You must have withdrawn to the address specified through the website and approved the transaction via email
:param asset: required
... | [
"Submit",
"a",
"withdraw",
"request",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L1839-L1881 | train |
sammchardy/python-binance | binance/client.py | Client.stream_keepalive | def stream_keepalive(self, listenKey):
"""PING a user data stream to prevent a time out.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#keepalive-user-data-stream-user_stream
:param listenKey: required
:type listenKey: str
:returns: API r... | python | def stream_keepalive(self, listenKey):
"""PING a user data stream to prevent a time out.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#keepalive-user-data-stream-user_stream
:param listenKey: required
:type listenKey: str
:returns: API r... | [
"def",
"stream_keepalive",
"(",
"self",
",",
"listenKey",
")",
":",
"params",
"=",
"{",
"'listenKey'",
":",
"listenKey",
"}",
"return",
"self",
".",
"_put",
"(",
"'userDataStream'",
",",
"False",
",",
"data",
"=",
"params",
")"
] | PING a user data stream to prevent a time out.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#keepalive-user-data-stream-user_stream
:param listenKey: required
:type listenKey: str
:returns: API response
.. code-block:: python
... | [
"PING",
"a",
"user",
"data",
"stream",
"to",
"prevent",
"a",
"time",
"out",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L2039-L2059 | train |
sammchardy/python-binance | binance/client.py | Client.stream_close | def stream_close(self, listenKey):
"""Close out a user data stream.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#close-user-data-stream-user_stream
:param listenKey: required
:type listenKey: str
:returns: API response
.. code-... | python | def stream_close(self, listenKey):
"""Close out a user data stream.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#close-user-data-stream-user_stream
:param listenKey: required
:type listenKey: str
:returns: API response
.. code-... | [
"def",
"stream_close",
"(",
"self",
",",
"listenKey",
")",
":",
"params",
"=",
"{",
"'listenKey'",
":",
"listenKey",
"}",
"return",
"self",
".",
"_delete",
"(",
"'userDataStream'",
",",
"False",
",",
"data",
"=",
"params",
")"
] | Close out a user data stream.
https://github.com/binance-exchange/binance-official-api-docs/blob/master/rest-api.md#close-user-data-stream-user_stream
:param listenKey: required
:type listenKey: str
:returns: API response
.. code-block:: python
{}
:raise... | [
"Close",
"out",
"a",
"user",
"data",
"stream",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/client.py#L2061-L2081 | train |
sammchardy/python-binance | binance/websockets.py | BinanceSocketManager.start_depth_socket | def start_depth_socket(self, symbol, callback, depth=None):
"""Start a websocket for symbol market depth returning either a diff or a partial book
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#partial-book-depth-streams
:param symbol: required
... | python | def start_depth_socket(self, symbol, callback, depth=None):
"""Start a websocket for symbol market depth returning either a diff or a partial book
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#partial-book-depth-streams
:param symbol: required
... | [
"def",
"start_depth_socket",
"(",
"self",
",",
"symbol",
",",
"callback",
",",
"depth",
"=",
"None",
")",
":",
"socket_name",
"=",
"symbol",
".",
"lower",
"(",
")",
"+",
"'@depth'",
"if",
"depth",
"and",
"depth",
"!=",
"'1'",
":",
"socket_name",
"=",
"... | Start a websocket for symbol market depth returning either a diff or a partial book
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#partial-book-depth-streams
:param symbol: required
:type symbol: str
:param callback: callback function to... | [
"Start",
"a",
"websocket",
"for",
"symbol",
"market",
"depth",
"returning",
"either",
"a",
"diff",
"or",
"a",
"partial",
"book"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/websockets.py#L105-L172 | train |
sammchardy/python-binance | binance/websockets.py | BinanceSocketManager.start_kline_socket | def start_kline_socket(self, symbol, callback, interval=Client.KLINE_INTERVAL_1MINUTE):
"""Start a websocket for symbol kline data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams
:param symbol: required
:type symb... | python | def start_kline_socket(self, symbol, callback, interval=Client.KLINE_INTERVAL_1MINUTE):
"""Start a websocket for symbol kline data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams
:param symbol: required
:type symb... | [
"def",
"start_kline_socket",
"(",
"self",
",",
"symbol",
",",
"callback",
",",
"interval",
"=",
"Client",
".",
"KLINE_INTERVAL_1MINUTE",
")",
":",
"socket_name",
"=",
"'{}@kline_{}'",
".",
"format",
"(",
"symbol",
".",
"lower",
"(",
")",
",",
"interval",
")"... | Start a websocket for symbol kline data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/web-socket-streams.md#klinecandlestick-streams
:param symbol: required
:type symbol: str
:param callback: callback function to handle messages
:type callback: funct... | [
"Start",
"a",
"websocket",
"for",
"symbol",
"kline",
"data"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/websockets.py#L174-L218 | train |
sammchardy/python-binance | binance/websockets.py | BinanceSocketManager.start_multiplex_socket | def start_multiplex_socket(self, streams, callback):
"""Start a multiplexed socket using a list of socket names.
User stream sockets can not be included.
Symbols in socket name must be lowercase i.e bnbbtc@aggTrade, neobtc@ticker
Combined stream events are wrapped as follows: {"stream"... | python | def start_multiplex_socket(self, streams, callback):
"""Start a multiplexed socket using a list of socket names.
User stream sockets can not be included.
Symbols in socket name must be lowercase i.e bnbbtc@aggTrade, neobtc@ticker
Combined stream events are wrapped as follows: {"stream"... | [
"def",
"start_multiplex_socket",
"(",
"self",
",",
"streams",
",",
"callback",
")",
":",
"stream_path",
"=",
"'streams={}'",
".",
"format",
"(",
"'/'",
".",
"join",
"(",
"streams",
")",
")",
"return",
"self",
".",
"_start_socket",
"(",
"stream_path",
",",
... | Start a multiplexed socket using a list of socket names.
User stream sockets can not be included.
Symbols in socket name must be lowercase i.e bnbbtc@aggTrade, neobtc@ticker
Combined stream events are wrapped as follows: {"stream":"<streamName>","data":<rawPayload>}
https://github.com... | [
"Start",
"a",
"multiplexed",
"socket",
"using",
"a",
"list",
"of",
"socket",
"names",
".",
"User",
"stream",
"sockets",
"can",
"not",
"be",
"included",
"."
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/websockets.py#L409-L430 | train |
sammchardy/python-binance | binance/websockets.py | BinanceSocketManager.start_user_socket | def start_user_socket(self, callback):
"""Start a websocket for user data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md
:param callback: callback function to handle messages
:type callback: function
:returns: connection key strin... | python | def start_user_socket(self, callback):
"""Start a websocket for user data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md
:param callback: callback function to handle messages
:type callback: function
:returns: connection key strin... | [
"def",
"start_user_socket",
"(",
"self",
",",
"callback",
")",
":",
"# Get the user listen key",
"user_listen_key",
"=",
"self",
".",
"_client",
".",
"stream_get_listen_key",
"(",
")",
"# and start the socket with this specific key",
"conn_key",
"=",
"self",
".",
"_star... | Start a websocket for user data
https://github.com/binance-exchange/binance-official-api-docs/blob/master/user-data-stream.md
:param callback: callback function to handle messages
:type callback: function
:returns: connection key string if successful, False otherwise
Message ... | [
"Start",
"a",
"websocket",
"for",
"user",
"data"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/websockets.py#L432-L448 | train |
sammchardy/python-binance | binance/websockets.py | BinanceSocketManager.stop_socket | def stop_socket(self, conn_key):
"""Stop a websocket given the connection key
:param conn_key: Socket connection key
:type conn_key: string
:returns: connection key string if successful, False otherwise
"""
if conn_key not in self._conns:
return
# d... | python | def stop_socket(self, conn_key):
"""Stop a websocket given the connection key
:param conn_key: Socket connection key
:type conn_key: string
:returns: connection key string if successful, False otherwise
"""
if conn_key not in self._conns:
return
# d... | [
"def",
"stop_socket",
"(",
"self",
",",
"conn_key",
")",
":",
"if",
"conn_key",
"not",
"in",
"self",
".",
"_conns",
":",
"return",
"# disable reconnecting if we are closing",
"self",
".",
"_conns",
"[",
"conn_key",
"]",
".",
"factory",
"=",
"WebSocketClientFacto... | Stop a websocket given the connection key
:param conn_key: Socket connection key
:type conn_key: string
:returns: connection key string if successful, False otherwise | [
"Stop",
"a",
"websocket",
"given",
"the",
"connection",
"key"
] | 31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc | https://github.com/sammchardy/python-binance/blob/31c0d0a32f9edd528c6c2c1dd3044d9a34ce43cc/binance/websockets.py#L484-L502 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.