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 |
|---|---|---|---|---|---|---|---|---|
nicolargo/glances | glances/cpu_percent.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/cpu_percent.py#L62-L93 | def __get_percpu(self):
"""Update and/or return the per CPU list using the psutil library."""
# Never update more than 1 time per cached_time
if self.timer_percpu.finished():
self.percpu_percent = []
for cpu_number, cputimes in enumerate(psutil.cpu_times_percent(interval=... | [
"def",
"__get_percpu",
"(",
"self",
")",
":",
"# Never update more than 1 time per cached_time",
"if",
"self",
".",
"timer_percpu",
".",
"finished",
"(",
")",
":",
"self",
".",
"percpu_percent",
"=",
"[",
"]",
"for",
"cpu_number",
",",
"cputimes",
"in",
"enumera... | Update and/or return the per CPU list using the psutil library. | [
"Update",
"and",
"/",
"or",
"return",
"the",
"per",
"CPU",
"list",
"using",
"the",
"psutil",
"library",
"."
] | python | train |
liftoff/pyminifier | pyminifier/minification.py | https://github.com/liftoff/pyminifier/blob/087ea7b0c8c964f1f907c3f350f5ce281798db86/pyminifier/minification.py#L31-L72 | def remove_comments(tokens):
"""
Removes comments from *tokens* which is expected to be a list equivalent of
tokenize.generate_tokens() (so we can update in-place).
.. note::
* If the comment makes up the whole line, the newline will also be removed (so you don't end up with lots of blank line... | [
"def",
"remove_comments",
"(",
"tokens",
")",
":",
"preserved_shebang",
"=",
"\"\"",
"preserved_encoding",
"=",
"\"\"",
"# This (short) loop preserves shebangs and encoding strings:",
"for",
"tok",
"in",
"tokens",
"[",
"0",
":",
"4",
"]",
":",
"# Will always be in the f... | Removes comments from *tokens* which is expected to be a list equivalent of
tokenize.generate_tokens() (so we can update in-place).
.. note::
* If the comment makes up the whole line, the newline will also be removed (so you don't end up with lots of blank lines).
* Preserves shebangs and enco... | [
"Removes",
"comments",
"from",
"*",
"tokens",
"*",
"which",
"is",
"expected",
"to",
"be",
"a",
"list",
"equivalent",
"of",
"tokenize",
".",
"generate_tokens",
"()",
"(",
"so",
"we",
"can",
"update",
"in",
"-",
"place",
")",
"."
] | python | train |
archman/beamline | beamline/models.py | https://github.com/archman/beamline/blob/417bc5dc13e754bc89d246427984590fced64d07/beamline/models.py#L146-L159 | def getAllConfig(self, fmt='json'):
"""
return all element configurations as json string file.
could be further processed by beamline.Lattice class
:param fmt: 'json' (default) or 'dict'
"""
for e in self.getCtrlConf(msgout=False):
self._lattice_c... | [
"def",
"getAllConfig",
"(",
"self",
",",
"fmt",
"=",
"'json'",
")",
":",
"for",
"e",
"in",
"self",
".",
"getCtrlConf",
"(",
"msgout",
"=",
"False",
")",
":",
"self",
".",
"_lattice_confdict",
".",
"update",
"(",
"e",
".",
"dumpConfig",
"(",
"type",
"... | return all element configurations as json string file.
could be further processed by beamline.Lattice class
:param fmt: 'json' (default) or 'dict' | [
"return",
"all",
"element",
"configurations",
"as",
"json",
"string",
"file",
".",
"could",
"be",
"further",
"processed",
"by",
"beamline",
".",
"Lattice",
"class"
] | python | train |
zeth/inputs | inputs.py | https://github.com/zeth/inputs/blob/a46681dbf77d6ab07834f550e5855c1f50701f99/inputs.py#L3202-L3208 | def _update_all_devices(self):
"""Update the all_devices list."""
self.all_devices = []
self.all_devices.extend(self.keyboards)
self.all_devices.extend(self.mice)
self.all_devices.extend(self.gamepads)
self.all_devices.extend(self.other_devices) | [
"def",
"_update_all_devices",
"(",
"self",
")",
":",
"self",
".",
"all_devices",
"=",
"[",
"]",
"self",
".",
"all_devices",
".",
"extend",
"(",
"self",
".",
"keyboards",
")",
"self",
".",
"all_devices",
".",
"extend",
"(",
"self",
".",
"mice",
")",
"se... | Update the all_devices list. | [
"Update",
"the",
"all_devices",
"list",
"."
] | python | train |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/jinja2/environment.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/jinja2/environment.py#L375-L390 | def getitem(self, obj, argument):
"""Get an item or attribute of an object but prefer the item."""
try:
return obj[argument]
except (TypeError, LookupError):
if isinstance(argument, string_types):
try:
attr = str(argument)
... | [
"def",
"getitem",
"(",
"self",
",",
"obj",
",",
"argument",
")",
":",
"try",
":",
"return",
"obj",
"[",
"argument",
"]",
"except",
"(",
"TypeError",
",",
"LookupError",
")",
":",
"if",
"isinstance",
"(",
"argument",
",",
"string_types",
")",
":",
"try"... | Get an item or attribute of an object but prefer the item. | [
"Get",
"an",
"item",
"or",
"attribute",
"of",
"an",
"object",
"but",
"prefer",
"the",
"item",
"."
] | python | test |
docker/docker-py | docker/api/container.py | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/container.py#L1057-L1092 | def start(self, container, *args, **kwargs):
"""
Start a container. Similar to the ``docker start`` command, but
doesn't support attach options.
**Deprecation warning:** Passing configuration options in ``start`` is
no longer supported. Users are expected to provide host config ... | [
"def",
"start",
"(",
"self",
",",
"container",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
"or",
"kwargs",
":",
"raise",
"errors",
".",
"DeprecatedMethod",
"(",
"'Providing configuration in the start() method is no longer '",
"'supported. Us... | Start a container. Similar to the ``docker start`` command, but
doesn't support attach options.
**Deprecation warning:** Passing configuration options in ``start`` is
no longer supported. Users are expected to provide host config options
in the ``host_config`` parameter of
:py:m... | [
"Start",
"a",
"container",
".",
"Similar",
"to",
"the",
"docker",
"start",
"command",
"but",
"doesn",
"t",
"support",
"attach",
"options",
"."
] | python | train |
biocommons/hgvs | hgvs/variantmapper.py | https://github.com/biocommons/hgvs/blob/4d16efb475e1802b2531a2f1c373e8819d8e533b/hgvs/variantmapper.py#L336-L368 | def n_to_c(self, var_n):
"""Given a parsed n. variant, return a c. variant on the specified
transcript using the specified alignment method (default is
"transcript" indicating a self alignment).
:param hgvs.sequencevariant.SequenceVariant var_n: a variant object
:returns: varian... | [
"def",
"n_to_c",
"(",
"self",
",",
"var_n",
")",
":",
"if",
"not",
"(",
"var_n",
".",
"type",
"==",
"\"n\"",
")",
":",
"raise",
"HGVSInvalidVariantError",
"(",
"\"Expected n. variant; got \"",
"+",
"str",
"(",
"var_n",
")",
")",
"if",
"self",
".",
"_vali... | Given a parsed n. variant, return a c. variant on the specified
transcript using the specified alignment method (default is
"transcript" indicating a self alignment).
:param hgvs.sequencevariant.SequenceVariant var_n: a variant object
:returns: variant object (:class:`hgvs.sequencevaria... | [
"Given",
"a",
"parsed",
"n",
".",
"variant",
"return",
"a",
"c",
".",
"variant",
"on",
"the",
"specified",
"transcript",
"using",
"the",
"specified",
"alignment",
"method",
"(",
"default",
"is",
"transcript",
"indicating",
"a",
"self",
"alignment",
")",
"."
... | python | train |
adamziel/python_translate | python_translate/translations.py | https://github.com/adamziel/python_translate/blob/0aee83f434bd2d1b95767bcd63adb7ac7036c7df/python_translate/translations.py#L132-L140 | def replace(self, messages, domain='messages'):
"""
Sets translations for a given domain.
"""
assert isinstance(messages, (dict, CaseInsensitiveDict))
assert isinstance(domain, (str, unicode))
self.messages[domain] = CaseInsensitiveDict({})
self.add(messages, dom... | [
"def",
"replace",
"(",
"self",
",",
"messages",
",",
"domain",
"=",
"'messages'",
")",
":",
"assert",
"isinstance",
"(",
"messages",
",",
"(",
"dict",
",",
"CaseInsensitiveDict",
")",
")",
"assert",
"isinstance",
"(",
"domain",
",",
"(",
"str",
",",
"uni... | Sets translations for a given domain. | [
"Sets",
"translations",
"for",
"a",
"given",
"domain",
"."
] | python | train |
pycontribs/pyrax | pyrax/autoscale.py | https://github.com/pycontribs/pyrax/blob/9ddfd5064b3a292d7337906f3b2d5dce95b50b99/pyrax/autoscale.py#L569-L603 | def update_policy(self, scaling_group, policy, name=None, policy_type=None,
cooldown=None, change=None, is_percent=False,
desired_capacity=None, args=None):
"""
Updates the specified policy. One or more of the parameters may be
specified.
"""
uri = "/%s/%s... | [
"def",
"update_policy",
"(",
"self",
",",
"scaling_group",
",",
"policy",
",",
"name",
"=",
"None",
",",
"policy_type",
"=",
"None",
",",
"cooldown",
"=",
"None",
",",
"change",
"=",
"None",
",",
"is_percent",
"=",
"False",
",",
"desired_capacity",
"=",
... | Updates the specified policy. One or more of the parameters may be
specified. | [
"Updates",
"the",
"specified",
"policy",
".",
"One",
"or",
"more",
"of",
"the",
"parameters",
"may",
"be",
"specified",
"."
] | python | train |
aeguana/PyFileMaker | PyFileMaker/FMServer.py | https://github.com/aeguana/PyFileMaker/blob/ef269b52a97e329d91da3c4851ddac800d7fd7e6/PyFileMaker/FMServer.py#L346-L359 | def getDbNames(self):
"""This function returns the list of open databases"""
request = []
request.append(uu({'-dbnames': '' }))
result = self._doRequest(request)
result = FMResultset.FMResultset(result)
dbNames = []
for dbName in result.resultset:
dbNames.append(string.lower(dbName['DATABASE_NAME'])... | [
"def",
"getDbNames",
"(",
"self",
")",
":",
"request",
"=",
"[",
"]",
"request",
".",
"append",
"(",
"uu",
"(",
"{",
"'-dbnames'",
":",
"''",
"}",
")",
")",
"result",
"=",
"self",
".",
"_doRequest",
"(",
"request",
")",
"result",
"=",
"FMResultset",
... | This function returns the list of open databases | [
"This",
"function",
"returns",
"the",
"list",
"of",
"open",
"databases"
] | python | train |
plandes/actioncli | src/python/zensols/actioncli/factory.py | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/factory.py#L133-L141 | def _find_class(self, class_name):
"Resolve the class from the name."
classes = {}
classes.update(globals())
classes.update(self.INSTANCE_CLASSES)
logger.debug(f'looking up class: {class_name}')
cls = classes[class_name]
logger.debug(f'found class: {cls}')
... | [
"def",
"_find_class",
"(",
"self",
",",
"class_name",
")",
":",
"classes",
"=",
"{",
"}",
"classes",
".",
"update",
"(",
"globals",
"(",
")",
")",
"classes",
".",
"update",
"(",
"self",
".",
"INSTANCE_CLASSES",
")",
"logger",
".",
"debug",
"(",
"f'look... | Resolve the class from the name. | [
"Resolve",
"the",
"class",
"from",
"the",
"name",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/requests/utils.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/requests/utils.py#L259-L281 | def from_key_val_list(value):
"""Take an object and test to see if it can be represented as a
dictionary. Unless it can not be represented as such, return an
OrderedDict, e.g.,
::
>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])
>>> from_key_val_list('strin... | [
"def",
"from_key_val_list",
"(",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"(",
"str",
",",
"bytes",
",",
"bool",
",",
"int",
")",
")",
":",
"raise",
"ValueError",
"(",
"'cannot encode... | Take an object and test to see if it can be represented as a
dictionary. Unless it can not be represented as such, return an
OrderedDict, e.g.,
::
>>> from_key_val_list([('key', 'val')])
OrderedDict([('key', 'val')])
>>> from_key_val_list('string')
ValueError: cannot encode... | [
"Take",
"an",
"object",
"and",
"test",
"to",
"see",
"if",
"it",
"can",
"be",
"represented",
"as",
"a",
"dictionary",
".",
"Unless",
"it",
"can",
"not",
"be",
"represented",
"as",
"such",
"return",
"an",
"OrderedDict",
"e",
".",
"g",
"."
] | python | train |
shveenkov/aiotarantool-queue-python | aiotarantool_queue/queue.py | https://github.com/shveenkov/aiotarantool-queue-python/blob/b84a1e704f63f7b8cb14cbca5ec99ab8047d1715/aiotarantool_queue/queue.py#L151-L155 | def cmd(self, cmd_name):
"""
Returns tarantool queue command name for current tube.
"""
return "{0}.tube.{1}:{2}".format(self.queue.lua_queue_name, self.name, cmd_name) | [
"def",
"cmd",
"(",
"self",
",",
"cmd_name",
")",
":",
"return",
"\"{0}.tube.{1}:{2}\"",
".",
"format",
"(",
"self",
".",
"queue",
".",
"lua_queue_name",
",",
"self",
".",
"name",
",",
"cmd_name",
")"
] | Returns tarantool queue command name for current tube. | [
"Returns",
"tarantool",
"queue",
"command",
"name",
"for",
"current",
"tube",
"."
] | python | train |
dhylands/rshell | rshell/main.py | https://github.com/dhylands/rshell/blob/a92a8fa8074ac792241c83c640a51b394667c324/rshell/main.py#L354-L361 | def escape(str):
"""Precede all special characters with a backslash."""
out = ''
for char in str:
if char in '\\ ':
out += '\\'
out += char
return out | [
"def",
"escape",
"(",
"str",
")",
":",
"out",
"=",
"''",
"for",
"char",
"in",
"str",
":",
"if",
"char",
"in",
"'\\\\ '",
":",
"out",
"+=",
"'\\\\'",
"out",
"+=",
"char",
"return",
"out"
] | Precede all special characters with a backslash. | [
"Precede",
"all",
"special",
"characters",
"with",
"a",
"backslash",
"."
] | python | train |
googleads/googleads-python-lib | googleads/common.py | https://github.com/googleads/googleads-python-lib/blob/aa3b1b474b0f9789ca55ca46f4b2b57aeae38874/googleads/common.py#L348-L376 | def _ExtractProxyConfig(product_yaml_key, proxy_config_data):
"""Returns an initialized ProxyConfig using the given proxy_config_data.
Args:
product_yaml_key: a string indicating the client being loaded.
proxy_config_data: a dict containing the contents of proxy_config from the
YAML file.
Returns:... | [
"def",
"_ExtractProxyConfig",
"(",
"product_yaml_key",
",",
"proxy_config_data",
")",
":",
"cafile",
"=",
"proxy_config_data",
".",
"get",
"(",
"'cafile'",
",",
"None",
")",
"disable_certificate_validation",
"=",
"proxy_config_data",
".",
"get",
"(",
"'disable_certifi... | Returns an initialized ProxyConfig using the given proxy_config_data.
Args:
product_yaml_key: a string indicating the client being loaded.
proxy_config_data: a dict containing the contents of proxy_config from the
YAML file.
Returns:
If there is a proxy to configure in proxy_config, this will re... | [
"Returns",
"an",
"initialized",
"ProxyConfig",
"using",
"the",
"given",
"proxy_config_data",
"."
] | python | train |
aerkalov/ebooklib | ebooklib/epub.py | https://github.com/aerkalov/ebooklib/blob/305f2dd7f02923ffabf9586a5d16266113d00c4a/ebooklib/epub.py#L319-L326 | def get_links_of_type(self, link_type):
"""
Returns list of additional links of specific type.
:Returns:
As tuple returns list of links.
"""
return (link for link in self.links if link.get('type', '') == link_type) | [
"def",
"get_links_of_type",
"(",
"self",
",",
"link_type",
")",
":",
"return",
"(",
"link",
"for",
"link",
"in",
"self",
".",
"links",
"if",
"link",
".",
"get",
"(",
"'type'",
",",
"''",
")",
"==",
"link_type",
")"
] | Returns list of additional links of specific type.
:Returns:
As tuple returns list of links. | [
"Returns",
"list",
"of",
"additional",
"links",
"of",
"specific",
"type",
"."
] | python | train |
gem/oq-engine | openquake/hazardlib/correlation.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/correlation.py#L92-L113 | def get_lower_triangle_correlation_matrix(self, sites, imt):
"""
Get lower-triangle matrix as a result of Cholesky-decomposition
of correlation matrix.
The resulting matrix should have zeros on values above
the main diagonal.
The actual implementations of :class:`BaseCo... | [
"def",
"get_lower_triangle_correlation_matrix",
"(",
"self",
",",
"sites",
",",
"imt",
")",
":",
"return",
"numpy",
".",
"linalg",
".",
"cholesky",
"(",
"self",
".",
"_get_correlation_matrix",
"(",
"sites",
",",
"imt",
")",
")"
] | Get lower-triangle matrix as a result of Cholesky-decomposition
of correlation matrix.
The resulting matrix should have zeros on values above
the main diagonal.
The actual implementations of :class:`BaseCorrelationModel` interface
might calculate the matrix considering site col... | [
"Get",
"lower",
"-",
"triangle",
"matrix",
"as",
"a",
"result",
"of",
"Cholesky",
"-",
"decomposition",
"of",
"correlation",
"matrix",
"."
] | python | train |
kakwa/ldapcherry | ldapcherry/__init__.py | https://github.com/kakwa/ldapcherry/blob/b5e7cb6a44065abc30d164e72981b3713a172dda/ldapcherry/__init__.py#L231-L276 | def _set_access_log(self, config, level):
""" Configure access logs
"""
access_handler = self._get_param(
'global',
'log.access_handler',
config,
'syslog',
)
# log format for syslog
syslog_formatter = logging.Formatter(... | [
"def",
"_set_access_log",
"(",
"self",
",",
"config",
",",
"level",
")",
":",
"access_handler",
"=",
"self",
".",
"_get_param",
"(",
"'global'",
",",
"'log.access_handler'",
",",
"config",
",",
"'syslog'",
",",
")",
"# log format for syslog",
"syslog_formatter",
... | Configure access logs | [
"Configure",
"access",
"logs"
] | python | train |
klen/makesite | makesite/install.py | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/install.py#L102-L120 | def _get_source(self):
" Get source from CVS or filepath. "
source_dir = op.join(self.deploy_dir, 'source')
for tp, cmd in settings.SRC_CLONE:
if self.src.startswith(tp + '+'):
program = which(tp)
assert program, '%s not found.' % tp
cm... | [
"def",
"_get_source",
"(",
"self",
")",
":",
"source_dir",
"=",
"op",
".",
"join",
"(",
"self",
".",
"deploy_dir",
",",
"'source'",
")",
"for",
"tp",
",",
"cmd",
"in",
"settings",
".",
"SRC_CLONE",
":",
"if",
"self",
".",
"src",
".",
"startswith",
"(... | Get source from CVS or filepath. | [
"Get",
"source",
"from",
"CVS",
"or",
"filepath",
"."
] | python | train |
a1ezzz/wasp-general | wasp_general/task/thread.py | https://github.com/a1ezzz/wasp-general/blob/1029839d33eb663f8dec76c1c46754d53c1de4a9/wasp_general/task/thread.py#L421-L427 | def thread_stopped(self):
""" :meth:`.WThreadTask._polling_iteration` implementation
"""
if self.__current_task is not None:
task = self.__task_chain[self.__current_task]
task.stop()
self.__current_task = None | [
"def",
"thread_stopped",
"(",
"self",
")",
":",
"if",
"self",
".",
"__current_task",
"is",
"not",
"None",
":",
"task",
"=",
"self",
".",
"__task_chain",
"[",
"self",
".",
"__current_task",
"]",
"task",
".",
"stop",
"(",
")",
"self",
".",
"__current_task"... | :meth:`.WThreadTask._polling_iteration` implementation | [
":",
"meth",
":",
".",
"WThreadTask",
".",
"_polling_iteration",
"implementation"
] | python | train |
waqasbhatti/astrobase | astrobase/lcproc/lcvfeatures.py | https://github.com/waqasbhatti/astrobase/blob/2922a14619d183fb28005fa7d02027ac436f2265/astrobase/lcproc/lcvfeatures.py#L376-L454 | def parallel_varfeatures(lclist,
outdir,
maxobjects=None,
timecols=None,
magcols=None,
errcols=None,
mindet=1000,
lcformat='hat-sql',
... | [
"def",
"parallel_varfeatures",
"(",
"lclist",
",",
"outdir",
",",
"maxobjects",
"=",
"None",
",",
"timecols",
"=",
"None",
",",
"magcols",
"=",
"None",
",",
"errcols",
"=",
"None",
",",
"mindet",
"=",
"1000",
",",
"lcformat",
"=",
"'hat-sql'",
",",
"lcfo... | This runs variable feature extraction in parallel for all LCs in `lclist`.
Parameters
----------
lclist : list of str
The list of light curve file names to process.
outdir : str
The directory where the output varfeatures pickle files will be written.
maxobjects : int
The ... | [
"This",
"runs",
"variable",
"feature",
"extraction",
"in",
"parallel",
"for",
"all",
"LCs",
"in",
"lclist",
"."
] | python | valid |
connectordb/connectordb-python | connectordb/_stream.py | https://github.com/connectordb/connectordb-python/blob/2092b0cb30898139a247176bcf433d5a4abde7cb/connectordb/_stream.py#L162-L173 | def unsubscribe(self, transform="", downlink=False):
"""Unsubscribes from a previously subscribed stream. Note that the same values of transform
and downlink must be passed in order to do the correct unsubscribe::
s.subscribe(callback,transform="if last")
s.unsubscribe(transform... | [
"def",
"unsubscribe",
"(",
"self",
",",
"transform",
"=",
"\"\"",
",",
"downlink",
"=",
"False",
")",
":",
"streampath",
"=",
"self",
".",
"path",
"if",
"downlink",
":",
"streampath",
"+=",
"\"/downlink\"",
"return",
"self",
".",
"db",
".",
"unsubscribe",
... | Unsubscribes from a previously subscribed stream. Note that the same values of transform
and downlink must be passed in order to do the correct unsubscribe::
s.subscribe(callback,transform="if last")
s.unsubscribe(transform="if last") | [
"Unsubscribes",
"from",
"a",
"previously",
"subscribed",
"stream",
".",
"Note",
"that",
"the",
"same",
"values",
"of",
"transform",
"and",
"downlink",
"must",
"be",
"passed",
"in",
"order",
"to",
"do",
"the",
"correct",
"unsubscribe",
"::"
] | python | test |
rocky/python3-trepan | trepan/lib/disassemble.py | https://github.com/rocky/python3-trepan/blob/14e91bc0acce090d67be145b1ac040cab92ac5f3/trepan/lib/disassemble.py#L35-L128 | def dis(msg, msg_nocr, section, errmsg, x=None, start_line=-1, end_line=None,
relative_pos = False, highlight='light', start_offset=0, end_offset=None,
include_header=False):
"""Disassemble classes, methods, functions, or code.
With no argument, disassemble the last traceback.
"""
last... | [
"def",
"dis",
"(",
"msg",
",",
"msg_nocr",
",",
"section",
",",
"errmsg",
",",
"x",
"=",
"None",
",",
"start_line",
"=",
"-",
"1",
",",
"end_line",
"=",
"None",
",",
"relative_pos",
"=",
"False",
",",
"highlight",
"=",
"'light'",
",",
"start_offset",
... | Disassemble classes, methods, functions, or code.
With no argument, disassemble the last traceback. | [
"Disassemble",
"classes",
"methods",
"functions",
"or",
"code",
"."
] | python | test |
nderkach/airbnb-python | airbnb/api.py | https://github.com/nderkach/airbnb-python/blob/0b3ed69518e41383eca93ae11b24247f3cc69a27/airbnb/api.py#L55-L64 | def randomizable(function):
"""
A decorator which randomizes requests if needed
"""
@functools.wraps(function)
def wrapper(self, *args, **kwargs):
if self.randomize:
self.randomize_headers()
return function(self, *args, **kwargs)
return wrapper | [
"def",
"randomizable",
"(",
"function",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"function",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"randomize",
":",
"self",
".",
"randomize_h... | A decorator which randomizes requests if needed | [
"A",
"decorator",
"which",
"randomizes",
"requests",
"if",
"needed"
] | python | train |
PMEAL/OpenPNM | openpnm/algorithms/ReactiveTransport.py | https://github.com/PMEAL/OpenPNM/blob/0547b5724ffedc0a593aae48639d36fe10e0baed/openpnm/algorithms/ReactiveTransport.py#L54-L120 | def setup(self, phase=None, quantity='', conductance='', r_tolerance=None,
max_iter=None, relaxation_source=None,
relaxation_quantity=None, **kwargs):
r"""
This method takes several arguments that are essential to running the
algorithm and adds them to the settings
... | [
"def",
"setup",
"(",
"self",
",",
"phase",
"=",
"None",
",",
"quantity",
"=",
"''",
",",
"conductance",
"=",
"''",
",",
"r_tolerance",
"=",
"None",
",",
"max_iter",
"=",
"None",
",",
"relaxation_source",
"=",
"None",
",",
"relaxation_quantity",
"=",
"Non... | r"""
This method takes several arguments that are essential to running the
algorithm and adds them to the settings
Parameters
----------
phase : OpenPNM Phase object
The phase on which the algorithm is to be run. If no value is
given, the existing value i... | [
"r",
"This",
"method",
"takes",
"several",
"arguments",
"that",
"are",
"essential",
"to",
"running",
"the",
"algorithm",
"and",
"adds",
"them",
"to",
"the",
"settings"
] | python | train |
accraze/pymtranslate | pymtranslate/translator.py | https://github.com/accraze/pymtranslate/blob/b18f9d7e8ef1583c988e8beb6c3304d362a4d979/pymtranslate/translator.py#L103-L179 | def iterateEM(self, count):
'''
Iterate through all transmissions of english to
foreign words. keep count of repeated occurences
do until convergence
set count(e|f) to 0 for all e,f
set total(f) to 0 for all f
for all sentence pairs (e_s,f_s)
... | [
"def",
"iterateEM",
"(",
"self",
",",
"count",
")",
":",
"for",
"iter",
"in",
"range",
"(",
"count",
")",
":",
"countef",
"=",
"{",
"}",
"totalf",
"=",
"{",
"}",
"# set the count of the words to zero",
"for",
"word",
"in",
"self",
".",
"en_words",
":",
... | Iterate through all transmissions of english to
foreign words. keep count of repeated occurences
do until convergence
set count(e|f) to 0 for all e,f
set total(f) to 0 for all f
for all sentence pairs (e_s,f_s)
set total_s(e) = 0 for all e
for ... | [
"Iterate",
"through",
"all",
"transmissions",
"of",
"english",
"to",
"foreign",
"words",
".",
"keep",
"count",
"of",
"repeated",
"occurences",
"do",
"until",
"convergence",
"set",
"count",
"(",
"e|f",
")",
"to",
"0",
"for",
"all",
"e",
"f",
"set",
"total",... | python | test |
bsmurphy/PyKrige | pykrige/uk.py | https://github.com/bsmurphy/PyKrige/blob/a4db3003b0b5688658c12faeb95a5a8b2b14b433/pykrige/uk.py#L859-L1076 | def execute(self, style, xpoints, ypoints, mask=None,
backend='vectorized', specified_drift_arrays=None):
"""Calculates a kriged grid and the associated variance.
Includes drift terms.
This is now the method that performs the main kriging calculation.
Note that cur... | [
"def",
"execute",
"(",
"self",
",",
"style",
",",
"xpoints",
",",
"ypoints",
",",
"mask",
"=",
"None",
",",
"backend",
"=",
"'vectorized'",
",",
"specified_drift_arrays",
"=",
"None",
")",
":",
"if",
"self",
".",
"verbose",
":",
"print",
"(",
"\"Executin... | Calculates a kriged grid and the associated variance.
Includes drift terms.
This is now the method that performs the main kriging calculation.
Note that currently measurements (i.e., z values) are considered
'exact'. This means that, when a specified coordinate for interpolation
... | [
"Calculates",
"a",
"kriged",
"grid",
"and",
"the",
"associated",
"variance",
".",
"Includes",
"drift",
"terms",
".",
"This",
"is",
"now",
"the",
"method",
"that",
"performs",
"the",
"main",
"kriging",
"calculation",
".",
"Note",
"that",
"currently",
"measureme... | python | train |
DAI-Lab/Copulas | copulas/multivariate/vine.py | https://github.com/DAI-Lab/Copulas/blob/821df61c3d36a6b81ef2883935f935c2eaaa862c/copulas/multivariate/vine.py#L82-L107 | def fit(self, X, truncated=3):
"""Fit a vine model to the data.
Args:
X(numpy.ndarray): data to be fitted.
truncated(int): max level to build the vine.
"""
self.n_sample, self.n_var = X.shape
self.columns = X.columns
self.tau_mat = X.corr(method='... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"truncated",
"=",
"3",
")",
":",
"self",
".",
"n_sample",
",",
"self",
".",
"n_var",
"=",
"X",
".",
"shape",
"self",
".",
"columns",
"=",
"X",
".",
"columns",
"self",
".",
"tau_mat",
"=",
"X",
".",
"cor... | Fit a vine model to the data.
Args:
X(numpy.ndarray): data to be fitted.
truncated(int): max level to build the vine. | [
"Fit",
"a",
"vine",
"model",
"to",
"the",
"data",
"."
] | python | train |
moonlitesolutions/SolrClient | SolrClient/helpers/reindexer.py | https://github.com/moonlitesolutions/SolrClient/blob/19c5280c9f8e97ee104d22ae883c4ccfd7c4f43b/SolrClient/helpers/reindexer.py#L99-L139 | def _from_solr(self, fq=[], report_frequency = 25):
'''
Method for retrieving batch data from Solr.
'''
cursor = '*'
stime = datetime.now()
query_count = 0
while True:
#Get data with starting cursorMark
query = self._get_query(curs... | [
"def",
"_from_solr",
"(",
"self",
",",
"fq",
"=",
"[",
"]",
",",
"report_frequency",
"=",
"25",
")",
":",
"cursor",
"=",
"'*'",
"stime",
"=",
"datetime",
".",
"now",
"(",
")",
"query_count",
"=",
"0",
"while",
"True",
":",
"#Get data with starting cursor... | Method for retrieving batch data from Solr. | [
"Method",
"for",
"retrieving",
"batch",
"data",
"from",
"Solr",
"."
] | python | train |
carlosp420/dataset-creator | dataset_creator/base_dataset.py | https://github.com/carlosp420/dataset-creator/blob/ea27340b145cb566a36c1836ff42263f1b2003a0/dataset_creator/base_dataset.py#L332-L344 | def make_slash_number(self):
"""
Charset lines have \2 or \3 depending on type of partitioning and codon
positions requested for our dataset.
:return:
"""
if self.partitioning == 'by codon position' and self.codon_positions == '1st-2nd':
return '\\2'
... | [
"def",
"make_slash_number",
"(",
"self",
")",
":",
"if",
"self",
".",
"partitioning",
"==",
"'by codon position'",
"and",
"self",
".",
"codon_positions",
"==",
"'1st-2nd'",
":",
"return",
"'\\\\2'",
"elif",
"self",
".",
"partitioning",
"in",
"[",
"'by codon posi... | Charset lines have \2 or \3 depending on type of partitioning and codon
positions requested for our dataset.
:return: | [
"Charset",
"lines",
"have",
"\\",
"2",
"or",
"\\",
"3",
"depending",
"on",
"type",
"of",
"partitioning",
"and",
"codon",
"positions",
"requested",
"for",
"our",
"dataset",
"."
] | python | train |
PyMySQL/Tornado-MySQL | tornado_mysql/converters.py | https://github.com/PyMySQL/Tornado-MySQL/blob/75d3466e4332e43b2bf853799f1122dec5da60bc/tornado_mysql/converters.py#L98-L129 | def convert_datetime(obj):
"""Returns a DATETIME or TIMESTAMP column value as a datetime object:
>>> datetime_or_None('2007-02-25 23:06:20')
datetime.datetime(2007, 2, 25, 23, 6, 20)
>>> datetime_or_None('2007-02-25T23:06:20')
datetime.datetime(2007, 2, 25, 23, 6, 20)
Illegal values ar... | [
"def",
"convert_datetime",
"(",
"obj",
")",
":",
"if",
"' '",
"in",
"obj",
":",
"sep",
"=",
"' '",
"elif",
"'T'",
"in",
"obj",
":",
"sep",
"=",
"'T'",
"else",
":",
"return",
"convert_date",
"(",
"obj",
")",
"try",
":",
"ymd",
",",
"hms",
"=",
"ob... | Returns a DATETIME or TIMESTAMP column value as a datetime object:
>>> datetime_or_None('2007-02-25 23:06:20')
datetime.datetime(2007, 2, 25, 23, 6, 20)
>>> datetime_or_None('2007-02-25T23:06:20')
datetime.datetime(2007, 2, 25, 23, 6, 20)
Illegal values are returned as None:
>>> dat... | [
"Returns",
"a",
"DATETIME",
"or",
"TIMESTAMP",
"column",
"value",
"as",
"a",
"datetime",
"object",
":"
] | python | train |
tanghaibao/jcvi | jcvi/formats/sbt.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/formats/sbt.py#L108-L182 | def names(args):
"""
%prog names namelist templatefile
Generate name blocks from the `namelist` file. The `namelist` file is
tab-delimited that contains >=4 columns of data. Three columns are mandatory.
First name, middle initial and last name. First row is table header. For the
extra columns, ... | [
"def",
"names",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"names",
".",
"__doc__",
")",
"opts",
",",
"args",
"=",
"p",
".",
"parse_args",
"(",
"args",
")",
"if",
"len",
"(",
"args",
")",
"!=",
"2",
":",
"sys",
".",
"exit",
"(",
"p",... | %prog names namelist templatefile
Generate name blocks from the `namelist` file. The `namelist` file is
tab-delimited that contains >=4 columns of data. Three columns are mandatory.
First name, middle initial and last name. First row is table header. For the
extra columns, the first column will go in t... | [
"%prog",
"names",
"namelist",
"templatefile"
] | python | train |
devassistant/devassistant | devassistant/gui/gui_helper.py | https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/gui/gui_helper.py#L78-L95 | def button_with_image(self, description, image=None, sensitive=True):
"""
The function creates a button with image
"""
btn = self.create_button()
btn.set_sensitive(sensitive)
h_box = self.create_box()
try:
img = self.create_image(image_name=image,
... | [
"def",
"button_with_image",
"(",
"self",
",",
"description",
",",
"image",
"=",
"None",
",",
"sensitive",
"=",
"True",
")",
":",
"btn",
"=",
"self",
".",
"create_button",
"(",
")",
"btn",
".",
"set_sensitive",
"(",
"sensitive",
")",
"h_box",
"=",
"self",... | The function creates a button with image | [
"The",
"function",
"creates",
"a",
"button",
"with",
"image"
] | python | train |
Vital-Fernandez/dazer | bin/lib/CodeTools/various.py | https://github.com/Vital-Fernandez/dazer/blob/3c9ae8ae6d40ea33f22cc20dc11365d6d6e65244/bin/lib/CodeTools/various.py#L75-L77 | def ufloatDict_nominal(self, ufloat_dict):
'This gives us a dictionary of nominal values from a dictionary of uncertainties'
return OrderedDict(izip(ufloat_dict.keys(), map(lambda x: x.nominal_value, ufloat_dict.values()))) | [
"def",
"ufloatDict_nominal",
"(",
"self",
",",
"ufloat_dict",
")",
":",
"return",
"OrderedDict",
"(",
"izip",
"(",
"ufloat_dict",
".",
"keys",
"(",
")",
",",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"nominal_value",
",",
"ufloat_dict",
".",
"values",
"(... | This gives us a dictionary of nominal values from a dictionary of uncertainties | [
"This",
"gives",
"us",
"a",
"dictionary",
"of",
"nominal",
"values",
"from",
"a",
"dictionary",
"of",
"uncertainties"
] | python | train |
manns/pyspread | pyspread/src/gui/_grid_renderer.py | https://github.com/manns/pyspread/blob/0e2fd44c2e0f06605efc3058c20a43a8c1f9e7e0/pyspread/src/gui/_grid_renderer.py#L301-L365 | def Draw(self, grid, attr, dc, rect, row, col, isSelected):
"""Draws the cell border and content using pycairo"""
key = row, col, grid.current_table
# If cell is merge draw the merging cell if invisibile
if grid.code_array.cell_attributes[key]["merge_area"]:
key = self.get_... | [
"def",
"Draw",
"(",
"self",
",",
"grid",
",",
"attr",
",",
"dc",
",",
"rect",
",",
"row",
",",
"col",
",",
"isSelected",
")",
":",
"key",
"=",
"row",
",",
"col",
",",
"grid",
".",
"current_table",
"# If cell is merge draw the merging cell if invisibile",
"... | Draws the cell border and content using pycairo | [
"Draws",
"the",
"cell",
"border",
"and",
"content",
"using",
"pycairo"
] | python | train |
randomdude999/rule_n | rule_n.py | https://github.com/randomdude999/rule_n/blob/4d8d72e71a9f1eaacb193d5b4383fba9f8cf67a6/rule_n.py#L206-L231 | def process(self, state):
"""Process a state and return the next state
Usage:
out = rule_110.process([True, False, True])
len(out) # 5, because a False is added to either side
out == [True, True, True, True, False]
out = rule_110.process([False, True, False, True])
len(out) # still 5, bec... | [
"def",
"process",
"(",
"self",
",",
"state",
")",
":",
"if",
"not",
"isinstance",
"(",
"state",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"\"state must be list\"",
")",
"if",
"self",
".",
"finite_canvas",
":",
"state",
"=",
"_crop_list_to_size",
"(... | Process a state and return the next state
Usage:
out = rule_110.process([True, False, True])
len(out) # 5, because a False is added to either side
out == [True, True, True, True, False]
out = rule_110.process([False, True, False, True])
len(out) # still 5, because leading / trailing False's are r... | [
"Process",
"a",
"state",
"and",
"return",
"the",
"next",
"state",
"Usage",
":"
] | python | train |
apetrynet/pyfilemail | pyfilemail/transfer.py | https://github.com/apetrynet/pyfilemail/blob/eb81b0e69ff42f4335d5298833e4769b750bf397/pyfilemail/transfer.py#L523-L550 | def rename_file(self, fmfile, newname):
"""Rename file in transfer.
:param fmfile: file data from filemail containing fileid
:param newname: new file name
:type fmfile: ``dict``
:type newname: ``str`` or ``unicode``
:rtype: ``bool``
"""
if not isinstance... | [
"def",
"rename_file",
"(",
"self",
",",
"fmfile",
",",
"newname",
")",
":",
"if",
"not",
"isinstance",
"(",
"fmfile",
",",
"dict",
")",
":",
"raise",
"FMBaseError",
"(",
"'fmfile must be a <dict>'",
")",
"method",
",",
"url",
"=",
"get_URL",
"(",
"'file_re... | Rename file in transfer.
:param fmfile: file data from filemail containing fileid
:param newname: new file name
:type fmfile: ``dict``
:type newname: ``str`` or ``unicode``
:rtype: ``bool`` | [
"Rename",
"file",
"in",
"transfer",
"."
] | python | train |
nilp0inter/cpe | cpe/comp/cpecomp_simple.py | https://github.com/nilp0inter/cpe/blob/670d947472a7652af5149324977b50f9a7af9bcf/cpe/comp/cpecomp_simple.py#L184-L195 | def _is_valid_language(self):
"""
Return True if the value of component in attribute "language" is valid,
and otherwise False.
:returns: True if value is valid, False otherwise
:rtype: boolean
"""
comp_str = self._encoded_value.lower()
lang_rxc = re.comp... | [
"def",
"_is_valid_language",
"(",
"self",
")",
":",
"comp_str",
"=",
"self",
".",
"_encoded_value",
".",
"lower",
"(",
")",
"lang_rxc",
"=",
"re",
".",
"compile",
"(",
"CPEComponentSimple",
".",
"_LANGTAG_PATTERN",
")",
"return",
"lang_rxc",
".",
"match",
"(... | Return True if the value of component in attribute "language" is valid,
and otherwise False.
:returns: True if value is valid, False otherwise
:rtype: boolean | [
"Return",
"True",
"if",
"the",
"value",
"of",
"component",
"in",
"attribute",
"language",
"is",
"valid",
"and",
"otherwise",
"False",
"."
] | python | train |
transifex/transifex-python-library | txlib/http/auth.py | https://github.com/transifex/transifex-python-library/blob/9fea86b718973de35ccca6d54bd1f445c9632406/txlib/http/auth.py#L74-L86 | def populate_request_data(self, request_args):
"""Add the authentication info to the supplied dictionary.
We use the `requests.HTTPBasicAuth` class as the `auth` param.
Args:
`request_args`: The arguments that will be passed to the request.
Returns:
The updated ... | [
"def",
"populate_request_data",
"(",
"self",
",",
"request_args",
")",
":",
"request_args",
"[",
"'auth'",
"]",
"=",
"HTTPBasicAuth",
"(",
"self",
".",
"_username",
",",
"self",
".",
"_password",
")",
"return",
"request_args"
] | Add the authentication info to the supplied dictionary.
We use the `requests.HTTPBasicAuth` class as the `auth` param.
Args:
`request_args`: The arguments that will be passed to the request.
Returns:
The updated arguments for the request. | [
"Add",
"the",
"authentication",
"info",
"to",
"the",
"supplied",
"dictionary",
"."
] | python | train |
bastikr/boolean.py | boolean/boolean.py | https://github.com/bastikr/boolean.py/blob/e984df480afc60605e9501a0d3d54d667e8f7dbf/boolean/boolean.py#L483-L503 | def _rdistributive(self, expr, op_example):
"""
Recursively flatten the `expr` expression for the `op_example`
AND or OR operation instance exmaple.
"""
if expr.isliteral:
return expr
expr_class = expr.__class__
args = (self._rdistributive(arg, op_ex... | [
"def",
"_rdistributive",
"(",
"self",
",",
"expr",
",",
"op_example",
")",
":",
"if",
"expr",
".",
"isliteral",
":",
"return",
"expr",
"expr_class",
"=",
"expr",
".",
"__class__",
"args",
"=",
"(",
"self",
".",
"_rdistributive",
"(",
"arg",
",",
"op_exam... | Recursively flatten the `expr` expression for the `op_example`
AND or OR operation instance exmaple. | [
"Recursively",
"flatten",
"the",
"expr",
"expression",
"for",
"the",
"op_example",
"AND",
"or",
"OR",
"operation",
"instance",
"exmaple",
"."
] | python | train |
bhmm/bhmm | bhmm/hmm/generic_hmm.py | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/hmm/generic_hmm.py#L398-L431 | def collect_observations_in_state(self, observations, state_index):
# TODO: this would work well in a subclass with data
"""Collect a vector of all observations belonging to a specified hidden state.
Parameters
----------
observations : list of numpy.array
List of ob... | [
"def",
"collect_observations_in_state",
"(",
"self",
",",
"observations",
",",
"state_index",
")",
":",
"# TODO: this would work well in a subclass with data",
"if",
"not",
"self",
".",
"hidden_state_trajectories",
":",
"raise",
"RuntimeError",
"(",
"'HMM model does not have ... | Collect a vector of all observations belonging to a specified hidden state.
Parameters
----------
observations : list of numpy.array
List of observed trajectories.
state_index : int
The index of the hidden state for which corresponding observations are to be retr... | [
"Collect",
"a",
"vector",
"of",
"all",
"observations",
"belonging",
"to",
"a",
"specified",
"hidden",
"state",
"."
] | python | train |
wummel/linkchecker | doc/examples/filter_xml_output.py | https://github.com/wummel/linkchecker/blob/c2ce810c3fb00b895a841a7be6b2e78c64e7b042/doc/examples/filter_xml_output.py#L35-L45 | def filter_tree(tree):
"""Filter all 401 errors."""
to_remove = []
for elem in tree.findall('urldata'):
valid = elem.find('valid')
if valid is not None and valid.text == '0' and \
valid.attrib.get('result', '').startswith('401'):
to_remove.append(elem)
root = tree.... | [
"def",
"filter_tree",
"(",
"tree",
")",
":",
"to_remove",
"=",
"[",
"]",
"for",
"elem",
"in",
"tree",
".",
"findall",
"(",
"'urldata'",
")",
":",
"valid",
"=",
"elem",
".",
"find",
"(",
"'valid'",
")",
"if",
"valid",
"is",
"not",
"None",
"and",
"va... | Filter all 401 errors. | [
"Filter",
"all",
"401",
"errors",
"."
] | python | train |
Microsoft/ApplicationInsights-Python | applicationinsights/channel/contracts/Location.py | https://github.com/Microsoft/ApplicationInsights-Python/blob/8452ab7126f9bb6964637d4aa1258c2af17563d6/applicationinsights/channel/contracts/Location.py#L31-L40 | def ip(self, value):
"""The ip property.
Args:
value (string). the property value.
"""
if value == self._defaults['ai.location.ip'] and 'ai.location.ip' in self._values:
del self._values['ai.location.ip']
else:
self._values['ai.locatio... | [
"def",
"ip",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"self",
".",
"_defaults",
"[",
"'ai.location.ip'",
"]",
"and",
"'ai.location.ip'",
"in",
"self",
".",
"_values",
":",
"del",
"self",
".",
"_values",
"[",
"'ai.location.ip'",
"]",
"els... | The ip property.
Args:
value (string). the property value. | [
"The",
"ip",
"property",
".",
"Args",
":",
"value",
"(",
"string",
")",
".",
"the",
"property",
"value",
"."
] | python | train |
aiogram/aiogram | aiogram/types/message.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/message.py#L252-L263 | def url(self) -> str:
"""
Get URL for the message
:return: str
"""
if self.chat.type not in [ChatType.SUPER_GROUP, ChatType.CHANNEL]:
raise TypeError('Invalid chat type!')
elif not self.chat.username:
raise TypeError('This chat does not have @user... | [
"def",
"url",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"chat",
".",
"type",
"not",
"in",
"[",
"ChatType",
".",
"SUPER_GROUP",
",",
"ChatType",
".",
"CHANNEL",
"]",
":",
"raise",
"TypeError",
"(",
"'Invalid chat type!'",
")",
"elif",
"not"... | Get URL for the message
:return: str | [
"Get",
"URL",
"for",
"the",
"message"
] | python | train |
googleapis/google-cloud-python | storage/google/cloud/storage/notification.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/storage/google/cloud/storage/notification.py#L291-L321 | def reload(self, client=None):
"""Update this notification from the server configuration.
See:
https://cloud.google.com/storage/docs/json_api/v1/notifications/get
If :attr:`user_project` is set on the bucket, bills the API request
to that project.
:type client: :class:... | [
"def",
"reload",
"(",
"self",
",",
"client",
"=",
"None",
")",
":",
"if",
"self",
".",
"notification_id",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Notification not intialized by server\"",
")",
"client",
"=",
"self",
".",
"_require_client",
"(",
"clie... | Update this notification from the server configuration.
See:
https://cloud.google.com/storage/docs/json_api/v1/notifications/get
If :attr:`user_project` is set on the bucket, bills the API request
to that project.
:type client: :class:`~google.cloud.storage.client.Client` or
... | [
"Update",
"this",
"notification",
"from",
"the",
"server",
"configuration",
"."
] | python | train |
ubyssey/dispatch | dispatch/modules/content/mixins.py | https://github.com/ubyssey/dispatch/blob/8da6084fe61726f20e9cf675190480cfc45ee764/dispatch/modules/content/mixins.py#L27-L49 | def get_author_string(self, links=False):
saved_args = locals()
saved_args = saved_args['links']
"""Returns list of authors as a comma-separated
string (with 'and' before last author)."""
def format_author(author):
if links and author.person.slug:
ret... | [
"def",
"get_author_string",
"(",
"self",
",",
"links",
"=",
"False",
")",
":",
"saved_args",
"=",
"locals",
"(",
")",
"saved_args",
"=",
"saved_args",
"[",
"'links'",
"]",
"def",
"format_author",
"(",
"author",
")",
":",
"if",
"links",
"and",
"author",
"... | Returns list of authors as a comma-separated
string (with 'and' before last author). | [
"Returns",
"list",
"of",
"authors",
"as",
"a",
"comma",
"-",
"separated",
"string",
"(",
"with",
"and",
"before",
"last",
"author",
")",
"."
] | python | test |
StackStorm/pybind | pybind/nos/v6_0_2f/qos/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/qos/__init__.py#L164-L185 | def _set_queue(self, v, load=False):
"""
Setter method for queue, mapped from YANG variable /qos/queue (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_queue is considered as a private
method. Backends looking to populate this variable should
do so via... | [
"def",
"_set_queue",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"base",
... | Setter method for queue, mapped from YANG variable /qos/queue (container)
If this variable is read-only (config: false) in the
source YANG file, then _set_queue is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._set_queue() directly. | [
"Setter",
"method",
"for",
"queue",
"mapped",
"from",
"YANG",
"variable",
"/",
"qos",
"/",
"queue",
"(",
"container",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"YANG",
"file",
"th... | python | train |
log2timeline/dfvfs | dfvfs/file_io/gzip_file_io.py | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/file_io/gzip_file_io.py#L117-L144 | def read(self, size=None):
"""Reads a byte string from the gzip file at the current offset.
The function will read a byte string up to the specified size or
all of the remaining data if no size was specified.
Args:
size (Optional[int]): number of bytes to read, where None is all
remain... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"data",
"=",
"b''",
"while",
"(",
"(",
"size",
"and",
"len",
"(",
"data",
")",
"<",
"size",
")",
"and",
"self",
".",
"_current_offset",
"<",
"self",
".",
"uncompressed_data_size",
")",
... | Reads a byte string from the gzip file at the current offset.
The function will read a byte string up to the specified size or
all of the remaining data if no size was specified.
Args:
size (Optional[int]): number of bytes to read, where None is all
remaining data.
Returns:
byte... | [
"Reads",
"a",
"byte",
"string",
"from",
"the",
"gzip",
"file",
"at",
"the",
"current",
"offset",
"."
] | python | train |
jason-weirather/py-seq-tools | seqtools/graph/__init__.py | https://github.com/jason-weirather/py-seq-tools/blob/f642c2c73ffef2acc83656a78059a476fc734ca1/seqtools/graph/__init__.py#L57-L66 | def get_root_graph(self,root):
"""Return back a graph containing just the root and children"""
children = self.get_children(root)
g = Graph()
nodes = [root]+children
for node in nodes: g.add_node(node)
node_ids = [x.id for x in nodes]
edges = [x for x in self._edges.values() if... | [
"def",
"get_root_graph",
"(",
"self",
",",
"root",
")",
":",
"children",
"=",
"self",
".",
"get_children",
"(",
"root",
")",
"g",
"=",
"Graph",
"(",
")",
"nodes",
"=",
"[",
"root",
"]",
"+",
"children",
"for",
"node",
"in",
"nodes",
":",
"g",
".",
... | Return back a graph containing just the root and children | [
"Return",
"back",
"a",
"graph",
"containing",
"just",
"the",
"root",
"and",
"children"
] | python | train |
itamarst/eliot | eliot/_traceback.py | https://github.com/itamarst/eliot/blob/c03c96520c5492fadfc438b4b0f6336e2785ba2d/eliot/_traceback.py#L101-L126 | def writeFailure(failure, logger=None):
"""
Write a L{twisted.python.failure.Failure} to the log.
This is for situations where you got an unexpected exception and want to
log a traceback. For example, if you have C{Deferred} that might error,
you'll want to wrap it with a L{eliot.twisted.DeferredCo... | [
"def",
"writeFailure",
"(",
"failure",
",",
"logger",
"=",
"None",
")",
":",
"# Failure.getBriefTraceback does not include source code, so does not do",
"# I/O.",
"_writeTracebackMessage",
"(",
"logger",
",",
"failure",
".",
"value",
".",
"__class__",
",",
"failure",
".... | Write a L{twisted.python.failure.Failure} to the log.
This is for situations where you got an unexpected exception and want to
log a traceback. For example, if you have C{Deferred} that might error,
you'll want to wrap it with a L{eliot.twisted.DeferredContext} and then add
C{writeFailure} as the error... | [
"Write",
"a",
"L",
"{",
"twisted",
".",
"python",
".",
"failure",
".",
"Failure",
"}",
"to",
"the",
"log",
"."
] | python | train |
svenkreiss/pysparkling | pysparkling/streaming/context.py | https://github.com/svenkreiss/pysparkling/blob/596d0ef2793100f7115efe228ff9bfc17beaa08d/pysparkling/streaming/context.py#L208-L221 | def stop(self, stopSparkContext=True, stopGraceFully=False):
"""Stop processing streams.
:param stopSparkContext: stop the SparkContext (NOT IMPLEMENTED)
:param stopGracefully: stop gracefully (NOT IMPLEMENTED)
"""
while self._on_stop_cb:
cb = self._on_stop_cb.pop()
... | [
"def",
"stop",
"(",
"self",
",",
"stopSparkContext",
"=",
"True",
",",
"stopGraceFully",
"=",
"False",
")",
":",
"while",
"self",
".",
"_on_stop_cb",
":",
"cb",
"=",
"self",
".",
"_on_stop_cb",
".",
"pop",
"(",
")",
"log",
".",
"debug",
"(",
"'calling ... | Stop processing streams.
:param stopSparkContext: stop the SparkContext (NOT IMPLEMENTED)
:param stopGracefully: stop gracefully (NOT IMPLEMENTED) | [
"Stop",
"processing",
"streams",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/parallel/controller/heartmonitor.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/parallel/controller/heartmonitor.py#L153-L166 | def handle_pong(self, msg):
"a heart just beat"
current = str_to_bytes(str(self.lifetime))
last = str_to_bytes(str(self.last_ping))
if msg[1] == current:
delta = time.time()-self.tic
# self.log.debug("heartbeat::heart %r took %.2f ms to respond"%(msg[0], 1000*delt... | [
"def",
"handle_pong",
"(",
"self",
",",
"msg",
")",
":",
"current",
"=",
"str_to_bytes",
"(",
"str",
"(",
"self",
".",
"lifetime",
")",
")",
"last",
"=",
"str_to_bytes",
"(",
"str",
"(",
"self",
".",
"last_ping",
")",
")",
"if",
"msg",
"[",
"1",
"]... | a heart just beat | [
"a",
"heart",
"just",
"beat"
] | python | test |
ayust/kitnirc | kitnirc/client.py | https://github.com/ayust/kitnirc/blob/cf19fe39219da75f053e1a3976bf21331b6fefea/kitnirc/client.py#L332-L341 | def send(self, *args):
"""Sends a single raw message to the IRC server.
Arguments are automatically joined by spaces. No newlines are allowed.
"""
msg = " ".join(a.nick if isinstance(a, User) else str(a) for a in args)
if "\n" in msg:
raise ValueError("Cannot send() ... | [
"def",
"send",
"(",
"self",
",",
"*",
"args",
")",
":",
"msg",
"=",
"\" \"",
".",
"join",
"(",
"a",
".",
"nick",
"if",
"isinstance",
"(",
"a",
",",
"User",
")",
"else",
"str",
"(",
"a",
")",
"for",
"a",
"in",
"args",
")",
"if",
"\"\\n\"",
"in... | Sends a single raw message to the IRC server.
Arguments are automatically joined by spaces. No newlines are allowed. | [
"Sends",
"a",
"single",
"raw",
"message",
"to",
"the",
"IRC",
"server",
"."
] | python | train |
brocade/pynos | pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_6/ver_6_0_1/yang/brocade_fcoe_ext.py#L481-L495 | def fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_tx_accepts(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
fcoe_get_interface = ET.Element("fcoe_get_interface")
config = fcoe_get_interface
output = ET.SubElement(fcoe_get_interface, "output... | [
"def",
"fcoe_get_interface_output_fcoe_intf_list_fcoe_intf_tx_accepts",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"fcoe_get_interface",
"=",
"ET",
".",
"Element",
"(",
"\"fcoe_get_interface\"",
")",
... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train |
molmod/molmod | molmod/zmatrix.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/zmatrix.py#L89-L118 | def _get_new_ref(self, existing_refs):
"""Get a new reference atom for a row in the ZMatrix
The reference atoms should obey the following conditions:
- They must be different
- They must be neighbours in the bond graph
- They must have an index lower than the c... | [
"def",
"_get_new_ref",
"(",
"self",
",",
"existing_refs",
")",
":",
"# ref0 is the atom whose position is defined by the current row in the",
"# zmatrix.",
"ref0",
"=",
"existing_refs",
"[",
"0",
"]",
"for",
"ref",
"in",
"existing_refs",
":",
"# try to find a neighbor of th... | Get a new reference atom for a row in the ZMatrix
The reference atoms should obey the following conditions:
- They must be different
- They must be neighbours in the bond graph
- They must have an index lower than the current atom
If multiple candidate refs... | [
"Get",
"a",
"new",
"reference",
"atom",
"for",
"a",
"row",
"in",
"the",
"ZMatrix"
] | python | train |
althonos/moclo | moclo/moclo/core/parts.py | https://github.com/althonos/moclo/blob/28a03748df8a2fa43f0c0c8098ca64d11559434e/moclo/moclo/core/parts.py#L102-L112 | def characterize(cls, record):
"""Load the record in a concrete subclass of this type.
"""
classes = list(cls.__subclasses__())
if not isabstract(cls):
classes.append(cls)
for subclass in classes:
entity = subclass(record)
if entity.is_valid():... | [
"def",
"characterize",
"(",
"cls",
",",
"record",
")",
":",
"classes",
"=",
"list",
"(",
"cls",
".",
"__subclasses__",
"(",
")",
")",
"if",
"not",
"isabstract",
"(",
"cls",
")",
":",
"classes",
".",
"append",
"(",
"cls",
")",
"for",
"subclass",
"in",... | Load the record in a concrete subclass of this type. | [
"Load",
"the",
"record",
"in",
"a",
"concrete",
"subclass",
"of",
"this",
"type",
"."
] | python | train |
osrg/ryu | ryu/services/protocols/bgp/utils/bgp.py | https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/services/protocols/bgp/utils/bgp.py#L204-L229 | def create_v4flowspec_actions(actions=None):
"""
Create list of traffic filtering actions
for Ipv4 Flow Specification and VPNv4 Flow Specification.
`` actions`` specifies Traffic Filtering Actions of
Flow Specification as a dictionary type value.
Returns a list of extended community values.
... | [
"def",
"create_v4flowspec_actions",
"(",
"actions",
"=",
"None",
")",
":",
"from",
"ryu",
".",
"services",
".",
"protocols",
".",
"bgp",
".",
"api",
".",
"prefix",
"import",
"(",
"FLOWSPEC_ACTION_TRAFFIC_RATE",
",",
"FLOWSPEC_ACTION_TRAFFIC_ACTION",
",",
"FLOWSPEC... | Create list of traffic filtering actions
for Ipv4 Flow Specification and VPNv4 Flow Specification.
`` actions`` specifies Traffic Filtering Actions of
Flow Specification as a dictionary type value.
Returns a list of extended community values. | [
"Create",
"list",
"of",
"traffic",
"filtering",
"actions",
"for",
"Ipv4",
"Flow",
"Specification",
"and",
"VPNv4",
"Flow",
"Specification",
"."
] | python | train |
danilobellini/audiolazy | audiolazy/lazy_math.py | https://github.com/danilobellini/audiolazy/blob/dba0a278937909980ed40b976d866b8e97c35dee/audiolazy/lazy_math.py#L95-L109 | def factorial(n):
"""
Factorial function that works with really big numbers.
"""
if isinstance(n, float):
if n.is_integer():
n = int(n)
if not isinstance(n, INT_TYPES):
raise TypeError("Non-integer input (perhaps you need Euler Gamma "
"function or Gauss Pi function)")
if n... | [
"def",
"factorial",
"(",
"n",
")",
":",
"if",
"isinstance",
"(",
"n",
",",
"float",
")",
":",
"if",
"n",
".",
"is_integer",
"(",
")",
":",
"n",
"=",
"int",
"(",
"n",
")",
"if",
"not",
"isinstance",
"(",
"n",
",",
"INT_TYPES",
")",
":",
"raise",... | Factorial function that works with really big numbers. | [
"Factorial",
"function",
"that",
"works",
"with",
"really",
"big",
"numbers",
"."
] | python | train |
SoCo/SoCo | soco/snapshot.py | https://github.com/SoCo/SoCo/blob/671937e07d7973b78c0cbee153d4f3ad68ec48c6/soco/snapshot.py#L276-L291 | def _restore_queue(self):
"""Restore the previous state of the queue.
Note:
The restore currently adds the items back into the queue
using the URI, for items the Sonos system already knows about
this is OK, but for other items, they may be missing some of
... | [
"def",
"_restore_queue",
"(",
"self",
")",
":",
"if",
"self",
".",
"queue",
"is",
"not",
"None",
":",
"# Clear the queue so that it can be reset",
"self",
".",
"device",
".",
"clear_queue",
"(",
")",
"# Now loop around all the queue entries adding them",
"for",
"queue... | Restore the previous state of the queue.
Note:
The restore currently adds the items back into the queue
using the URI, for items the Sonos system already knows about
this is OK, but for other items, they may be missing some of
their metadata as it will not be aut... | [
"Restore",
"the",
"previous",
"state",
"of",
"the",
"queue",
"."
] | python | train |
optimizely/python-sdk | optimizely/decision_service.py | https://github.com/optimizely/python-sdk/blob/ec028d9efcf22498c3820f2650fa10f5c30bec90/optimizely/decision_service.py#L79-L103 | def get_stored_variation(self, experiment, user_profile):
""" Determine if the user has a stored variation available for the given experiment and return that.
Args:
experiment: Object representing the experiment for which user is to be bucketed.
user_profile: UserProfile object representing the use... | [
"def",
"get_stored_variation",
"(",
"self",
",",
"experiment",
",",
"user_profile",
")",
":",
"user_id",
"=",
"user_profile",
".",
"user_id",
"variation_id",
"=",
"user_profile",
".",
"get_variation_for_experiment",
"(",
"experiment",
".",
"id",
")",
"if",
"variat... | Determine if the user has a stored variation available for the given experiment and return that.
Args:
experiment: Object representing the experiment for which user is to be bucketed.
user_profile: UserProfile object representing the user's profile.
Returns:
Variation if available. None othe... | [
"Determine",
"if",
"the",
"user",
"has",
"a",
"stored",
"variation",
"available",
"for",
"the",
"given",
"experiment",
"and",
"return",
"that",
"."
] | python | train |
gawel/irc3 | irc3/base.py | https://github.com/gawel/irc3/blob/cd27840a5809a1f803dc620860fe75d83d2a2ec8/irc3/base.py#L230-L262 | def reload(self, *modules):
"""Reload one or more plugins"""
self.notify('before_reload')
if 'configfiles' in self.config:
# reload configfiles
self.log.info('Reloading configuration...')
cfg = utils.parse_config(
self.server and 'server' or '... | [
"def",
"reload",
"(",
"self",
",",
"*",
"modules",
")",
":",
"self",
".",
"notify",
"(",
"'before_reload'",
")",
"if",
"'configfiles'",
"in",
"self",
".",
"config",
":",
"# reload configfiles",
"self",
".",
"log",
".",
"info",
"(",
"'Reloading configuration.... | Reload one or more plugins | [
"Reload",
"one",
"or",
"more",
"plugins"
] | python | train |
spyder-ide/spyder | spyder/plugins/editor/widgets/base.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/editor/widgets/base.py#L1168-L1190 | def mousePressEvent(self, event):
"""Reimplement Qt method"""
if sys.platform.startswith('linux') and event.button() == Qt.MidButton:
self.calltip_widget.hide()
self.setFocus()
event = QMouseEvent(QEvent.MouseButtonPress, event.pos(),
... | [
"def",
"mousePressEvent",
"(",
"self",
",",
"event",
")",
":",
"if",
"sys",
".",
"platform",
".",
"startswith",
"(",
"'linux'",
")",
"and",
"event",
".",
"button",
"(",
")",
"==",
"Qt",
".",
"MidButton",
":",
"self",
".",
"calltip_widget",
".",
"hide",... | Reimplement Qt method | [
"Reimplement",
"Qt",
"method"
] | python | train |
boriel/zxbasic | arch/zx48k/backend/__init__.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/arch/zx48k/backend/__init__.py#L1433-L1457 | def _call(ins):
""" Calls a function XXXX (or address XXXX)
2nd parameter contains size of the returning result if any, and will be
pushed onto the stack.
"""
output = []
output.append('call %s' % str(ins.quad[1]))
try:
val = int(ins.quad[2])
if val == 1:
output.... | [
"def",
"_call",
"(",
"ins",
")",
":",
"output",
"=",
"[",
"]",
"output",
".",
"append",
"(",
"'call %s'",
"%",
"str",
"(",
"ins",
".",
"quad",
"[",
"1",
"]",
")",
")",
"try",
":",
"val",
"=",
"int",
"(",
"ins",
".",
"quad",
"[",
"2",
"]",
"... | Calls a function XXXX (or address XXXX)
2nd parameter contains size of the returning result if any, and will be
pushed onto the stack. | [
"Calls",
"a",
"function",
"XXXX",
"(",
"or",
"address",
"XXXX",
")",
"2nd",
"parameter",
"contains",
"size",
"of",
"the",
"returning",
"result",
"if",
"any",
"and",
"will",
"be",
"pushed",
"onto",
"the",
"stack",
"."
] | python | train |
StackStorm/pybind | pybind/nos/v6_0_2f/mac_group/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/nos/v6_0_2f/mac_group/__init__.py#L131-L152 | def _set_mac_group_entry(self, v, load=False):
"""
Setter method for mac_group_entry, mapped from YANG variable /mac_group/mac_group_entry (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_mac_group_entry is considered as a private
method. Backends looking to po... | [
"def",
"_set_mac_group_entry",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
... | Setter method for mac_group_entry, mapped from YANG variable /mac_group/mac_group_entry (list)
If this variable is read-only (config: false) in the
source YANG file, then _set_mac_group_entry is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._... | [
"Setter",
"method",
"for",
"mac_group_entry",
"mapped",
"from",
"YANG",
"variable",
"/",
"mac_group",
"/",
"mac_group_entry",
"(",
"list",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
"Y... | python | train |
aliyun/aliyun-odps-python-sdk | odps/lib/cloudpickle.py | https://github.com/aliyun/aliyun-odps-python-sdk/blob/4b0de18f5864386df6068f26f026e62f932c41e4/odps/lib/cloudpickle.py#L354-L363 | def save_module(self, obj):
"""
Save a module as an import
"""
self.modules.add(obj)
if _is_dynamic(obj):
self.save_reduce(dynamic_subimport, (obj.__name__, vars(obj)),
obj=obj)
else:
self.save_reduce(subimport, (obj.__... | [
"def",
"save_module",
"(",
"self",
",",
"obj",
")",
":",
"self",
".",
"modules",
".",
"add",
"(",
"obj",
")",
"if",
"_is_dynamic",
"(",
"obj",
")",
":",
"self",
".",
"save_reduce",
"(",
"dynamic_subimport",
",",
"(",
"obj",
".",
"__name__",
",",
"var... | Save a module as an import | [
"Save",
"a",
"module",
"as",
"an",
"import"
] | python | train |
klen/muffin-admin | muffin_admin/peewee.py | https://github.com/klen/muffin-admin/blob/404dc8e5107e943b7c42fa21c679c34ddb4de1d5/muffin_admin/peewee.py#L233-L235 | def filter_query(self, query, field, value):
"""Filter a query."""
return query.where(field ** "%{}%".format(value.lower())) | [
"def",
"filter_query",
"(",
"self",
",",
"query",
",",
"field",
",",
"value",
")",
":",
"return",
"query",
".",
"where",
"(",
"field",
"**",
"\"%{}%\"",
".",
"format",
"(",
"value",
".",
"lower",
"(",
")",
")",
")"
] | Filter a query. | [
"Filter",
"a",
"query",
"."
] | python | train |
databio/pypiper | pypiper/utils.py | https://github.com/databio/pypiper/blob/00e6c2b94033c4187d47ff14c5580bbfc2ff097f/pypiper/utils.py#L360-L370 | def is_in_file_tree(fpath, folder):
"""
Determine whether a file is in a folder.
:param str fpath: filepath to investigate
:param folder: path to folder to query
:return bool: whether the path indicated is in the folder indicated
"""
file_folder, _ = os.path.split(fpath)
other_folder = ... | [
"def",
"is_in_file_tree",
"(",
"fpath",
",",
"folder",
")",
":",
"file_folder",
",",
"_",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fpath",
")",
"other_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"folder",
",",
"\"\"",
")",
"return",
"other_... | Determine whether a file is in a folder.
:param str fpath: filepath to investigate
:param folder: path to folder to query
:return bool: whether the path indicated is in the folder indicated | [
"Determine",
"whether",
"a",
"file",
"is",
"in",
"a",
"folder",
"."
] | python | train |
meejah/txtorcon | txtorcon/addrmap.py | https://github.com/meejah/txtorcon/blob/14053b95adf0b4bd9dd9c317bece912a26578a93/txtorcon/addrmap.py#L37-L90 | def update(self, *args):
"""
deals with an update from Tor; see parsing logic in torcontroller
"""
gmtexpires = None
(name, ip, expires) = args[:3]
for arg in args:
if arg.lower().startswith('expires='):
gmtexpires = arg[8:]
if gmtex... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
")",
":",
"gmtexpires",
"=",
"None",
"(",
"name",
",",
"ip",
",",
"expires",
")",
"=",
"args",
"[",
":",
"3",
"]",
"for",
"arg",
"in",
"args",
":",
"if",
"arg",
".",
"lower",
"(",
")",
".",
"sta... | deals with an update from Tor; see parsing logic in torcontroller | [
"deals",
"with",
"an",
"update",
"from",
"Tor",
";",
"see",
"parsing",
"logic",
"in",
"torcontroller"
] | python | train |
computational-metabolomics/msp2db | msp2db/utils.py | https://github.com/computational-metabolomics/msp2db/blob/f86f01efca26fd2745547c9993f97337c6bef123/msp2db/utils.py#L6-L28 | def get_precursor_mz(exact_mass, precursor_type):
""" Calculate precursor mz based on exact mass and precursor type
Args:
exact_mass (float): exact mass of compound of interest
precursor_type (str): Precursor type (currently only works with '[M-H]-', '[M+H]+' and '[M+H-H2O]+'
Return:
... | [
"def",
"get_precursor_mz",
"(",
"exact_mass",
",",
"precursor_type",
")",
":",
"# these are just taken from what was present in the massbank .msp file for those missing the exact mass",
"d",
"=",
"{",
"'[M-H]-'",
":",
"-",
"1.007276",
",",
"'[M+H]+'",
":",
"1.007276",
",",
... | Calculate precursor mz based on exact mass and precursor type
Args:
exact_mass (float): exact mass of compound of interest
precursor_type (str): Precursor type (currently only works with '[M-H]-', '[M+H]+' and '[M+H-H2O]+'
Return:
neutral mass of compound | [
"Calculate",
"precursor",
"mz",
"based",
"on",
"exact",
"mass",
"and",
"precursor",
"type"
] | python | train |
joke2k/faker | faker/providers/company/fr_FR/__init__.py | https://github.com/joke2k/faker/blob/965824b61132e52d92d1a6ce470396dbbe01c96c/faker/providers/company/fr_FR/__init__.py#L97-L111 | def _is_catch_phrase_valid(self, catch_phrase):
"""
Validates a french catch phrase.
:param catch_phrase: The catch phrase to validate.
"""
for word in self.words_which_should_not_appear_twice:
# Fastest way to check if a piece of word does not appear twice.
... | [
"def",
"_is_catch_phrase_valid",
"(",
"self",
",",
"catch_phrase",
")",
":",
"for",
"word",
"in",
"self",
".",
"words_which_should_not_appear_twice",
":",
"# Fastest way to check if a piece of word does not appear twice.",
"begin_pos",
"=",
"catch_phrase",
".",
"find",
"(",... | Validates a french catch phrase.
:param catch_phrase: The catch phrase to validate. | [
"Validates",
"a",
"french",
"catch",
"phrase",
"."
] | python | train |
frejanordsiek/GeminiMotorDrive | GeminiMotorDrive/drivers.py | https://github.com/frejanordsiek/GeminiMotorDrive/blob/8de347ffb91228fbfe3832098b4996fa0141d8f1/GeminiMotorDrive/drivers.py#L529-L631 | def send_commands(self, commands, timeout=1.0,
max_retries=1, eor=('\n', '\n- ')):
""" Send a sequence of commands to the drive and collect output.
Takes a sequence of many commands and executes them one by one
till either all are executed or one runs out of retries
... | [
"def",
"send_commands",
"(",
"self",
",",
"commands",
",",
"timeout",
"=",
"1.0",
",",
"max_retries",
"=",
"1",
",",
"eor",
"=",
"(",
"'\\n'",
",",
"'\\n- '",
")",
")",
":",
"# If eor is not a list, make a list of it replicated enough for",
"# every command.",
"if... | Send a sequence of commands to the drive and collect output.
Takes a sequence of many commands and executes them one by one
till either all are executed or one runs out of retries
(`max_retries`). Retries are optionally performed if a command's
repsonse indicates that there was an error... | [
"Send",
"a",
"sequence",
"of",
"commands",
"to",
"the",
"drive",
"and",
"collect",
"output",
"."
] | python | train |
heitzmann/gdspy | gdspy/__init__.py | https://github.com/heitzmann/gdspy/blob/2c8d1313248c544e2066d19095b7ad7158c79bc9/gdspy/__init__.py#L2217-L2243 | def add(self, element):
"""
Add a new element or list of elements to this cell.
Parameters
----------
element : object, list
The element or list of elements to be inserted in this cell.
Returns
-------
out : ``Cell``
This cell.
... | [
"def",
"add",
"(",
"self",
",",
"element",
")",
":",
"if",
"isinstance",
"(",
"element",
",",
"list",
")",
":",
"for",
"e",
"in",
"element",
":",
"if",
"isinstance",
"(",
"e",
",",
"Label",
")",
":",
"self",
".",
"labels",
".",
"append",
"(",
"e"... | Add a new element or list of elements to this cell.
Parameters
----------
element : object, list
The element or list of elements to be inserted in this cell.
Returns
-------
out : ``Cell``
This cell. | [
"Add",
"a",
"new",
"element",
"or",
"list",
"of",
"elements",
"to",
"this",
"cell",
"."
] | python | train |
click-contrib/click-repl | click_repl/__init__.py | https://github.com/click-contrib/click-repl/blob/2d78dc520eb0bb5b813bad3b72344edbd22a7f4e/click_repl/__init__.py#L168-L257 | def repl( # noqa: C901
old_ctx,
prompt_kwargs=None,
allow_system_commands=True,
allow_internal_commands=True,
):
"""
Start an interactive shell. All subcommands are available in it.
:param old_ctx: The current Click context.
:param prompt_kwargs: Parameters passed to
:py:func:`... | [
"def",
"repl",
"(",
"# noqa: C901",
"old_ctx",
",",
"prompt_kwargs",
"=",
"None",
",",
"allow_system_commands",
"=",
"True",
",",
"allow_internal_commands",
"=",
"True",
",",
")",
":",
"# parent should be available, but we're not going to bother if not",
"group_ctx",
"=",... | Start an interactive shell. All subcommands are available in it.
:param old_ctx: The current Click context.
:param prompt_kwargs: Parameters passed to
:py:func:`prompt_toolkit.shortcuts.prompt`.
If stdin is not a TTY, no prompt will be printed, but only commands read
from stdin. | [
"Start",
"an",
"interactive",
"shell",
".",
"All",
"subcommands",
"are",
"available",
"in",
"it",
"."
] | python | train |
DataONEorg/d1_python | gmn/src/d1_gmn/app/revision.py | https://github.com/DataONEorg/d1_python/blob/3ac4d4f3ca052d3e8641a6a329cab526c8ddcb0d/gmn/src/d1_gmn/app/revision.py#L230-L246 | def _set_chain_sid(chain_model, sid):
"""Set or update SID for chain.
If the chain already has a SID, ``sid`` must either be None or match the existing
SID.
"""
if not sid:
return
if chain_model.sid and chain_model.sid.did != sid:
raise d1_common.types.exceptions.ServiceFailure... | [
"def",
"_set_chain_sid",
"(",
"chain_model",
",",
"sid",
")",
":",
"if",
"not",
"sid",
":",
"return",
"if",
"chain_model",
".",
"sid",
"and",
"chain_model",
".",
"sid",
".",
"did",
"!=",
"sid",
":",
"raise",
"d1_common",
".",
"types",
".",
"exceptions",
... | Set or update SID for chain.
If the chain already has a SID, ``sid`` must either be None or match the existing
SID. | [
"Set",
"or",
"update",
"SID",
"for",
"chain",
"."
] | python | train |
aws/sagemaker-python-sdk | src/sagemaker/logs.py | https://github.com/aws/sagemaker-python-sdk/blob/a9e724c7d3f5572b68c3903548c792a59d99799a/src/sagemaker/logs.py#L80-L113 | def multi_stream_iter(client, log_group, streams, positions=None):
"""Iterate over the available events coming from a set of log streams in a single log group
interleaving the events from each stream so they're yielded in timestamp order.
Args:
client (boto3 client): The boto client for logs.
... | [
"def",
"multi_stream_iter",
"(",
"client",
",",
"log_group",
",",
"streams",
",",
"positions",
"=",
"None",
")",
":",
"positions",
"=",
"positions",
"or",
"{",
"s",
":",
"Position",
"(",
"timestamp",
"=",
"0",
",",
"skip",
"=",
"0",
")",
"for",
"s",
... | Iterate over the available events coming from a set of log streams in a single log group
interleaving the events from each stream so they're yielded in timestamp order.
Args:
client (boto3 client): The boto client for logs.
log_group (str): The name of the log group.
streams (list of st... | [
"Iterate",
"over",
"the",
"available",
"events",
"coming",
"from",
"a",
"set",
"of",
"log",
"streams",
"in",
"a",
"single",
"log",
"group",
"interleaving",
"the",
"events",
"from",
"each",
"stream",
"so",
"they",
"re",
"yielded",
"in",
"timestamp",
"order",
... | python | train |
iotile/coretools | transport_plugins/awsiot/iotile_transport_awsiot/gateway_agent.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/transport_plugins/awsiot/iotile_transport_awsiot/gateway_agent.py#L159-L170 | def _publish_response(self, slug, message):
"""Publish a response message for a device
Args:
slug (string): The device slug that we are publishing on behalf of
message (dict): A set of key value pairs that are used to create the message
that is sent.
"""
... | [
"def",
"_publish_response",
"(",
"self",
",",
"slug",
",",
"message",
")",
":",
"resp_topic",
"=",
"self",
".",
"topics",
".",
"gateway_topic",
"(",
"slug",
",",
"'data/response'",
")",
"self",
".",
"_logger",
".",
"debug",
"(",
"\"Publishing response message:... | Publish a response message for a device
Args:
slug (string): The device slug that we are publishing on behalf of
message (dict): A set of key value pairs that are used to create the message
that is sent. | [
"Publish",
"a",
"response",
"message",
"for",
"a",
"device"
] | python | train |
RadhikaG/markdown-magic | magic/gifAPI.py | https://github.com/RadhikaG/markdown-magic/blob/af99549b033269d861ea13f0541cb4f894057c47/magic/gifAPI.py#L5-L49 | def processGif(searchStr):
'''
This function returns the url of the gif searched for
with the given search parameters using the Giphy API.
Thanks!
Fails gracefully when it can't find a gif by returning an
appropriate image url with the failure message on it.
'''
# Sanitizing searc... | [
"def",
"processGif",
"(",
"searchStr",
")",
":",
"# Sanitizing searchStr",
"# TODO: Find a better way to do this",
"searchStr",
".",
"replace",
"(",
"'| '",
",",
"' '",
")",
"searchStr",
".",
"replace",
"(",
"'|'",
",",
"' '",
")",
"searchStr",
".",
"replace",
"... | This function returns the url of the gif searched for
with the given search parameters using the Giphy API.
Thanks!
Fails gracefully when it can't find a gif by returning an
appropriate image url with the failure message on it. | [
"This",
"function",
"returns",
"the",
"url",
"of",
"the",
"gif",
"searched",
"for",
"with",
"the",
"given",
"search",
"parameters",
"using",
"the",
"Giphy",
"API",
".",
"Thanks!"
] | python | train |
swharden/SWHLab | doc/oldcode/swhlab/core/ap.py | https://github.com/swharden/SWHLab/blob/a86c3c65323cec809a4bd4f81919644927094bf5/doc/oldcode/swhlab/core/ap.py#L153-L215 | def analyzeAP(Y,dY,I,rate,verbose=False):
"""
given a sweep and a time point, return the AP array for that AP.
APs will be centered in time by their maximum upslope.
"""
Ims = int(rate/1000) #Is per MS
IsToLook=5*Ims #TODO: clarify this, ms until downslope is over
upslope=np.max(dY[I:I+IsToL... | [
"def",
"analyzeAP",
"(",
"Y",
",",
"dY",
",",
"I",
",",
"rate",
",",
"verbose",
"=",
"False",
")",
":",
"Ims",
"=",
"int",
"(",
"rate",
"/",
"1000",
")",
"#Is per MS",
"IsToLook",
"=",
"5",
"*",
"Ims",
"#TODO: clarify this, ms until downslope is over",
"... | given a sweep and a time point, return the AP array for that AP.
APs will be centered in time by their maximum upslope. | [
"given",
"a",
"sweep",
"and",
"a",
"time",
"point",
"return",
"the",
"AP",
"array",
"for",
"that",
"AP",
".",
"APs",
"will",
"be",
"centered",
"in",
"time",
"by",
"their",
"maximum",
"upslope",
"."
] | python | valid |
mrsarm/mongotail | mongotail/err.py | https://github.com/mrsarm/mongotail/blob/82ba74e32eff92faa320833a8d19c58555f9cd49/mongotail/err.py#L42-L48 | def error_parsing(msg="unknown options"):
"""
Print any parsing error and exit with status -1
"""
sys.stderr.write("Error parsing command line: %s\ntry 'mongotail --help' for more information\n" % msg)
sys.stderr.flush()
exit(EINVAL) | [
"def",
"error_parsing",
"(",
"msg",
"=",
"\"unknown options\"",
")",
":",
"sys",
".",
"stderr",
".",
"write",
"(",
"\"Error parsing command line: %s\\ntry 'mongotail --help' for more information\\n\"",
"%",
"msg",
")",
"sys",
".",
"stderr",
".",
"flush",
"(",
")",
"... | Print any parsing error and exit with status -1 | [
"Print",
"any",
"parsing",
"error",
"and",
"exit",
"with",
"status",
"-",
"1"
] | python | test |
Dallinger/Dallinger | dallinger/models.py | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/models.py#L1663-L1673 | def json_data(self):
"""The json representation of a transmissions."""
return {
"vector_id": self.vector_id,
"origin_id": self.origin_id,
"destination_id": self.destination_id,
"info_id": self.info_id,
"network_id": self.network_id,
... | [
"def",
"json_data",
"(",
"self",
")",
":",
"return",
"{",
"\"vector_id\"",
":",
"self",
".",
"vector_id",
",",
"\"origin_id\"",
":",
"self",
".",
"origin_id",
",",
"\"destination_id\"",
":",
"self",
".",
"destination_id",
",",
"\"info_id\"",
":",
"self",
"."... | The json representation of a transmissions. | [
"The",
"json",
"representation",
"of",
"a",
"transmissions",
"."
] | python | train |
twidi/py-dataql | dataql/solvers/resources.py | https://github.com/twidi/py-dataql/blob/5841a3fd559829193ed709c255166085bdde1c52/dataql/solvers/resources.py#L261-L316 | def coerce(self, value, resource):
"""Coerce the value to an acceptable one.
Only these kinds of values are returned as is:
- str
- int
- float
- True
- False
- None
For all others values, it will be coerced using ``self.coerce_default`` (with co... | [
"def",
"coerce",
"(",
"self",
",",
"value",
",",
"resource",
")",
":",
"if",
"value",
"in",
"(",
"True",
",",
"False",
",",
"None",
")",
":",
"return",
"value",
"if",
"isinstance",
"(",
"value",
",",
"(",
"int",
",",
"float",
")",
")",
":",
"retu... | Coerce the value to an acceptable one.
Only these kinds of values are returned as is:
- str
- int
- float
- True
- False
- None
For all others values, it will be coerced using ``self.coerce_default`` (with convert the
value to a string in the def... | [
"Coerce",
"the",
"value",
"to",
"an",
"acceptable",
"one",
"."
] | python | train |
google/grr | grr/client/grr_response_client/comms.py | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/client/grr_response_client/comms.py#L431-L440 | def Wait(self, timeout):
"""Wait for the specified timeout."""
time.sleep(timeout - int(timeout))
# Split a long sleep interval into 1 second intervals so we can heartbeat.
for _ in range(int(timeout)):
time.sleep(1)
if self.heart_beat_cb:
self.heart_beat_cb() | [
"def",
"Wait",
"(",
"self",
",",
"timeout",
")",
":",
"time",
".",
"sleep",
"(",
"timeout",
"-",
"int",
"(",
"timeout",
")",
")",
"# Split a long sleep interval into 1 second intervals so we can heartbeat.",
"for",
"_",
"in",
"range",
"(",
"int",
"(",
"timeout",... | Wait for the specified timeout. | [
"Wait",
"for",
"the",
"specified",
"timeout",
"."
] | python | train |
shoebot/shoebot | lib/web/yahoo.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/web/yahoo.py#L256-L289 | def sort(words, context="", strict=True, relative=True, service=YAHOO_SEARCH,
wait=10, asynchronous=False, cached=False):
"""Performs a Yahoo sort on the given list.
Sorts the items in the list according to
the result count Yahoo yields on an item.
Setting a context sorts the it... | [
"def",
"sort",
"(",
"words",
",",
"context",
"=",
"\"\"",
",",
"strict",
"=",
"True",
",",
"relative",
"=",
"True",
",",
"service",
"=",
"YAHOO_SEARCH",
",",
"wait",
"=",
"10",
",",
"asynchronous",
"=",
"False",
",",
"cached",
"=",
"False",
")",
":",... | Performs a Yahoo sort on the given list.
Sorts the items in the list according to
the result count Yahoo yields on an item.
Setting a context sorts the items according
to their relation to this context;
for example sorting [red, green, blue] by "love"
yields red as the highest results... | [
"Performs",
"a",
"Yahoo",
"sort",
"on",
"the",
"given",
"list",
".",
"Sorts",
"the",
"items",
"in",
"the",
"list",
"according",
"to",
"the",
"result",
"count",
"Yahoo",
"yields",
"on",
"an",
"item",
".",
"Setting",
"a",
"context",
"sorts",
"the",
"items"... | python | valid |
calmjs/calmjs.parse | src/calmjs/parse/parsers/es5.py | https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/parsers/es5.py#L1223-L1229 | def p_iteration_statement_4(self, p):
"""
iteration_statement \
: FOR LPAREN left_hand_side_expr IN expr RPAREN statement
"""
p[0] = self.asttypes.ForIn(item=p[3], iterable=p[5], statement=p[7])
p[0].setpos(p) | [
"def",
"p_iteration_statement_4",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"asttypes",
".",
"ForIn",
"(",
"item",
"=",
"p",
"[",
"3",
"]",
",",
"iterable",
"=",
"p",
"[",
"5",
"]",
",",
"statement",
"=",
"p",
"[",
... | iteration_statement \
: FOR LPAREN left_hand_side_expr IN expr RPAREN statement | [
"iteration_statement",
"\\",
":",
"FOR",
"LPAREN",
"left_hand_side_expr",
"IN",
"expr",
"RPAREN",
"statement"
] | python | train |
elastic/elasticsearch-dsl-py | elasticsearch_dsl/index.py | https://github.com/elastic/elasticsearch-dsl-py/blob/874b52472fc47b601de0e5fa0e4300e21aff0085/elasticsearch_dsl/index.py#L373-L380 | def exists(self, using=None, **kwargs):
"""
Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged.
"""
return self._get_connection(using).indices.exists(index=self._nam... | [
"def",
"exists",
"(",
"self",
",",
"using",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_get_connection",
"(",
"using",
")",
".",
"indices",
".",
"exists",
"(",
"index",
"=",
"self",
".",
"_name",
",",
"*",
"*",
"kwargs"... | Returns ``True`` if the index already exists in elasticsearch.
Any additional keyword arguments will be passed to
``Elasticsearch.indices.exists`` unchanged. | [
"Returns",
"True",
"if",
"the",
"index",
"already",
"exists",
"in",
"elasticsearch",
"."
] | python | train |
i3visio/osrframework | osrframework/thirdparties/pipl_com/lib/containers.py | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/thirdparties/pipl_com/lib/containers.py#L63-L67 | def all_fields(self):
"""A list with all the fields contained in this object."""
return [field
for container in FieldsContainer.class_container.values()
for field in getattr(self, container)] | [
"def",
"all_fields",
"(",
"self",
")",
":",
"return",
"[",
"field",
"for",
"container",
"in",
"FieldsContainer",
".",
"class_container",
".",
"values",
"(",
")",
"for",
"field",
"in",
"getattr",
"(",
"self",
",",
"container",
")",
"]"
] | A list with all the fields contained in this object. | [
"A",
"list",
"with",
"all",
"the",
"fields",
"contained",
"in",
"this",
"object",
"."
] | python | train |
lambdamusic/Ontospy | ontospy/ontodocs/viz_factory.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/ontodocs/viz_factory.py#L92-L105 | def _buildTemplates(self):
"""
do all the things necessary to build the viz
should be adapted to work for single-file viz, or multi-files etc.
:param output_path:
:return:
"""
# in this case we only have one
contents = self._renderTemplate(self.template_... | [
"def",
"_buildTemplates",
"(",
"self",
")",
":",
"# in this case we only have one",
"contents",
"=",
"self",
".",
"_renderTemplate",
"(",
"self",
".",
"template_name",
",",
"extraContext",
"=",
"None",
")",
"# the main url used for opening viz",
"f",
"=",
"self",
"... | do all the things necessary to build the viz
should be adapted to work for single-file viz, or multi-files etc.
:param output_path:
:return: | [
"do",
"all",
"the",
"things",
"necessary",
"to",
"build",
"the",
"viz",
"should",
"be",
"adapted",
"to",
"work",
"for",
"single",
"-",
"file",
"viz",
"or",
"multi",
"-",
"files",
"etc",
"."
] | python | train |
quantopian/serializable-traitlets | straitlets/serializable.py | https://github.com/quantopian/serializable-traitlets/blob/dd334366d1130825aea55d3dfecd6756973594e0/straitlets/serializable.py#L167-L175 | def write_example_yaml(cls, dest, skip=()):
"""
Write a file containing an example yaml string for a Serializable
subclass.
"""
# Make sure we can make an instance before we open a file.
inst = cls.example_instance(skip=skip)
with open(dest, 'w') as f:
... | [
"def",
"write_example_yaml",
"(",
"cls",
",",
"dest",
",",
"skip",
"=",
"(",
")",
")",
":",
"# Make sure we can make an instance before we open a file.",
"inst",
"=",
"cls",
".",
"example_instance",
"(",
"skip",
"=",
"skip",
")",
"with",
"open",
"(",
"dest",
"... | Write a file containing an example yaml string for a Serializable
subclass. | [
"Write",
"a",
"file",
"containing",
"an",
"example",
"yaml",
"string",
"for",
"a",
"Serializable",
"subclass",
"."
] | python | train |
pytroll/satpy | satpy/readers/seviri_l1b_hrit.py | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/seviri_l1b_hrit.py#L534-L578 | def calibrate(self, data, calibration):
"""Calibrate the data."""
tic = datetime.now()
channel_name = self.channel_name
if calibration == 'counts':
res = data
elif calibration in ['radiance', 'reflectance', 'brightness_temperature']:
# Choose calibration ... | [
"def",
"calibrate",
"(",
"self",
",",
"data",
",",
"calibration",
")",
":",
"tic",
"=",
"datetime",
".",
"now",
"(",
")",
"channel_name",
"=",
"self",
".",
"channel_name",
"if",
"calibration",
"==",
"'counts'",
":",
"res",
"=",
"data",
"elif",
"calibrati... | Calibrate the data. | [
"Calibrate",
"the",
"data",
"."
] | python | train |
bcbio/bcbio-nextgen | bcbio/structural/cnvkit.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/structural/cnvkit.py#L228-L235 | def _get_general_coverage(data, itype):
"""Retrieve coverage information from new shared SV bins.
"""
work_bam = dd.get_align_bam(data) or dd.get_work_bam(data)
return [{"bam": work_bam, "file": tz.get_in(["depth", "bins", "target"], data),
"cnntype": "target", "itype": itype, "sample": dd.... | [
"def",
"_get_general_coverage",
"(",
"data",
",",
"itype",
")",
":",
"work_bam",
"=",
"dd",
".",
"get_align_bam",
"(",
"data",
")",
"or",
"dd",
".",
"get_work_bam",
"(",
"data",
")",
"return",
"[",
"{",
"\"bam\"",
":",
"work_bam",
",",
"\"file\"",
":",
... | Retrieve coverage information from new shared SV bins. | [
"Retrieve",
"coverage",
"information",
"from",
"new",
"shared",
"SV",
"bins",
"."
] | python | train |
blakev/python-syncthing | syncthing/__init__.py | https://github.com/blakev/python-syncthing/blob/a7f4930f86f7543cd96990277945467896fb523d/syncthing/__init__.py#L714-L735 | def scan(self, folder, sub=None, next_=None):
""" Request immediate rescan of a folder, or a specific path within a
folder.
Args:
folder (str): Folder ID.
sub (str): Path relative to the folder root. If sub is omitted
the entire folder is ... | [
"def",
"scan",
"(",
"self",
",",
"folder",
",",
"sub",
"=",
"None",
",",
"next_",
"=",
"None",
")",
":",
"if",
"not",
"sub",
":",
"sub",
"=",
"''",
"assert",
"isinstance",
"(",
"sub",
",",
"string_types",
")",
"assert",
"isinstance",
"(",
"next_",
... | Request immediate rescan of a folder, or a specific path within a
folder.
Args:
folder (str): Folder ID.
sub (str): Path relative to the folder root. If sub is omitted
the entire folder is scanned for changes, otherwise only
th... | [
"Request",
"immediate",
"rescan",
"of",
"a",
"folder",
"or",
"a",
"specific",
"path",
"within",
"a",
"folder",
"."
] | python | train |
Erotemic/utool | utool/util_hash.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_hash.py#L438-L498 | def hash_data(data, hashlen=None, alphabet=None):
r"""
Get a unique hash depending on the state of the data.
Args:
data (object): any sort of loosely organized data
hashlen (None): (default = None)
alphabet (None): (default = None)
Returns:
str: text - hash string
... | [
"def",
"hash_data",
"(",
"data",
",",
"hashlen",
"=",
"None",
",",
"alphabet",
"=",
"None",
")",
":",
"if",
"alphabet",
"is",
"None",
":",
"alphabet",
"=",
"ALPHABET_27",
"if",
"hashlen",
"is",
"None",
":",
"hashlen",
"=",
"HASH_LEN2",
"if",
"isinstance"... | r"""
Get a unique hash depending on the state of the data.
Args:
data (object): any sort of loosely organized data
hashlen (None): (default = None)
alphabet (None): (default = None)
Returns:
str: text - hash string
CommandLine:
python -m utool.util_hash hash_d... | [
"r",
"Get",
"a",
"unique",
"hash",
"depending",
"on",
"the",
"state",
"of",
"the",
"data",
"."
] | python | train |
rmed/pyemtmad | pyemtmad/api/parking.py | https://github.com/rmed/pyemtmad/blob/c21c42d0c7b50035dfed29540d7e64ab67833728/pyemtmad/api/parking.py#L230-L254 | def list_features(self, **kwargs):
"""Obtain a list of parkings.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[Parking]), or message
string in case of error.
"""
# Endpoint parameters
... | [
"def",
"list_features",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Endpoint parameters",
"params",
"=",
"{",
"'language'",
":",
"util",
".",
"language_code",
"(",
"kwargs",
".",
"get",
"(",
"'lang'",
")",
")",
",",
"'publicData'",
":",
"True",
"}... | Obtain a list of parkings.
Args:
lang (str): Language code (*es* or *en*).
Returns:
Status boolean and parsed response (list[Parking]), or message
string in case of error. | [
"Obtain",
"a",
"list",
"of",
"parkings",
"."
] | python | train |
Cornices/cornice.ext.swagger | cornice_swagger/views.py | https://github.com/Cornices/cornice.ext.swagger/blob/c31a5cc8d5dd112b11dc41ccb6d09b423b537abc/cornice_swagger/views.py#L61-L76 | def swagger_ui_script_template(request, **kwargs):
"""
:param request:
:return:
Generates the <script> code that bootstraps Swagger UI, it will be injected
into index template
"""
swagger_spec_url = request.route_url('cornice_swagger.open_api_path')
template = pkg_resources.resource_str... | [
"def",
"swagger_ui_script_template",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"swagger_spec_url",
"=",
"request",
".",
"route_url",
"(",
"'cornice_swagger.open_api_path'",
")",
"template",
"=",
"pkg_resources",
".",
"resource_string",
"(",
"'cornice_swagger'... | :param request:
:return:
Generates the <script> code that bootstraps Swagger UI, it will be injected
into index template | [
":",
"param",
"request",
":",
":",
"return",
":"
] | python | valid |
gem/oq-engine | openquake/hazardlib/gsim/cauzzi_faccioli_2008.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/cauzzi_faccioli_2008.py#L153-L175 | def _compute_mean(self, C, mag, dists, vs30, rake, imt):
"""
Compute mean value for PGV, PGA and Displacement responce spectrum,
as given in equation 2, page 462 with the addition of the faulting
style term as given in equation 5, page 465. Converts also
displacement responce spe... | [
"def",
"_compute_mean",
"(",
"self",
",",
"C",
",",
"mag",
",",
"dists",
",",
"vs30",
",",
"rake",
",",
"imt",
")",
":",
"mean",
"=",
"(",
"self",
".",
"_compute_term_1_2",
"(",
"C",
",",
"mag",
")",
"+",
"self",
".",
"_compute_term_3",
"(",
"C",
... | Compute mean value for PGV, PGA and Displacement responce spectrum,
as given in equation 2, page 462 with the addition of the faulting
style term as given in equation 5, page 465. Converts also
displacement responce spectrum values to SA. | [
"Compute",
"mean",
"value",
"for",
"PGV",
"PGA",
"and",
"Displacement",
"responce",
"spectrum",
"as",
"given",
"in",
"equation",
"2",
"page",
"462",
"with",
"the",
"addition",
"of",
"the",
"faulting",
"style",
"term",
"as",
"given",
"in",
"equation",
"5",
... | python | train |
krukas/Trionyx | trionyx/trionyx/views/core.py | https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/views/core.py#L68-L72 | def get_model_config(self):
"""Get Trionyx model config"""
if not hasattr(self, '__config'):
setattr(self, '__config', models_config.get_config(self.get_model_class()))
return getattr(self, '__config', None) | [
"def",
"get_model_config",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'__config'",
")",
":",
"setattr",
"(",
"self",
",",
"'__config'",
",",
"models_config",
".",
"get_config",
"(",
"self",
".",
"get_model_class",
"(",
")",
")",
")... | Get Trionyx model config | [
"Get",
"Trionyx",
"model",
"config"
] | python | train |
airspeed-velocity/asv | asv/extern/asizeof.py | https://github.com/airspeed-velocity/asv/blob/d23bb8b74e8adacbfa3cf5724bda55fb39d56ba6/asv/extern/asizeof.py#L1638-L1658 | def _sizes(self, objs, sized=None):
'''Return the size or an **Asized** instance for each
given object and the total size. The total
includes the size of duplicates only once.
'''
self.exclude_refs(*objs) # skip refs to objs
s, t = {}, []
for o in objs:
... | [
"def",
"_sizes",
"(",
"self",
",",
"objs",
",",
"sized",
"=",
"None",
")",
":",
"self",
".",
"exclude_refs",
"(",
"*",
"objs",
")",
"# skip refs to objs",
"s",
",",
"t",
"=",
"{",
"}",
",",
"[",
"]",
"for",
"o",
"in",
"objs",
":",
"i",
"=",
"id... | Return the size or an **Asized** instance for each
given object and the total size. The total
includes the size of duplicates only once. | [
"Return",
"the",
"size",
"or",
"an",
"**",
"Asized",
"**",
"instance",
"for",
"each",
"given",
"object",
"and",
"the",
"total",
"size",
".",
"The",
"total",
"includes",
"the",
"size",
"of",
"duplicates",
"only",
"once",
"."
] | python | train |
saltstack/salt | salt/modules/saltutil.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/saltutil.py#L362-L392 | def refresh_grains(**kwargs):
'''
.. versionadded:: 2016.3.6,2016.11.4,2017.7.0
Refresh the minion's grains without syncing custom grains modules from
``salt://_grains``.
.. note::
The available execution modules will be reloaded as part of this
proceess, as grains can affect which... | [
"def",
"refresh_grains",
"(",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"clean_kwargs",
"(",
"*",
"*",
"kwargs",
")",
"_refresh_pillar",
"=",
"kwargs",
".",
"pop",
"(",
"'refresh_pillar'",
",",
"True",
")",
"i... | .. versionadded:: 2016.3.6,2016.11.4,2017.7.0
Refresh the minion's grains without syncing custom grains modules from
``salt://_grains``.
.. note::
The available execution modules will be reloaded as part of this
proceess, as grains can affect which modules are available.
refresh_pilla... | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"6",
"2016",
".",
"11",
".",
"4",
"2017",
".",
"7",
".",
"0"
] | python | train |
log2timeline/dftimewolf | dftimewolf/lib/containers/interface.py | https://github.com/log2timeline/dftimewolf/blob/45f898476a288d73c4256ae8e3836a2a4848c0d7/dftimewolf/lib/containers/interface.py#L45-L54 | def copy_from_dict(self, attributes):
"""Copies the attribute container from a dictionary.
Args:
attributes (dict[str, object]): attribute values per name.
"""
for attribute_name, attribute_value in attributes.items():
# Not using startswith to improve performance.
if attribute_name[0]... | [
"def",
"copy_from_dict",
"(",
"self",
",",
"attributes",
")",
":",
"for",
"attribute_name",
",",
"attribute_value",
"in",
"attributes",
".",
"items",
"(",
")",
":",
"# Not using startswith to improve performance.",
"if",
"attribute_name",
"[",
"0",
"]",
"==",
"'_'... | Copies the attribute container from a dictionary.
Args:
attributes (dict[str, object]): attribute values per name. | [
"Copies",
"the",
"attribute",
"container",
"from",
"a",
"dictionary",
".",
"Args",
":",
"attributes",
"(",
"dict",
"[",
"str",
"object",
"]",
")",
":",
"attribute",
"values",
"per",
"name",
"."
] | python | train |
bunq/sdk_python | bunq/sdk/model/generated/endpoint.py | https://github.com/bunq/sdk_python/blob/da6c9b83e6d83ee8062617f53c6eb7293c0d863d/bunq/sdk/model/generated/endpoint.py#L7569-L7660 | def create(cls, cash_register_id, description, status, amount_total,
monetary_account_id=None, allow_amount_higher=None,
allow_amount_lower=None, want_tip=None, minimum_age=None,
require_address=None, redirect_url=None, visibility=None,
expiration=None, tab_at... | [
"def",
"create",
"(",
"cls",
",",
"cash_register_id",
",",
"description",
",",
"status",
",",
"amount_total",
",",
"monetary_account_id",
"=",
"None",
",",
"allow_amount_higher",
"=",
"None",
",",
"allow_amount_lower",
"=",
"None",
",",
"want_tip",
"=",
"None",
... | Create a TabUsageMultiple. On creation the status must be set to OPEN
:type user_id: int
:type monetary_account_id: int
:type cash_register_id: int
:param description: The description of the TabUsageMultiple. Maximum
9000 characters. Field is required but can be an empty string.... | [
"Create",
"a",
"TabUsageMultiple",
".",
"On",
"creation",
"the",
"status",
"must",
"be",
"set",
"to",
"OPEN"
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.