id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
18,100 | drdoctr/doctr | doctr/travis.py | sync_from_log | def sync_from_log(src, dst, log_file, exclude=()):
"""
Sync the files in ``src`` to ``dst``.
The files that are synced are logged to ``log_file``. If ``log_file``
exists, the files in ``log_file`` are removed first.
Returns ``(added, removed)``, where added is a list of all files synced from
`... | python | def sync_from_log(src, dst, log_file, exclude=()):
"""
Sync the files in ``src`` to ``dst``.
The files that are synced are logged to ``log_file``. If ``log_file``
exists, the files in ``log_file`` are removed first.
Returns ``(added, removed)``, where added is a list of all files synced from
`... | [
"def",
"sync_from_log",
"(",
"src",
",",
"dst",
",",
"log_file",
",",
"exclude",
"=",
"(",
")",
")",
":",
"from",
"os",
".",
"path",
"import",
"join",
",",
"exists",
",",
"isdir",
"exclude",
"=",
"[",
"os",
".",
"path",
".",
"normpath",
"(",
"i",
... | Sync the files in ``src`` to ``dst``.
The files that are synced are logged to ``log_file``. If ``log_file``
exists, the files in ``log_file`` are removed first.
Returns ``(added, removed)``, where added is a list of all files synced from
``src`` (even if it already existed in ``dst``), and ``removed``... | [
"Sync",
"the",
"files",
"in",
"src",
"to",
"dst",
"."
] | 0f19ff78c8239efcc98d417f36b0a31d9be01ba5 | https://github.com/drdoctr/doctr/blob/0f19ff78c8239efcc98d417f36b0a31d9be01ba5/doctr/travis.py#L410-L477 |
18,101 | drdoctr/doctr | doctr/travis.py | push_docs | def push_docs(deploy_branch='gh-pages', retries=5):
"""
Push the changes to the branch named ``deploy_branch``.
Assumes that :func:`setup_GitHub_push` has been run and returned True, and
that :func:`commit_docs` has been run. Does not push anything if no changes
were made.
"""
code = 1
... | python | def push_docs(deploy_branch='gh-pages', retries=5):
"""
Push the changes to the branch named ``deploy_branch``.
Assumes that :func:`setup_GitHub_push` has been run and returned True, and
that :func:`commit_docs` has been run. Does not push anything if no changes
were made.
"""
code = 1
... | [
"def",
"push_docs",
"(",
"deploy_branch",
"=",
"'gh-pages'",
",",
"retries",
"=",
"5",
")",
":",
"code",
"=",
"1",
"while",
"code",
"and",
"retries",
":",
"print",
"(",
"\"Pulling\"",
")",
"code",
"=",
"run",
"(",
"[",
"'git'",
",",
"'pull'",
",",
"'... | Push the changes to the branch named ``deploy_branch``.
Assumes that :func:`setup_GitHub_push` has been run and returned True, and
that :func:`commit_docs` has been run. Does not push anything if no changes
were made. | [
"Push",
"the",
"changes",
"to",
"the",
"branch",
"named",
"deploy_branch",
"."
] | 0f19ff78c8239efcc98d417f36b0a31d9be01ba5 | https://github.com/drdoctr/doctr/blob/0f19ff78c8239efcc98d417f36b0a31d9be01ba5/doctr/travis.py#L536-L560 |
18,102 | licenses/lice | lice/core.py | clean_path | def clean_path(p):
""" Clean a path by expanding user and environment variables and
ensuring absolute path.
"""
p = os.path.expanduser(p)
p = os.path.expandvars(p)
p = os.path.abspath(p)
return p | python | def clean_path(p):
""" Clean a path by expanding user and environment variables and
ensuring absolute path.
"""
p = os.path.expanduser(p)
p = os.path.expandvars(p)
p = os.path.abspath(p)
return p | [
"def",
"clean_path",
"(",
"p",
")",
":",
"p",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"p",
")",
"p",
"=",
"os",
".",
"path",
".",
"expandvars",
"(",
"p",
")",
"p",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"p",
")",
"return",
"p"
] | Clean a path by expanding user and environment variables and
ensuring absolute path. | [
"Clean",
"a",
"path",
"by",
"expanding",
"user",
"and",
"environment",
"variables",
"and",
"ensuring",
"absolute",
"path",
"."
] | 71635c2544d5edf9e93af4141467763916a86624 | https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L93-L100 |
18,103 | licenses/lice | lice/core.py | load_file_template | def load_file_template(path):
""" Load template from the specified filesystem path.
"""
template = StringIO()
if not os.path.exists(path):
raise ValueError("path does not exist: %s" % path)
with open(clean_path(path), "rb") as infile: # opened as binary
for line in infile:
... | python | def load_file_template(path):
""" Load template from the specified filesystem path.
"""
template = StringIO()
if not os.path.exists(path):
raise ValueError("path does not exist: %s" % path)
with open(clean_path(path), "rb") as infile: # opened as binary
for line in infile:
... | [
"def",
"load_file_template",
"(",
"path",
")",
":",
"template",
"=",
"StringIO",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"raise",
"ValueError",
"(",
"\"path does not exist: %s\"",
"%",
"path",
")",
"with",
"open",
... | Load template from the specified filesystem path. | [
"Load",
"template",
"from",
"the",
"specified",
"filesystem",
"path",
"."
] | 71635c2544d5edf9e93af4141467763916a86624 | https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L126-L135 |
18,104 | licenses/lice | lice/core.py | load_package_template | def load_package_template(license, header=False):
""" Load license template distributed with package.
"""
content = StringIO()
filename = 'template-%s-header.txt' if header else 'template-%s.txt'
with resource_stream(__name__, filename % license) as licfile:
for line in licfile:
... | python | def load_package_template(license, header=False):
""" Load license template distributed with package.
"""
content = StringIO()
filename = 'template-%s-header.txt' if header else 'template-%s.txt'
with resource_stream(__name__, filename % license) as licfile:
for line in licfile:
... | [
"def",
"load_package_template",
"(",
"license",
",",
"header",
"=",
"False",
")",
":",
"content",
"=",
"StringIO",
"(",
")",
"filename",
"=",
"'template-%s-header.txt'",
"if",
"header",
"else",
"'template-%s.txt'",
"with",
"resource_stream",
"(",
"__name__",
",",
... | Load license template distributed with package. | [
"Load",
"license",
"template",
"distributed",
"with",
"package",
"."
] | 71635c2544d5edf9e93af4141467763916a86624 | https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L138-L146 |
18,105 | licenses/lice | lice/core.py | extract_vars | def extract_vars(template):
""" Extract variables from template. Variables are enclosed in
double curly braces.
"""
keys = set()
for match in re.finditer(r"\{\{ (?P<key>\w+) \}\}", template.getvalue()):
keys.add(match.groups()[0])
return sorted(list(keys)) | python | def extract_vars(template):
""" Extract variables from template. Variables are enclosed in
double curly braces.
"""
keys = set()
for match in re.finditer(r"\{\{ (?P<key>\w+) \}\}", template.getvalue()):
keys.add(match.groups()[0])
return sorted(list(keys)) | [
"def",
"extract_vars",
"(",
"template",
")",
":",
"keys",
"=",
"set",
"(",
")",
"for",
"match",
"in",
"re",
".",
"finditer",
"(",
"r\"\\{\\{ (?P<key>\\w+) \\}\\}\"",
",",
"template",
".",
"getvalue",
"(",
")",
")",
":",
"keys",
".",
"add",
"(",
"match",
... | Extract variables from template. Variables are enclosed in
double curly braces. | [
"Extract",
"variables",
"from",
"template",
".",
"Variables",
"are",
"enclosed",
"in",
"double",
"curly",
"braces",
"."
] | 71635c2544d5edf9e93af4141467763916a86624 | https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L149-L156 |
18,106 | licenses/lice | lice/core.py | generate_license | def generate_license(template, context):
""" Generate a license by extracting variables from the template and
replacing them with the corresponding values in the given context.
"""
out = StringIO()
content = template.getvalue()
for key in extract_vars(template):
if key not in context... | python | def generate_license(template, context):
""" Generate a license by extracting variables from the template and
replacing them with the corresponding values in the given context.
"""
out = StringIO()
content = template.getvalue()
for key in extract_vars(template):
if key not in context... | [
"def",
"generate_license",
"(",
"template",
",",
"context",
")",
":",
"out",
"=",
"StringIO",
"(",
")",
"content",
"=",
"template",
".",
"getvalue",
"(",
")",
"for",
"key",
"in",
"extract_vars",
"(",
"template",
")",
":",
"if",
"key",
"not",
"in",
"con... | Generate a license by extracting variables from the template and
replacing them with the corresponding values in the given context. | [
"Generate",
"a",
"license",
"by",
"extracting",
"variables",
"from",
"the",
"template",
"and",
"replacing",
"them",
"with",
"the",
"corresponding",
"values",
"in",
"the",
"given",
"context",
"."
] | 71635c2544d5edf9e93af4141467763916a86624 | https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L159-L171 |
18,107 | licenses/lice | lice/core.py | get_suffix | def get_suffix(name):
"""Check if file name have valid suffix for formatting.
if have suffix return it else return False.
"""
a = name.count(".")
if a:
ext = name.split(".")[-1]
if ext in LANGS.keys():
return ext
return False
else:
return False | python | def get_suffix(name):
"""Check if file name have valid suffix for formatting.
if have suffix return it else return False.
"""
a = name.count(".")
if a:
ext = name.split(".")[-1]
if ext in LANGS.keys():
return ext
return False
else:
return False | [
"def",
"get_suffix",
"(",
"name",
")",
":",
"a",
"=",
"name",
".",
"count",
"(",
"\".\"",
")",
"if",
"a",
":",
"ext",
"=",
"name",
".",
"split",
"(",
"\".\"",
")",
"[",
"-",
"1",
"]",
"if",
"ext",
"in",
"LANGS",
".",
"keys",
"(",
")",
":",
... | Check if file name have valid suffix for formatting.
if have suffix return it else return False. | [
"Check",
"if",
"file",
"name",
"have",
"valid",
"suffix",
"for",
"formatting",
".",
"if",
"have",
"suffix",
"return",
"it",
"else",
"return",
"False",
"."
] | 71635c2544d5edf9e93af4141467763916a86624 | https://github.com/licenses/lice/blob/71635c2544d5edf9e93af4141467763916a86624/lice/core.py#L191-L202 |
18,108 | crate/crate-python | src/crate/client/http.py | _raise_for_status | def _raise_for_status(response):
""" make sure that only crate.exceptions are raised that are defined in
the DB-API specification """
message = ''
if 400 <= response.status < 500:
message = '%s Client Error: %s' % (response.status, response.reason)
elif 500 <= response.status < 600:
... | python | def _raise_for_status(response):
""" make sure that only crate.exceptions are raised that are defined in
the DB-API specification """
message = ''
if 400 <= response.status < 500:
message = '%s Client Error: %s' % (response.status, response.reason)
elif 500 <= response.status < 600:
... | [
"def",
"_raise_for_status",
"(",
"response",
")",
":",
"message",
"=",
"''",
"if",
"400",
"<=",
"response",
".",
"status",
"<",
"500",
":",
"message",
"=",
"'%s Client Error: %s'",
"%",
"(",
"response",
".",
"status",
",",
"response",
".",
"reason",
")",
... | make sure that only crate.exceptions are raised that are defined in
the DB-API specification | [
"make",
"sure",
"that",
"only",
"crate",
".",
"exceptions",
"are",
"raised",
"that",
"are",
"defined",
"in",
"the",
"DB",
"-",
"API",
"specification"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L164-L189 |
18,109 | crate/crate-python | src/crate/client/http.py | _server_url | def _server_url(server):
"""
Normalizes a given server string to an url
>>> print(_server_url('a'))
http://a
>>> print(_server_url('a:9345'))
http://a:9345
>>> print(_server_url('https://a:9345'))
https://a:9345
>>> print(_server_url('https://a'))
https://a
>>> print(_server... | python | def _server_url(server):
"""
Normalizes a given server string to an url
>>> print(_server_url('a'))
http://a
>>> print(_server_url('a:9345'))
http://a:9345
>>> print(_server_url('https://a:9345'))
https://a:9345
>>> print(_server_url('https://a'))
https://a
>>> print(_server... | [
"def",
"_server_url",
"(",
"server",
")",
":",
"if",
"not",
"_HTTP_PAT",
".",
"match",
"(",
"server",
")",
":",
"server",
"=",
"'http://%s'",
"%",
"server",
"parsed",
"=",
"urlparse",
"(",
"server",
")",
"url",
"=",
"'%s://%s'",
"%",
"(",
"parsed",
"."... | Normalizes a given server string to an url
>>> print(_server_url('a'))
http://a
>>> print(_server_url('a:9345'))
http://a:9345
>>> print(_server_url('https://a:9345'))
https://a:9345
>>> print(_server_url('https://a'))
https://a
>>> print(_server_url('demo.crate.io'))
http://dem... | [
"Normalizes",
"a",
"given",
"server",
"string",
"to",
"an",
"url"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L192-L211 |
18,110 | crate/crate-python | src/crate/client/http.py | Client.sql | def sql(self, stmt, parameters=None, bulk_parameters=None):
"""
Execute SQL stmt against the crate server.
"""
if stmt is None:
return None
data = _create_sql_payload(stmt, parameters, bulk_parameters)
logger.debug(
'Sending request to %s with pay... | python | def sql(self, stmt, parameters=None, bulk_parameters=None):
"""
Execute SQL stmt against the crate server.
"""
if stmt is None:
return None
data = _create_sql_payload(stmt, parameters, bulk_parameters)
logger.debug(
'Sending request to %s with pay... | [
"def",
"sql",
"(",
"self",
",",
"stmt",
",",
"parameters",
"=",
"None",
",",
"bulk_parameters",
"=",
"None",
")",
":",
"if",
"stmt",
"is",
"None",
":",
"return",
"None",
"data",
"=",
"_create_sql_payload",
"(",
"stmt",
",",
"parameters",
",",
"bulk_param... | Execute SQL stmt against the crate server. | [
"Execute",
"SQL",
"stmt",
"against",
"the",
"crate",
"server",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L318-L331 |
18,111 | crate/crate-python | src/crate/client/http.py | Client.blob_put | def blob_put(self, table, digest, data):
"""
Stores the contents of the file like @data object in a blob under the
given table and digest.
"""
response = self._request('PUT', _blob_path(table, digest),
data=data)
if response.status == 201:... | python | def blob_put(self, table, digest, data):
"""
Stores the contents of the file like @data object in a blob under the
given table and digest.
"""
response = self._request('PUT', _blob_path(table, digest),
data=data)
if response.status == 201:... | [
"def",
"blob_put",
"(",
"self",
",",
"table",
",",
"digest",
",",
"data",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"'PUT'",
",",
"_blob_path",
"(",
"table",
",",
"digest",
")",
",",
"data",
"=",
"data",
")",
"if",
"response",
".",
"... | Stores the contents of the file like @data object in a blob under the
given table and digest. | [
"Stores",
"the",
"contents",
"of",
"the",
"file",
"like"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L341-L356 |
18,112 | crate/crate-python | src/crate/client/http.py | Client.blob_get | def blob_get(self, table, digest, chunk_size=1024 * 128):
"""
Returns a file like object representing the contents of the blob
with the given digest.
"""
response = self._request('GET', _blob_path(table, digest), stream=True)
if response.status == 404:
raise D... | python | def blob_get(self, table, digest, chunk_size=1024 * 128):
"""
Returns a file like object representing the contents of the blob
with the given digest.
"""
response = self._request('GET', _blob_path(table, digest), stream=True)
if response.status == 404:
raise D... | [
"def",
"blob_get",
"(",
"self",
",",
"table",
",",
"digest",
",",
"chunk_size",
"=",
"1024",
"*",
"128",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"'GET'",
",",
"_blob_path",
"(",
"table",
",",
"digest",
")",
",",
"stream",
"=",
"True"... | Returns a file like object representing the contents of the blob
with the given digest. | [
"Returns",
"a",
"file",
"like",
"object",
"representing",
"the",
"contents",
"of",
"the",
"blob",
"with",
"the",
"given",
"digest",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L369-L378 |
18,113 | crate/crate-python | src/crate/client/http.py | Client.blob_exists | def blob_exists(self, table, digest):
"""
Returns true if the blob with the given digest exists
under the given table.
"""
response = self._request('HEAD', _blob_path(table, digest))
if response.status == 200:
return True
elif response.status == 404:
... | python | def blob_exists(self, table, digest):
"""
Returns true if the blob with the given digest exists
under the given table.
"""
response = self._request('HEAD', _blob_path(table, digest))
if response.status == 200:
return True
elif response.status == 404:
... | [
"def",
"blob_exists",
"(",
"self",
",",
"table",
",",
"digest",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"'HEAD'",
",",
"_blob_path",
"(",
"table",
",",
"digest",
")",
")",
"if",
"response",
".",
"status",
"==",
"200",
":",
"return",
... | Returns true if the blob with the given digest exists
under the given table. | [
"Returns",
"true",
"if",
"the",
"blob",
"with",
"the",
"given",
"digest",
"exists",
"under",
"the",
"given",
"table",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L380-L390 |
18,114 | crate/crate-python | src/crate/client/http.py | Client._request | def _request(self, method, path, server=None, **kwargs):
"""Execute a request to the cluster
A server is selected from the server pool.
"""
while True:
next_server = server or self._get_server()
try:
response = self.server_pool[next_server].reques... | python | def _request(self, method, path, server=None, **kwargs):
"""Execute a request to the cluster
A server is selected from the server pool.
"""
while True:
next_server = server or self._get_server()
try:
response = self.server_pool[next_server].reques... | [
"def",
"_request",
"(",
"self",
",",
"method",
",",
"path",
",",
"server",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"while",
"True",
":",
"next_server",
"=",
"server",
"or",
"self",
".",
"_get_server",
"(",
")",
"try",
":",
"response",
"=",
... | Execute a request to the cluster
A server is selected from the server pool. | [
"Execute",
"a",
"request",
"to",
"the",
"cluster"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L397-L440 |
18,115 | crate/crate-python | src/crate/client/http.py | Client._json_request | def _json_request(self, method, path, data):
"""
Issue request against the crate HTTP API.
"""
response = self._request(method, path, data=data)
_raise_for_status(response)
if len(response.data) > 0:
return _json_from_response(response)
return respons... | python | def _json_request(self, method, path, data):
"""
Issue request against the crate HTTP API.
"""
response = self._request(method, path, data=data)
_raise_for_status(response)
if len(response.data) > 0:
return _json_from_response(response)
return respons... | [
"def",
"_json_request",
"(",
"self",
",",
"method",
",",
"path",
",",
"data",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"method",
",",
"path",
",",
"data",
"=",
"data",
")",
"_raise_for_status",
"(",
"response",
")",
"if",
"len",
"(",
... | Issue request against the crate HTTP API. | [
"Issue",
"request",
"against",
"the",
"crate",
"HTTP",
"API",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L442-L451 |
18,116 | crate/crate-python | src/crate/client/http.py | Client._get_server | def _get_server(self):
"""
Get server to use for request.
Also process inactive server list, re-add them after given interval.
"""
with self._lock:
inactive_server_count = len(self._inactive_servers)
for i in range(inactive_server_count):
t... | python | def _get_server(self):
"""
Get server to use for request.
Also process inactive server list, re-add them after given interval.
"""
with self._lock:
inactive_server_count = len(self._inactive_servers)
for i in range(inactive_server_count):
t... | [
"def",
"_get_server",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"inactive_server_count",
"=",
"len",
"(",
"self",
".",
"_inactive_servers",
")",
"for",
"i",
"in",
"range",
"(",
"inactive_server_count",
")",
":",
"try",
":",
"ts",
",",
"se... | Get server to use for request.
Also process inactive server list, re-add them after given interval. | [
"Get",
"server",
"to",
"use",
"for",
"request",
".",
"Also",
"process",
"inactive",
"server",
"list",
"re",
"-",
"add",
"them",
"after",
"given",
"interval",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L453-L484 |
18,117 | crate/crate-python | src/crate/client/http.py | Client._drop_server | def _drop_server(self, server, message):
"""
Drop server from active list and adds it to the inactive ones.
"""
try:
self._active_servers.remove(server)
except ValueError:
pass
else:
heapq.heappush(self._inactive_servers, (time(), serve... | python | def _drop_server(self, server, message):
"""
Drop server from active list and adds it to the inactive ones.
"""
try:
self._active_servers.remove(server)
except ValueError:
pass
else:
heapq.heappush(self._inactive_servers, (time(), serve... | [
"def",
"_drop_server",
"(",
"self",
",",
"server",
",",
"message",
")",
":",
"try",
":",
"self",
".",
"_active_servers",
".",
"remove",
"(",
"server",
")",
"except",
"ValueError",
":",
"pass",
"else",
":",
"heapq",
".",
"heappush",
"(",
"self",
".",
"_... | Drop server from active list and adds it to the inactive ones. | [
"Drop",
"server",
"from",
"active",
"list",
"and",
"adds",
"it",
"to",
"the",
"inactive",
"ones",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/http.py#L492-L508 |
18,118 | crate/crate-python | src/crate/client/sqlalchemy/predicates/__init__.py | match | def match(column, term, match_type=None, options=None):
"""Generates match predicate for fulltext search
:param column: A reference to a column or an index, or a subcolumn, or a
dictionary of subcolumns with boost values.
:param term: The term to match against. This string is analyzed and the
re... | python | def match(column, term, match_type=None, options=None):
"""Generates match predicate for fulltext search
:param column: A reference to a column or an index, or a subcolumn, or a
dictionary of subcolumns with boost values.
:param term: The term to match against. This string is analyzed and the
re... | [
"def",
"match",
"(",
"column",
",",
"term",
",",
"match_type",
"=",
"None",
",",
"options",
"=",
"None",
")",
":",
"return",
"Match",
"(",
"column",
",",
"term",
",",
"match_type",
",",
"options",
")"
] | Generates match predicate for fulltext search
:param column: A reference to a column or an index, or a subcolumn, or a
dictionary of subcolumns with boost values.
:param term: The term to match against. This string is analyzed and the
resulting tokens are compared to the index.
:param match_typ... | [
"Generates",
"match",
"predicate",
"for",
"fulltext",
"search"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/sqlalchemy/predicates/__init__.py#L70-L86 |
18,119 | crate/crate-python | src/crate/client/blob.py | BlobContainer.put | def put(self, f, digest=None):
"""
Upload a blob
:param f:
File object to be uploaded (required to support seek if digest is
not provided).
:param digest:
Optional SHA-1 hex digest of the file contents. Gets computed
before actual upload i... | python | def put(self, f, digest=None):
"""
Upload a blob
:param f:
File object to be uploaded (required to support seek if digest is
not provided).
:param digest:
Optional SHA-1 hex digest of the file contents. Gets computed
before actual upload i... | [
"def",
"put",
"(",
"self",
",",
"f",
",",
"digest",
"=",
"None",
")",
":",
"if",
"digest",
":",
"actual_digest",
"=",
"digest",
"else",
":",
"actual_digest",
"=",
"self",
".",
"_compute_digest",
"(",
"f",
")",
"created",
"=",
"self",
".",
"conn",
"."... | Upload a blob
:param f:
File object to be uploaded (required to support seek if digest is
not provided).
:param digest:
Optional SHA-1 hex digest of the file contents. Gets computed
before actual upload if not provided, which requires an extra file
... | [
"Upload",
"a",
"blob"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/blob.py#L46-L71 |
18,120 | crate/crate-python | src/crate/client/blob.py | BlobContainer.get | def get(self, digest, chunk_size=1024 * 128):
"""
Return the contents of a blob
:param digest: the hex digest of the blob to return
:param chunk_size: the size of the chunks returned on each iteration
:return: generator returning chunks of data
"""
return self.co... | python | def get(self, digest, chunk_size=1024 * 128):
"""
Return the contents of a blob
:param digest: the hex digest of the blob to return
:param chunk_size: the size of the chunks returned on each iteration
:return: generator returning chunks of data
"""
return self.co... | [
"def",
"get",
"(",
"self",
",",
"digest",
",",
"chunk_size",
"=",
"1024",
"*",
"128",
")",
":",
"return",
"self",
".",
"conn",
".",
"client",
".",
"blob_get",
"(",
"self",
".",
"container_name",
",",
"digest",
",",
"chunk_size",
")"
] | Return the contents of a blob
:param digest: the hex digest of the blob to return
:param chunk_size: the size of the chunks returned on each iteration
:return: generator returning chunks of data | [
"Return",
"the",
"contents",
"of",
"a",
"blob"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/blob.py#L73-L82 |
18,121 | crate/crate-python | src/crate/client/blob.py | BlobContainer.delete | def delete(self, digest):
"""
Delete a blob
:param digest: the hex digest of the blob to be deleted
:return: True if blob existed
"""
return self.conn.client.blob_del(self.container_name, digest) | python | def delete(self, digest):
"""
Delete a blob
:param digest: the hex digest of the blob to be deleted
:return: True if blob existed
"""
return self.conn.client.blob_del(self.container_name, digest) | [
"def",
"delete",
"(",
"self",
",",
"digest",
")",
":",
"return",
"self",
".",
"conn",
".",
"client",
".",
"blob_del",
"(",
"self",
".",
"container_name",
",",
"digest",
")"
] | Delete a blob
:param digest: the hex digest of the blob to be deleted
:return: True if blob existed | [
"Delete",
"a",
"blob"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/blob.py#L84-L91 |
18,122 | crate/crate-python | src/crate/client/blob.py | BlobContainer.exists | def exists(self, digest):
"""
Check if a blob exists
:param digest: Hex digest of the blob
:return: Boolean indicating existence of the blob
"""
return self.conn.client.blob_exists(self.container_name, digest) | python | def exists(self, digest):
"""
Check if a blob exists
:param digest: Hex digest of the blob
:return: Boolean indicating existence of the blob
"""
return self.conn.client.blob_exists(self.container_name, digest) | [
"def",
"exists",
"(",
"self",
",",
"digest",
")",
":",
"return",
"self",
".",
"conn",
".",
"client",
".",
"blob_exists",
"(",
"self",
".",
"container_name",
",",
"digest",
")"
] | Check if a blob exists
:param digest: Hex digest of the blob
:return: Boolean indicating existence of the blob | [
"Check",
"if",
"a",
"blob",
"exists"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/blob.py#L93-L100 |
18,123 | crate/crate-python | src/crate/client/cursor.py | Cursor.next | def next(self):
"""
Return the next row of a query result set, respecting if cursor was
closed.
"""
if self.rows is None:
raise ProgrammingError(
"No result available. " +
"execute() or executemany() must be called first."
)... | python | def next(self):
"""
Return the next row of a query result set, respecting if cursor was
closed.
"""
if self.rows is None:
raise ProgrammingError(
"No result available. " +
"execute() or executemany() must be called first."
)... | [
"def",
"next",
"(",
"self",
")",
":",
"if",
"self",
".",
"rows",
"is",
"None",
":",
"raise",
"ProgrammingError",
"(",
"\"No result available. \"",
"+",
"\"execute() or executemany() must be called first.\"",
")",
"elif",
"not",
"self",
".",
"_closed",
":",
"return... | Return the next row of a query result set, respecting if cursor was
closed. | [
"Return",
"the",
"next",
"row",
"of",
"a",
"query",
"result",
"set",
"respecting",
"if",
"cursor",
"was",
"closed",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/cursor.py#L175-L188 |
18,124 | crate/crate-python | src/crate/client/cursor.py | Cursor.duration | def duration(self):
"""
This read-only attribute specifies the server-side duration of a query
in milliseconds.
"""
if self._closed or \
not self._result or \
"duration" not in self._result:
return -1
return self._result.get("du... | python | def duration(self):
"""
This read-only attribute specifies the server-side duration of a query
in milliseconds.
"""
if self._closed or \
not self._result or \
"duration" not in self._result:
return -1
return self._result.get("du... | [
"def",
"duration",
"(",
"self",
")",
":",
"if",
"self",
".",
"_closed",
"or",
"not",
"self",
".",
"_result",
"or",
"\"duration\"",
"not",
"in",
"self",
".",
"_result",
":",
"return",
"-",
"1",
"return",
"self",
".",
"_result",
".",
"get",
"(",
"\"dur... | This read-only attribute specifies the server-side duration of a query
in milliseconds. | [
"This",
"read",
"-",
"only",
"attribute",
"specifies",
"the",
"server",
"-",
"side",
"duration",
"of",
"a",
"query",
"in",
"milliseconds",
"."
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/cursor.py#L212-L221 |
18,125 | crate/crate-python | src/crate/client/sqlalchemy/compiler.py | rewrite_update | def rewrite_update(clauseelement, multiparams, params):
""" change the params to enable partial updates
sqlalchemy by default only supports updates of complex types in the form of
"col = ?", ({"x": 1, "y": 2}
but crate supports
"col['x'] = ?, col['y'] = ?", (1, 2)
by using the `Crat... | python | def rewrite_update(clauseelement, multiparams, params):
""" change the params to enable partial updates
sqlalchemy by default only supports updates of complex types in the form of
"col = ?", ({"x": 1, "y": 2}
but crate supports
"col['x'] = ?, col['y'] = ?", (1, 2)
by using the `Crat... | [
"def",
"rewrite_update",
"(",
"clauseelement",
",",
"multiparams",
",",
"params",
")",
":",
"newmultiparams",
"=",
"[",
"]",
"_multiparams",
"=",
"multiparams",
"[",
"0",
"]",
"if",
"len",
"(",
"_multiparams",
")",
"==",
"0",
":",
"return",
"clauseelement",
... | change the params to enable partial updates
sqlalchemy by default only supports updates of complex types in the form of
"col = ?", ({"x": 1, "y": 2}
but crate supports
"col['x'] = ?, col['y'] = ?", (1, 2)
by using the `Craty` (`MutableDict`) type.
The update statement is only rewrit... | [
"change",
"the",
"params",
"to",
"enable",
"partial",
"updates"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/sqlalchemy/compiler.py#L32-L70 |
18,126 | crate/crate-python | src/crate/client/sqlalchemy/compiler.py | CrateCompiler._get_crud_params | def _get_crud_params(compiler, stmt, **kw):
""" extract values from crud parameters
taken from SQLAlchemy's crud module (since 1.0.x) and
adapted for Crate dialect"""
compiler.postfetch = []
compiler.insert_prefetch = []
compiler.update_prefetch = []
compiler.re... | python | def _get_crud_params(compiler, stmt, **kw):
""" extract values from crud parameters
taken from SQLAlchemy's crud module (since 1.0.x) and
adapted for Crate dialect"""
compiler.postfetch = []
compiler.insert_prefetch = []
compiler.update_prefetch = []
compiler.re... | [
"def",
"_get_crud_params",
"(",
"compiler",
",",
"stmt",
",",
"*",
"*",
"kw",
")",
":",
"compiler",
".",
"postfetch",
"=",
"[",
"]",
"compiler",
".",
"insert_prefetch",
"=",
"[",
"]",
"compiler",
".",
"update_prefetch",
"=",
"[",
"]",
"compiler",
".",
... | extract values from crud parameters
taken from SQLAlchemy's crud module (since 1.0.x) and
adapted for Crate dialect | [
"extract",
"values",
"from",
"crud",
"parameters"
] | 68e39c95f5bbe88b74bbfa26de4347fc644636a8 | https://github.com/crate/crate-python/blob/68e39c95f5bbe88b74bbfa26de4347fc644636a8/src/crate/client/sqlalchemy/compiler.py#L362-L423 |
18,127 | kstateome/django-cas | cas/models.py | get_tgt_for | def get_tgt_for(user):
"""
Fetch a ticket granting ticket for a given user.
:param user: UserObj
:return: TGT or Exepction
"""
if not settings.CAS_PROXY_CALLBACK:
raise CasConfigException("No proxy callback set in settings")
try:
return Tgt.objects.get(username=user.userna... | python | def get_tgt_for(user):
"""
Fetch a ticket granting ticket for a given user.
:param user: UserObj
:return: TGT or Exepction
"""
if not settings.CAS_PROXY_CALLBACK:
raise CasConfigException("No proxy callback set in settings")
try:
return Tgt.objects.get(username=user.userna... | [
"def",
"get_tgt_for",
"(",
"user",
")",
":",
"if",
"not",
"settings",
".",
"CAS_PROXY_CALLBACK",
":",
"raise",
"CasConfigException",
"(",
"\"No proxy callback set in settings\"",
")",
"try",
":",
"return",
"Tgt",
".",
"objects",
".",
"get",
"(",
"username",
"=",... | Fetch a ticket granting ticket for a given user.
:param user: UserObj
:return: TGT or Exepction | [
"Fetch",
"a",
"ticket",
"granting",
"ticket",
"for",
"a",
"given",
"user",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/models.py#L77-L94 |
18,128 | kstateome/django-cas | cas/models.py | Tgt.get_proxy_ticket_for | def get_proxy_ticket_for(self, service):
"""
Verifies CAS 2.0+ XML-based authentication ticket.
:param: service
Returns username on success and None on failure.
"""
if not settings.CAS_PROXY_CALLBACK:
raise CasConfigException("No proxy callback set in setti... | python | def get_proxy_ticket_for(self, service):
"""
Verifies CAS 2.0+ XML-based authentication ticket.
:param: service
Returns username on success and None on failure.
"""
if not settings.CAS_PROXY_CALLBACK:
raise CasConfigException("No proxy callback set in setti... | [
"def",
"get_proxy_ticket_for",
"(",
"self",
",",
"service",
")",
":",
"if",
"not",
"settings",
".",
"CAS_PROXY_CALLBACK",
":",
"raise",
"CasConfigException",
"(",
"\"No proxy callback set in settings\"",
")",
"params",
"=",
"{",
"'pgt'",
":",
"self",
".",
"tgt",
... | Verifies CAS 2.0+ XML-based authentication ticket.
:param: service
Returns username on success and None on failure. | [
"Verifies",
"CAS",
"2",
".",
"0",
"+",
"XML",
"-",
"based",
"authentication",
"ticket",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/models.py#L36-L65 |
18,129 | kstateome/django-cas | cas/backends.py | _internal_verify_cas | def _internal_verify_cas(ticket, service, suffix):
"""Verifies CAS 2.0 and 3.0 XML-based authentication ticket.
Returns username on success and None on failure.
"""
params = {'ticket': ticket, 'service': service}
if settings.CAS_PROXY_CALLBACK:
params['pgtUrl'] = settings.CAS_PROXY_CALLBAC... | python | def _internal_verify_cas(ticket, service, suffix):
"""Verifies CAS 2.0 and 3.0 XML-based authentication ticket.
Returns username on success and None on failure.
"""
params = {'ticket': ticket, 'service': service}
if settings.CAS_PROXY_CALLBACK:
params['pgtUrl'] = settings.CAS_PROXY_CALLBAC... | [
"def",
"_internal_verify_cas",
"(",
"ticket",
",",
"service",
",",
"suffix",
")",
":",
"params",
"=",
"{",
"'ticket'",
":",
"ticket",
",",
"'service'",
":",
"service",
"}",
"if",
"settings",
".",
"CAS_PROXY_CALLBACK",
":",
"params",
"[",
"'pgtUrl'",
"]",
"... | Verifies CAS 2.0 and 3.0 XML-based authentication ticket.
Returns username on success and None on failure. | [
"Verifies",
"CAS",
"2",
".",
"0",
"and",
"3",
".",
"0",
"XML",
"-",
"based",
"authentication",
"ticket",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/backends.py#L75-L138 |
18,130 | kstateome/django-cas | cas/backends.py | verify_proxy_ticket | def verify_proxy_ticket(ticket, service):
"""
Verifies CAS 2.0+ XML-based proxy ticket.
:param: ticket
:param: service
Returns username on success and None on failure.
"""
params = {'ticket': ticket, 'service': service}
url = (urljoin(settings.CAS_SERVER_URL, 'proxyValidate') + '?' +... | python | def verify_proxy_ticket(ticket, service):
"""
Verifies CAS 2.0+ XML-based proxy ticket.
:param: ticket
:param: service
Returns username on success and None on failure.
"""
params = {'ticket': ticket, 'service': service}
url = (urljoin(settings.CAS_SERVER_URL, 'proxyValidate') + '?' +... | [
"def",
"verify_proxy_ticket",
"(",
"ticket",
",",
"service",
")",
":",
"params",
"=",
"{",
"'ticket'",
":",
"ticket",
",",
"'service'",
":",
"service",
"}",
"url",
"=",
"(",
"urljoin",
"(",
"settings",
".",
"CAS_SERVER_URL",
",",
"'proxyValidate'",
")",
"+... | Verifies CAS 2.0+ XML-based proxy ticket.
:param: ticket
:param: service
Returns username on success and None on failure. | [
"Verifies",
"CAS",
"2",
".",
"0",
"+",
"XML",
"-",
"based",
"proxy",
"ticket",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/backends.py#L141-L171 |
18,131 | kstateome/django-cas | cas/backends.py | _get_pgtiou | def _get_pgtiou(pgt):
"""
Returns a PgtIOU object given a pgt.
The PgtIOU (tgt) is set by the CAS server in a different request
that has completed before this call, however, it may not be found in
the database by this calling thread, hence the attempt to get the
ticket is retried for up to 5 se... | python | def _get_pgtiou(pgt):
"""
Returns a PgtIOU object given a pgt.
The PgtIOU (tgt) is set by the CAS server in a different request
that has completed before this call, however, it may not be found in
the database by this calling thread, hence the attempt to get the
ticket is retried for up to 5 se... | [
"def",
"_get_pgtiou",
"(",
"pgt",
")",
":",
"pgtIou",
"=",
"None",
"retries_left",
"=",
"5",
"if",
"not",
"settings",
".",
"CAS_PGT_FETCH_WAIT",
":",
"retries_left",
"=",
"1",
"while",
"not",
"pgtIou",
"and",
"retries_left",
":",
"try",
":",
"return",
"Pgt... | Returns a PgtIOU object given a pgt.
The PgtIOU (tgt) is set by the CAS server in a different request
that has completed before this call, however, it may not be found in
the database by this calling thread, hence the attempt to get the
ticket is retried for up to 5 seconds. This should be handled some... | [
"Returns",
"a",
"PgtIOU",
"object",
"given",
"a",
"pgt",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/backends.py#L181-L213 |
18,132 | kstateome/django-cas | cas/decorators.py | gateway | def gateway():
"""
Authenticates single sign on session if ticket is available,
but doesn't redirect to sign in url otherwise.
"""
if settings.CAS_GATEWAY == False:
raise ImproperlyConfigured('CAS_GATEWAY must be set to True')
def wrap(func):
def wrapped_f(*args):
... | python | def gateway():
"""
Authenticates single sign on session if ticket is available,
but doesn't redirect to sign in url otherwise.
"""
if settings.CAS_GATEWAY == False:
raise ImproperlyConfigured('CAS_GATEWAY must be set to True')
def wrap(func):
def wrapped_f(*args):
... | [
"def",
"gateway",
"(",
")",
":",
"if",
"settings",
".",
"CAS_GATEWAY",
"==",
"False",
":",
"raise",
"ImproperlyConfigured",
"(",
"'CAS_GATEWAY must be set to True'",
")",
"def",
"wrap",
"(",
"func",
")",
":",
"def",
"wrapped_f",
"(",
"*",
"args",
")",
":",
... | Authenticates single sign on session if ticket is available,
but doesn't redirect to sign in url otherwise. | [
"Authenticates",
"single",
"sign",
"on",
"session",
"if",
"ticket",
"is",
"available",
"but",
"doesn",
"t",
"redirect",
"to",
"sign",
"in",
"url",
"otherwise",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/decorators.py#L60-L106 |
18,133 | kstateome/django-cas | cas/views.py | _service_url | def _service_url(request, redirect_to=None, gateway=False):
"""
Generates application service URL for CAS
:param: request Request Object
:param: redirect_to URL to redriect to
:param: gateway Should this be a gatewayed pass through
"""
if settings.CAS_FORCE_SSL_SERVICE_URL:
protoc... | python | def _service_url(request, redirect_to=None, gateway=False):
"""
Generates application service URL for CAS
:param: request Request Object
:param: redirect_to URL to redriect to
:param: gateway Should this be a gatewayed pass through
"""
if settings.CAS_FORCE_SSL_SERVICE_URL:
protoc... | [
"def",
"_service_url",
"(",
"request",
",",
"redirect_to",
"=",
"None",
",",
"gateway",
"=",
"False",
")",
":",
"if",
"settings",
".",
"CAS_FORCE_SSL_SERVICE_URL",
":",
"protocol",
"=",
"'https://'",
"else",
":",
"protocol",
"=",
"(",
"'http://'",
",",
"'htt... | Generates application service URL for CAS
:param: request Request Object
:param: redirect_to URL to redriect to
:param: gateway Should this be a gatewayed pass through | [
"Generates",
"application",
"service",
"URL",
"for",
"CAS"
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/views.py#L32-L79 |
18,134 | kstateome/django-cas | cas/views.py | proxy_callback | def proxy_callback(request):
"""Handles CAS 2.0+ XML-based proxy callback call.
Stores the proxy granting ticket in the database for
future use.
NB: Use created and set it in python in case database
has issues with setting up the default timestamp value
"""
pgtIou = request.GET.get('pgtIou... | python | def proxy_callback(request):
"""Handles CAS 2.0+ XML-based proxy callback call.
Stores the proxy granting ticket in the database for
future use.
NB: Use created and set it in python in case database
has issues with setting up the default timestamp value
"""
pgtIou = request.GET.get('pgtIou... | [
"def",
"proxy_callback",
"(",
"request",
")",
":",
"pgtIou",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'pgtIou'",
")",
"tgt",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'pgtId'",
")",
"if",
"not",
"(",
"pgtIou",
"and",
"tgt",
")",
":",
"logg... | Handles CAS 2.0+ XML-based proxy callback call.
Stores the proxy granting ticket in the database for
future use.
NB: Use created and set it in python in case database
has issues with setting up the default timestamp value | [
"Handles",
"CAS",
"2",
".",
"0",
"+",
"XML",
"-",
"based",
"proxy",
"callback",
"call",
".",
"Stores",
"the",
"proxy",
"granting",
"ticket",
"in",
"the",
"database",
"for",
"future",
"use",
"."
] | 8a871093966f001b4dadf7d097ac326169f3c066 | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/views.py#L245-L270 |
18,135 | eventbrite/eventbrite-sdk-python | eventbrite/decorators.py | objectify | def objectify(func):
""" Converts the returned value from a models.Payload to
a models.EventbriteObject. Used by the access methods
of the client.Eventbrite object
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
payload = func(*args, **kwargs)
e... | python | def objectify(func):
""" Converts the returned value from a models.Payload to
a models.EventbriteObject. Used by the access methods
of the client.Eventbrite object
"""
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
payload = func(*args, **kwargs)
e... | [
"def",
"objectify",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"payload",
"=",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
"... | Converts the returned value from a models.Payload to
a models.EventbriteObject. Used by the access methods
of the client.Eventbrite object | [
"Converts",
"the",
"returned",
"value",
"from",
"a",
"models",
".",
"Payload",
"to",
"a",
"models",
".",
"EventbriteObject",
".",
"Used",
"by",
"the",
"access",
"methods",
"of",
"the",
"client",
".",
"Eventbrite",
"object"
] | f2e5dc5aa1aa3e45766de13f16fd65722163d91a | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/decorators.py#L9-L22 |
18,136 | eventbrite/eventbrite-sdk-python | eventbrite/client.py | Eventbrite.get_user | def get_user(self, user_id=None):
"""
Returns a user for the specified user as user.
GET users/:id/
:param int user_id: (optional) The id assigned to a user
"""
if user_id:
return self.get('/users/{0}/'.format(user_id))
return self.get('/users/me/') | python | def get_user(self, user_id=None):
"""
Returns a user for the specified user as user.
GET users/:id/
:param int user_id: (optional) The id assigned to a user
"""
if user_id:
return self.get('/users/{0}/'.format(user_id))
return self.get('/users/me/') | [
"def",
"get_user",
"(",
"self",
",",
"user_id",
"=",
"None",
")",
":",
"if",
"user_id",
":",
"return",
"self",
".",
"get",
"(",
"'/users/{0}/'",
".",
"format",
"(",
"user_id",
")",
")",
"return",
"self",
".",
"get",
"(",
"'/users/me/'",
")"
] | Returns a user for the specified user as user.
GET users/:id/
:param int user_id: (optional) The id assigned to a user | [
"Returns",
"a",
"user",
"for",
"the",
"specified",
"user",
"as",
"user",
"."
] | f2e5dc5aa1aa3e45766de13f16fd65722163d91a | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/client.py#L94-L105 |
18,137 | eventbrite/eventbrite-sdk-python | eventbrite/client.py | Eventbrite.get_event_attendees | def get_event_attendees(self, event_id, status=None, changed_since=None):
"""
Returns a paginated response with a key of attendees, containing a
list of attendee.
GET /events/:id/attendees/
"""
data = {}
if status: # TODO - check the types of valid status
... | python | def get_event_attendees(self, event_id, status=None, changed_since=None):
"""
Returns a paginated response with a key of attendees, containing a
list of attendee.
GET /events/:id/attendees/
"""
data = {}
if status: # TODO - check the types of valid status
... | [
"def",
"get_event_attendees",
"(",
"self",
",",
"event_id",
",",
"status",
"=",
"None",
",",
"changed_since",
"=",
"None",
")",
":",
"data",
"=",
"{",
"}",
"if",
"status",
":",
"# TODO - check the types of valid status",
"data",
"[",
"'status'",
"]",
"=",
"s... | Returns a paginated response with a key of attendees, containing a
list of attendee.
GET /events/:id/attendees/ | [
"Returns",
"a",
"paginated",
"response",
"with",
"a",
"key",
"of",
"attendees",
"containing",
"a",
"list",
"of",
"attendee",
"."
] | f2e5dc5aa1aa3e45766de13f16fd65722163d91a | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/client.py#L133-L145 |
18,138 | eventbrite/eventbrite-sdk-python | eventbrite/client.py | Eventbrite.webhook_to_object | def webhook_to_object(self, webhook):
"""
Converts JSON sent by an Eventbrite Webhook to the appropriate
Eventbrite object.
# TODO - Add capability to handle Django request objects
"""
if isinstance(webhook, string_type):
# If still JSON, convert to a Python ... | python | def webhook_to_object(self, webhook):
"""
Converts JSON sent by an Eventbrite Webhook to the appropriate
Eventbrite object.
# TODO - Add capability to handle Django request objects
"""
if isinstance(webhook, string_type):
# If still JSON, convert to a Python ... | [
"def",
"webhook_to_object",
"(",
"self",
",",
"webhook",
")",
":",
"if",
"isinstance",
"(",
"webhook",
",",
"string_type",
")",
":",
"# If still JSON, convert to a Python dict",
"webhook",
"=",
"json",
".",
"dumps",
"(",
"webhook",
")",
"# if a flask.Request object,... | Converts JSON sent by an Eventbrite Webhook to the appropriate
Eventbrite object.
# TODO - Add capability to handle Django request objects | [
"Converts",
"JSON",
"sent",
"by",
"an",
"Eventbrite",
"Webhook",
"to",
"the",
"appropriate",
"Eventbrite",
"object",
"."
] | f2e5dc5aa1aa3e45766de13f16fd65722163d91a | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/eventbrite/client.py#L227-L249 |
18,139 | eventbrite/eventbrite-sdk-python | utils/generate_access_methods.py | get_params_from_page | def get_params_from_page(path, file_name, method_count):
""" This function accesses the rendered content.
We must do this because how the params are not defined in the docs,
but rather the rendered HTML
"""
# open the rendered file.
file_name = file_name.replace(".rst", "")
file_... | python | def get_params_from_page(path, file_name, method_count):
""" This function accesses the rendered content.
We must do this because how the params are not defined in the docs,
but rather the rendered HTML
"""
# open the rendered file.
file_name = file_name.replace(".rst", "")
file_... | [
"def",
"get_params_from_page",
"(",
"path",
",",
"file_name",
",",
"method_count",
")",
":",
"# open the rendered file.",
"file_name",
"=",
"file_name",
".",
"replace",
"(",
"\".rst\"",
",",
"\"\"",
")",
"file_path",
"=",
"\"{0}/../_build/html/endpoints/{1}/index.html\"... | This function accesses the rendered content.
We must do this because how the params are not defined in the docs,
but rather the rendered HTML | [
"This",
"function",
"accesses",
"the",
"rendered",
"content",
".",
"We",
"must",
"do",
"this",
"because",
"how",
"the",
"params",
"are",
"not",
"defined",
"in",
"the",
"docs",
"but",
"rather",
"the",
"rendered",
"HTML"
] | f2e5dc5aa1aa3e45766de13f16fd65722163d91a | https://github.com/eventbrite/eventbrite-sdk-python/blob/f2e5dc5aa1aa3e45766de13f16fd65722163d91a/utils/generate_access_methods.py#L172-L201 |
18,140 | robromano/django-adminrestrict | adminrestrict/middleware.py | AdminPagesRestrictMiddleware.process_request | def process_request(self, request):
"""
Check if the request is made form an allowed IP
"""
# Section adjusted to restrict login to ?edit
# (sing cms-toolbar-login)into DjangoCMS login.
restricted_request_uri = request.path.startswith(
reverse('admin:index') o... | python | def process_request(self, request):
"""
Check if the request is made form an allowed IP
"""
# Section adjusted to restrict login to ?edit
# (sing cms-toolbar-login)into DjangoCMS login.
restricted_request_uri = request.path.startswith(
reverse('admin:index') o... | [
"def",
"process_request",
"(",
"self",
",",
"request",
")",
":",
"# Section adjusted to restrict login to ?edit",
"# (sing cms-toolbar-login)into DjangoCMS login.",
"restricted_request_uri",
"=",
"request",
".",
"path",
".",
"startswith",
"(",
"reverse",
"(",
"'admin:index'",... | Check if the request is made form an allowed IP | [
"Check",
"if",
"the",
"request",
"is",
"made",
"form",
"an",
"allowed",
"IP"
] | f05fd21e49677731e3d291da956b84bcac9a5c69 | https://github.com/robromano/django-adminrestrict/blob/f05fd21e49677731e3d291da956b84bcac9a5c69/adminrestrict/middleware.py#L87-L116 |
18,141 | pydanny-archive/django-wysiwyg | django_wysiwyg/templatetags/wysiwyg.py | get_settings | def get_settings(editor_override=None):
"""Utility function to retrieve settings.py values with defaults"""
flavor = getattr(settings, "DJANGO_WYSIWYG_FLAVOR", "yui")
if editor_override is not None:
flavor = editor_override
return {
"DJANGO_WYSIWYG_MEDIA_URL": getattr(settings, "DJANGO... | python | def get_settings(editor_override=None):
"""Utility function to retrieve settings.py values with defaults"""
flavor = getattr(settings, "DJANGO_WYSIWYG_FLAVOR", "yui")
if editor_override is not None:
flavor = editor_override
return {
"DJANGO_WYSIWYG_MEDIA_URL": getattr(settings, "DJANGO... | [
"def",
"get_settings",
"(",
"editor_override",
"=",
"None",
")",
":",
"flavor",
"=",
"getattr",
"(",
"settings",
",",
"\"DJANGO_WYSIWYG_FLAVOR\"",
",",
"\"yui\"",
")",
"if",
"editor_override",
"is",
"not",
"None",
":",
"flavor",
"=",
"editor_override",
"return",... | Utility function to retrieve settings.py values with defaults | [
"Utility",
"function",
"to",
"retrieve",
"settings",
".",
"py",
"values",
"with",
"defaults"
] | f05866356d417309624ec4863acdebd2084b1bc2 | https://github.com/pydanny-archive/django-wysiwyg/blob/f05866356d417309624ec4863acdebd2084b1bc2/django_wysiwyg/templatetags/wysiwyg.py#L13-L23 |
18,142 | paragbaxi/qualysapi | qualysapi/config.py | QualysConnectConfig.get_auth | def get_auth(self):
''' Returns username from the configfile. '''
return (self._cfgparse.get(self._section, 'username'), self._cfgparse.get(self._section, 'password')) | python | def get_auth(self):
''' Returns username from the configfile. '''
return (self._cfgparse.get(self._section, 'username'), self._cfgparse.get(self._section, 'password')) | [
"def",
"get_auth",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"_cfgparse",
".",
"get",
"(",
"self",
".",
"_section",
",",
"'username'",
")",
",",
"self",
".",
"_cfgparse",
".",
"get",
"(",
"self",
".",
"_section",
",",
"'password'",
")",
")"
... | Returns username from the configfile. | [
"Returns",
"username",
"from",
"the",
"configfile",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/config.py#L211-L213 |
18,143 | paragbaxi/qualysapi | qualysapi/util.py | connect | def connect(config_file=qcs.default_filename, section='info', remember_me=False, remember_me_always=False):
""" Return a QGAPIConnect object for v1 API pulling settings from config
file.
"""
# Retrieve login credentials.
conf = qcconf.QualysConnectConfig(filename=config_file, section=section, rememb... | python | def connect(config_file=qcs.default_filename, section='info', remember_me=False, remember_me_always=False):
""" Return a QGAPIConnect object for v1 API pulling settings from config
file.
"""
# Retrieve login credentials.
conf = qcconf.QualysConnectConfig(filename=config_file, section=section, rememb... | [
"def",
"connect",
"(",
"config_file",
"=",
"qcs",
".",
"default_filename",
",",
"section",
"=",
"'info'",
",",
"remember_me",
"=",
"False",
",",
"remember_me_always",
"=",
"False",
")",
":",
"# Retrieve login credentials.",
"conf",
"=",
"qcconf",
".",
"QualysCon... | Return a QGAPIConnect object for v1 API pulling settings from config
file. | [
"Return",
"a",
"QGAPIConnect",
"object",
"for",
"v1",
"API",
"pulling",
"settings",
"from",
"config",
"file",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/util.py#L18-L30 |
18,144 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.format_api_version | def format_api_version(self, api_version):
""" Return QualysGuard API version for api_version specified.
"""
# Convert to int.
if type(api_version) == str:
api_version = api_version.lower()
if api_version[0] == 'v' and api_version[1].isdigit():
# ... | python | def format_api_version(self, api_version):
""" Return QualysGuard API version for api_version specified.
"""
# Convert to int.
if type(api_version) == str:
api_version = api_version.lower()
if api_version[0] == 'v' and api_version[1].isdigit():
# ... | [
"def",
"format_api_version",
"(",
"self",
",",
"api_version",
")",
":",
"# Convert to int.",
"if",
"type",
"(",
"api_version",
")",
"==",
"str",
":",
"api_version",
"=",
"api_version",
".",
"lower",
"(",
")",
"if",
"api_version",
"[",
"0",
"]",
"==",
"'v'"... | Return QualysGuard API version for api_version specified. | [
"Return",
"QualysGuard",
"API",
"version",
"for",
"api_version",
"specified",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L72-L97 |
18,145 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.which_api_version | def which_api_version(self, api_call):
""" Return QualysGuard API version for api_call specified.
"""
# Leverage patterns of calls to API methods.
if api_call.endswith('.php'):
# API v1.
return 1
elif api_call.startswith('api/2.0/'):
# API v2.... | python | def which_api_version(self, api_call):
""" Return QualysGuard API version for api_call specified.
"""
# Leverage patterns of calls to API methods.
if api_call.endswith('.php'):
# API v1.
return 1
elif api_call.startswith('api/2.0/'):
# API v2.... | [
"def",
"which_api_version",
"(",
"self",
",",
"api_call",
")",
":",
"# Leverage patterns of calls to API methods.",
"if",
"api_call",
".",
"endswith",
"(",
"'.php'",
")",
":",
"# API v1.",
"return",
"1",
"elif",
"api_call",
".",
"startswith",
"(",
"'api/2.0/'",
")... | Return QualysGuard API version for api_call specified. | [
"Return",
"QualysGuard",
"API",
"version",
"for",
"api_call",
"specified",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L99-L116 |
18,146 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.url_api_version | def url_api_version(self, api_version):
""" Return base API url string for the QualysGuard api_version and server.
"""
# Set base url depending on API version.
if api_version == 1:
# QualysGuard API v1 url.
url = "https://%s/msp/" % (self.server,)
elif ap... | python | def url_api_version(self, api_version):
""" Return base API url string for the QualysGuard api_version and server.
"""
# Set base url depending on API version.
if api_version == 1:
# QualysGuard API v1 url.
url = "https://%s/msp/" % (self.server,)
elif ap... | [
"def",
"url_api_version",
"(",
"self",
",",
"api_version",
")",
":",
"# Set base url depending on API version.",
"if",
"api_version",
"==",
"1",
":",
"# QualysGuard API v1 url.",
"url",
"=",
"\"https://%s/msp/\"",
"%",
"(",
"self",
".",
"server",
",",
")",
"elif",
... | Return base API url string for the QualysGuard api_version and server. | [
"Return",
"base",
"API",
"url",
"string",
"for",
"the",
"QualysGuard",
"api_version",
"and",
"server",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L118-L141 |
18,147 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.format_http_method | def format_http_method(self, api_version, api_call, data):
""" Return QualysGuard API http method, with POST preferred..
"""
# Define get methods for automatic http request methodology.
#
# All API v2 requests are POST methods.
if api_version == 2:
return 'po... | python | def format_http_method(self, api_version, api_call, data):
""" Return QualysGuard API http method, with POST preferred..
"""
# Define get methods for automatic http request methodology.
#
# All API v2 requests are POST methods.
if api_version == 2:
return 'po... | [
"def",
"format_http_method",
"(",
"self",
",",
"api_version",
",",
"api_call",
",",
"data",
")",
":",
"# Define get methods for automatic http request methodology.",
"#",
"# All API v2 requests are POST methods.",
"if",
"api_version",
"==",
"2",
":",
"return",
"'post'",
"... | Return QualysGuard API http method, with POST preferred.. | [
"Return",
"QualysGuard",
"API",
"http",
"method",
"with",
"POST",
"preferred",
".."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L143-L179 |
18,148 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.preformat_call | def preformat_call(self, api_call):
""" Return properly formatted QualysGuard API call.
"""
# Remove possible starting slashes or trailing question marks in call.
api_call_formatted = api_call.lstrip('/')
api_call_formatted = api_call_formatted.rstrip('?')
if api_call !=... | python | def preformat_call(self, api_call):
""" Return properly formatted QualysGuard API call.
"""
# Remove possible starting slashes or trailing question marks in call.
api_call_formatted = api_call.lstrip('/')
api_call_formatted = api_call_formatted.rstrip('?')
if api_call !=... | [
"def",
"preformat_call",
"(",
"self",
",",
"api_call",
")",
":",
"# Remove possible starting slashes or trailing question marks in call.",
"api_call_formatted",
"=",
"api_call",
".",
"lstrip",
"(",
"'/'",
")",
"api_call_formatted",
"=",
"api_call_formatted",
".",
"rstrip",
... | Return properly formatted QualysGuard API call. | [
"Return",
"properly",
"formatted",
"QualysGuard",
"API",
"call",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L181-L191 |
18,149 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.format_call | def format_call(self, api_version, api_call):
""" Return properly formatted QualysGuard API call according to api_version etiquette.
"""
# Remove possible starting slashes or trailing question marks in call.
api_call = api_call.lstrip('/')
api_call = api_call.rstrip('?')
... | python | def format_call(self, api_version, api_call):
""" Return properly formatted QualysGuard API call according to api_version etiquette.
"""
# Remove possible starting slashes or trailing question marks in call.
api_call = api_call.lstrip('/')
api_call = api_call.rstrip('?')
... | [
"def",
"format_call",
"(",
"self",
",",
"api_version",
",",
"api_call",
")",
":",
"# Remove possible starting slashes or trailing question marks in call.",
"api_call",
"=",
"api_call",
".",
"lstrip",
"(",
"'/'",
")",
"api_call",
"=",
"api_call",
".",
"rstrip",
"(",
... | Return properly formatted QualysGuard API call according to api_version etiquette. | [
"Return",
"properly",
"formatted",
"QualysGuard",
"API",
"call",
"according",
"to",
"api_version",
"etiquette",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L193-L210 |
18,150 | paragbaxi/qualysapi | qualysapi/connector.py | QGConnector.format_payload | def format_payload(self, api_version, data):
""" Return appropriate QualysGuard API call.
"""
# Check if payload is for API v1 or API v2.
if (api_version in (1, 2)):
# Check if string type.
if type(data) == str:
# Convert to dictionary.
... | python | def format_payload(self, api_version, data):
""" Return appropriate QualysGuard API call.
"""
# Check if payload is for API v1 or API v2.
if (api_version in (1, 2)):
# Check if string type.
if type(data) == str:
# Convert to dictionary.
... | [
"def",
"format_payload",
"(",
"self",
",",
"api_version",
",",
"data",
")",
":",
"# Check if payload is for API v1 or API v2.",
"if",
"(",
"api_version",
"in",
"(",
"1",
",",
"2",
")",
")",
":",
"# Check if string type.",
"if",
"type",
"(",
"data",
")",
"==",
... | Return appropriate QualysGuard API call. | [
"Return",
"appropriate",
"QualysGuard",
"API",
"call",
"."
] | 2c8bf1d5d300117403062885c8e10b5665eb4615 | https://github.com/paragbaxi/qualysapi/blob/2c8bf1d5d300117403062885c8e10b5665eb4615/qualysapi/connector.py#L212-L233 |
18,151 | tox-dev/tox-travis | src/tox_travis/after.py | travis_after | def travis_after(ini, envlist):
"""Wait for all jobs to finish, then exit successfully."""
# after-all disabled for pull requests
if os.environ.get('TRAVIS_PULL_REQUEST', 'false') != 'false':
return
if not after_config_matches(ini, envlist):
return # This is not the one that needs to w... | python | def travis_after(ini, envlist):
"""Wait for all jobs to finish, then exit successfully."""
# after-all disabled for pull requests
if os.environ.get('TRAVIS_PULL_REQUEST', 'false') != 'false':
return
if not after_config_matches(ini, envlist):
return # This is not the one that needs to w... | [
"def",
"travis_after",
"(",
"ini",
",",
"envlist",
")",
":",
"# after-all disabled for pull requests",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'TRAVIS_PULL_REQUEST'",
",",
"'false'",
")",
"!=",
"'false'",
":",
"return",
"if",
"not",
"after_config_matches",
... | Wait for all jobs to finish, then exit successfully. | [
"Wait",
"for",
"all",
"jobs",
"to",
"finish",
"then",
"exit",
"successfully",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/after.py#L25-L62 |
18,152 | tox-dev/tox-travis | src/tox_travis/after.py | after_config_matches | def after_config_matches(ini, envlist):
"""Determine if this job should wait for the others."""
section = ini.sections.get('travis:after', {})
if not section:
return False # Never wait if it's not configured
if 'envlist' in section or 'toxenv' in section:
if 'toxenv' in section:
... | python | def after_config_matches(ini, envlist):
"""Determine if this job should wait for the others."""
section = ini.sections.get('travis:after', {})
if not section:
return False # Never wait if it's not configured
if 'envlist' in section or 'toxenv' in section:
if 'toxenv' in section:
... | [
"def",
"after_config_matches",
"(",
"ini",
",",
"envlist",
")",
":",
"section",
"=",
"ini",
".",
"sections",
".",
"get",
"(",
"'travis:after'",
",",
"{",
"}",
")",
"if",
"not",
"section",
":",
"return",
"False",
"# Never wait if it's not configured",
"if",
"... | Determine if this job should wait for the others. | [
"Determine",
"if",
"this",
"job",
"should",
"wait",
"for",
"the",
"others",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/after.py#L65-L96 |
18,153 | tox-dev/tox-travis | src/tox_travis/after.py | get_job_statuses | def get_job_statuses(github_token, api_url, build_id,
polling_interval, job_number):
"""Wait for all the travis jobs to complete.
Once the other jobs are complete, return a list of booleans,
indicating whether or not the job was successful. Ignore jobs
marked "allow_failure".
"... | python | def get_job_statuses(github_token, api_url, build_id,
polling_interval, job_number):
"""Wait for all the travis jobs to complete.
Once the other jobs are complete, return a list of booleans,
indicating whether or not the job was successful. Ignore jobs
marked "allow_failure".
"... | [
"def",
"get_job_statuses",
"(",
"github_token",
",",
"api_url",
",",
"build_id",
",",
"polling_interval",
",",
"job_number",
")",
":",
"auth",
"=",
"get_json",
"(",
"'{api_url}/auth/github'",
".",
"format",
"(",
"api_url",
"=",
"api_url",
")",
",",
"data",
"="... | Wait for all the travis jobs to complete.
Once the other jobs are complete, return a list of booleans,
indicating whether or not the job was successful. Ignore jobs
marked "allow_failure". | [
"Wait",
"for",
"all",
"the",
"travis",
"jobs",
"to",
"complete",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/after.py#L99-L127 |
18,154 | tox-dev/tox-travis | src/tox_travis/after.py | get_json | def get_json(url, auth=None, data=None):
"""Make a GET request, and return the response as parsed JSON."""
headers = {
'Accept': 'application/vnd.travis-ci.2+json',
'User-Agent': 'Travis/Tox-Travis-1.0a',
# User-Agent must start with "Travis/" in order to work
}
if auth:
... | python | def get_json(url, auth=None, data=None):
"""Make a GET request, and return the response as parsed JSON."""
headers = {
'Accept': 'application/vnd.travis-ci.2+json',
'User-Agent': 'Travis/Tox-Travis-1.0a',
# User-Agent must start with "Travis/" in order to work
}
if auth:
... | [
"def",
"get_json",
"(",
"url",
",",
"auth",
"=",
"None",
",",
"data",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"'Accept'",
":",
"'application/vnd.travis-ci.2+json'",
",",
"'User-Agent'",
":",
"'Travis/Tox-Travis-1.0a'",
",",
"# User-Agent must start with \"Travis... | Make a GET request, and return the response as parsed JSON. | [
"Make",
"a",
"GET",
"request",
"and",
"return",
"the",
"response",
"as",
"parsed",
"JSON",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/after.py#L130-L147 |
18,155 | tox-dev/tox-travis | src/tox_travis/envlist.py | detect_envlist | def detect_envlist(ini):
"""Default envlist automatically based on the Travis environment."""
# Find the envs that tox knows about
declared_envs = get_declared_envs(ini)
# Find all the envs for all the desired factors given
desired_factors = get_desired_factors(ini)
# Reduce desired factors
... | python | def detect_envlist(ini):
"""Default envlist automatically based on the Travis environment."""
# Find the envs that tox knows about
declared_envs = get_declared_envs(ini)
# Find all the envs for all the desired factors given
desired_factors = get_desired_factors(ini)
# Reduce desired factors
... | [
"def",
"detect_envlist",
"(",
"ini",
")",
":",
"# Find the envs that tox knows about",
"declared_envs",
"=",
"get_declared_envs",
"(",
"ini",
")",
"# Find all the envs for all the desired factors given",
"desired_factors",
"=",
"get_desired_factors",
"(",
"ini",
")",
"# Reduc... | Default envlist automatically based on the Travis environment. | [
"Default",
"envlist",
"automatically",
"based",
"on",
"the",
"Travis",
"environment",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L14-L27 |
18,156 | tox-dev/tox-travis | src/tox_travis/envlist.py | autogen_envconfigs | def autogen_envconfigs(config, envs):
"""Make the envconfigs for undeclared envs.
This is a stripped-down version of parseini.__init__ made for making
an envconfig.
"""
prefix = 'tox' if config.toxinipath.basename == 'setup.cfg' else None
reader = tox.config.SectionReader("tox", config._cfg, pr... | python | def autogen_envconfigs(config, envs):
"""Make the envconfigs for undeclared envs.
This is a stripped-down version of parseini.__init__ made for making
an envconfig.
"""
prefix = 'tox' if config.toxinipath.basename == 'setup.cfg' else None
reader = tox.config.SectionReader("tox", config._cfg, pr... | [
"def",
"autogen_envconfigs",
"(",
"config",
",",
"envs",
")",
":",
"prefix",
"=",
"'tox'",
"if",
"config",
".",
"toxinipath",
".",
"basename",
"==",
"'setup.cfg'",
"else",
"None",
"reader",
"=",
"tox",
".",
"config",
".",
"SectionReader",
"(",
"\"tox\"",
"... | Make the envconfigs for undeclared envs.
This is a stripped-down version of parseini.__init__ made for making
an envconfig. | [
"Make",
"the",
"envconfigs",
"for",
"undeclared",
"envs",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L30-L59 |
18,157 | tox-dev/tox-travis | src/tox_travis/envlist.py | get_declared_envs | def get_declared_envs(ini):
"""Get the full list of envs from the tox ini.
This notably also includes envs that aren't in the envlist,
but are declared by having their own testenv:envname section.
The envs are expected in a particular order. First the ones
declared in the envlist, then the other t... | python | def get_declared_envs(ini):
"""Get the full list of envs from the tox ini.
This notably also includes envs that aren't in the envlist,
but are declared by having their own testenv:envname section.
The envs are expected in a particular order. First the ones
declared in the envlist, then the other t... | [
"def",
"get_declared_envs",
"(",
"ini",
")",
":",
"tox_section_name",
"=",
"'tox:tox'",
"if",
"ini",
".",
"path",
".",
"endswith",
"(",
"'setup.cfg'",
")",
"else",
"'tox'",
"tox_section",
"=",
"ini",
".",
"sections",
".",
"get",
"(",
"tox_section_name",
",",... | Get the full list of envs from the tox ini.
This notably also includes envs that aren't in the envlist,
but are declared by having their own testenv:envname section.
The envs are expected in a particular order. First the ones
declared in the envlist, then the other testenvs in order. | [
"Get",
"the",
"full",
"list",
"of",
"envs",
"from",
"the",
"tox",
"ini",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L62-L81 |
18,158 | tox-dev/tox-travis | src/tox_travis/envlist.py | get_version_info | def get_version_info():
"""Get version info from the sys module.
Override from environment for testing.
"""
overrides = os.environ.get('__TOX_TRAVIS_SYS_VERSION')
if overrides:
version, major, minor = overrides.split(',')[:3]
major, minor = int(major), int(minor)
else:
v... | python | def get_version_info():
"""Get version info from the sys module.
Override from environment for testing.
"""
overrides = os.environ.get('__TOX_TRAVIS_SYS_VERSION')
if overrides:
version, major, minor = overrides.split(',')[:3]
major, minor = int(major), int(minor)
else:
v... | [
"def",
"get_version_info",
"(",
")",
":",
"overrides",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'__TOX_TRAVIS_SYS_VERSION'",
")",
"if",
"overrides",
":",
"version",
",",
"major",
",",
"minor",
"=",
"overrides",
".",
"split",
"(",
"','",
")",
"[",
":"... | Get version info from the sys module.
Override from environment for testing. | [
"Get",
"version",
"info",
"from",
"the",
"sys",
"module",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L84-L95 |
18,159 | tox-dev/tox-travis | src/tox_travis/envlist.py | guess_python_env | def guess_python_env():
"""Guess the default python env to use."""
version, major, minor = get_version_info()
if 'PyPy' in version:
return 'pypy3' if major == 3 else 'pypy'
return 'py{major}{minor}'.format(major=major, minor=minor) | python | def guess_python_env():
"""Guess the default python env to use."""
version, major, minor = get_version_info()
if 'PyPy' in version:
return 'pypy3' if major == 3 else 'pypy'
return 'py{major}{minor}'.format(major=major, minor=minor) | [
"def",
"guess_python_env",
"(",
")",
":",
"version",
",",
"major",
",",
"minor",
"=",
"get_version_info",
"(",
")",
"if",
"'PyPy'",
"in",
"version",
":",
"return",
"'pypy3'",
"if",
"major",
"==",
"3",
"else",
"'pypy'",
"return",
"'py{major}{minor}'",
".",
... | Guess the default python env to use. | [
"Guess",
"the",
"default",
"python",
"env",
"to",
"use",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L98-L103 |
18,160 | tox-dev/tox-travis | src/tox_travis/envlist.py | get_default_envlist | def get_default_envlist(version):
"""Parse a default tox env based on the version.
The version comes from the ``TRAVIS_PYTHON_VERSION`` environment
variable. If that isn't set or is invalid, then use
sys.version_info to come up with a reasonable default.
"""
if version in ['pypy', 'pypy3']:
... | python | def get_default_envlist(version):
"""Parse a default tox env based on the version.
The version comes from the ``TRAVIS_PYTHON_VERSION`` environment
variable. If that isn't set or is invalid, then use
sys.version_info to come up with a reasonable default.
"""
if version in ['pypy', 'pypy3']:
... | [
"def",
"get_default_envlist",
"(",
"version",
")",
":",
"if",
"version",
"in",
"[",
"'pypy'",
",",
"'pypy3'",
"]",
":",
"return",
"version",
"# Assume single digit major and minor versions",
"match",
"=",
"re",
".",
"match",
"(",
"r'^(\\d)\\.(\\d)(?:\\.\\d+)?$'",
",... | Parse a default tox env based on the version.
The version comes from the ``TRAVIS_PYTHON_VERSION`` environment
variable. If that isn't set or is invalid, then use
sys.version_info to come up with a reasonable default. | [
"Parse",
"a",
"default",
"tox",
"env",
"based",
"on",
"the",
"version",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L106-L122 |
18,161 | tox-dev/tox-travis | src/tox_travis/envlist.py | get_desired_factors | def get_desired_factors(ini):
"""Get the list of desired envs per declared factor.
Look at all the accepted configuration locations, and give a list
of envlists, one for each Travis factor found.
Look in the ``[travis]`` section for the known Travis factors,
which are backed by environment variabl... | python | def get_desired_factors(ini):
"""Get the list of desired envs per declared factor.
Look at all the accepted configuration locations, and give a list
of envlists, one for each Travis factor found.
Look in the ``[travis]`` section for the known Travis factors,
which are backed by environment variabl... | [
"def",
"get_desired_factors",
"(",
"ini",
")",
":",
"# Find configuration based on known travis factors",
"travis_section",
"=",
"ini",
".",
"sections",
".",
"get",
"(",
"'travis'",
",",
"{",
"}",
")",
"found_factors",
"=",
"[",
"(",
"factor",
",",
"parse_dict",
... | Get the list of desired envs per declared factor.
Look at all the accepted configuration locations, and give a list
of envlists, one for each Travis factor found.
Look in the ``[travis]`` section for the known Travis factors,
which are backed by environment variable checking behind the
scenes, but... | [
"Get",
"the",
"list",
"of",
"desired",
"envs",
"per",
"declared",
"factor",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L125-L197 |
18,162 | tox-dev/tox-travis | src/tox_travis/envlist.py | match_envs | def match_envs(declared_envs, desired_envs, passthru):
"""Determine the envs that match the desired_envs.
If ``passthru` is True, and none of the declared envs match the
desired envs, then the desired envs will be used verbatim.
:param declared_envs: The envs that are declared in the tox config.
:... | python | def match_envs(declared_envs, desired_envs, passthru):
"""Determine the envs that match the desired_envs.
If ``passthru` is True, and none of the declared envs match the
desired envs, then the desired envs will be used verbatim.
:param declared_envs: The envs that are declared in the tox config.
:... | [
"def",
"match_envs",
"(",
"declared_envs",
",",
"desired_envs",
",",
"passthru",
")",
":",
"matched",
"=",
"[",
"declared",
"for",
"declared",
"in",
"declared_envs",
"if",
"any",
"(",
"env_matches",
"(",
"declared",
",",
"desired",
")",
"for",
"desired",
"in... | Determine the envs that match the desired_envs.
If ``passthru` is True, and none of the declared envs match the
desired envs, then the desired envs will be used verbatim.
:param declared_envs: The envs that are declared in the tox config.
:param desired_envs: The envs desired from the tox-travis confi... | [
"Determine",
"the",
"envs",
"that",
"match",
"the",
"desired_envs",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L200-L215 |
18,163 | tox-dev/tox-travis | src/tox_travis/envlist.py | env_matches | def env_matches(declared, desired):
"""Determine if a declared env matches a desired env.
Rather than simply using the name of the env verbatim, take a
closer look to see if all the desired factors are fulfilled. If
the desired factors are fulfilled, but there are other factors,
it should still mat... | python | def env_matches(declared, desired):
"""Determine if a declared env matches a desired env.
Rather than simply using the name of the env verbatim, take a
closer look to see if all the desired factors are fulfilled. If
the desired factors are fulfilled, but there are other factors,
it should still mat... | [
"def",
"env_matches",
"(",
"declared",
",",
"desired",
")",
":",
"desired_factors",
"=",
"desired",
".",
"split",
"(",
"'-'",
")",
"declared_factors",
"=",
"declared",
".",
"split",
"(",
"'-'",
")",
"return",
"all",
"(",
"factor",
"in",
"declared_factors",
... | Determine if a declared env matches a desired env.
Rather than simply using the name of the env verbatim, take a
closer look to see if all the desired factors are fulfilled. If
the desired factors are fulfilled, but there are other factors,
it should still match the env. | [
"Determine",
"if",
"a",
"declared",
"env",
"matches",
"a",
"desired",
"env",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L218-L228 |
18,164 | tox-dev/tox-travis | src/tox_travis/envlist.py | override_ignore_outcome | def override_ignore_outcome(ini):
"""Decide whether to override ignore_outcomes."""
travis_reader = tox.config.SectionReader("travis", ini)
return travis_reader.getbool('unignore_outcomes', False) | python | def override_ignore_outcome(ini):
"""Decide whether to override ignore_outcomes."""
travis_reader = tox.config.SectionReader("travis", ini)
return travis_reader.getbool('unignore_outcomes', False) | [
"def",
"override_ignore_outcome",
"(",
"ini",
")",
":",
"travis_reader",
"=",
"tox",
".",
"config",
".",
"SectionReader",
"(",
"\"travis\"",
",",
"ini",
")",
"return",
"travis_reader",
".",
"getbool",
"(",
"'unignore_outcomes'",
",",
"False",
")"
] | Decide whether to override ignore_outcomes. | [
"Decide",
"whether",
"to",
"override",
"ignore_outcomes",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/envlist.py#L231-L234 |
18,165 | tox-dev/tox-travis | src/tox_travis/hooks.py | tox_addoption | def tox_addoption(parser):
"""Add arguments and needed monkeypatches."""
parser.add_argument(
'--travis-after', dest='travis_after', action='store_true',
help='Exit successfully after all Travis jobs complete successfully.')
if 'TRAVIS' in os.environ:
pypy_version_monkeypatch()
... | python | def tox_addoption(parser):
"""Add arguments and needed monkeypatches."""
parser.add_argument(
'--travis-after', dest='travis_after', action='store_true',
help='Exit successfully after all Travis jobs complete successfully.')
if 'TRAVIS' in os.environ:
pypy_version_monkeypatch()
... | [
"def",
"tox_addoption",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"'--travis-after'",
",",
"dest",
"=",
"'travis_after'",
",",
"action",
"=",
"'store_true'",
",",
"help",
"=",
"'Exit successfully after all Travis jobs complete successfully.'",
")",
... | Add arguments and needed monkeypatches. | [
"Add",
"arguments",
"and",
"needed",
"monkeypatches",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/hooks.py#L19-L27 |
18,166 | tox-dev/tox-travis | src/tox_travis/hooks.py | tox_configure | def tox_configure(config):
"""Check for the presence of the added options."""
if 'TRAVIS' not in os.environ:
return
ini = config._cfg
# envlist
if 'TOXENV' not in os.environ and not config.option.env:
envlist = detect_envlist(ini)
undeclared = set(envlist) - set(config.envc... | python | def tox_configure(config):
"""Check for the presence of the added options."""
if 'TRAVIS' not in os.environ:
return
ini = config._cfg
# envlist
if 'TOXENV' not in os.environ and not config.option.env:
envlist = detect_envlist(ini)
undeclared = set(envlist) - set(config.envc... | [
"def",
"tox_configure",
"(",
"config",
")",
":",
"if",
"'TRAVIS'",
"not",
"in",
"os",
".",
"environ",
":",
"return",
"ini",
"=",
"config",
".",
"_cfg",
"# envlist",
"if",
"'TOXENV'",
"not",
"in",
"os",
".",
"environ",
"and",
"not",
"config",
".",
"opti... | Check for the presence of the added options. | [
"Check",
"for",
"the",
"presence",
"of",
"the",
"added",
"options",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/hooks.py#L31-L59 |
18,167 | tox-dev/tox-travis | src/tox_travis/utils.py | parse_dict | def parse_dict(value):
"""Parse a dict value from the tox config.
.. code-block: ini
[travis]
python =
2.7: py27, docs
3.5: py{35,36}
With this config, the value of ``python`` would be parsed
by this function, and would return::
{
'2.7': 'p... | python | def parse_dict(value):
"""Parse a dict value from the tox config.
.. code-block: ini
[travis]
python =
2.7: py27, docs
3.5: py{35,36}
With this config, the value of ``python`` would be parsed
by this function, and would return::
{
'2.7': 'p... | [
"def",
"parse_dict",
"(",
"value",
")",
":",
"lines",
"=",
"[",
"line",
".",
"strip",
"(",
")",
"for",
"line",
"in",
"value",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
")",
"]",
"pairs",
"=",
"[",
"line",
".",
"split",
"(",
"':'",
",",
"1... | Parse a dict value from the tox config.
.. code-block: ini
[travis]
python =
2.7: py27, docs
3.5: py{35,36}
With this config, the value of ``python`` would be parsed
by this function, and would return::
{
'2.7': 'py27, docs',
'3.5':... | [
"Parse",
"a",
"dict",
"value",
"from",
"the",
"tox",
"config",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/utils.py#L11-L32 |
18,168 | tox-dev/tox-travis | src/tox_travis/hacks.py | pypy_version_monkeypatch | def pypy_version_monkeypatch():
"""Patch Tox to work with non-default PyPy 3 versions."""
# Travis virtualenv do not provide `pypy3`, which tox tries to execute.
# This doesnt affect Travis python version `pypy3`, as the pyenv pypy3
# is in the PATH.
# https://github.com/travis-ci/travis-ci/issues/6... | python | def pypy_version_monkeypatch():
"""Patch Tox to work with non-default PyPy 3 versions."""
# Travis virtualenv do not provide `pypy3`, which tox tries to execute.
# This doesnt affect Travis python version `pypy3`, as the pyenv pypy3
# is in the PATH.
# https://github.com/travis-ci/travis-ci/issues/6... | [
"def",
"pypy_version_monkeypatch",
"(",
")",
":",
"# Travis virtualenv do not provide `pypy3`, which tox tries to execute.",
"# This doesnt affect Travis python version `pypy3`, as the pyenv pypy3",
"# is in the PATH.",
"# https://github.com/travis-ci/travis-ci/issues/6304",
"# Force use of the vi... | Patch Tox to work with non-default PyPy 3 versions. | [
"Patch",
"Tox",
"to",
"work",
"with",
"non",
"-",
"default",
"PyPy",
"3",
"versions",
"."
] | d97a966c19abb020298a7e4b91fe83dd1d0a4517 | https://github.com/tox-dev/tox-travis/blob/d97a966c19abb020298a7e4b91fe83dd1d0a4517/src/tox_travis/hacks.py#L9-L18 |
18,169 | adafruit/Adafruit_CircuitPython_MCP230xx | adafruit_mcp230xx.py | DigitalInOut.direction | def direction(self):
"""The direction of the pin, either True for an input or
False for an output.
"""
if _get_bit(self._mcp.iodir, self._pin):
return digitalio.Direction.INPUT
return digitalio.Direction.OUTPUT | python | def direction(self):
"""The direction of the pin, either True for an input or
False for an output.
"""
if _get_bit(self._mcp.iodir, self._pin):
return digitalio.Direction.INPUT
return digitalio.Direction.OUTPUT | [
"def",
"direction",
"(",
"self",
")",
":",
"if",
"_get_bit",
"(",
"self",
".",
"_mcp",
".",
"iodir",
",",
"self",
".",
"_pin",
")",
":",
"return",
"digitalio",
".",
"Direction",
".",
"INPUT",
"return",
"digitalio",
".",
"Direction",
".",
"OUTPUT"
] | The direction of the pin, either True for an input or
False for an output. | [
"The",
"direction",
"of",
"the",
"pin",
"either",
"True",
"for",
"an",
"input",
"or",
"False",
"for",
"an",
"output",
"."
] | da9480befecef31c2428062919b9f3da6f428d15 | https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx/blob/da9480befecef31c2428062919b9f3da6f428d15/adafruit_mcp230xx.py#L148-L154 |
18,170 | adafruit/Adafruit_CircuitPython_MCP230xx | adafruit_mcp230xx.py | DigitalInOut.pull | def pull(self):
"""Enable or disable internal pull-up resistors for this pin. A
value of digitalio.Pull.UP will enable a pull-up resistor, and None will
disable it. Pull-down resistors are NOT supported!
"""
if _get_bit(self._mcp.gppu, self._pin):
return digitalio.P... | python | def pull(self):
"""Enable or disable internal pull-up resistors for this pin. A
value of digitalio.Pull.UP will enable a pull-up resistor, and None will
disable it. Pull-down resistors are NOT supported!
"""
if _get_bit(self._mcp.gppu, self._pin):
return digitalio.P... | [
"def",
"pull",
"(",
"self",
")",
":",
"if",
"_get_bit",
"(",
"self",
".",
"_mcp",
".",
"gppu",
",",
"self",
".",
"_pin",
")",
":",
"return",
"digitalio",
".",
"Pull",
".",
"UP",
"return",
"None"
] | Enable or disable internal pull-up resistors for this pin. A
value of digitalio.Pull.UP will enable a pull-up resistor, and None will
disable it. Pull-down resistors are NOT supported! | [
"Enable",
"or",
"disable",
"internal",
"pull",
"-",
"up",
"resistors",
"for",
"this",
"pin",
".",
"A",
"value",
"of",
"digitalio",
".",
"Pull",
".",
"UP",
"will",
"enable",
"a",
"pull",
"-",
"up",
"resistor",
"and",
"None",
"will",
"disable",
"it",
"."... | da9480befecef31c2428062919b9f3da6f428d15 | https://github.com/adafruit/Adafruit_CircuitPython_MCP230xx/blob/da9480befecef31c2428062919b9f3da6f428d15/adafruit_mcp230xx.py#L166-L173 |
18,171 | sebdah/dynamic-dynamodb | dynamic_dynamodb/statistics/table.py | get_throttled_read_event_count | def get_throttled_read_event_count(
table_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of throttled read events during a given time frame
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookback_window... | python | def get_throttled_read_event_count(
table_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of throttled read events during a given time frame
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookback_window... | [
"def",
"get_throttled_read_event_count",
"(",
"table_name",
",",
"lookback_window_start",
"=",
"15",
",",
"lookback_period",
"=",
"5",
")",
":",
"try",
":",
"metrics",
"=",
"__get_aws_metric",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_period",
... | Returns the number of throttled read events during a given time frame
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookback_window_start: Relative start time for the CloudWatch metric
:type lookback_period: int
:param lookback_perio... | [
"Returns",
"the",
"number",
"of",
"throttled",
"read",
"events",
"during",
"a",
"given",
"time",
"frame"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/statistics/table.py#L58-L86 |
18,172 | sebdah/dynamic-dynamodb | dynamic_dynamodb/statistics/table.py | get_throttled_by_consumed_read_percent | def get_throttled_by_consumed_read_percent(
table_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of throttled read events in percent of consumption
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookbac... | python | def get_throttled_by_consumed_read_percent(
table_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of throttled read events in percent of consumption
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookbac... | [
"def",
"get_throttled_by_consumed_read_percent",
"(",
"table_name",
",",
"lookback_window_start",
"=",
"15",
",",
"lookback_period",
"=",
"5",
")",
":",
"try",
":",
"metrics1",
"=",
"__get_aws_metric",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_pe... | Returns the number of throttled read events in percent of consumption
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookback_window_start: Relative start time for the CloudWatch metric
:type lookback_period: int
:param lookback_perio... | [
"Returns",
"the",
"number",
"of",
"throttled",
"read",
"events",
"in",
"percent",
"of",
"consumption"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/statistics/table.py#L132-L171 |
18,173 | sebdah/dynamic-dynamodb | dynamic_dynamodb/statistics/table.py | get_throttled_by_consumed_write_percent | def get_throttled_by_consumed_write_percent(
table_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of throttled write events in percent of consumption
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookb... | python | def get_throttled_by_consumed_write_percent(
table_name, lookback_window_start=15, lookback_period=5):
""" Returns the number of throttled write events in percent of consumption
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookb... | [
"def",
"get_throttled_by_consumed_write_percent",
"(",
"table_name",
",",
"lookback_window_start",
"=",
"15",
",",
"lookback_period",
"=",
"5",
")",
":",
"try",
":",
"metrics1",
"=",
"__get_aws_metric",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_p... | Returns the number of throttled write events in percent of consumption
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookback_window_start: Relative start time for the CloudWatch metric
:type lookback_period: int
:param lookback_peri... | [
"Returns",
"the",
"number",
"of",
"throttled",
"write",
"events",
"in",
"percent",
"of",
"consumption"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/statistics/table.py#L291-L332 |
18,174 | sebdah/dynamic-dynamodb | dynamic_dynamodb/statistics/table.py | __get_aws_metric | def __get_aws_metric(table_name, lookback_window_start, lookback_period,
metric_name):
""" Returns a metric list from the AWS CloudWatch service, may return
None if no metric exists
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start... | python | def __get_aws_metric(table_name, lookback_window_start, lookback_period,
metric_name):
""" Returns a metric list from the AWS CloudWatch service, may return
None if no metric exists
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start... | [
"def",
"__get_aws_metric",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_period",
",",
"metric_name",
")",
":",
"try",
":",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"start_time",
"=",
"now",
"-",
"timedelta",
"(",
"minutes",
"=",
"l... | Returns a metric list from the AWS CloudWatch service, may return
None if no metric exists
:type table_name: str
:param table_name: Name of the DynamoDB table
:type lookback_window_start: int
:param lookback_window_start: How many minutes to look at
:type lookback_period: int
:type lookbac... | [
"Returns",
"a",
"metric",
"list",
"from",
"the",
"AWS",
"CloudWatch",
"service",
"may",
"return",
"None",
"if",
"no",
"metric",
"exists"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/statistics/table.py#L340-L378 |
18,175 | sebdah/dynamic-dynamodb | dynamic_dynamodb/core/gsi.py | ensure_provisioning | def ensure_provisioning(
table_name, table_key, gsi_name, gsi_key,
num_consec_read_checks, num_consec_write_checks):
""" Ensure that provisioning is correct for Global Secondary Indexes
:type table_name: str
:param table_name: Name of the DynamoDB table
:type table_key: str
:param t... | python | def ensure_provisioning(
table_name, table_key, gsi_name, gsi_key,
num_consec_read_checks, num_consec_write_checks):
""" Ensure that provisioning is correct for Global Secondary Indexes
:type table_name: str
:param table_name: Name of the DynamoDB table
:type table_key: str
:param t... | [
"def",
"ensure_provisioning",
"(",
"table_name",
",",
"table_key",
",",
"gsi_name",
",",
"gsi_key",
",",
"num_consec_read_checks",
",",
"num_consec_write_checks",
")",
":",
"if",
"get_global_option",
"(",
"'circuit_breaker_url'",
")",
"or",
"get_gsi_option",
"(",
"tab... | Ensure that provisioning is correct for Global Secondary Indexes
:type table_name: str
:param table_name: Name of the DynamoDB table
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_name: str
:param gsi_name: Name of the GSI
:type gsi_key: str
:param ... | [
"Ensure",
"that",
"provisioning",
"is",
"correct",
"for",
"Global",
"Secondary",
"Indexes"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/core/gsi.py#L13-L93 |
18,176 | sebdah/dynamic-dynamodb | dynamic_dynamodb/core/gsi.py | __update_throughput | def __update_throughput(
table_name, table_key, gsi_name, gsi_key, read_units, write_units):
""" Update throughput on the GSI
:type table_name: str
:param table_name: Name of the DynamoDB table
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_name: st... | python | def __update_throughput(
table_name, table_key, gsi_name, gsi_key, read_units, write_units):
""" Update throughput on the GSI
:type table_name: str
:param table_name: Name of the DynamoDB table
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_name: st... | [
"def",
"__update_throughput",
"(",
"table_name",
",",
"table_key",
",",
"gsi_name",
",",
"gsi_key",
",",
"read_units",
",",
"write_units",
")",
":",
"try",
":",
"current_ru",
"=",
"dynamodb",
".",
"get_provisioned_gsi_read_units",
"(",
"table_name",
",",
"gsi_name... | Update throughput on the GSI
:type table_name: str
:param table_name: Name of the DynamoDB table
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_name: str
:param gsi_name: Name of the GSI
:type gsi_key: str
:param gsi_key: Configuration option key na... | [
"Update",
"throughput",
"on",
"the",
"GSI"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/core/gsi.py#L1027-L1088 |
18,177 | sebdah/dynamic-dynamodb | dynamic_dynamodb/core/circuit_breaker.py | is_open | def is_open(table_name=None, table_key=None, gsi_name=None, gsi_key=None):
""" Checks whether the circuit breaker is open
:param table_name: Name of the table being checked
:param table_key: Configuration key for table
:param gsi_name: Name of the GSI being checked
:param gsi_key: Configuration key... | python | def is_open(table_name=None, table_key=None, gsi_name=None, gsi_key=None):
""" Checks whether the circuit breaker is open
:param table_name: Name of the table being checked
:param table_key: Configuration key for table
:param gsi_name: Name of the GSI being checked
:param gsi_key: Configuration key... | [
"def",
"is_open",
"(",
"table_name",
"=",
"None",
",",
"table_key",
"=",
"None",
",",
"gsi_name",
"=",
"None",
",",
"gsi_key",
"=",
"None",
")",
":",
"logger",
".",
"debug",
"(",
"'Checking circuit breaker status'",
")",
"# Parse the URL to make sure it is OK",
... | Checks whether the circuit breaker is open
:param table_name: Name of the table being checked
:param table_key: Configuration key for table
:param gsi_name: Name of the GSI being checked
:param gsi_key: Configuration key for the GSI
:returns: bool -- True if the circuit is open | [
"Checks",
"whether",
"the",
"circuit",
"breaker",
"is",
"open"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/core/circuit_breaker.py#L13-L97 |
18,178 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/cloudwatch.py | __get_connection_cloudwatch | def __get_connection_cloudwatch():
""" Ensure connection to CloudWatch """
region = get_global_option('region')
try:
if (get_global_option('aws_access_key_id') and
get_global_option('aws_secret_access_key')):
logger.debug(
'Authenticating to CloudWatch usi... | python | def __get_connection_cloudwatch():
""" Ensure connection to CloudWatch """
region = get_global_option('region')
try:
if (get_global_option('aws_access_key_id') and
get_global_option('aws_secret_access_key')):
logger.debug(
'Authenticating to CloudWatch usi... | [
"def",
"__get_connection_cloudwatch",
"(",
")",
":",
"region",
"=",
"get_global_option",
"(",
"'region'",
")",
"try",
":",
"if",
"(",
"get_global_option",
"(",
"'aws_access_key_id'",
")",
"and",
"get_global_option",
"(",
"'aws_secret_access_key'",
")",
")",
":",
"... | Ensure connection to CloudWatch | [
"Ensure",
"connection",
"to",
"CloudWatch"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/cloudwatch.py#L9-L36 |
18,179 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/dynamodb.py | get_tables_and_gsis | def get_tables_and_gsis():
""" Get a set of tables and gsis and their configuration keys
:returns: set -- A set of tuples (table_name, table_conf_key)
"""
table_names = set()
configured_tables = get_configured_tables()
not_used_tables = set(configured_tables)
# Add regexp table names
f... | python | def get_tables_and_gsis():
""" Get a set of tables and gsis and their configuration keys
:returns: set -- A set of tuples (table_name, table_conf_key)
"""
table_names = set()
configured_tables = get_configured_tables()
not_used_tables = set(configured_tables)
# Add regexp table names
f... | [
"def",
"get_tables_and_gsis",
"(",
")",
":",
"table_names",
"=",
"set",
"(",
")",
"configured_tables",
"=",
"get_configured_tables",
"(",
")",
"not_used_tables",
"=",
"set",
"(",
"configured_tables",
")",
"# Add regexp table names",
"for",
"table_instance",
"in",
"l... | Get a set of tables and gsis and their configuration keys
:returns: set -- A set of tuples (table_name, table_conf_key) | [
"Get",
"a",
"set",
"of",
"tables",
"and",
"gsis",
"and",
"their",
"configuration",
"keys"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/dynamodb.py#L21-L65 |
18,180 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/dynamodb.py | list_tables | def list_tables():
""" Return list of DynamoDB tables available from AWS
:returns: list -- List of DynamoDB tables
"""
tables = []
try:
table_list = DYNAMODB_CONNECTION.list_tables()
while True:
for table_name in table_list[u'TableNames']:
tables.append(... | python | def list_tables():
""" Return list of DynamoDB tables available from AWS
:returns: list -- List of DynamoDB tables
"""
tables = []
try:
table_list = DYNAMODB_CONNECTION.list_tables()
while True:
for table_name in table_list[u'TableNames']:
tables.append(... | [
"def",
"list_tables",
"(",
")",
":",
"tables",
"=",
"[",
"]",
"try",
":",
"table_list",
"=",
"DYNAMODB_CONNECTION",
".",
"list_tables",
"(",
")",
"while",
"True",
":",
"for",
"table_name",
"in",
"table_list",
"[",
"u'TableNames'",
"]",
":",
"tables",
".",
... | Return list of DynamoDB tables available from AWS
:returns: list -- List of DynamoDB tables | [
"Return",
"list",
"of",
"DynamoDB",
"tables",
"available",
"from",
"AWS"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/dynamodb.py#L214-L260 |
18,181 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/dynamodb.py | table_gsis | def table_gsis(table_name):
""" Returns a list of GSIs for the given table
:type table_name: str
:param table_name: Name of the DynamoDB table
:returns: list -- List of GSI names
"""
try:
desc = DYNAMODB_CONNECTION.describe_table(table_name)[u'Table']
except JSONResponseError:
... | python | def table_gsis(table_name):
""" Returns a list of GSIs for the given table
:type table_name: str
:param table_name: Name of the DynamoDB table
:returns: list -- List of GSI names
"""
try:
desc = DYNAMODB_CONNECTION.describe_table(table_name)[u'Table']
except JSONResponseError:
... | [
"def",
"table_gsis",
"(",
"table_name",
")",
":",
"try",
":",
"desc",
"=",
"DYNAMODB_CONNECTION",
".",
"describe_table",
"(",
"table_name",
")",
"[",
"u'Table'",
"]",
"except",
"JSONResponseError",
":",
"raise",
"if",
"u'GlobalSecondaryIndexes'",
"in",
"desc",
"... | Returns a list of GSIs for the given table
:type table_name: str
:param table_name: Name of the DynamoDB table
:returns: list -- List of GSI names | [
"Returns",
"a",
"list",
"of",
"GSIs",
"for",
"the",
"given",
"table"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/dynamodb.py#L602-L617 |
18,182 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/dynamodb.py | __get_connection_dynamodb | def __get_connection_dynamodb(retries=3):
""" Ensure connection to DynamoDB
:type retries: int
:param retries: Number of times to retry to connect to DynamoDB
"""
connected = False
region = get_global_option('region')
while not connected:
if (get_global_option('aws_access_key_id') ... | python | def __get_connection_dynamodb(retries=3):
""" Ensure connection to DynamoDB
:type retries: int
:param retries: Number of times to retry to connect to DynamoDB
"""
connected = False
region = get_global_option('region')
while not connected:
if (get_global_option('aws_access_key_id') ... | [
"def",
"__get_connection_dynamodb",
"(",
"retries",
"=",
"3",
")",
":",
"connected",
"=",
"False",
"region",
"=",
"get_global_option",
"(",
"'region'",
")",
"while",
"not",
"connected",
":",
"if",
"(",
"get_global_option",
"(",
"'aws_access_key_id'",
")",
"and",... | Ensure connection to DynamoDB
:type retries: int
:param retries: Number of times to retry to connect to DynamoDB | [
"Ensure",
"connection",
"to",
"DynamoDB"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/dynamodb.py#L620-L658 |
18,183 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/dynamodb.py | __is_gsi_maintenance_window | def __is_gsi_maintenance_window(table_name, gsi_name, maintenance_windows):
""" Checks that the current time is within the maintenance window
:type table_name: str
:param table_name: Name of the DynamoDB table
:type gsi_name: str
:param gsi_name: Name of the GSI
:type maintenance_windows: str
... | python | def __is_gsi_maintenance_window(table_name, gsi_name, maintenance_windows):
""" Checks that the current time is within the maintenance window
:type table_name: str
:param table_name: Name of the DynamoDB table
:type gsi_name: str
:param gsi_name: Name of the GSI
:type maintenance_windows: str
... | [
"def",
"__is_gsi_maintenance_window",
"(",
"table_name",
",",
"gsi_name",
",",
"maintenance_windows",
")",
":",
"# Example string '00:00-01:00,10:00-11:00'",
"maintenance_window_list",
"=",
"[",
"]",
"for",
"window",
"in",
"maintenance_windows",
".",
"split",
"(",
"','",
... | Checks that the current time is within the maintenance window
:type table_name: str
:param table_name: Name of the DynamoDB table
:type gsi_name: str
:param gsi_name: Name of the GSI
:type maintenance_windows: str
:param maintenance_windows: Example: '00:00-01:00,10:00-11:00'
:returns: bool... | [
"Checks",
"that",
"the",
"current",
"time",
"is",
"within",
"the",
"maintenance",
"window"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/dynamodb.py#L661-L692 |
18,184 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/sns.py | publish_gsi_notification | def publish_gsi_notification(
table_key, gsi_key, message, message_types, subject=None):
""" Publish a notification for a specific GSI
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_key: str
:param gsi_key: Table configuration option key name
:type ... | python | def publish_gsi_notification(
table_key, gsi_key, message, message_types, subject=None):
""" Publish a notification for a specific GSI
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_key: str
:param gsi_key: Table configuration option key name
:type ... | [
"def",
"publish_gsi_notification",
"(",
"table_key",
",",
"gsi_key",
",",
"message",
",",
"message_types",
",",
"subject",
"=",
"None",
")",
":",
"topic",
"=",
"get_gsi_option",
"(",
"table_key",
",",
"gsi_key",
",",
"'sns_topic_arn'",
")",
"if",
"not",
"topic... | Publish a notification for a specific GSI
:type table_key: str
:param table_key: Table configuration option key name
:type gsi_key: str
:param gsi_key: Table configuration option key name
:type message: str
:param message: Message to send via SNS
:type message_types: list
:param message... | [
"Publish",
"a",
"notification",
"for",
"a",
"specific",
"GSI"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/sns.py#L11-L40 |
18,185 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/sns.py | publish_table_notification | def publish_table_notification(table_key, message, message_types, subject=None):
""" Publish a notification for a specific table
:type table_key: str
:param table_key: Table configuration option key name
:type message: str
:param message: Message to send via SNS
:type message_types: list
:p... | python | def publish_table_notification(table_key, message, message_types, subject=None):
""" Publish a notification for a specific table
:type table_key: str
:param table_key: Table configuration option key name
:type message: str
:param message: Message to send via SNS
:type message_types: list
:p... | [
"def",
"publish_table_notification",
"(",
"table_key",
",",
"message",
",",
"message_types",
",",
"subject",
"=",
"None",
")",
":",
"topic",
"=",
"get_table_option",
"(",
"table_key",
",",
"'sns_topic_arn'",
")",
"if",
"not",
"topic",
":",
"return",
"for",
"me... | Publish a notification for a specific table
:type table_key: str
:param table_key: Table configuration option key name
:type message: str
:param message: Message to send via SNS
:type message_types: list
:param message_types:
List with types:
- scale-up
- scale-down
... | [
"Publish",
"a",
"notification",
"for",
"a",
"specific",
"table"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/sns.py#L43-L68 |
18,186 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/sns.py | __publish | def __publish(topic, message, subject=None):
""" Publish a message to a SNS topic
:type topic: str
:param topic: SNS topic to publish the message to
:type message: str
:param message: Message to send via SNS
:type subject: str
:param subject: Subject to use for e-mail notifications
:ret... | python | def __publish(topic, message, subject=None):
""" Publish a message to a SNS topic
:type topic: str
:param topic: SNS topic to publish the message to
:type message: str
:param message: Message to send via SNS
:type subject: str
:param subject: Subject to use for e-mail notifications
:ret... | [
"def",
"__publish",
"(",
"topic",
",",
"message",
",",
"subject",
"=",
"None",
")",
":",
"try",
":",
"SNS_CONNECTION",
".",
"publish",
"(",
"topic",
"=",
"topic",
",",
"message",
"=",
"message",
",",
"subject",
"=",
"subject",
")",
"logger",
".",
"info... | Publish a message to a SNS topic
:type topic: str
:param topic: SNS topic to publish the message to
:type message: str
:param message: Message to send via SNS
:type subject: str
:param subject: Subject to use for e-mail notifications
:returns: None | [
"Publish",
"a",
"message",
"to",
"a",
"SNS",
"topic"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/sns.py#L71-L89 |
18,187 | sebdah/dynamic-dynamodb | dynamic_dynamodb/aws/sns.py | __get_connection_SNS | def __get_connection_SNS():
""" Ensure connection to SNS """
region = get_global_option('region')
try:
if (get_global_option('aws_access_key_id') and
get_global_option('aws_secret_access_key')):
logger.debug(
'Authenticating to SNS using '
... | python | def __get_connection_SNS():
""" Ensure connection to SNS """
region = get_global_option('region')
try:
if (get_global_option('aws_access_key_id') and
get_global_option('aws_secret_access_key')):
logger.debug(
'Authenticating to SNS using '
... | [
"def",
"__get_connection_SNS",
"(",
")",
":",
"region",
"=",
"get_global_option",
"(",
"'region'",
")",
"try",
":",
"if",
"(",
"get_global_option",
"(",
"'aws_access_key_id'",
")",
"and",
"get_global_option",
"(",
"'aws_secret_access_key'",
")",
")",
":",
"logger"... | Ensure connection to SNS | [
"Ensure",
"connection",
"to",
"SNS"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/aws/sns.py#L92-L121 |
18,188 | sebdah/dynamic-dynamodb | dynamic_dynamodb/core/table.py | __calculate_always_decrease_rw_values | def __calculate_always_decrease_rw_values(
table_name, read_units, provisioned_reads,
write_units, provisioned_writes):
""" Calculate values for always-decrease-rw-together
This will only return reads and writes decreases if both reads and writes
are lower than the current provisioning
... | python | def __calculate_always_decrease_rw_values(
table_name, read_units, provisioned_reads,
write_units, provisioned_writes):
""" Calculate values for always-decrease-rw-together
This will only return reads and writes decreases if both reads and writes
are lower than the current provisioning
... | [
"def",
"__calculate_always_decrease_rw_values",
"(",
"table_name",
",",
"read_units",
",",
"provisioned_reads",
",",
"write_units",
",",
"provisioned_writes",
")",
":",
"if",
"read_units",
"<=",
"provisioned_reads",
"and",
"write_units",
"<=",
"provisioned_writes",
":",
... | Calculate values for always-decrease-rw-together
This will only return reads and writes decreases if both reads and writes
are lower than the current provisioning
:type table_name: str
:param table_name: Name of the DynamoDB table
:type read_units: int
:param read_units: New read unit provisi... | [
"Calculate",
"values",
"for",
"always",
"-",
"decrease",
"-",
"rw",
"-",
"together"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/core/table.py#L81-L121 |
18,189 | sebdah/dynamic-dynamodb | dynamic_dynamodb/core/table.py | __update_throughput | def __update_throughput(table_name, key_name, read_units, write_units):
""" Update throughput on the DynamoDB table
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type read_units: int
:param read_units:... | python | def __update_throughput(table_name, key_name, read_units, write_units):
""" Update throughput on the DynamoDB table
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type read_units: int
:param read_units:... | [
"def",
"__update_throughput",
"(",
"table_name",
",",
"key_name",
",",
"read_units",
",",
"write_units",
")",
":",
"try",
":",
"current_ru",
"=",
"dynamodb",
".",
"get_provisioned_table_read_units",
"(",
"table_name",
")",
"current_wu",
"=",
"dynamodb",
".",
"get_... | Update throughput on the DynamoDB table
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type read_units: int
:param read_units: New read unit provisioning
:type write_units: int
:param write_units: N... | [
"Update",
"throughput",
"on",
"the",
"DynamoDB",
"table"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/core/table.py#L897-L945 |
18,190 | sebdah/dynamic-dynamodb | dynamic_dynamodb/config/__init__.py | get_configuration | def get_configuration():
""" Get the configuration from command line and config files """
# This is the dict we will return
configuration = {
'global': {},
'logging': {},
'tables': ordereddict()
}
# Read the command line options
cmd_line_options = command_line_parser.par... | python | def get_configuration():
""" Get the configuration from command line and config files """
# This is the dict we will return
configuration = {
'global': {},
'logging': {},
'tables': ordereddict()
}
# Read the command line options
cmd_line_options = command_line_parser.par... | [
"def",
"get_configuration",
"(",
")",
":",
"# This is the dict we will return",
"configuration",
"=",
"{",
"'global'",
":",
"{",
"}",
",",
"'logging'",
":",
"{",
"}",
",",
"'tables'",
":",
"ordereddict",
"(",
")",
"}",
"# Read the command line options",
"cmd_line_... | Get the configuration from command line and config files | [
"Get",
"the",
"configuration",
"from",
"command",
"line",
"and",
"config",
"files"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/config/__init__.py#L162-L203 |
18,191 | sebdah/dynamic-dynamodb | dynamic_dynamodb/config/__init__.py | __get_cmd_table_options | def __get_cmd_table_options(cmd_line_options):
""" Get all table options from the command line
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:returns: dict -- E.g. {'table_name': {}}
"""
table_name = cmd_line_options['table_name']
options = {... | python | def __get_cmd_table_options(cmd_line_options):
""" Get all table options from the command line
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:returns: dict -- E.g. {'table_name': {}}
"""
table_name = cmd_line_options['table_name']
options = {... | [
"def",
"__get_cmd_table_options",
"(",
"cmd_line_options",
")",
":",
"table_name",
"=",
"cmd_line_options",
"[",
"'table_name'",
"]",
"options",
"=",
"{",
"table_name",
":",
"{",
"}",
"}",
"for",
"option",
"in",
"DEFAULT_OPTIONS",
"[",
"'table'",
"]",
".",
"ke... | Get all table options from the command line
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:returns: dict -- E.g. {'table_name': {}} | [
"Get",
"all",
"table",
"options",
"from",
"the",
"command",
"line"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/config/__init__.py#L206-L222 |
18,192 | sebdah/dynamic-dynamodb | dynamic_dynamodb/config/__init__.py | __get_config_table_options | def __get_config_table_options(conf_file_options):
""" Get all table options from the config file
:type conf_file_options: ordereddict
:param conf_file_options: Dictionary with all config file options
:returns: ordereddict -- E.g. {'table_name': {}}
"""
options = ordereddict()
if not conf_... | python | def __get_config_table_options(conf_file_options):
""" Get all table options from the config file
:type conf_file_options: ordereddict
:param conf_file_options: Dictionary with all config file options
:returns: ordereddict -- E.g. {'table_name': {}}
"""
options = ordereddict()
if not conf_... | [
"def",
"__get_config_table_options",
"(",
"conf_file_options",
")",
":",
"options",
"=",
"ordereddict",
"(",
")",
"if",
"not",
"conf_file_options",
":",
"return",
"options",
"for",
"table_name",
"in",
"conf_file_options",
"[",
"'tables'",
"]",
":",
"options",
"[",... | Get all table options from the config file
:type conf_file_options: ordereddict
:param conf_file_options: Dictionary with all config file options
:returns: ordereddict -- E.g. {'table_name': {}} | [
"Get",
"all",
"table",
"options",
"from",
"the",
"config",
"file"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/config/__init__.py#L225-L296 |
18,193 | sebdah/dynamic-dynamodb | dynamic_dynamodb/config/__init__.py | __get_global_options | def __get_global_options(cmd_line_options, conf_file_options=None):
""" Get all global options
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:type conf_file_options: dict
:param conf_file_options: Dictionary with all config file options
:returns:... | python | def __get_global_options(cmd_line_options, conf_file_options=None):
""" Get all global options
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:type conf_file_options: dict
:param conf_file_options: Dictionary with all config file options
:returns:... | [
"def",
"__get_global_options",
"(",
"cmd_line_options",
",",
"conf_file_options",
"=",
"None",
")",
":",
"options",
"=",
"{",
"}",
"for",
"option",
"in",
"DEFAULT_OPTIONS",
"[",
"'global'",
"]",
".",
"keys",
"(",
")",
":",
"options",
"[",
"option",
"]",
"=... | Get all global options
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:type conf_file_options: dict
:param conf_file_options: Dictionary with all config file options
:returns: dict | [
"Get",
"all",
"global",
"options"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/config/__init__.py#L299-L319 |
18,194 | sebdah/dynamic-dynamodb | dynamic_dynamodb/config/__init__.py | __get_logging_options | def __get_logging_options(cmd_line_options, conf_file_options=None):
""" Get all logging options
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:type conf_file_options: dict
:param conf_file_options: Dictionary with all config file options
:return... | python | def __get_logging_options(cmd_line_options, conf_file_options=None):
""" Get all logging options
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:type conf_file_options: dict
:param conf_file_options: Dictionary with all config file options
:return... | [
"def",
"__get_logging_options",
"(",
"cmd_line_options",
",",
"conf_file_options",
"=",
"None",
")",
":",
"options",
"=",
"{",
"}",
"for",
"option",
"in",
"DEFAULT_OPTIONS",
"[",
"'logging'",
"]",
".",
"keys",
"(",
")",
":",
"options",
"[",
"option",
"]",
... | Get all logging options
:type cmd_line_options: dict
:param cmd_line_options: Dictionary with all command line options
:type conf_file_options: dict
:param conf_file_options: Dictionary with all config file options
:returns: dict | [
"Get",
"all",
"logging",
"options"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/config/__init__.py#L322-L342 |
18,195 | sebdah/dynamic-dynamodb | dynamic_dynamodb/config/__init__.py | __check_logging_rules | def __check_logging_rules(configuration):
""" Check that the logging values are proper """
valid_log_levels = [
'debug',
'info',
'warning',
'error'
]
if configuration['logging']['log_level'].lower() not in valid_log_levels:
print('Log level must be one of {0}'.for... | python | def __check_logging_rules(configuration):
""" Check that the logging values are proper """
valid_log_levels = [
'debug',
'info',
'warning',
'error'
]
if configuration['logging']['log_level'].lower() not in valid_log_levels:
print('Log level must be one of {0}'.for... | [
"def",
"__check_logging_rules",
"(",
"configuration",
")",
":",
"valid_log_levels",
"=",
"[",
"'debug'",
",",
"'info'",
",",
"'warning'",
",",
"'error'",
"]",
"if",
"configuration",
"[",
"'logging'",
"]",
"[",
"'log_level'",
"]",
".",
"lower",
"(",
")",
"not... | Check that the logging values are proper | [
"Check",
"that",
"the",
"logging",
"values",
"are",
"proper"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/config/__init__.py#L505-L516 |
18,196 | sebdah/dynamic-dynamodb | dynamic_dynamodb/calculators.py | is_consumed_over_proposed | def is_consumed_over_proposed(
current_provisioning, proposed_provisioning, consumed_units_percent):
"""
Determines if the currently consumed capacity is over the proposed capacity
for this table
:type current_provisioning: int
:param current_provisioning: The current provisioning
:type... | python | def is_consumed_over_proposed(
current_provisioning, proposed_provisioning, consumed_units_percent):
"""
Determines if the currently consumed capacity is over the proposed capacity
for this table
:type current_provisioning: int
:param current_provisioning: The current provisioning
:type... | [
"def",
"is_consumed_over_proposed",
"(",
"current_provisioning",
",",
"proposed_provisioning",
",",
"consumed_units_percent",
")",
":",
"consumption_based_current_provisioning",
"=",
"int",
"(",
"math",
".",
"ceil",
"(",
"current_provisioning",
"*",
"(",
"consumed_units_per... | Determines if the currently consumed capacity is over the proposed capacity
for this table
:type current_provisioning: int
:param current_provisioning: The current provisioning
:type proposed_provisioning: int
:param proposed_provisioning: New provisioning
:type consumed_units_percent: float
... | [
"Determines",
"if",
"the",
"currently",
"consumed",
"capacity",
"is",
"over",
"the",
"proposed",
"capacity",
"for",
"this",
"table"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/calculators.py#L342-L358 |
18,197 | sebdah/dynamic-dynamodb | dynamic_dynamodb/calculators.py | __get_min_reads | def __get_min_reads(current_provisioning, min_provisioned_reads, log_tag):
""" Get the minimum number of reads to current_provisioning
:type current_provisioning: int
:param current_provisioning: Current provisioned reads
:type min_provisioned_reads: int
:param min_provisioned_reads: Configured min... | python | def __get_min_reads(current_provisioning, min_provisioned_reads, log_tag):
""" Get the minimum number of reads to current_provisioning
:type current_provisioning: int
:param current_provisioning: Current provisioned reads
:type min_provisioned_reads: int
:param min_provisioned_reads: Configured min... | [
"def",
"__get_min_reads",
"(",
"current_provisioning",
",",
"min_provisioned_reads",
",",
"log_tag",
")",
":",
"# Fallback value to ensure that we always have at least 1 read",
"reads",
"=",
"1",
"if",
"min_provisioned_reads",
":",
"reads",
"=",
"int",
"(",
"min_provisioned... | Get the minimum number of reads to current_provisioning
:type current_provisioning: int
:param current_provisioning: Current provisioned reads
:type min_provisioned_reads: int
:param min_provisioned_reads: Configured min provisioned reads
:type log_tag: str
:param log_tag: Prefix for the log
... | [
"Get",
"the",
"minimum",
"number",
"of",
"reads",
"to",
"current_provisioning"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/calculators.py#L361-L389 |
18,198 | sebdah/dynamic-dynamodb | dynamic_dynamodb/calculators.py | __get_min_writes | def __get_min_writes(current_provisioning, min_provisioned_writes, log_tag):
""" Get the minimum number of writes to current_provisioning
:type current_provisioning: int
:param current_provisioning: Current provisioned writes
:type min_provisioned_writes: int
:param min_provisioned_writes: Configur... | python | def __get_min_writes(current_provisioning, min_provisioned_writes, log_tag):
""" Get the minimum number of writes to current_provisioning
:type current_provisioning: int
:param current_provisioning: Current provisioned writes
:type min_provisioned_writes: int
:param min_provisioned_writes: Configur... | [
"def",
"__get_min_writes",
"(",
"current_provisioning",
",",
"min_provisioned_writes",
",",
"log_tag",
")",
":",
"# Fallback value to ensure that we always have at least 1 read",
"writes",
"=",
"1",
"if",
"min_provisioned_writes",
":",
"writes",
"=",
"int",
"(",
"min_provis... | Get the minimum number of writes to current_provisioning
:type current_provisioning: int
:param current_provisioning: Current provisioned writes
:type min_provisioned_writes: int
:param min_provisioned_writes: Configured min provisioned writes
:type log_tag: str
:param log_tag: Prefix for the l... | [
"Get",
"the",
"minimum",
"number",
"of",
"writes",
"to",
"current_provisioning"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/calculators.py#L392-L420 |
18,199 | sebdah/dynamic-dynamodb | dynamic_dynamodb/daemon.py | Daemon.restart | def restart(self, *args, **kwargs):
""" Restart the daemon """
self.stop()
try:
self.start(*args, **kwargs)
except IOError:
raise | python | def restart(self, *args, **kwargs):
""" Restart the daemon """
self.stop()
try:
self.start(*args, **kwargs)
except IOError:
raise | [
"def",
"restart",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"stop",
"(",
")",
"try",
":",
"self",
".",
"start",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"except",
"IOError",
":",
"raise"
] | Restart the daemon | [
"Restart",
"the",
"daemon"
] | bfd0ca806b1c3301e724696de90ef0f973410493 | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/daemon.py#L132-L138 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.