repo stringlengths 7 54 | path stringlengths 4 192 | url stringlengths 87 284 | code stringlengths 78 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values |
|---|---|---|---|---|---|---|---|---|
flask-restful/flask-restful | flask_restful/__init__.py | https://github.com/flask-restful/flask-restful/blob/25544d697c1f82bafbd1320960df459f58a58e03/flask_restful/__init__.py#L386-L404 | def resource(self, *urls, **kwargs):
"""Wraps a :class:`~flask_restful.Resource` class, adding it to the
api. Parameters are the same as :meth:`~flask_restful.Api.add_resource`.
Example::
app = Flask(__name__)
api = restful.Api(app)
@api.resource('/foo')
... | [
"def",
"resource",
"(",
"self",
",",
"*",
"urls",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"decorator",
"(",
"cls",
")",
":",
"self",
".",
"add_resource",
"(",
"cls",
",",
"*",
"urls",
",",
"*",
"*",
"kwargs",
")",
"return",
"cls",
"return",
"de... | Wraps a :class:`~flask_restful.Resource` class, adding it to the
api. Parameters are the same as :meth:`~flask_restful.Api.add_resource`.
Example::
app = Flask(__name__)
api = restful.Api(app)
@api.resource('/foo')
class Foo(Resource):
d... | [
"Wraps",
"a",
":",
"class",
":",
"~flask_restful",
".",
"Resource",
"class",
"adding",
"it",
"to",
"the",
"api",
".",
"Parameters",
"are",
"the",
"same",
"as",
":",
"meth",
":",
"~flask_restful",
".",
"Api",
".",
"add_resource",
"."
] | python | train |
RusticiSoftware/TinCanPython | tincan/remote_lrs.py | https://github.com/RusticiSoftware/TinCanPython/blob/424eedaa6d19221efb1108edb915fc332abbb317/tincan/remote_lrs.py#L509-L551 | def _delete_state(self, activity, agent, state_id=None, registration=None, etag=None):
"""Private method to delete a specified state from the LRS
:param activity: Activity object of state to be deleted
:type activity: :class:`tincan.activity.Activity`
:param agent: Agent object of state... | [
"def",
"_delete_state",
"(",
"self",
",",
"activity",
",",
"agent",
",",
"state_id",
"=",
"None",
",",
"registration",
"=",
"None",
",",
"etag",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"activity",
",",
"Activity",
")",
":",
"activity",
"... | Private method to delete a specified state from the LRS
:param activity: Activity object of state to be deleted
:type activity: :class:`tincan.activity.Activity`
:param agent: Agent object of state to be deleted
:type agent: :class:`tincan.agent.Agent`
:param state_id: UUID of s... | [
"Private",
"method",
"to",
"delete",
"a",
"specified",
"state",
"from",
"the",
"LRS"
] | python | train |
Robpol86/Flask-Celery-Helper | flask_celery.py | https://github.com/Robpol86/Flask-Celery-Helper/blob/92bd3b02954422665260116adda8eb899546c365/flask_celery.py#L228-L269 | def single_instance(func=None, lock_timeout=None, include_args=False):
"""Celery task decorator. Forces the task to have only one running instance at a time.
Use with binded tasks (@celery.task(bind=True)).
Modeled after:
http://loose-bits.com/2010/10/distributed-task-locking-in-celery.html
http:/... | [
"def",
"single_instance",
"(",
"func",
"=",
"None",
",",
"lock_timeout",
"=",
"None",
",",
"include_args",
"=",
"False",
")",
":",
"if",
"func",
"is",
"None",
":",
"return",
"partial",
"(",
"single_instance",
",",
"lock_timeout",
"=",
"lock_timeout",
",",
... | Celery task decorator. Forces the task to have only one running instance at a time.
Use with binded tasks (@celery.task(bind=True)).
Modeled after:
http://loose-bits.com/2010/10/distributed-task-locking-in-celery.html
http://blogs.it.ox.ac.uk/inapickle/2012/01/05/python-decorators-with-optional-argume... | [
"Celery",
"task",
"decorator",
".",
"Forces",
"the",
"task",
"to",
"have",
"only",
"one",
"running",
"instance",
"at",
"a",
"time",
"."
] | python | valid |
genericclient/genericclient-base | genericclient_base/utils.py | https://github.com/genericclient/genericclient-base/blob/193f7c879c40decaf03504af633f593b88e4abc5/genericclient_base/utils.py#L60-L74 | def parse_headers_link(headers):
"""Returns the parsed header links of the response, if any."""
header = CaseInsensitiveDict(headers).get('link')
l = {}
if header:
links = parse_link(header)
for link in links:
key = link.get('rel') or link.get('url')
l[key] = ... | [
"def",
"parse_headers_link",
"(",
"headers",
")",
":",
"header",
"=",
"CaseInsensitiveDict",
"(",
"headers",
")",
".",
"get",
"(",
"'link'",
")",
"l",
"=",
"{",
"}",
"if",
"header",
":",
"links",
"=",
"parse_link",
"(",
"header",
")",
"for",
"link",
"i... | Returns the parsed header links of the response, if any. | [
"Returns",
"the",
"parsed",
"header",
"links",
"of",
"the",
"response",
"if",
"any",
"."
] | python | train |
iopipe/iopipe-python | iopipe/agent.py | https://github.com/iopipe/iopipe-python/blob/4eb653977341bc67f8b1b87aedb3aaaefc25af61/iopipe/agent.py#L246-L258 | def submit_future(self, func, *args, **kwargs):
"""
Submit a function call to be run as a future in a thread pool. This
should be an I/O bound operation.
"""
# This mode will run futures synchronously. This should only be used
# for benchmarking purposes.
if self.... | [
"def",
"submit_future",
"(",
"self",
",",
"func",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# This mode will run futures synchronously. This should only be used",
"# for benchmarking purposes.",
"if",
"self",
".",
"config",
"[",
"\"sync_http\"",
"]",
"is",... | Submit a function call to be run as a future in a thread pool. This
should be an I/O bound operation. | [
"Submit",
"a",
"function",
"call",
"to",
"be",
"run",
"as",
"a",
"future",
"in",
"a",
"thread",
"pool",
".",
"This",
"should",
"be",
"an",
"I",
"/",
"O",
"bound",
"operation",
"."
] | python | train |
Robpol86/terminaltables | terminaltables/width_and_alignment.py | https://github.com/Robpol86/terminaltables/blob/ad8f46e50afdbaea377fc1f713bc0e7a31c4fccc/terminaltables/width_and_alignment.py#L84-L113 | def max_dimensions(table_data, padding_left=0, padding_right=0, padding_top=0, padding_bottom=0):
"""Get maximum widths of each column and maximum height of each row.
:param iter table_data: List of list of strings (unmodified table data).
:param int padding_left: Number of space chars on left side of cell... | [
"def",
"max_dimensions",
"(",
"table_data",
",",
"padding_left",
"=",
"0",
",",
"padding_right",
"=",
"0",
",",
"padding_top",
"=",
"0",
",",
"padding_bottom",
"=",
"0",
")",
":",
"inner_widths",
"=",
"[",
"0",
"]",
"*",
"(",
"max",
"(",
"len",
"(",
... | Get maximum widths of each column and maximum height of each row.
:param iter table_data: List of list of strings (unmodified table data).
:param int padding_left: Number of space chars on left side of cell.
:param int padding_right: Number of space chars on right side of cell.
:param int padding_top: ... | [
"Get",
"maximum",
"widths",
"of",
"each",
"column",
"and",
"maximum",
"height",
"of",
"each",
"row",
"."
] | python | train |
DEIB-GECO/PyGMQL | gmql/dataset/GMQLDataset.py | https://github.com/DEIB-GECO/PyGMQL/blob/e58b2f9402a86056dcda484a32e3de0bb06ed991/gmql/dataset/GMQLDataset.py#L1363-L1388 | def materialize(self, output_path=None, output_name=None, all_load=True):
"""
*Wrapper of* ``MATERIALIZE``
Starts the execution of the operations for the GMQLDataset. PyGMQL implements lazy execution
and no operation is performed until the materialization of the results is requestd.
... | [
"def",
"materialize",
"(",
"self",
",",
"output_path",
"=",
"None",
",",
"output_name",
"=",
"None",
",",
"all_load",
"=",
"True",
")",
":",
"current_mode",
"=",
"get_mode",
"(",
")",
"new_index",
"=",
"self",
".",
"__modify_dag",
"(",
"current_mode",
")",... | *Wrapper of* ``MATERIALIZE``
Starts the execution of the operations for the GMQLDataset. PyGMQL implements lazy execution
and no operation is performed until the materialization of the results is requestd.
This operation can happen both locally or remotely.
* Local mode: if the GMQLDat... | [
"*",
"Wrapper",
"of",
"*",
"MATERIALIZE"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Environment.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Environment.py#L613-L637 | def Override(self, overrides):
"""
Produce a modified environment whose variables are overridden by
the overrides dictionaries. "overrides" is a dictionary that
will override the variables of this environment.
This function is much more efficient than Clone() or creating
... | [
"def",
"Override",
"(",
"self",
",",
"overrides",
")",
":",
"if",
"not",
"overrides",
":",
"return",
"self",
"o",
"=",
"copy_non_reserved_keywords",
"(",
"overrides",
")",
"if",
"not",
"o",
":",
"return",
"self",
"overrides",
"=",
"{",
"}",
"merges",
"="... | Produce a modified environment whose variables are overridden by
the overrides dictionaries. "overrides" is a dictionary that
will override the variables of this environment.
This function is much more efficient than Clone() or creating
a new Environment because it doesn't copy the con... | [
"Produce",
"a",
"modified",
"environment",
"whose",
"variables",
"are",
"overridden",
"by",
"the",
"overrides",
"dictionaries",
".",
"overrides",
"is",
"a",
"dictionary",
"that",
"will",
"override",
"the",
"variables",
"of",
"this",
"environment",
"."
] | python | train |
20c/xbahn | xbahn/engineer.py | https://github.com/20c/xbahn/blob/afb27b0576841338a366d7cac0200a782bd84be6/xbahn/engineer.py#L130-L149 | def engineer_info(self, action):
"""
Returns:
dict: engineer command information
- arguments (list<dict>): command arguments
- args (list): args to pass through to click.argument
- kwargs (dict): keyword arguments to pass through to c... | [
"def",
"engineer_info",
"(",
"self",
",",
"action",
")",
":",
"fn",
"=",
"getattr",
"(",
"self",
",",
"action",
",",
"None",
")",
"if",
"not",
"fn",
":",
"raise",
"AttributeError",
"(",
"\"Engineer action not found: %s\"",
"%",
"action",
")",
"if",
"not",
... | Returns:
dict: engineer command information
- arguments (list<dict>): command arguments
- args (list): args to pass through to click.argument
- kwargs (dict): keyword arguments to pass through to click.argument
- options (list<dict>): ... | [
"Returns",
":",
"dict",
":",
"engineer",
"command",
"information",
"-",
"arguments",
"(",
"list<dict",
">",
")",
":",
"command",
"arguments",
"-",
"args",
"(",
"list",
")",
":",
"args",
"to",
"pass",
"through",
"to",
"click",
".",
"argument",
"-",
"kwarg... | python | train |
bjodah/pycompilation | pycompilation/compilation.py | https://github.com/bjodah/pycompilation/blob/43eac8d82f8258d30d4df77fd2ad3f3e4f4dca18/pycompilation/compilation.py#L311-L381 | def simple_cythonize(src, destdir=None, cwd=None, logger=None,
full_module_name=None, only_update=False,
**cy_kwargs):
"""
Generates a C file from a Cython source file.
Parameters
----------
src: path string
path to Cython source
destdir: path s... | [
"def",
"simple_cythonize",
"(",
"src",
",",
"destdir",
"=",
"None",
",",
"cwd",
"=",
"None",
",",
"logger",
"=",
"None",
",",
"full_module_name",
"=",
"None",
",",
"only_update",
"=",
"False",
",",
"*",
"*",
"cy_kwargs",
")",
":",
"from",
"Cython",
"."... | Generates a C file from a Cython source file.
Parameters
----------
src: path string
path to Cython source
destdir: path string (optional)
Path to output directory (default: '.')
cwd: path string (optional)
Root of relative paths (default: '.')
logger: logging.Logger
... | [
"Generates",
"a",
"C",
"file",
"from",
"a",
"Cython",
"source",
"file",
"."
] | python | train |
IBMStreams/pypi.streamsx | streamsx/topology/context.py | https://github.com/IBMStreams/pypi.streamsx/blob/abd67b4757120f6f805787fba390f53e9df9cdd8/streamsx/topology/context.py#L55-L89 | def submit(ctxtype, graph, config=None, username=None, password=None):
"""
Submits a `Topology` (application) using the specified context type.
Used to submit an application for compilation into a Streams application and
execution within an Streaming Analytics service or IBM Streams instance.
`ctx... | [
"def",
"submit",
"(",
"ctxtype",
",",
"graph",
",",
"config",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"streamsx",
".",
"_streams",
".",
"_version",
".",
"_mismatch_check",
"(",
"__name__",
")",
"graph",
"=",
"... | Submits a `Topology` (application) using the specified context type.
Used to submit an application for compilation into a Streams application and
execution within an Streaming Analytics service or IBM Streams instance.
`ctxtype` defines how the application will be submitted, see :py:class:`ContextTypes`.
... | [
"Submits",
"a",
"Topology",
"(",
"application",
")",
"using",
"the",
"specified",
"context",
"type",
"."
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/app/backends/ipython/_widget.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/app/backends/ipython/_widget.py#L21-L31 | def _stop_timers(canvas):
"""Stop all timers in a canvas."""
for attr in dir(canvas):
try:
attr_obj = getattr(canvas, attr)
except NotImplementedError:
# This try/except is needed because canvas.position raises
# an error (it is not implemented in this backend... | [
"def",
"_stop_timers",
"(",
"canvas",
")",
":",
"for",
"attr",
"in",
"dir",
"(",
"canvas",
")",
":",
"try",
":",
"attr_obj",
"=",
"getattr",
"(",
"canvas",
",",
"attr",
")",
"except",
"NotImplementedError",
":",
"# This try/except is needed because canvas.positi... | Stop all timers in a canvas. | [
"Stop",
"all",
"timers",
"in",
"a",
"canvas",
"."
] | python | train |
common-workflow-language/workflow-service | wes_service/util.py | https://github.com/common-workflow-language/workflow-service/blob/e879604b65c55546e4f87be1c9df9903a3e0b896/wes_service/util.py#L38-L44 | def getoptlist(self, p):
"""Returns all option values stored that match p as a list."""
optlist = []
for k, v in self.pairs:
if k == p:
optlist.append(v)
return optlist | [
"def",
"getoptlist",
"(",
"self",
",",
"p",
")",
":",
"optlist",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"pairs",
":",
"if",
"k",
"==",
"p",
":",
"optlist",
".",
"append",
"(",
"v",
")",
"return",
"optlist"
] | Returns all option values stored that match p as a list. | [
"Returns",
"all",
"option",
"values",
"stored",
"that",
"match",
"p",
"as",
"a",
"list",
"."
] | python | train |
shoebot/shoebot | shoebot/grammar/livecode.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/shoebot/grammar/livecode.py#L84-L103 | def run_tenuous(self):
"""
Run edited source, if no exceptions occur then it
graduates to known good.
"""
with LiveExecution.lock:
ns_snapshot = copy.copy(self.ns)
try:
source = self.edited_source
self.edited_source = None
... | [
"def",
"run_tenuous",
"(",
"self",
")",
":",
"with",
"LiveExecution",
".",
"lock",
":",
"ns_snapshot",
"=",
"copy",
".",
"copy",
"(",
"self",
".",
"ns",
")",
"try",
":",
"source",
"=",
"self",
".",
"edited_source",
"self",
".",
"edited_source",
"=",
"N... | Run edited source, if no exceptions occur then it
graduates to known good. | [
"Run",
"edited",
"source",
"if",
"no",
"exceptions",
"occur",
"then",
"it",
"graduates",
"to",
"known",
"good",
"."
] | python | valid |
RedHatInsights/insights-core | insights/client/config.py | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/config.py#L393-L417 | def _update_dict(self, dict_):
'''
Update without allowing undefined options or overwrite of class methods
'''
dict_ = dict((k, v) for k, v in dict_.items() if (
k not in self._init_attrs))
# zzz
if 'no_gpg' in dict_ and dict_['no_gpg']:
d... | [
"def",
"_update_dict",
"(",
"self",
",",
"dict_",
")",
":",
"dict_",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"dict_",
".",
"items",
"(",
")",
"if",
"(",
"k",
"not",
"in",
"self",
".",
"_init_attrs",
")",
")",
"#... | Update without allowing undefined options or overwrite of class methods | [
"Update",
"without",
"allowing",
"undefined",
"options",
"or",
"overwrite",
"of",
"class",
"methods"
] | python | train |
oscarlazoarjona/fast | fast/symbolic.py | https://github.com/oscarlazoarjona/fast/blob/3e5400672af2a7b7cc616e7f4aa10d7672720222/fast/symbolic.py#L1431-L1462 | def cross(a, b):
r"""Cross product of two 3d vectors."""
if isinstance(a, Mul):
a = a.expand()
avect = 1
aivect = -1
for ai, fact in enumerate(a.args):
if isinstance(fact, Vector3D):
avect = fact
aivect = ai
break
... | [
"def",
"cross",
"(",
"a",
",",
"b",
")",
":",
"if",
"isinstance",
"(",
"a",
",",
"Mul",
")",
":",
"a",
"=",
"a",
".",
"expand",
"(",
")",
"avect",
"=",
"1",
"aivect",
"=",
"-",
"1",
"for",
"ai",
",",
"fact",
"in",
"enumerate",
"(",
"a",
"."... | r"""Cross product of two 3d vectors. | [
"r",
"Cross",
"product",
"of",
"two",
"3d",
"vectors",
"."
] | python | train |
saltstack/salt | salt/master.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2063-L2174 | def publish(self, clear_load):
'''
This method sends out publications to the minions, it can only be used
by the LocalClient.
'''
extra = clear_load.get('kwargs', {})
publisher_acl = salt.acl.PublisherACL(self.opts['publisher_acl_blacklist'])
if publisher_acl.us... | [
"def",
"publish",
"(",
"self",
",",
"clear_load",
")",
":",
"extra",
"=",
"clear_load",
".",
"get",
"(",
"'kwargs'",
",",
"{",
"}",
")",
"publisher_acl",
"=",
"salt",
".",
"acl",
".",
"PublisherACL",
"(",
"self",
".",
"opts",
"[",
"'publisher_acl_blackli... | This method sends out publications to the minions, it can only be used
by the LocalClient. | [
"This",
"method",
"sends",
"out",
"publications",
"to",
"the",
"minions",
"it",
"can",
"only",
"be",
"used",
"by",
"the",
"LocalClient",
"."
] | python | train |
trendels/rhino | rhino/response.py | https://github.com/trendels/rhino/blob/f1f0ef21b6080a2bd130b38b5bef163074c94aed/rhino/response.py#L362-L404 | def response(code, body='', etag=None, last_modified=None, expires=None, **kw):
"""Helper to build an HTTP response.
Parameters:
code
: An integer status code.
body
: The response body. See `Response.__init__` for details.
etag
: A value for the ETag header. Double quotes will be... | [
"def",
"response",
"(",
"code",
",",
"body",
"=",
"''",
",",
"etag",
"=",
"None",
",",
"last_modified",
"=",
"None",
",",
"expires",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"etag",
"is",
"not",
"None",
":",
"if",
"not",
"(",
"etag",
"... | Helper to build an HTTP response.
Parameters:
code
: An integer status code.
body
: The response body. See `Response.__init__` for details.
etag
: A value for the ETag header. Double quotes will be added unless the
string starts and ends with a double quote.
last_modified... | [
"Helper",
"to",
"build",
"an",
"HTTP",
"response",
"."
] | python | train |
DataONEorg/d1_python | gmn/src/d1_gmn/app/management/commands/process_replication_queue.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/management/commands/process_replication_queue.py#L228-L246 | def _create_replica(self, sysmeta_pyxb, sciobj_bytestream):
"""GMN handles replicas differently from native objects, with the main
differences being related to handling of restrictions related to revision chains
and SIDs.
So this create sequence differs significantly from the regular on... | [
"def",
"_create_replica",
"(",
"self",
",",
"sysmeta_pyxb",
",",
"sciobj_bytestream",
")",
":",
"pid",
"=",
"d1_common",
".",
"xml",
".",
"get_req_val",
"(",
"sysmeta_pyxb",
".",
"identifier",
")",
"self",
".",
"_assert_is_pid_of_local_unprocessed_replica",
"(",
"... | GMN handles replicas differently from native objects, with the main
differences being related to handling of restrictions related to revision chains
and SIDs.
So this create sequence differs significantly from the regular one that is
accessed through MNStorage.create(). | [
"GMN",
"handles",
"replicas",
"differently",
"from",
"native",
"objects",
"with",
"the",
"main",
"differences",
"being",
"related",
"to",
"handling",
"of",
"restrictions",
"related",
"to",
"revision",
"chains",
"and",
"SIDs",
"."
] | python | train |
arraylabs/pymyq | pymyq/api.py | https://github.com/arraylabs/pymyq/blob/413ae01ca23568f7b5f698a87e872f456072356b/pymyq/api.py#L255-L283 | async def get_devices(self, covers_only: bool = True) -> list:
"""Get a list of all devices associated with the account."""
from .device import MyQDevice
_LOGGER.debug('Retrieving list of devices')
devices_resp = await self._request('get', DEVICE_LIST_ENDPOINT)
# print(json.dump... | [
"async",
"def",
"get_devices",
"(",
"self",
",",
"covers_only",
":",
"bool",
"=",
"True",
")",
"->",
"list",
":",
"from",
".",
"device",
"import",
"MyQDevice",
"_LOGGER",
".",
"debug",
"(",
"'Retrieving list of devices'",
")",
"devices_resp",
"=",
"await",
"... | Get a list of all devices associated with the account. | [
"Get",
"a",
"list",
"of",
"all",
"devices",
"associated",
"with",
"the",
"account",
"."
] | python | train |
basho/riak-python-client | riak/transports/pool.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/pool.py#L209-L221 | def delete_resource(self, resource):
"""
Deletes the resource from the pool and destroys the associated
resource. Not usually needed by users of the pool, but called
internally when BadResource is raised.
:param resource: the resource to remove
:type resource: Resource
... | [
"def",
"delete_resource",
"(",
"self",
",",
"resource",
")",
":",
"with",
"self",
".",
"lock",
":",
"self",
".",
"resources",
".",
"remove",
"(",
"resource",
")",
"self",
".",
"destroy_resource",
"(",
"resource",
".",
"object",
")",
"del",
"resource"
] | Deletes the resource from the pool and destroys the associated
resource. Not usually needed by users of the pool, but called
internally when BadResource is raised.
:param resource: the resource to remove
:type resource: Resource | [
"Deletes",
"the",
"resource",
"from",
"the",
"pool",
"and",
"destroys",
"the",
"associated",
"resource",
".",
"Not",
"usually",
"needed",
"by",
"users",
"of",
"the",
"pool",
"but",
"called",
"internally",
"when",
"BadResource",
"is",
"raised",
"."
] | python | train |
peepall/FancyLogger | FancyLogger/__init__.py | https://github.com/peepall/FancyLogger/blob/7f13f1397e76ed768fb6b6358194118831fafc6d/FancyLogger/__init__.py#L305-L336 | def set_task(self,
task_id,
total,
prefix,
suffix='',
decimals=0,
bar_length=60,
keep_alive=False,
display_time=False):
"""
Defines a new progress bar with the given in... | [
"def",
"set_task",
"(",
"self",
",",
"task_id",
",",
"total",
",",
"prefix",
",",
"suffix",
"=",
"''",
",",
"decimals",
"=",
"0",
",",
"bar_length",
"=",
"60",
",",
"keep_alive",
"=",
"False",
",",
"display_time",
"=",
"False",
")",
":",
"self",
".",... | Defines a new progress bar with the given information.
:param task_id: Unique identifier for this progress bar. Will erase if already existing.
:param total: The total number of iteration for this progress bar.
:param prefix: The text that should be displayed at the le... | [
"Defines",
"a",
"new",
"progress",
"bar",
"with",
"the",
"given",
"information",
".",
":",
"param",
"task_id",
":",
"Unique",
"identifier",
"for",
"this",
"progress",
"bar",
".",
"Will",
"erase",
"if",
"already",
"existing",
".",
":",
"param",
"total",
":"... | python | train |
greenbone/ospd | ospd/ospd.py | https://github.com/greenbone/ospd/blob/cef773166b15a19c17764721d3fe404fa0e107bf/ospd/ospd.py#L759-L800 | def handle_client_stream(self, stream, is_unix=False):
""" Handles stream of data received from client. """
assert stream
data = []
stream.settimeout(2)
while True:
try:
if is_unix:
buf = stream.recv(1024)
else:
... | [
"def",
"handle_client_stream",
"(",
"self",
",",
"stream",
",",
"is_unix",
"=",
"False",
")",
":",
"assert",
"stream",
"data",
"=",
"[",
"]",
"stream",
".",
"settimeout",
"(",
"2",
")",
"while",
"True",
":",
"try",
":",
"if",
"is_unix",
":",
"buf",
"... | Handles stream of data received from client. | [
"Handles",
"stream",
"of",
"data",
"received",
"from",
"client",
"."
] | python | train |
jbarlow83/OCRmyPDF | src/ocrmypdf/_pipeline.py | https://github.com/jbarlow83/OCRmyPDF/blob/79c84eefa353632a3d7ccddbd398c6678c1c1777/src/ocrmypdf/_pipeline.py#L241-L253 | def get_page_square_dpi(pageinfo, options):
"Get the DPI when we require xres == yres, scaled to physical units"
xres = pageinfo.xres or 0
yres = pageinfo.yres or 0
userunit = pageinfo.userunit or 1
return float(
max(
(xres * userunit) or VECTOR_PAGE_DPI,
(yres * user... | [
"def",
"get_page_square_dpi",
"(",
"pageinfo",
",",
"options",
")",
":",
"xres",
"=",
"pageinfo",
".",
"xres",
"or",
"0",
"yres",
"=",
"pageinfo",
".",
"yres",
"or",
"0",
"userunit",
"=",
"pageinfo",
".",
"userunit",
"or",
"1",
"return",
"float",
"(",
... | Get the DPI when we require xres == yres, scaled to physical units | [
"Get",
"the",
"DPI",
"when",
"we",
"require",
"xres",
"==",
"yres",
"scaled",
"to",
"physical",
"units"
] | python | train |
deepmind/sonnet | sonnet/python/modules/relational_memory.py | https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/relational_memory.py#L184-L210 | def _create_gates(self, inputs, memory):
"""Create input and forget gates for this step using `inputs` and `memory`.
Args:
inputs: Tensor input.
memory: The current state of memory.
Returns:
input_gate: A LSTM-like insert gate.
forget_gate: A LSTM-like forget gate.
"""
# We... | [
"def",
"_create_gates",
"(",
"self",
",",
"inputs",
",",
"memory",
")",
":",
"# We'll create the input and forget gates at once. Hence, calculate double",
"# the gate size.",
"num_gates",
"=",
"2",
"*",
"self",
".",
"_calculate_gate_size",
"(",
")",
"memory",
"=",
"tf",... | Create input and forget gates for this step using `inputs` and `memory`.
Args:
inputs: Tensor input.
memory: The current state of memory.
Returns:
input_gate: A LSTM-like insert gate.
forget_gate: A LSTM-like forget gate. | [
"Create",
"input",
"and",
"forget",
"gates",
"for",
"this",
"step",
"using",
"inputs",
"and",
"memory",
"."
] | python | train |
data-8/datascience | datascience/tables.py | https://github.com/data-8/datascience/blob/4cee38266903ca169cea4a53b8cc39502d85c464/datascience/tables.py#L2190-L2295 | def scatter(self, column_for_x, select=None, overlay=True, fit_line=False,
colors=None, labels=None, sizes=None, width=5, height=5, s=20, **vargs):
"""Creates scatterplots, optionally adding a line of best fit.
Args:
``column_for_x`` (``str``): The column to use for the x-axis value... | [
"def",
"scatter",
"(",
"self",
",",
"column_for_x",
",",
"select",
"=",
"None",
",",
"overlay",
"=",
"True",
",",
"fit_line",
"=",
"False",
",",
"colors",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"sizes",
"=",
"None",
",",
"width",
"=",
"5",
"... | Creates scatterplots, optionally adding a line of best fit.
Args:
``column_for_x`` (``str``): The column to use for the x-axis values
and label of the scatter plots.
Kwargs:
``overlay`` (``bool``): If true, creates a chart with one color
per data... | [
"Creates",
"scatterplots",
"optionally",
"adding",
"a",
"line",
"of",
"best",
"fit",
"."
] | python | train |
lappis-unb/salic-ml | src/salicml_api/analysis/api.py | https://github.com/lappis-unb/salic-ml/blob/1b3ebc4f8067740999897ccffd9892dc94482a93/src/salicml_api/analysis/api.py#L60-L79 | def indicator_details(indicator):
"""
Return a dictionary with all metrics in FinancialIndicator,
if there aren't values for that Indicator, it is filled with default values
"""
metrics = format_metrics_json(indicator)
metrics_list = set(indicator.metrics
.filter(name__in... | [
"def",
"indicator_details",
"(",
"indicator",
")",
":",
"metrics",
"=",
"format_metrics_json",
"(",
"indicator",
")",
"metrics_list",
"=",
"set",
"(",
"indicator",
".",
"metrics",
".",
"filter",
"(",
"name__in",
"=",
"metrics_name_map",
".",
"keys",
"(",
")",
... | Return a dictionary with all metrics in FinancialIndicator,
if there aren't values for that Indicator, it is filled with default values | [
"Return",
"a",
"dictionary",
"with",
"all",
"metrics",
"in",
"FinancialIndicator",
"if",
"there",
"aren",
"t",
"values",
"for",
"that",
"Indicator",
"it",
"is",
"filled",
"with",
"default",
"values"
] | python | train |
f3at/feat | src/feat/database/couchdb/view.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/database/couchdb/view.py#L262-L305 | def main():
"""Command-line entry point for running the view server."""
import getopt
from . import __version__ as VERSION
try:
option_list, argument_list = getopt.gnu_getopt(
sys.argv[1:], 'h',
['version', 'help', 'json-module=', 'debug', 'log-file='])
message ... | [
"def",
"main",
"(",
")",
":",
"import",
"getopt",
"from",
".",
"import",
"__version__",
"as",
"VERSION",
"try",
":",
"option_list",
",",
"argument_list",
"=",
"getopt",
".",
"gnu_getopt",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
",",
"'h'",
",",
... | Command-line entry point for running the view server. | [
"Command",
"-",
"line",
"entry",
"point",
"for",
"running",
"the",
"view",
"server",
"."
] | python | train |
zhmcclient/python-zhmcclient | zhmcclient/_storage_volume.py | https://github.com/zhmcclient/python-zhmcclient/blob/9657563e5d9184c51d3c903442a58b9725fdf335/zhmcclient/_storage_volume.py#L411-L493 | def update_properties(self, properties, email_to_addresses=None,
email_cc_addresses=None, email_insert=None):
"""
Update writeable properties of this storage volume on the HMC, and
optionally send emails to storage administrators requesting
modification of the s... | [
"def",
"update_properties",
"(",
"self",
",",
"properties",
",",
"email_to_addresses",
"=",
"None",
",",
"email_cc_addresses",
"=",
"None",
",",
"email_insert",
"=",
"None",
")",
":",
"volreq_obj",
"=",
"copy",
".",
"deepcopy",
"(",
"properties",
")",
"volreq_... | Update writeable properties of this storage volume on the HMC, and
optionally send emails to storage administrators requesting
modification of the storage volume on the storage subsystem and of any
resources related to the storage volume.
This method performs the "Modify Storage Group P... | [
"Update",
"writeable",
"properties",
"of",
"this",
"storage",
"volume",
"on",
"the",
"HMC",
"and",
"optionally",
"send",
"emails",
"to",
"storage",
"administrators",
"requesting",
"modification",
"of",
"the",
"storage",
"volume",
"on",
"the",
"storage",
"subsystem... | python | train |
cloudera/cm_api | python/src/cm_api/endpoints/hosts.py | https://github.com/cloudera/cm_api/blob/5d2512375bd94684b4da36df9e0d9177865ffcbb/python/src/cm_api/endpoints/hosts.py#L25-L36 | def create_host(resource_root, host_id, name, ipaddr, rack_id=None):
"""
Create a host
@param resource_root: The root Resource object.
@param host_id: Host id
@param name: Host name
@param ipaddr: IP address
@param rack_id: Rack id. Default None
@return: An ApiHost object
"""
apihost = ApiHost(resou... | [
"def",
"create_host",
"(",
"resource_root",
",",
"host_id",
",",
"name",
",",
"ipaddr",
",",
"rack_id",
"=",
"None",
")",
":",
"apihost",
"=",
"ApiHost",
"(",
"resource_root",
",",
"host_id",
",",
"name",
",",
"ipaddr",
",",
"rack_id",
")",
"return",
"ca... | Create a host
@param resource_root: The root Resource object.
@param host_id: Host id
@param name: Host name
@param ipaddr: IP address
@param rack_id: Rack id. Default None
@return: An ApiHost object | [
"Create",
"a",
"host"
] | python | train |
SoCo/SoCo | soco/core.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/core.py#L354-L364 | def is_bridge(self):
"""bool: Is this zone a bridge?"""
# Since this does not change over time (?) check whether we already
# know the answer. If so, there is no need to go further
if self._is_bridge is not None:
return self._is_bridge
# if not, we have to get it from... | [
"def",
"is_bridge",
"(",
"self",
")",
":",
"# Since this does not change over time (?) check whether we already",
"# know the answer. If so, there is no need to go further",
"if",
"self",
".",
"_is_bridge",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_is_bridge",
"# if ... | bool: Is this zone a bridge? | [
"bool",
":",
"Is",
"this",
"zone",
"a",
"bridge?"
] | python | train |
ioos/cc-plugin-ncei | cc_plugin_ncei/ncei_timeseries_profile.py | https://github.com/ioos/cc-plugin-ncei/blob/963fefd7fa43afd32657ac4c36aad4ddb4c25acf/cc_plugin_ncei/ncei_timeseries_profile.py#L21-L43 | def check_dimensions(self, dataset):
'''
Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.
:param netCDF4.Dataset dataset: An open netCDF dataset
'''
results = []
required_ctx = TestCtx(BaseCheck.HIGH, 'All geophys... | [
"def",
"check_dimensions",
"(",
"self",
",",
"dataset",
")",
":",
"results",
"=",
"[",
"]",
"required_ctx",
"=",
"TestCtx",
"(",
"BaseCheck",
".",
"HIGH",
",",
"'All geophysical variables are timeseries-profile-orthogonal feature types'",
")",
"message",
"=",
"'{} mus... | Checks that the feature types of this dataset are consistent with a timeseries-profile-orthogonal dataset.
:param netCDF4.Dataset dataset: An open netCDF dataset | [
"Checks",
"that",
"the",
"feature",
"types",
"of",
"this",
"dataset",
"are",
"consistent",
"with",
"a",
"timeseries",
"-",
"profile",
"-",
"orthogonal",
"dataset",
"."
] | python | train |
openid/python-openid | openid/yadis/etxrd.py | https://github.com/openid/python-openid/blob/f7e13536f0d1828d3cef5ae7a7b55cabadff37fc/openid/yadis/etxrd.py#L119-L133 | def getYadisXRD(xrd_tree):
"""Return the XRD element that should contain the Yadis services"""
xrd = None
# for the side-effect of assigning the last one in the list to the
# xrd variable
for xrd in xrd_tree.findall(xrd_tag):
pass
# There were no elements found, or else xrd would be se... | [
"def",
"getYadisXRD",
"(",
"xrd_tree",
")",
":",
"xrd",
"=",
"None",
"# for the side-effect of assigning the last one in the list to the",
"# xrd variable",
"for",
"xrd",
"in",
"xrd_tree",
".",
"findall",
"(",
"xrd_tag",
")",
":",
"pass",
"# There were no elements found, ... | Return the XRD element that should contain the Yadis services | [
"Return",
"the",
"XRD",
"element",
"that",
"should",
"contain",
"the",
"Yadis",
"services"
] | python | train |
numenta/nupic | src/nupic/frameworks/opf/htm_prediction_model.py | https://github.com/numenta/nupic/blob/5922fafffdccc8812e72b3324965ad2f7d4bbdad/src/nupic/frameworks/opf/htm_prediction_model.py#L712-L957 | def _handleSDRClassifierMultiStep(self, patternNZ,
inputTSRecordIdx,
rawInput):
""" Handle the CLA Classifier compute logic when implementing multi-step
prediction. This is where the patternNZ is associated with one of the
other fields ... | [
"def",
"_handleSDRClassifierMultiStep",
"(",
"self",
",",
"patternNZ",
",",
"inputTSRecordIdx",
",",
"rawInput",
")",
":",
"inferenceArgs",
"=",
"self",
".",
"getInferenceArgs",
"(",
")",
"predictedFieldName",
"=",
"inferenceArgs",
".",
"get",
"(",
"'predictedField'... | Handle the CLA Classifier compute logic when implementing multi-step
prediction. This is where the patternNZ is associated with one of the
other fields from the dataset 0 to N steps in the future. This method is
used by each type of network (encoder only, SP only, SP +TM) to handle the
compute logic thr... | [
"Handle",
"the",
"CLA",
"Classifier",
"compute",
"logic",
"when",
"implementing",
"multi",
"-",
"step",
"prediction",
".",
"This",
"is",
"where",
"the",
"patternNZ",
"is",
"associated",
"with",
"one",
"of",
"the",
"other",
"fields",
"from",
"the",
"dataset",
... | python | valid |
pandas-dev/pandas | pandas/core/indexes/range.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/indexes/range.py#L355-L369 | def equals(self, other):
"""
Determines if two Index objects contain the same elements.
"""
if isinstance(other, RangeIndex):
ls = len(self)
lo = len(other)
return (ls == lo == 0 or
ls == lo == 1 and
self._start ... | [
"def",
"equals",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"RangeIndex",
")",
":",
"ls",
"=",
"len",
"(",
"self",
")",
"lo",
"=",
"len",
"(",
"other",
")",
"return",
"(",
"ls",
"==",
"lo",
"==",
"0",
"or",
"ls"... | Determines if two Index objects contain the same elements. | [
"Determines",
"if",
"two",
"Index",
"objects",
"contain",
"the",
"same",
"elements",
"."
] | python | train |
CitrineInformatics/python-citrination-client | citrination_client/models/client.py | https://github.com/CitrineInformatics/python-citrination-client/blob/409984fc65ce101a620f069263f155303492465c/citrination_client/models/client.py#L144-L168 | def submit_predict_request(self, data_view_id, candidates, prediction_source='scalar', use_prior=True):
"""
Submits an async prediction request.
:param data_view_id: The id returned from create
:param candidates: Array of candidates
:param prediction_source: 'scalar' or 'scalar_... | [
"def",
"submit_predict_request",
"(",
"self",
",",
"data_view_id",
",",
"candidates",
",",
"prediction_source",
"=",
"'scalar'",
",",
"use_prior",
"=",
"True",
")",
":",
"data",
"=",
"{",
"\"prediction_source\"",
":",
"prediction_source",
",",
"\"use_prior\"",
":"... | Submits an async prediction request.
:param data_view_id: The id returned from create
:param candidates: Array of candidates
:param prediction_source: 'scalar' or 'scalar_from_distribution'
:param use_prior: True to use prior prediction, otherwise False
:return: Predict request ... | [
"Submits",
"an",
"async",
"prediction",
"request",
"."
] | python | valid |
linkedin/Zopkio | zopkio/deployer.py | https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L224-L230 | def hangup(self, unique_id, configs=None):
"""
Issue a signal to hangup the specified process
:Parameter unique_id: the name of the process
"""
self._send_signal(unique_id, signal.SIGHUP, configs) | [
"def",
"hangup",
"(",
"self",
",",
"unique_id",
",",
"configs",
"=",
"None",
")",
":",
"self",
".",
"_send_signal",
"(",
"unique_id",
",",
"signal",
".",
"SIGHUP",
",",
"configs",
")"
] | Issue a signal to hangup the specified process
:Parameter unique_id: the name of the process | [
"Issue",
"a",
"signal",
"to",
"hangup",
"the",
"specified",
"process"
] | python | train |
aliyun/aliyun-odps-python-sdk | odps/df/expr/merge.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/df/expr/merge.py#L990-L1045 | def setdiff(left, *rights, **kwargs):
"""
Exclude data from a collection, like `except` clause in SQL. All collections involved should
have same schema.
:param left: collection to drop data from
:param rights: collection or list of collections
:param distinct: whether to preserve duplicate entr... | [
"def",
"setdiff",
"(",
"left",
",",
"*",
"rights",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"time",
"from",
".",
".",
"utils",
"import",
"output",
"distinct",
"=",
"kwargs",
".",
"get",
"(",
"'distinct'",
",",
"False",
")",
"if",
"isinstance",
"(... | Exclude data from a collection, like `except` clause in SQL. All collections involved should
have same schema.
:param left: collection to drop data from
:param rights: collection or list of collections
:param distinct: whether to preserve duplicate entries
:return: collection
:Examples:
>>... | [
"Exclude",
"data",
"from",
"a",
"collection",
"like",
"except",
"clause",
"in",
"SQL",
".",
"All",
"collections",
"involved",
"should",
"have",
"same",
"schema",
"."
] | python | train |
viniciuschiele/flask-io | flask_io/mimetypes.py | https://github.com/viniciuschiele/flask-io/blob/4e559419b3d8e6859f83fa16557b00542d5f3aa7/flask_io/mimetypes.py#L81-L98 | def replace(self, main_type=None, sub_type=None, params=None):
"""
Return a new MimeType with new values for the specified fields.
:param str main_type: The new main type.
:param str sub_type: The new sub type.
:param dict params: The new parameters.
:return: A new instan... | [
"def",
"replace",
"(",
"self",
",",
"main_type",
"=",
"None",
",",
"sub_type",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"main_type",
"is",
"None",
":",
"main_type",
"=",
"self",
".",
"main_type",
"if",
"sub_type",
"is",
"None",
":",
"... | Return a new MimeType with new values for the specified fields.
:param str main_type: The new main type.
:param str sub_type: The new sub type.
:param dict params: The new parameters.
:return: A new instance of MimeType | [
"Return",
"a",
"new",
"MimeType",
"with",
"new",
"values",
"for",
"the",
"specified",
"fields",
".",
":",
"param",
"str",
"main_type",
":",
"The",
"new",
"main",
"type",
".",
":",
"param",
"str",
"sub_type",
":",
"The",
"new",
"sub",
"type",
".",
":",
... | python | train |
jldantas/libmft | libmft/attribute.py | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L695-L715 | def _astimezone_ts(self, timezone):
"""Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise return... | [
"def",
"_astimezone_ts",
"(",
"self",
",",
"timezone",
")",
":",
"if",
"self",
".",
"created",
".",
"tzinfo",
"is",
"timezone",
":",
"return",
"self",
"else",
":",
"nw_obj",
"=",
"Timestamps",
"(",
"(",
"None",
",",
")",
"*",
"4",
")",
"nw_obj",
".",... | Changes the time zones of all timestamps.
Receives a new timezone and applies to all timestamps, if necessary.
Args:
timezone (:obj:`tzinfo`): Time zone to be applied
Returns:
A new ``Timestamps`` object if the time zone changes, otherwise returns ``self``. | [
"Changes",
"the",
"time",
"zones",
"of",
"all",
"timestamps",
"."
] | python | train |
OpenKMIP/PyKMIP | kmip/pie/sqltypes.py | https://github.com/OpenKMIP/PyKMIP/blob/b51c5b044bd05f8c85a1d65d13a583a4d8fc1b0e/kmip/pie/sqltypes.py#L61-L76 | def process_result_value(self, value, dialect):
"""
Returns a new list of enums.CryptographicUsageMask Enums. This converts
the integer value into the list of enums.
Args:
value(int): The integer value stored in the database that is used
to create the list of... | [
"def",
"process_result_value",
"(",
"self",
",",
"value",
",",
"dialect",
")",
":",
"masks",
"=",
"list",
"(",
")",
"if",
"value",
":",
"for",
"e",
"in",
"enums",
".",
"CryptographicUsageMask",
":",
"if",
"e",
".",
"value",
"&",
"value",
":",
"masks",
... | Returns a new list of enums.CryptographicUsageMask Enums. This converts
the integer value into the list of enums.
Args:
value(int): The integer value stored in the database that is used
to create the list of enums.CryptographicUsageMask Enums.
dialect(string): SQ... | [
"Returns",
"a",
"new",
"list",
"of",
"enums",
".",
"CryptographicUsageMask",
"Enums",
".",
"This",
"converts",
"the",
"integer",
"value",
"into",
"the",
"list",
"of",
"enums",
"."
] | python | test |
Blueqat/Blueqat | blueqat/pauli.py | https://github.com/Blueqat/Blueqat/blob/2ac8592c79e7acf4f385d982af82fbd68dafa5cc/blueqat/pauli.py#L555-L557 | def from_terms_dict(terms_dict):
"""For internal use."""
return Expr(tuple(Term(k, v) for k, v in terms_dict.items() if v)) | [
"def",
"from_terms_dict",
"(",
"terms_dict",
")",
":",
"return",
"Expr",
"(",
"tuple",
"(",
"Term",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"terms_dict",
".",
"items",
"(",
")",
"if",
"v",
")",
")"
] | For internal use. | [
"For",
"internal",
"use",
"."
] | python | train |
ArchiveTeam/wpull | wpull/network/connection.py | https://github.com/ArchiveTeam/wpull/blob/ddf051aa3322479325ba20aa778cb2cb97606bf5/wpull/network/connection.py#L476-L500 | def _verify_cert(self, sock: ssl.SSLSocket):
'''Check if certificate matches hostname.'''
# Based on tornado.iostream.SSLIOStream
# Needed for older OpenSSL (<0.9.8f) versions
verify_mode = self._ssl_context.verify_mode
assert verify_mode in (ssl.CERT_NONE, ssl.CERT_REQUIRED,
... | [
"def",
"_verify_cert",
"(",
"self",
",",
"sock",
":",
"ssl",
".",
"SSLSocket",
")",
":",
"# Based on tornado.iostream.SSLIOStream",
"# Needed for older OpenSSL (<0.9.8f) versions",
"verify_mode",
"=",
"self",
".",
"_ssl_context",
".",
"verify_mode",
"assert",
"verify_mode... | Check if certificate matches hostname. | [
"Check",
"if",
"certificate",
"matches",
"hostname",
"."
] | python | train |
tasdikrahman/vocabulary | vocabulary/responselib.py | https://github.com/tasdikrahman/vocabulary/blob/54403c5981af25dc3457796b57048ae27f09e9be/vocabulary/responselib.py#L88-L105 | def respond(self, data, format='json'):
"""
Converts a json object to a python datastructure based on
specified format
:param data: the json object
:param format: python datastructure type. Defaults to: "json"
:returns: a python specified object
"""
dispa... | [
"def",
"respond",
"(",
"self",
",",
"data",
",",
"format",
"=",
"'json'",
")",
":",
"dispatchers",
"=",
"{",
"\"dict\"",
":",
"self",
".",
"__respond_with_dict",
",",
"\"list\"",
":",
"self",
".",
"__respond_with_list",
"}",
"if",
"not",
"dispatchers",
"."... | Converts a json object to a python datastructure based on
specified format
:param data: the json object
:param format: python datastructure type. Defaults to: "json"
:returns: a python specified object | [
"Converts",
"a",
"json",
"object",
"to",
"a",
"python",
"datastructure",
"based",
"on",
"specified",
"format"
] | python | train |
secdev/scapy | scapy/packet.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/packet.py#L496-L521 | def self_build(self, field_pos_list=None):
"""
Create the default layer regarding fields_desc dict
:param field_pos_list:
"""
if self.raw_packet_cache is not None:
for fname, fval in six.iteritems(self.raw_packet_cache_fields):
if self.getfieldval(fna... | [
"def",
"self_build",
"(",
"self",
",",
"field_pos_list",
"=",
"None",
")",
":",
"if",
"self",
".",
"raw_packet_cache",
"is",
"not",
"None",
":",
"for",
"fname",
",",
"fval",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"raw_packet_cache_fields",
")",
... | Create the default layer regarding fields_desc dict
:param field_pos_list: | [
"Create",
"the",
"default",
"layer",
"regarding",
"fields_desc",
"dict"
] | python | train |
nkgilley/python-ecobee-api | pyecobee/__init__.py | https://github.com/nkgilley/python-ecobee-api/blob/cc8d90d20abcb9ef5b66ec9cb035bae2f06ba174/pyecobee/__init__.py#L12-L32 | def config_from_file(filename, config=None):
''' Small configuration file management function'''
if config:
# We're writing configuration
try:
with open(filename, 'w') as fdesc:
fdesc.write(json.dumps(config))
except IOError as error:
logger.except... | [
"def",
"config_from_file",
"(",
"filename",
",",
"config",
"=",
"None",
")",
":",
"if",
"config",
":",
"# We're writing configuration",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"fdesc",
":",
"fdesc",
".",
"write",
"(",
"json",
... | Small configuration file management function | [
"Small",
"configuration",
"file",
"management",
"function"
] | python | test |
saltstack/salt | salt/modules/zpool.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/zpool.py#L1438-L1467 | def labelclear(device, force=False):
'''
.. versionadded:: 2018.3.0
Removes ZFS label information from the specified device
device : string
Device name; must not be part of an active pool configuration.
force : boolean
Treat exported or foreign devices as inactive
CLI Example... | [
"def",
"labelclear",
"(",
"device",
",",
"force",
"=",
"False",
")",
":",
"## clear label for all specified device",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"__utils__",
"[",
"'zfs.zpool_command'",
"]",
"(",
"command",
"=",
"'labelclear'",
",",
"... | .. versionadded:: 2018.3.0
Removes ZFS label information from the specified device
device : string
Device name; must not be part of an active pool configuration.
force : boolean
Treat exported or foreign devices as inactive
CLI Example:
.. code-block:: bash
salt '*' zpo... | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | python | train |
scanny/python-pptx | pptx/chart/data.py | https://github.com/scanny/python-pptx/blob/d6ab8234f8b03953d2f831ff9394b1852db34130/pptx/chart/data.py#L187-L197 | def number_format(self):
"""
The formatting template string that determines how a number in this
series is formatted, both in the chart and in the Excel spreadsheet;
for example '#,##0.0'. If not specified for this series, it is
inherited from the parent chart data object.
... | [
"def",
"number_format",
"(",
"self",
")",
":",
"number_format",
"=",
"self",
".",
"_number_format",
"if",
"number_format",
"is",
"None",
":",
"return",
"self",
".",
"_chart_data",
".",
"number_format",
"return",
"number_format"
] | The formatting template string that determines how a number in this
series is formatted, both in the chart and in the Excel spreadsheet;
for example '#,##0.0'. If not specified for this series, it is
inherited from the parent chart data object. | [
"The",
"formatting",
"template",
"string",
"that",
"determines",
"how",
"a",
"number",
"in",
"this",
"series",
"is",
"formatted",
"both",
"in",
"the",
"chart",
"and",
"in",
"the",
"Excel",
"spreadsheet",
";",
"for",
"example",
"#",
"##0",
".",
"0",
".",
... | python | train |
ewels/MultiQC | multiqc/modules/mirtrace/mirtrace.py | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/mirtrace/mirtrace.py#L218-L237 | def mirtrace_qc_plot(self):
""" Generate the miRTrace QC Plot"""
# Specify the order of the different possible categories
keys = OrderedDict()
keys['adapter_removed_length_ok'] = { 'color': '#006837', 'name': 'Reads ≥ 18 nt after adapter removal' }
keys['adapter_not_detected... | [
"def",
"mirtrace_qc_plot",
"(",
"self",
")",
":",
"# Specify the order of the different possible categories",
"keys",
"=",
"OrderedDict",
"(",
")",
"keys",
"[",
"'adapter_removed_length_ok'",
"]",
"=",
"{",
"'color'",
":",
"'#006837'",
",",
"'name'",
":",
"'Reads ≥ 18... | Generate the miRTrace QC Plot | [
"Generate",
"the",
"miRTrace",
"QC",
"Plot"
] | python | train |
manolomartinez/greg | greg/classes.py | https://github.com/manolomartinez/greg/blob/63bb24197c13087a01963ac439cd8380007d9467/greg/classes.py#L276-L345 | def download_entry(self, entry):
"""
Find entry link and download entry
"""
downloadlinks = {}
downloaded = False
ignoreenclosures = self.retrieve_config('ignoreenclosures', 'no')
notype = self.retrieve_config('notype', 'no')
if ignoreenclosures == 'no':
... | [
"def",
"download_entry",
"(",
"self",
",",
"entry",
")",
":",
"downloadlinks",
"=",
"{",
"}",
"downloaded",
"=",
"False",
"ignoreenclosures",
"=",
"self",
".",
"retrieve_config",
"(",
"'ignoreenclosures'",
",",
"'no'",
")",
"notype",
"=",
"self",
".",
"retri... | Find entry link and download entry | [
"Find",
"entry",
"link",
"and",
"download",
"entry"
] | python | train |
btr1975/persistentdatatools | persistentdatatools/persistentdatatools.py | https://github.com/btr1975/persistentdatatools/blob/39e1294ce34a0a34363c65d94cdd592be5ad791b/persistentdatatools/persistentdatatools.py#L392-L405 | def list_files_in_directory(full_directory_path):
"""
List the files in a specified directory
Args:
full_directory_path: The full directory path to check, derive from the os module
Returns: returns a list of files
"""
files = list()
for file_name in __os.listdir(full_directory_path... | [
"def",
"list_files_in_directory",
"(",
"full_directory_path",
")",
":",
"files",
"=",
"list",
"(",
")",
"for",
"file_name",
"in",
"__os",
".",
"listdir",
"(",
"full_directory_path",
")",
":",
"if",
"__os",
".",
"path",
".",
"isfile",
"(",
"__os",
".",
"pat... | List the files in a specified directory
Args:
full_directory_path: The full directory path to check, derive from the os module
Returns: returns a list of files | [
"List",
"the",
"files",
"in",
"a",
"specified",
"directory",
"Args",
":",
"full_directory_path",
":",
"The",
"full",
"directory",
"path",
"to",
"check",
"derive",
"from",
"the",
"os",
"module"
] | python | train |
SeattleTestbed/seash | pyreadline/lineeditor/lineobj.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/lineeditor/lineobj.py#L726-L736 | def copy_selection_to_clipboard(self): # ()
u'''Copy the text in the region to the windows clipboard.'''
if self.enable_win32_clipboard and self.enable_selection and self.selection_mark >= 0:
selection_mark = min(self.selection_mark,len(self.line_buffer))
cursor = min... | [
"def",
"copy_selection_to_clipboard",
"(",
"self",
")",
":",
"# ()\r",
"if",
"self",
".",
"enable_win32_clipboard",
"and",
"self",
".",
"enable_selection",
"and",
"self",
".",
"selection_mark",
">=",
"0",
":",
"selection_mark",
"=",
"min",
"(",
"self",
".",
"s... | u'''Copy the text in the region to the windows clipboard. | [
"u",
"Copy",
"the",
"text",
"in",
"the",
"region",
"to",
"the",
"windows",
"clipboard",
"."
] | python | train |
Duke-GCB/DukeDSClient | ddsc/core/parallel.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/core/parallel.py#L247-L263 | def get_finished_results(self):
"""
Go through pending results and retrieve the results if they are done.
Then start child tasks for the task that finished.
"""
task_and_results = []
for pending_result in self.pending_results:
if pending_result.ready():
... | [
"def",
"get_finished_results",
"(",
"self",
")",
":",
"task_and_results",
"=",
"[",
"]",
"for",
"pending_result",
"in",
"self",
".",
"pending_results",
":",
"if",
"pending_result",
".",
"ready",
"(",
")",
":",
"ret",
"=",
"pending_result",
".",
"get",
"(",
... | Go through pending results and retrieve the results if they are done.
Then start child tasks for the task that finished. | [
"Go",
"through",
"pending",
"results",
"and",
"retrieve",
"the",
"results",
"if",
"they",
"are",
"done",
".",
"Then",
"start",
"child",
"tasks",
"for",
"the",
"task",
"that",
"finished",
"."
] | python | train |
benoitkugler/abstractDataLibrary | pyDLib/Core/data_model.py | https://github.com/benoitkugler/abstractDataLibrary/blob/16be28e99837e40287a63803bbfdf67ac1806b7b/pyDLib/Core/data_model.py#L57-L62 | def modifie(self, key: str, value: Any) -> None:
"""Store the modification. `value` should be dumped in DB compatible format."""
if key in self.FIELDS_OPTIONS:
self.modifie_options(key, value)
else:
self.modifications[key] = value | [
"def",
"modifie",
"(",
"self",
",",
"key",
":",
"str",
",",
"value",
":",
"Any",
")",
"->",
"None",
":",
"if",
"key",
"in",
"self",
".",
"FIELDS_OPTIONS",
":",
"self",
".",
"modifie_options",
"(",
"key",
",",
"value",
")",
"else",
":",
"self",
".",... | Store the modification. `value` should be dumped in DB compatible format. | [
"Store",
"the",
"modification",
".",
"value",
"should",
"be",
"dumped",
"in",
"DB",
"compatible",
"format",
"."
] | python | train |
mabuchilab/QNET | src/qnet/utils/indices.py | https://github.com/mabuchilab/QNET/blob/cc20d26dad78691d34c67173e5cd67dcac94208a/src/qnet/utils/indices.py#L152-L156 | def incr_primed(self, incr=1):
"""Return a copy of the index with an incremented :attr:`primed`"""
return self.__class__(
self.name, primed=self._primed + incr,
**self._assumptions.generator) | [
"def",
"incr_primed",
"(",
"self",
",",
"incr",
"=",
"1",
")",
":",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"name",
",",
"primed",
"=",
"self",
".",
"_primed",
"+",
"incr",
",",
"*",
"*",
"self",
".",
"_assumptions",
".",
"generator",
... | Return a copy of the index with an incremented :attr:`primed` | [
"Return",
"a",
"copy",
"of",
"the",
"index",
"with",
"an",
"incremented",
":",
"attr",
":",
"primed"
] | python | train |
aio-libs/aioredis | aioredis/commands/list.py | https://github.com/aio-libs/aioredis/blob/e8c33e39558d4cc91cf70dde490d8b330c97dc2e/aioredis/commands/list.py#L38-L50 | def brpoplpush(self, sourcekey, destkey, timeout=0, encoding=_NOTSET):
"""Remove and get the last element in a list, or block until one
is available.
:raises TypeError: if timeout is not int
:raises ValueError: if timeout is less than 0
"""
if not isinstance(timeout, int... | [
"def",
"brpoplpush",
"(",
"self",
",",
"sourcekey",
",",
"destkey",
",",
"timeout",
"=",
"0",
",",
"encoding",
"=",
"_NOTSET",
")",
":",
"if",
"not",
"isinstance",
"(",
"timeout",
",",
"int",
")",
":",
"raise",
"TypeError",
"(",
"\"timeout argument must be... | Remove and get the last element in a list, or block until one
is available.
:raises TypeError: if timeout is not int
:raises ValueError: if timeout is less than 0 | [
"Remove",
"and",
"get",
"the",
"last",
"element",
"in",
"a",
"list",
"or",
"block",
"until",
"one",
"is",
"available",
"."
] | python | train |
quantmind/pulsar | pulsar/utils/pylib/redisparser.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/utils/pylib/redisparser.py#L86-L91 | def get(self):
'''Called by the protocol consumer'''
if self._current:
return self._resume(self._current, False)
else:
return self._get(None) | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"_current",
":",
"return",
"self",
".",
"_resume",
"(",
"self",
".",
"_current",
",",
"False",
")",
"else",
":",
"return",
"self",
".",
"_get",
"(",
"None",
")"
] | Called by the protocol consumer | [
"Called",
"by",
"the",
"protocol",
"consumer"
] | python | train |
spyder-ide/spyder | spyder/app/mainwindow.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/app/mainwindow.py#L2301-L2309 | def change_last_focused_widget(self, old, now):
"""To keep track of to the last focused widget"""
if (now is None and QApplication.activeWindow() is not None):
QApplication.activeWindow().setFocus()
self.last_focused_widget = QApplication.focusWidget()
elif now is no... | [
"def",
"change_last_focused_widget",
"(",
"self",
",",
"old",
",",
"now",
")",
":",
"if",
"(",
"now",
"is",
"None",
"and",
"QApplication",
".",
"activeWindow",
"(",
")",
"is",
"not",
"None",
")",
":",
"QApplication",
".",
"activeWindow",
"(",
")",
".",
... | To keep track of to the last focused widget | [
"To",
"keep",
"track",
"of",
"to",
"the",
"last",
"focused",
"widget"
] | python | train |
troeger/opensubmit | executor/opensubmitexec/job.py | https://github.com/troeger/opensubmit/blob/384a95b7c6fa41e3f949a129d25dafd9a1c54859/executor/opensubmitexec/job.py#L176-L196 | def run_program(self, name, arguments=[], timeout=30, exclusive=False):
"""Runs a program in the working directory to completion.
Args:
name (str): The name of the program to be executed.
arguments (tuple): Command-line arguments for the program.
timeout (int)... | [
"def",
"run_program",
"(",
"self",
",",
"name",
",",
"arguments",
"=",
"[",
"]",
",",
"timeout",
"=",
"30",
",",
"exclusive",
"=",
"False",
")",
":",
"logger",
".",
"debug",
"(",
"\"Running program ...\"",
")",
"if",
"exclusive",
":",
"kill_longrunning",
... | Runs a program in the working directory to completion.
Args:
name (str): The name of the program to be executed.
arguments (tuple): Command-line arguments for the program.
timeout (int): The timeout for execution.
exclusive (bool): Prevent parallel va... | [
"Runs",
"a",
"program",
"in",
"the",
"working",
"directory",
"to",
"completion",
"."
] | python | train |
tijme/not-your-average-web-crawler | nyawc/Crawler.py | https://github.com/tijme/not-your-average-web-crawler/blob/d77c14e1616c541bb3980f649a7e6f8ed02761fb/nyawc/Crawler.py#L122-L143 | def __spawn_new_request(self):
"""Spawn the first queued request if there is one available.
Returns:
bool: True if a new request was spawned, false otherwise.
"""
first_in_line = self.queue.get_first(QueueItem.STATUS_QUEUED)
if first_in_line is None:
... | [
"def",
"__spawn_new_request",
"(",
"self",
")",
":",
"first_in_line",
"=",
"self",
".",
"queue",
".",
"get_first",
"(",
"QueueItem",
".",
"STATUS_QUEUED",
")",
"if",
"first_in_line",
"is",
"None",
":",
"return",
"False",
"while",
"self",
".",
"routing",
".",... | Spawn the first queued request if there is one available.
Returns:
bool: True if a new request was spawned, false otherwise. | [
"Spawn",
"the",
"first",
"queued",
"request",
"if",
"there",
"is",
"one",
"available",
"."
] | python | train |
Jaymon/captain | captain/__init__.py | https://github.com/Jaymon/captain/blob/4297f32961d423a10d0f053bc252e29fbe939a47/captain/__init__.py#L79-L116 | def exit(mod_name=""):
"""A stand-in for the normal sys.exit()
all the magic happens here, when this is called at the end of a script it will
figure out all the available commands and arguments that can be passed in,
then handle exiting the script and returning the status code.
:Example:
... | [
"def",
"exit",
"(",
"mod_name",
"=",
"\"\"",
")",
":",
"if",
"mod_name",
"and",
"mod_name",
"==",
"\"__main__\"",
":",
"calling_mod",
"=",
"sys",
".",
"modules",
".",
"get",
"(",
"\"__main__\"",
",",
"None",
")",
"else",
":",
"calling_mod",
"=",
"discove... | A stand-in for the normal sys.exit()
all the magic happens here, when this is called at the end of a script it will
figure out all the available commands and arguments that can be passed in,
then handle exiting the script and returning the status code.
:Example:
from captain import exit
... | [
"A",
"stand",
"-",
"in",
"for",
"the",
"normal",
"sys",
".",
"exit",
"()"
] | python | valid |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/bson/__init__.py | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/bson/__init__.py#L352-L360 | def _elements_to_dict(data, position, obj_end, opts):
"""Decode a BSON document."""
result = opts.document_class()
pos = position
for key, value, pos in _iterate_elements(data, position, obj_end, opts):
result[key] = value
if pos != obj_end:
raise InvalidBSON('bad object or element l... | [
"def",
"_elements_to_dict",
"(",
"data",
",",
"position",
",",
"obj_end",
",",
"opts",
")",
":",
"result",
"=",
"opts",
".",
"document_class",
"(",
")",
"pos",
"=",
"position",
"for",
"key",
",",
"value",
",",
"pos",
"in",
"_iterate_elements",
"(",
"data... | Decode a BSON document. | [
"Decode",
"a",
"BSON",
"document",
"."
] | python | train |
aleontiev/dj | dj/generator.py | https://github.com/aleontiev/dj/blob/0612d442fdd8d472aea56466568b9857556ecb51/dj/generator.py#L44-L66 | def render(self):
"""Render the blueprint into a temp directory using the context."""
context = self.context
if 'app' not in context:
context['app'] = self.application.name
temp_dir = self.temp_dir
templates_root = self.blueprint.templates_directory
for root, ... | [
"def",
"render",
"(",
"self",
")",
":",
"context",
"=",
"self",
".",
"context",
"if",
"'app'",
"not",
"in",
"context",
":",
"context",
"[",
"'app'",
"]",
"=",
"self",
".",
"application",
".",
"name",
"temp_dir",
"=",
"self",
".",
"temp_dir",
"templates... | Render the blueprint into a temp directory using the context. | [
"Render",
"the",
"blueprint",
"into",
"a",
"temp",
"directory",
"using",
"the",
"context",
"."
] | python | train |
openai/universe | universe/remotes/allocator_remote.py | https://github.com/openai/universe/blob/cc9ce6ec241821bfb0f3b85dd455bd36e4ee7a8c/universe/remotes/allocator_remote.py#L166-L169 | def allocate(self, handles, initial=False, params={}):
"""Call from main thread. Initiate a request for more environments"""
assert all(re.search('^\d+$', h) for h in handles), "All handles must be numbers: {}".format(handles)
self.requests.put(('allocate', (handles, initial, params))) | [
"def",
"allocate",
"(",
"self",
",",
"handles",
",",
"initial",
"=",
"False",
",",
"params",
"=",
"{",
"}",
")",
":",
"assert",
"all",
"(",
"re",
".",
"search",
"(",
"'^\\d+$'",
",",
"h",
")",
"for",
"h",
"in",
"handles",
")",
",",
"\"All handles m... | Call from main thread. Initiate a request for more environments | [
"Call",
"from",
"main",
"thread",
".",
"Initiate",
"a",
"request",
"for",
"more",
"environments"
] | python | train |
nvbn/thefuck | thefuck/types.py | https://github.com/nvbn/thefuck/blob/40ab4eb62db57627bff10cf029d29c94704086a2/thefuck/types.py#L69-L83 | def from_raw_script(cls, raw_script):
"""Creates instance of `Command` from a list of script parts.
:type raw_script: [basestring]
:rtype: Command
:raises: EmptyCommand
"""
script = format_raw_script(raw_script)
if not script:
raise EmptyCommand
... | [
"def",
"from_raw_script",
"(",
"cls",
",",
"raw_script",
")",
":",
"script",
"=",
"format_raw_script",
"(",
"raw_script",
")",
"if",
"not",
"script",
":",
"raise",
"EmptyCommand",
"expanded",
"=",
"shell",
".",
"from_shell",
"(",
"script",
")",
"output",
"="... | Creates instance of `Command` from a list of script parts.
:type raw_script: [basestring]
:rtype: Command
:raises: EmptyCommand | [
"Creates",
"instance",
"of",
"Command",
"from",
"a",
"list",
"of",
"script",
"parts",
"."
] | python | train |
PyThaiNLP/pythainlp | pythainlp/util/date.py | https://github.com/PyThaiNLP/pythainlp/blob/e9a300b8a99dfd1a67a955e7c06f62e4afe0fbca/pythainlp/util/date.py#L281-L293 | def reign_year_to_ad(reign_year: int, reign: int) -> int:
"""
Reign year of Chakri dynasty, Thailand
"""
if int(reign) == 10:
ad = int(reign_year) + 2015
elif int(reign) == 9:
ad = int(reign_year) + 1945
elif int(reign) == 8:
ad = int(reign_year) + 1928
elif int(reign... | [
"def",
"reign_year_to_ad",
"(",
"reign_year",
":",
"int",
",",
"reign",
":",
"int",
")",
"->",
"int",
":",
"if",
"int",
"(",
"reign",
")",
"==",
"10",
":",
"ad",
"=",
"int",
"(",
"reign_year",
")",
"+",
"2015",
"elif",
"int",
"(",
"reign",
")",
"... | Reign year of Chakri dynasty, Thailand | [
"Reign",
"year",
"of",
"Chakri",
"dynasty",
"Thailand"
] | python | train |
PolicyStat/jobtastic | jobtastic/task.py | https://github.com/PolicyStat/jobtastic/blob/19cd3137ebf46877cee1ee5155d318bb6261ee1c/jobtastic/task.py#L405-L411 | def _get_cache(self):
"""
Return the cache to use for thundering herd protection, etc.
"""
if not self._cache:
self._cache = get_cache(self.app)
return self._cache | [
"def",
"_get_cache",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cache",
":",
"self",
".",
"_cache",
"=",
"get_cache",
"(",
"self",
".",
"app",
")",
"return",
"self",
".",
"_cache"
] | Return the cache to use for thundering herd protection, etc. | [
"Return",
"the",
"cache",
"to",
"use",
"for",
"thundering",
"herd",
"protection",
"etc",
"."
] | python | train |
python-bugzilla/python-bugzilla | bugzilla/base.py | https://github.com/python-bugzilla/python-bugzilla/blob/7de8b225104f24a1eee3e837bf1e02d60aefe69f/bugzilla/base.py#L565-L573 | def _login(self, user, password, restrict_login=None):
"""
Backend login method for Bugzilla3
"""
payload = {'login': user, 'password': password}
if restrict_login:
payload['restrict_login'] = True
return self._proxy.User.login(payload) | [
"def",
"_login",
"(",
"self",
",",
"user",
",",
"password",
",",
"restrict_login",
"=",
"None",
")",
":",
"payload",
"=",
"{",
"'login'",
":",
"user",
",",
"'password'",
":",
"password",
"}",
"if",
"restrict_login",
":",
"payload",
"[",
"'restrict_login'",... | Backend login method for Bugzilla3 | [
"Backend",
"login",
"method",
"for",
"Bugzilla3"
] | python | train |
nuSTORM/gnomon | gnomon/processors/Fitter.py | https://github.com/nuSTORM/gnomon/blob/7616486ecd6e26b76f677c380e62db1c0ade558a/gnomon/processors/Fitter.py#L175-L188 | def sort_points(self, points):
"""Take points (z,x,q) and sort by increasing z"""
new_points = []
z_lookup = {}
for z, x, Q in points:
z_lookup[z] = (z, x, Q)
z_keys = z_lookup.keys()
z_keys.sort()
for key in z_keys:
new_points.append(z_l... | [
"def",
"sort_points",
"(",
"self",
",",
"points",
")",
":",
"new_points",
"=",
"[",
"]",
"z_lookup",
"=",
"{",
"}",
"for",
"z",
",",
"x",
",",
"Q",
"in",
"points",
":",
"z_lookup",
"[",
"z",
"]",
"=",
"(",
"z",
",",
"x",
",",
"Q",
")",
"z_key... | Take points (z,x,q) and sort by increasing z | [
"Take",
"points",
"(",
"z",
"x",
"q",
")",
"and",
"sort",
"by",
"increasing",
"z"
] | python | train |
linkedin/asciietch | asciietch/graph.py | https://github.com/linkedin/asciietch/blob/33499e9b1c5226c04078d08a210ef657c630291c/asciietch/graph.py#L133-L192 | def asciigraph(self, values=None, max_height=None, max_width=None, label=False):
'''
Accepts a list of y values and returns an ascii graph
Optionally values can also be a dictionary with a key of timestamp, and a value of value. InGraphs returns data in this format for example.
'''
... | [
"def",
"asciigraph",
"(",
"self",
",",
"values",
"=",
"None",
",",
"max_height",
"=",
"None",
",",
"max_width",
"=",
"None",
",",
"label",
"=",
"False",
")",
":",
"result",
"=",
"''",
"border_fill_char",
"=",
"'*'",
"start_ctime",
"=",
"None",
"end_ctime... | Accepts a list of y values and returns an ascii graph
Optionally values can also be a dictionary with a key of timestamp, and a value of value. InGraphs returns data in this format for example. | [
"Accepts",
"a",
"list",
"of",
"y",
"values",
"and",
"returns",
"an",
"ascii",
"graph",
"Optionally",
"values",
"can",
"also",
"be",
"a",
"dictionary",
"with",
"a",
"key",
"of",
"timestamp",
"and",
"a",
"value",
"of",
"value",
".",
"InGraphs",
"returns",
... | python | train |
metapensiero/metapensiero.signal | src/metapensiero/signal/user.py | https://github.com/metapensiero/metapensiero.signal/blob/1cbbb2e4bff00bf4887163b08b70d278e472bfe3/src/metapensiero/signal/user.py#L145-L157 | def _check_local_handlers(cls, signals, handlers, namespace, configs):
"""For every marked handler, see if there is a suitable signal. If
not, raise an error."""
for aname, sig_name in handlers.items():
# WARN: this code doesn't take in account the case where a new
# meth... | [
"def",
"_check_local_handlers",
"(",
"cls",
",",
"signals",
",",
"handlers",
",",
"namespace",
",",
"configs",
")",
":",
"for",
"aname",
",",
"sig_name",
"in",
"handlers",
".",
"items",
"(",
")",
":",
"# WARN: this code doesn't take in account the case where a new",... | For every marked handler, see if there is a suitable signal. If
not, raise an error. | [
"For",
"every",
"marked",
"handler",
"see",
"if",
"there",
"is",
"a",
"suitable",
"signal",
".",
"If",
"not",
"raise",
"an",
"error",
"."
] | python | train |
facelessuser/backrefs | backrefs/_bre_parse.py | https://github.com/facelessuser/backrefs/blob/3b3d60f5d57b02044f880aa29c9c5add0e31a34f/backrefs/_bre_parse.py#L1078-L1092 | def get_group(self, t, i):
"""Get group number."""
try:
value = []
if t in _DIGIT and t != '0':
value.append(t)
t = next(i)
if t in _DIGIT:
value.append(t)
else:
i.rewind(1)
... | [
"def",
"get_group",
"(",
"self",
",",
"t",
",",
"i",
")",
":",
"try",
":",
"value",
"=",
"[",
"]",
"if",
"t",
"in",
"_DIGIT",
"and",
"t",
"!=",
"'0'",
":",
"value",
".",
"append",
"(",
"t",
")",
"t",
"=",
"next",
"(",
"i",
")",
"if",
"t",
... | Get group number. | [
"Get",
"group",
"number",
"."
] | python | train |
spulec/moto | scripts/scaffold.py | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/scripts/scaffold.py#L167-L216 | def initialize_service(service, operation, api_protocol):
"""create lib and test dirs if not exist
"""
lib_dir = get_lib_dir(service)
test_dir = get_test_dir(service)
print_progress('Initializing service', service, 'green')
client = boto3.client(service)
service_class = client.__class__.__... | [
"def",
"initialize_service",
"(",
"service",
",",
"operation",
",",
"api_protocol",
")",
":",
"lib_dir",
"=",
"get_lib_dir",
"(",
"service",
")",
"test_dir",
"=",
"get_test_dir",
"(",
"service",
")",
"print_progress",
"(",
"'Initializing service'",
",",
"service",... | create lib and test dirs if not exist | [
"create",
"lib",
"and",
"test",
"dirs",
"if",
"not",
"exist"
] | python | train |
nabla-c0d3/sslyze | sslyze/utils/http_response_parser.py | https://github.com/nabla-c0d3/sslyze/blob/0fb3ae668453d7ecf616d0755f237ca7be9f62fa/sslyze/utils/http_response_parser.py#L26-L37 | def _parse(read_method: Callable) -> HTTPResponse:
"""Trick to standardize the API between sockets and SSLConnection objects.
"""
response = read_method(4096)
while b'HTTP/' not in response or b'\r\n\r\n' not in response:
# Parse until the end of the headers
respo... | [
"def",
"_parse",
"(",
"read_method",
":",
"Callable",
")",
"->",
"HTTPResponse",
":",
"response",
"=",
"read_method",
"(",
"4096",
")",
"while",
"b'HTTP/'",
"not",
"in",
"response",
"or",
"b'\\r\\n\\r\\n'",
"not",
"in",
"response",
":",
"# Parse until the end of... | Trick to standardize the API between sockets and SSLConnection objects. | [
"Trick",
"to",
"standardize",
"the",
"API",
"between",
"sockets",
"and",
"SSLConnection",
"objects",
"."
] | python | train |
iotile/coretools | iotilesensorgraph/iotile/sg/sensor_log.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L382-L419 | def inspect_last(self, stream, only_allocated=False):
"""Return the last value pushed into a stream.
This function works even if the stream is virtual and no
virtual walker has been created for it. It is primarily
useful to aid in debugging sensor graphs.
Args:
str... | [
"def",
"inspect_last",
"(",
"self",
",",
"stream",
",",
"only_allocated",
"=",
"False",
")",
":",
"if",
"only_allocated",
":",
"found",
"=",
"False",
"for",
"walker",
"in",
"self",
".",
"_virtual_walkers",
":",
"if",
"walker",
".",
"matches",
"(",
"stream"... | Return the last value pushed into a stream.
This function works even if the stream is virtual and no
virtual walker has been created for it. It is primarily
useful to aid in debugging sensor graphs.
Args:
stream (DataStream): The stream to inspect.
only_allocat... | [
"Return",
"the",
"last",
"value",
"pushed",
"into",
"a",
"stream",
"."
] | python | train |
dossier/dossier.models | dossier/models/features/sip.py | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/features/sip.py#L27-L87 | def noun_phrases_as_tokens(text):
'''Generate a bag of lists of unnormalized tokens representing noun
phrases from ``text``.
This is built around python's nltk library for getting Noun
Phrases (NPs). This is all documented in the NLTK Book
http://www.nltk.org/book/ch03.html and blog posts that cite... | [
"def",
"noun_phrases_as_tokens",
"(",
"text",
")",
":",
"## from NLTK Book:",
"sentence_re",
"=",
"r'''(?x) # set flag to allow verbose regexps\n ([A-Z])(\\.[A-Z])+\\.? # abbreviations, e.g. U.S.A.\n | \\w+(-\\w+)* # words with optional internal hyphens\n | ... | Generate a bag of lists of unnormalized tokens representing noun
phrases from ``text``.
This is built around python's nltk library for getting Noun
Phrases (NPs). This is all documented in the NLTK Book
http://www.nltk.org/book/ch03.html and blog posts that cite the
book.
:rtype: list of lists... | [
"Generate",
"a",
"bag",
"of",
"lists",
"of",
"unnormalized",
"tokens",
"representing",
"noun",
"phrases",
"from",
"text",
"."
] | python | train |
andreikop/qutepart | qutepart/vim.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/vim.py#L116-L130 | def keyPressEvent(self, ev):
"""Check the event. Return True if processed and False otherwise
"""
if ev.key() in (Qt.Key_Shift, Qt.Key_Control,
Qt.Key_Meta, Qt.Key_Alt,
Qt.Key_AltGr, Qt.Key_CapsLock,
Qt.Key_NumLock, Qt.Key_S... | [
"def",
"keyPressEvent",
"(",
"self",
",",
"ev",
")",
":",
"if",
"ev",
".",
"key",
"(",
")",
"in",
"(",
"Qt",
".",
"Key_Shift",
",",
"Qt",
".",
"Key_Control",
",",
"Qt",
".",
"Key_Meta",
",",
"Qt",
".",
"Key_Alt",
",",
"Qt",
".",
"Key_AltGr",
",",... | Check the event. Return True if processed and False otherwise | [
"Check",
"the",
"event",
".",
"Return",
"True",
"if",
"processed",
"and",
"False",
"otherwise"
] | python | train |
KelSolaar/Manager | manager/components_manager.py | https://github.com/KelSolaar/Manager/blob/39c8153fc021fc8a76e345a6e336ec2644f089d1/manager/components_manager.py#L1322-L1342 | def get_interface(self, component):
"""
Gets given Component interface.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a... | [
"def",
"get_interface",
"(",
"self",
",",
"component",
")",
":",
"profile",
"=",
"self",
".",
"get_profile",
"(",
"component",
")",
"if",
"profile",
":",
"return",
"profile",
".",
"interface"
] | Gets given Component interface.
Usage::
>>> manager = Manager()
>>> manager.register_component("tests_component_a.rc")
True
>>> manager.get_interface("core.tests_component_a")
<tests_component_a.TestsComponentA object at 0x17b0d70>
:param co... | [
"Gets",
"given",
"Component",
"interface",
"."
] | python | train |
llazzaro/analyzerstrategies | analyzerstrategies/zscorePortfolioStrategy.py | https://github.com/llazzaro/analyzerstrategies/blob/3c647802f582bf2f06c6793f282bee0d26514cd6/analyzerstrategies/zscorePortfolioStrategy.py#L74-L81 | def __getCashToBuyStock(self):
''' calculate the amount of money to buy stock '''
account=self.__strategy.getAccountCopy()
if (account.buyingPower >= account.getTotalValue() / self.__buyingRatio):
return account.getTotalValue() / self.__buyingRatio
else:
return 0 | [
"def",
"__getCashToBuyStock",
"(",
"self",
")",
":",
"account",
"=",
"self",
".",
"__strategy",
".",
"getAccountCopy",
"(",
")",
"if",
"(",
"account",
".",
"buyingPower",
">=",
"account",
".",
"getTotalValue",
"(",
")",
"/",
"self",
".",
"__buyingRatio",
"... | calculate the amount of money to buy stock | [
"calculate",
"the",
"amount",
"of",
"money",
"to",
"buy",
"stock"
] | python | train |
ilevkivskyi/typing_inspect | typing_inspect.py | https://github.com/ilevkivskyi/typing_inspect/blob/fd81278cc440b6003f8298bcb22d5bc0f82ee3cd/typing_inspect.py#L140-L151 | def is_union_type(tp):
"""Test if the type is a union type. Examples::
is_union_type(int) == False
is_union_type(Union) == True
is_union_type(Union[int, int]) == False
is_union_type(Union[T, int]) == True
"""
if NEW_TYPING:
return (tp is Union or
isin... | [
"def",
"is_union_type",
"(",
"tp",
")",
":",
"if",
"NEW_TYPING",
":",
"return",
"(",
"tp",
"is",
"Union",
"or",
"isinstance",
"(",
"tp",
",",
"_GenericAlias",
")",
"and",
"tp",
".",
"__origin__",
"is",
"Union",
")",
"return",
"type",
"(",
"tp",
")",
... | Test if the type is a union type. Examples::
is_union_type(int) == False
is_union_type(Union) == True
is_union_type(Union[int, int]) == False
is_union_type(Union[T, int]) == True | [
"Test",
"if",
"the",
"type",
"is",
"a",
"union",
"type",
".",
"Examples",
"::"
] | python | train |
hugapi/hug | hug/routing.py | https://github.com/hugapi/hug/blob/080901c81576657f82e2432fd4a82f1d0d2f370c/hug/routing.py#L256-L277 | def allow_origins(self, *origins, methods=None, max_age=None, credentials=None, headers=None, **overrides):
"""Convenience method for quickly allowing other resources to access this one"""
response_headers = {}
if origins:
@hug.response_middleware()
def process_data(reque... | [
"def",
"allow_origins",
"(",
"self",
",",
"*",
"origins",
",",
"methods",
"=",
"None",
",",
"max_age",
"=",
"None",
",",
"credentials",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"*",
"*",
"overrides",
")",
":",
"response_headers",
"=",
"{",
"}",
... | Convenience method for quickly allowing other resources to access this one | [
"Convenience",
"method",
"for",
"quickly",
"allowing",
"other",
"resources",
"to",
"access",
"this",
"one"
] | python | train |
pyQode/pyqode.core | pyqode/core/panels/marker.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/marker.py#L36-L50 | def icon(self):
"""
Gets the icon file name. Read-only.
"""
if isinstance(self._icon, str):
if QtGui.QIcon.hasThemeIcon(self._icon):
return QtGui.QIcon.fromTheme(self._icon)
else:
return QtGui.QIcon(self._icon)
elif isinstan... | [
"def",
"icon",
"(",
"self",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_icon",
",",
"str",
")",
":",
"if",
"QtGui",
".",
"QIcon",
".",
"hasThemeIcon",
"(",
"self",
".",
"_icon",
")",
":",
"return",
"QtGui",
".",
"QIcon",
".",
"fromTheme",
"("... | Gets the icon file name. Read-only. | [
"Gets",
"the",
"icon",
"file",
"name",
".",
"Read",
"-",
"only",
"."
] | python | train |
shin-/dockerpy-creds | dockerpycreds/utils.py | https://github.com/shin-/dockerpy-creds/blob/9c0b66d2e445a838e1518f2c3273df7ddc7ec0d4/dockerpycreds/utils.py#L6-L29 | def find_executable(executable, path=None):
"""
As distutils.spawn.find_executable, but on Windows, look up
every extension declared in PATHEXT instead of just `.exe`
"""
if sys.platform != 'win32':
return distutils.spawn.find_executable(executable, path)
if path is None:
path =... | [
"def",
"find_executable",
"(",
"executable",
",",
"path",
"=",
"None",
")",
":",
"if",
"sys",
".",
"platform",
"!=",
"'win32'",
":",
"return",
"distutils",
".",
"spawn",
".",
"find_executable",
"(",
"executable",
",",
"path",
")",
"if",
"path",
"is",
"No... | As distutils.spawn.find_executable, but on Windows, look up
every extension declared in PATHEXT instead of just `.exe` | [
"As",
"distutils",
".",
"spawn",
".",
"find_executable",
"but",
"on",
"Windows",
"look",
"up",
"every",
"extension",
"declared",
"in",
"PATHEXT",
"instead",
"of",
"just",
".",
"exe"
] | python | train |
mozilla/mozdownload | mozdownload/scraper.py | https://github.com/mozilla/mozdownload/blob/97796a028455bb5200434562d23b66d5a5eb537b/mozdownload/scraper.py#L528-L541 | def build_filename(self, binary):
"""Return the proposed filename with extension for the binary."""
try:
# Get exact timestamp of the build to build the local file name
folder = self.builds[self.build_index]
timestamp = re.search(r'([\d\-]+)-\D.*', folder).group(1)
... | [
"def",
"build_filename",
"(",
"self",
",",
"binary",
")",
":",
"try",
":",
"# Get exact timestamp of the build to build the local file name",
"folder",
"=",
"self",
".",
"builds",
"[",
"self",
".",
"build_index",
"]",
"timestamp",
"=",
"re",
".",
"search",
"(",
... | Return the proposed filename with extension for the binary. | [
"Return",
"the",
"proposed",
"filename",
"with",
"extension",
"for",
"the",
"binary",
"."
] | python | train |
chimera0/accel-brain-code | Reinforcement-Learning/pyqlearning/annealing_model.py | https://github.com/chimera0/accel-brain-code/blob/03661f6f544bed656269fcd4b3c23c9061629daa/Reinforcement-Learning/pyqlearning/annealing_model.py#L140-L145 | def set_computed_cost_arr(self, value):
''' setter '''
if isinstance(value, np.ndarray):
self.__computed_cost_arr = value
else:
raise TypeError() | [
"def",
"set_computed_cost_arr",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"np",
".",
"ndarray",
")",
":",
"self",
".",
"__computed_cost_arr",
"=",
"value",
"else",
":",
"raise",
"TypeError",
"(",
")"
] | setter | [
"setter"
] | python | train |
LogicalDash/LiSE | ELiDE/ELiDE/card.py | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/card.py#L241-L247 | def on_art_image(self, *args):
"""When I get a new ``art_image``, store its texture in
``art_texture``.
"""
if self.art_image is not None:
self.art_texture = self.art_image.texture | [
"def",
"on_art_image",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"self",
".",
"art_image",
"is",
"not",
"None",
":",
"self",
".",
"art_texture",
"=",
"self",
".",
"art_image",
".",
"texture"
] | When I get a new ``art_image``, store its texture in
``art_texture``. | [
"When",
"I",
"get",
"a",
"new",
"art_image",
"store",
"its",
"texture",
"in",
"art_texture",
"."
] | python | train |
miguelgrinberg/python-engineio | engineio/async_drivers/aiohttp.py | https://github.com/miguelgrinberg/python-engineio/blob/261fd67103cb5d9a44369415748e66fdf62de6fb/engineio/async_drivers/aiohttp.py#L22-L72 | def translate_request(request):
"""This function takes the arguments passed to the request handler and
uses them to generate a WSGI compatible environ dictionary.
"""
message = request._message
payload = request._payload
uri_parts = urlsplit(message.path)
environ = {
'wsgi.input': p... | [
"def",
"translate_request",
"(",
"request",
")",
":",
"message",
"=",
"request",
".",
"_message",
"payload",
"=",
"request",
".",
"_payload",
"uri_parts",
"=",
"urlsplit",
"(",
"message",
".",
"path",
")",
"environ",
"=",
"{",
"'wsgi.input'",
":",
"payload",... | This function takes the arguments passed to the request handler and
uses them to generate a WSGI compatible environ dictionary. | [
"This",
"function",
"takes",
"the",
"arguments",
"passed",
"to",
"the",
"request",
"handler",
"and",
"uses",
"them",
"to",
"generate",
"a",
"WSGI",
"compatible",
"environ",
"dictionary",
"."
] | python | train |
trevorstephens/gplearn | gplearn/genetic.py | https://github.com/trevorstephens/gplearn/blob/5c0465f2ecdcd5abcdf3fe520688d24cd59e4a52/gplearn/genetic.py#L36-L152 | def _parallel_evolve(n_programs, parents, X, y, sample_weight, seeds, params):
"""Private function used to build a batch of programs within a job."""
n_samples, n_features = X.shape
# Unpack parameters
tournament_size = params['tournament_size']
function_set = params['function_set']
arities = pa... | [
"def",
"_parallel_evolve",
"(",
"n_programs",
",",
"parents",
",",
"X",
",",
"y",
",",
"sample_weight",
",",
"seeds",
",",
"params",
")",
":",
"n_samples",
",",
"n_features",
"=",
"X",
".",
"shape",
"# Unpack parameters",
"tournament_size",
"=",
"params",
"[... | Private function used to build a batch of programs within a job. | [
"Private",
"function",
"used",
"to",
"build",
"a",
"batch",
"of",
"programs",
"within",
"a",
"job",
"."
] | python | train |
CenturyLinkCloud/clc-python-sdk | src/clc/APIv1/user.py | https://github.com/CenturyLinkCloud/clc-python-sdk/blob/f4dba40c627cb08dd4b7d0d277e8d67578010b05/src/clc/APIv1/user.py#L44-L54 | def GetUsers(alias=None):
"""Gets all of users assigned to a given account.
https://t3n.zendesk.com/entries/22427662-GetUsers
:param alias: short code for a particular account. If none will use account's default alias
"""
if alias is None: alias = clc.v1.Account.GetAlias()
r = clc.v1.API.Call('post','... | [
"def",
"GetUsers",
"(",
"alias",
"=",
"None",
")",
":",
"if",
"alias",
"is",
"None",
":",
"alias",
"=",
"clc",
".",
"v1",
".",
"Account",
".",
"GetAlias",
"(",
")",
"r",
"=",
"clc",
".",
"v1",
".",
"API",
".",
"Call",
"(",
"'post'",
",",
"'User... | Gets all of users assigned to a given account.
https://t3n.zendesk.com/entries/22427662-GetUsers
:param alias: short code for a particular account. If none will use account's default alias | [
"Gets",
"all",
"of",
"users",
"assigned",
"to",
"a",
"given",
"account",
".",
"https",
":",
"//",
"t3n",
".",
"zendesk",
".",
"com",
"/",
"entries",
"/",
"22427662",
"-",
"GetUsers"
] | python | train |
projectatomic/osbs-client | osbs/build/build_request.py | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/build/build_request.py#L488-L500 | def remove_tag_and_push_registries(tag_and_push_registries, version):
"""
Remove matching entries from tag_and_push_registries (in-place)
:param tag_and_push_registries: dict, uri -> dict
:param version: str, 'version' to match against
"""
registries = [uri
... | [
"def",
"remove_tag_and_push_registries",
"(",
"tag_and_push_registries",
",",
"version",
")",
":",
"registries",
"=",
"[",
"uri",
"for",
"uri",
",",
"regdict",
"in",
"tag_and_push_registries",
".",
"items",
"(",
")",
"if",
"regdict",
"[",
"'version'",
"]",
"==",... | Remove matching entries from tag_and_push_registries (in-place)
:param tag_and_push_registries: dict, uri -> dict
:param version: str, 'version' to match against | [
"Remove",
"matching",
"entries",
"from",
"tag_and_push_registries",
"(",
"in",
"-",
"place",
")"
] | python | train |
ssato/python-anytemplate | anytemplate/engines/cheetah.py | https://github.com/ssato/python-anytemplate/blob/3e56baa914bd47f044083b20e33100f836443596/anytemplate/engines/cheetah.py#L68-L76 | def supports(cls, template_file=None):
"""
:return: Whether the engine can process given template file or not.
"""
if anytemplate.compat.IS_PYTHON_3:
cls._priority = 99
return False # Always as it's not ported to python 3.
return super(Engine, cls).suppo... | [
"def",
"supports",
"(",
"cls",
",",
"template_file",
"=",
"None",
")",
":",
"if",
"anytemplate",
".",
"compat",
".",
"IS_PYTHON_3",
":",
"cls",
".",
"_priority",
"=",
"99",
"return",
"False",
"# Always as it's not ported to python 3.",
"return",
"super",
"(",
... | :return: Whether the engine can process given template file or not. | [
":",
"return",
":",
"Whether",
"the",
"engine",
"can",
"process",
"given",
"template",
"file",
"or",
"not",
"."
] | python | train |
SALib/SALib | src/SALib/analyze/sobol.py | https://github.com/SALib/SALib/blob/9744d73bb17cfcffc8282c7dc4a727efdc4bea3f/src/SALib/analyze/sobol.py#L253-L302 | def Si_to_pandas_dict(S_dict):
"""Convert Si information into Pandas DataFrame compatible dict.
Parameters
----------
S_dict : ResultDict
Sobol sensitivity indices
See Also
----------
Si_list_to_dict
Returns
----------
tuple : of total, first, and second ... | [
"def",
"Si_to_pandas_dict",
"(",
"S_dict",
")",
":",
"problem",
"=",
"S_dict",
".",
"problem",
"total_order",
"=",
"{",
"'ST'",
":",
"S_dict",
"[",
"'ST'",
"]",
",",
"'ST_conf'",
":",
"S_dict",
"[",
"'ST_conf'",
"]",
"}",
"first_order",
"=",
"{",
"'S1'",... | Convert Si information into Pandas DataFrame compatible dict.
Parameters
----------
S_dict : ResultDict
Sobol sensitivity indices
See Also
----------
Si_list_to_dict
Returns
----------
tuple : of total, first, and second order sensitivities.
Total... | [
"Convert",
"Si",
"information",
"into",
"Pandas",
"DataFrame",
"compatible",
"dict",
".",
"Parameters",
"----------",
"S_dict",
":",
"ResultDict",
"Sobol",
"sensitivity",
"indices",
"See",
"Also",
"----------",
"Si_list_to_dict",
"Returns",
"----------",
"tuple",
":",... | python | train |
neherlab/treetime | treetime/treeanc.py | https://github.com/neherlab/treetime/blob/f6cdb58d19243a18ffdaa2b2ec71872fa00e65c0/treetime/treeanc.py#L1991-L2053 | def get_tree_dict(self, keep_var_ambigs=False):
"""
For VCF-based objects, returns a nested dict with all the information required to
reconstruct sequences for all nodes (terminal and internal).
Parameters
----------
keep_var_ambigs : boolean
If true, generat... | [
"def",
"get_tree_dict",
"(",
"self",
",",
"keep_var_ambigs",
"=",
"False",
")",
":",
"if",
"self",
".",
"is_vcf",
":",
"tree_dict",
"=",
"{",
"}",
"tree_dict",
"[",
"'reference'",
"]",
"=",
"self",
".",
"ref",
"tree_dict",
"[",
"'positions'",
"]",
"=",
... | For VCF-based objects, returns a nested dict with all the information required to
reconstruct sequences for all nodes (terminal and internal).
Parameters
----------
keep_var_ambigs : boolean
If true, generates dict sequences based on the *original* compressed sequences, whic... | [
"For",
"VCF",
"-",
"based",
"objects",
"returns",
"a",
"nested",
"dict",
"with",
"all",
"the",
"information",
"required",
"to",
"reconstruct",
"sequences",
"for",
"all",
"nodes",
"(",
"terminal",
"and",
"internal",
")",
"."
] | python | test |
Erotemic/utool | utool/util_regex.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_regex.py#L443-L469 | def regex_parse(regex, text, fromstart=True):
r"""
regex_parse
Args:
regex (str):
text (str):
fromstart (bool):
Returns:
dict or None:
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_regex import * # NOQA
>>> regex = r'(?P<string>\'[^\']... | [
"def",
"regex_parse",
"(",
"regex",
",",
"text",
",",
"fromstart",
"=",
"True",
")",
":",
"match",
"=",
"regex_get_match",
"(",
"regex",
",",
"text",
",",
"fromstart",
"=",
"fromstart",
")",
"if",
"match",
"is",
"not",
"None",
":",
"parse_dict",
"=",
"... | r"""
regex_parse
Args:
regex (str):
text (str):
fromstart (bool):
Returns:
dict or None:
Example:
>>> # DISABLE_DOCTEST
>>> from utool.util_regex import * # NOQA
>>> regex = r'(?P<string>\'[^\']*\')'
>>> text = " 'just' 'a' sentance wit... | [
"r",
"regex_parse"
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/qt/console/rich_ipython_widget.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/rich_ipython_widget.py#L136-L161 | def _handle_display_data(self, msg):
""" Overridden to handle rich data types, like SVG.
"""
if not self._hidden and self._is_from_this_session(msg):
source = msg['content']['source']
data = msg['content']['data']
metadata = msg['content']['metadata']
... | [
"def",
"_handle_display_data",
"(",
"self",
",",
"msg",
")",
":",
"if",
"not",
"self",
".",
"_hidden",
"and",
"self",
".",
"_is_from_this_session",
"(",
"msg",
")",
":",
"source",
"=",
"msg",
"[",
"'content'",
"]",
"[",
"'source'",
"]",
"data",
"=",
"m... | Overridden to handle rich data types, like SVG. | [
"Overridden",
"to",
"handle",
"rich",
"data",
"types",
"like",
"SVG",
"."
] | python | test |
scizzorz/bumpy | bumpy.py | https://github.com/scizzorz/bumpy/blob/99ed5c5ccaa61842cafe9faf8b082de44bdf01f9/bumpy.py#L317-L328 | def age(*paths):
'''Return the minimum age of a set of files.
Returns 0 if no paths are given.
Returns time.time() if a path does not exist.'''
if not paths:
return 0
for path in paths:
if not os.path.exists(path):
return time.time()
return min([(time.time() - os.path.getmtime(path)) for path in paths]) | [
"def",
"age",
"(",
"*",
"paths",
")",
":",
"if",
"not",
"paths",
":",
"return",
"0",
"for",
"path",
"in",
"paths",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"time",
".",
"time",
"(",
")",
"return",
"mi... | Return the minimum age of a set of files.
Returns 0 if no paths are given.
Returns time.time() if a path does not exist. | [
"Return",
"the",
"minimum",
"age",
"of",
"a",
"set",
"of",
"files",
".",
"Returns",
"0",
"if",
"no",
"paths",
"are",
"given",
".",
"Returns",
"time",
".",
"time",
"()",
"if",
"a",
"path",
"does",
"not",
"exist",
"."
] | python | train |
pantsbuild/pex | pex/interpreter.py | https://github.com/pantsbuild/pex/blob/87b2129d860250d3b9edce75b9cb62f9789ee521/pex/interpreter.py#L349-L364 | def find(cls, paths):
"""
Given a list of files or directories, try to detect python interpreters amongst them.
Returns a list of PythonInterpreter objects.
"""
pythons = []
for path in paths:
for fn in cls.expand_path(path):
basefile = os.path.basename(fn)
if cls._matc... | [
"def",
"find",
"(",
"cls",
",",
"paths",
")",
":",
"pythons",
"=",
"[",
"]",
"for",
"path",
"in",
"paths",
":",
"for",
"fn",
"in",
"cls",
".",
"expand_path",
"(",
"path",
")",
":",
"basefile",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"fn",
... | Given a list of files or directories, try to detect python interpreters amongst them.
Returns a list of PythonInterpreter objects. | [
"Given",
"a",
"list",
"of",
"files",
"or",
"directories",
"try",
"to",
"detect",
"python",
"interpreters",
"amongst",
"them",
".",
"Returns",
"a",
"list",
"of",
"PythonInterpreter",
"objects",
"."
] | python | train |
gmr/rejected | rejected/process.py | https://github.com/gmr/rejected/blob/610a3e1401122ecb98d891b6795cca0255e5b044/rejected/process.py#L523-L536 | def report_stats(self):
"""Create the dict of stats data for the MCP stats queue"""
if not self.previous:
self.previous = dict()
for key in self.counters:
self.previous[key] = 0
values = {
'name': self.name,
'consumer_name': self.co... | [
"def",
"report_stats",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"previous",
":",
"self",
".",
"previous",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"self",
".",
"counters",
":",
"self",
".",
"previous",
"[",
"key",
"]",
"=",
"0",
"values",... | Create the dict of stats data for the MCP stats queue | [
"Create",
"the",
"dict",
"of",
"stats",
"data",
"for",
"the",
"MCP",
"stats",
"queue"
] | python | train |
grahame/dividebatur | dividebatur/counter.py | https://github.com/grahame/dividebatur/blob/adc1f6e8013943471f1679e3c94f9448a1e4a472/dividebatur/counter.py#L568-L653 | def determine_bulk_exclusions(self, candidate_aggregates):
"determine candidates who may be bulk excluded, under 273(13)"
# adjustment as under (13C) - seems to only apply if more than one candidate was elected in a round
continuing = self.get_continuing_candidates(candidate_aggregates)
... | [
"def",
"determine_bulk_exclusions",
"(",
"self",
",",
"candidate_aggregates",
")",
":",
"# adjustment as under (13C) - seems to only apply if more than one candidate was elected in a round",
"continuing",
"=",
"self",
".",
"get_continuing_candidates",
"(",
"candidate_aggregates",
")"... | determine candidates who may be bulk excluded, under 273(13) | [
"determine",
"candidates",
"who",
"may",
"be",
"bulk",
"excluded",
"under",
"273",
"(",
"13",
")"
] | python | train |
vaexio/vaex | packages/vaex-core/vaex/delayed.py | https://github.com/vaexio/vaex/blob/a45b672f8287afca2ada8e36b74b604b9b28dd85/packages/vaex-core/vaex/delayed.py#L28-L73 | def delayed(f):
'''Decorator to transparantly accept delayed computation.
Example:
>>> delayed_sum = ds.sum(ds.E, binby=ds.x, limits=limits,
>>> shape=4, delay=True)
>>> @vaex.delayed
>>> def total_sum(sums):
>>> return sums.sum()
>>> sum_of_sums = total_sum(delay... | [
"def",
"delayed",
"(",
"f",
")",
":",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# print \"calling\", f, \"with\", kwargs",
"# key_values = kwargs.items()",
"key_promise",
"=",
"list",
"(",
"[",
"(",
"key",
",",
"promisify",
"(",
... | Decorator to transparantly accept delayed computation.
Example:
>>> delayed_sum = ds.sum(ds.E, binby=ds.x, limits=limits,
>>> shape=4, delay=True)
>>> @vaex.delayed
>>> def total_sum(sums):
>>> return sums.sum()
>>> sum_of_sums = total_sum(delayed_sum)
>>> ds.exec... | [
"Decorator",
"to",
"transparantly",
"accept",
"delayed",
"computation",
"."
] | python | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.