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 |
|---|---|---|---|---|---|---|---|---|
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/qt/console/history_console_widget.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/history_console_widget.py#L135-L164 | def history_previous(self, substring='', as_prefix=True):
""" If possible, set the input buffer to a previous history item.
Parameters:
-----------
substring : str, optional
If specified, search for an item with this substring.
as_prefix : bool, optional
... | [
"def",
"history_previous",
"(",
"self",
",",
"substring",
"=",
"''",
",",
"as_prefix",
"=",
"True",
")",
":",
"index",
"=",
"self",
".",
"_history_index",
"replace",
"=",
"False",
"while",
"index",
">",
"0",
":",
"index",
"-=",
"1",
"history",
"=",
"se... | If possible, set the input buffer to a previous history item.
Parameters:
-----------
substring : str, optional
If specified, search for an item with this substring.
as_prefix : bool, optional
If True, the substring must match at the beginning (default).
... | [
"If",
"possible",
"set",
"the",
"input",
"buffer",
"to",
"a",
"previous",
"history",
"item",
"."
] | python | test |
zeaphoo/reston | reston/core/apk.py | https://github.com/zeaphoo/reston/blob/96502487b2259572df55237c9526f92627465088/reston/core/apk.py#L536-L569 | def get_main_activity(self):
"""
Return the name of the main activity
:rtype: string
"""
x = set()
y = set()
for i in self.xml:
activities_and_aliases = self.xml[i].getElementsByTagName("activity") + \
sel... | [
"def",
"get_main_activity",
"(",
"self",
")",
":",
"x",
"=",
"set",
"(",
")",
"y",
"=",
"set",
"(",
")",
"for",
"i",
"in",
"self",
".",
"xml",
":",
"activities_and_aliases",
"=",
"self",
".",
"xml",
"[",
"i",
"]",
".",
"getElementsByTagName",
"(",
... | Return the name of the main activity
:rtype: string | [
"Return",
"the",
"name",
"of",
"the",
"main",
"activity"
] | python | train |
lemieuxl/pyGenClean | pyGenClean/run_data_clean_up.py | https://github.com/lemieuxl/pyGenClean/blob/6173a48ccc0cf3a3bd711b1f2a1fa16248b8bf55/pyGenClean/run_data_clean_up.py#L3280-L3293 | def all_files_exist(file_list):
"""Check if all files exist.
:param file_list: the names of files to check.
:type file_list: list
:returns: ``True`` if all files exist, ``False`` otherwise.
"""
all_exist = True
for filename in file_list:
all_exist = all_exist and os.path.isfile(f... | [
"def",
"all_files_exist",
"(",
"file_list",
")",
":",
"all_exist",
"=",
"True",
"for",
"filename",
"in",
"file_list",
":",
"all_exist",
"=",
"all_exist",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"filename",
")",
"return",
"all_exist"
] | Check if all files exist.
:param file_list: the names of files to check.
:type file_list: list
:returns: ``True`` if all files exist, ``False`` otherwise. | [
"Check",
"if",
"all",
"files",
"exist",
"."
] | python | train |
intake/intake | intake/gui/source/gui.py | https://github.com/intake/intake/blob/277b96bfdee39d8a3048ea5408c6d6716d568336/intake/gui/source/gui.py#L112-L121 | def callback(self, sources):
"""When a source is selected, enable widgets that depend on that condition
and do done_callback"""
enable = bool(sources)
if not enable:
self.plot_widget.value = False
enable_widget(self.plot_widget, enable)
if self.done_callback:... | [
"def",
"callback",
"(",
"self",
",",
"sources",
")",
":",
"enable",
"=",
"bool",
"(",
"sources",
")",
"if",
"not",
"enable",
":",
"self",
".",
"plot_widget",
".",
"value",
"=",
"False",
"enable_widget",
"(",
"self",
".",
"plot_widget",
",",
"enable",
"... | When a source is selected, enable widgets that depend on that condition
and do done_callback | [
"When",
"a",
"source",
"is",
"selected",
"enable",
"widgets",
"that",
"depend",
"on",
"that",
"condition",
"and",
"do",
"done_callback"
] | python | train |
LionelR/pyair | pyair/xair.py | https://github.com/LionelR/pyair/blob/467e8a843ca9f882f8bb2958805b7293591996ad/pyair/xair.py#L73-L90 | def _format(noms):
"""
Formate une donnée d'entrée pour être exploitable dans les fonctions liste_*
et get_*.
Paramètres:
noms: chaîne de caractère, liste ou tuples de chaînes de caractères ou
pandas.Series de chaînes de caractères.
Retourne:
Une chaînes de caractères dont chaque éléme... | [
"def",
"_format",
"(",
"noms",
")",
":",
"if",
"isinstance",
"(",
"noms",
",",
"(",
"list",
",",
"tuple",
",",
"pd",
".",
"Series",
")",
")",
":",
"noms",
"=",
"','",
".",
"join",
"(",
"noms",
")",
"noms",
"=",
"noms",
".",
"replace",
"(",
"\",... | Formate une donnée d'entrée pour être exploitable dans les fonctions liste_*
et get_*.
Paramètres:
noms: chaîne de caractère, liste ou tuples de chaînes de caractères ou
pandas.Series de chaînes de caractères.
Retourne:
Une chaînes de caractères dont chaque élément est séparé du suivant par le... | [
"Formate",
"une",
"donnée",
"d",
"entrée",
"pour",
"être",
"exploitable",
"dans",
"les",
"fonctions",
"liste_",
"*",
"et",
"get_",
"*",
"."
] | python | valid |
Capitains/flask-capitains-nemo | flask_nemo/query/interface.py | https://github.com/Capitains/flask-capitains-nemo/blob/8d91f2c05b925a6c8ea8c997baf698c87257bc58/flask_nemo/query/interface.py#L42-L56 | def process(self, nemo):
""" Register nemo and parses annotations
.. note:: Process parses the annotation and extends informations about the target URNs by retrieving resource in range
:param nemo: Nemo
"""
self.__nemo__ = nemo
for annotation in self.__annotations__:
... | [
"def",
"process",
"(",
"self",
",",
"nemo",
")",
":",
"self",
".",
"__nemo__",
"=",
"nemo",
"for",
"annotation",
"in",
"self",
".",
"__annotations__",
":",
"annotation",
".",
"target",
".",
"expanded",
"=",
"frozenset",
"(",
"self",
".",
"__getinnerreffs__... | Register nemo and parses annotations
.. note:: Process parses the annotation and extends informations about the target URNs by retrieving resource in range
:param nemo: Nemo | [
"Register",
"nemo",
"and",
"parses",
"annotations"
] | python | valid |
mar10/wsgidav | wsgidav/dav_provider.py | https://github.com/mar10/wsgidav/blob/cec0d84222fc24bea01be1cea91729001963f172/wsgidav/dav_provider.py#L432-L479 | def get_descendants(
self,
collections=True,
resources=True,
depth_first=False,
depth="infinity",
add_self=False,
):
"""Return a list _DAVResource objects of a collection (children,
grand-children, ...).
This default implementation calls self.... | [
"def",
"get_descendants",
"(",
"self",
",",
"collections",
"=",
"True",
",",
"resources",
"=",
"True",
",",
"depth_first",
"=",
"False",
",",
"depth",
"=",
"\"infinity\"",
",",
"add_self",
"=",
"False",
",",
")",
":",
"assert",
"depth",
"in",
"(",
"\"0\"... | Return a list _DAVResource objects of a collection (children,
grand-children, ...).
This default implementation calls self.get_member_list() recursively.
This function may also be called for non-collections (with add_self=True).
:Parameters:
depth_first : bool
... | [
"Return",
"a",
"list",
"_DAVResource",
"objects",
"of",
"a",
"collection",
"(",
"children",
"grand",
"-",
"children",
"...",
")",
"."
] | python | valid |
avihad/twistes | twistes/client.py | https://github.com/avihad/twistes/blob/9ab8f5aa088b8886aefe3dec85a400e5035e034a/twistes/client.py#L380-L405 | def create(self, index, doc_type, body, id=None, **query_params):
"""
Adds a typed JSON document in a specific index, making it searchable.
Behind the scenes this method calls index(..., op_type='create')
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`... | [
"def",
"create",
"(",
"self",
",",
"index",
",",
"doc_type",
",",
"body",
",",
"id",
"=",
"None",
",",
"*",
"*",
"query_params",
")",
":",
"query_params",
"[",
"'op_type'",
"]",
"=",
"'create'",
"result",
"=",
"yield",
"self",
".",
"index",
"(",
"ind... | Adds a typed JSON document in a specific index, making it searchable.
Behind the scenes this method calls index(..., op_type='create')
`<http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html>`_
:param index: The name of the index
:param doc_type: The type of the... | [
"Adds",
"a",
"typed",
"JSON",
"document",
"in",
"a",
"specific",
"index",
"making",
"it",
"searchable",
".",
"Behind",
"the",
"scenes",
"this",
"method",
"calls",
"index",
"(",
"...",
"op_type",
"=",
"create",
")",
"<http",
":",
"//",
"www",
".",
"elasti... | python | train |
raiden-network/raiden | raiden/storage/migrations/v20_to_v21.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/storage/migrations/v20_to_v21.py#L52-L100 | def _update_statechanges(storage: SQLiteStorage):
"""
Update each ContractReceiveChannelNew's channel_state member
by setting the `mediation_fee` that was added to the NettingChannelState
"""
batch_size = 50
batch_query = storage.batch_query_state_changes(
batch_size=batch_size,
... | [
"def",
"_update_statechanges",
"(",
"storage",
":",
"SQLiteStorage",
")",
":",
"batch_size",
"=",
"50",
"batch_query",
"=",
"storage",
".",
"batch_query_state_changes",
"(",
"batch_size",
"=",
"batch_size",
",",
"filters",
"=",
"[",
"(",
"'_type'",
",",
"'raiden... | Update each ContractReceiveChannelNew's channel_state member
by setting the `mediation_fee` that was added to the NettingChannelState | [
"Update",
"each",
"ContractReceiveChannelNew",
"s",
"channel_state",
"member",
"by",
"setting",
"the",
"mediation_fee",
"that",
"was",
"added",
"to",
"the",
"NettingChannelState"
] | python | train |
buriburisuri/sugartensor | sugartensor/sg_activation.py | https://github.com/buriburisuri/sugartensor/blob/d2c039954777c7fbe3eb0c2ae40c45c9854deb40/sugartensor/sg_activation.py#L29-L40 | def sg_leaky_relu(x, opt):
r""""See [Xu, et al. 2015](https://arxiv.org/pdf/1505.00853v2.pdf)
Args:
x: A tensor
opt:
name: A name for the operation (optional).
Returns:
A `Tensor` with the same type and shape as `x`.
"""
return tf.where(tf.greater(x, 0), x, 0.01... | [
"def",
"sg_leaky_relu",
"(",
"x",
",",
"opt",
")",
":",
"return",
"tf",
".",
"where",
"(",
"tf",
".",
"greater",
"(",
"x",
",",
"0",
")",
",",
"x",
",",
"0.01",
"*",
"x",
",",
"name",
"=",
"opt",
".",
"name",
")"
] | r""""See [Xu, et al. 2015](https://arxiv.org/pdf/1505.00853v2.pdf)
Args:
x: A tensor
opt:
name: A name for the operation (optional).
Returns:
A `Tensor` with the same type and shape as `x`. | [
"r",
"See",
"[",
"Xu",
"et",
"al",
".",
"2015",
"]",
"(",
"https",
":",
"//",
"arxiv",
".",
"org",
"/",
"pdf",
"/",
"1505",
".",
"00853v2",
".",
"pdf",
")"
] | python | train |
Parsely/birding | src/birding/follow.py | https://github.com/Parsely/birding/blob/c7f6eee56424234e361b1a455595de202e744dac/src/birding/follow.py#L58-L68 | def follow_fd(fd):
"""Dump each line of input to stdio."""
dump = Dump()
for line in fd:
if not line.strip():
continue
with flushing(sys.stdout, sys.stderr):
status = load(line)
if status:
dump(status) | [
"def",
"follow_fd",
"(",
"fd",
")",
":",
"dump",
"=",
"Dump",
"(",
")",
"for",
"line",
"in",
"fd",
":",
"if",
"not",
"line",
".",
"strip",
"(",
")",
":",
"continue",
"with",
"flushing",
"(",
"sys",
".",
"stdout",
",",
"sys",
".",
"stderr",
")",
... | Dump each line of input to stdio. | [
"Dump",
"each",
"line",
"of",
"input",
"to",
"stdio",
"."
] | python | train |
boriel/zxbasic | asmparse.py | https://github.com/boriel/zxbasic/blob/23b28db10e41117805bdb3c0f78543590853b132/asmparse.py#L1394-L1397 | def p_preprocessor_line_line(p):
""" preproc_line : _LINE INTEGER
"""
p.lexer.lineno = int(p[2]) + p.lexer.lineno - p.lineno(2) | [
"def",
"p_preprocessor_line_line",
"(",
"p",
")",
":",
"p",
".",
"lexer",
".",
"lineno",
"=",
"int",
"(",
"p",
"[",
"2",
"]",
")",
"+",
"p",
".",
"lexer",
".",
"lineno",
"-",
"p",
".",
"lineno",
"(",
"2",
")"
] | preproc_line : _LINE INTEGER | [
"preproc_line",
":",
"_LINE",
"INTEGER"
] | python | train |
diging/tethne | tethne/readers/wos.py | https://github.com/diging/tethne/blob/ba10eeb264b7a3f2dbcce71cfd5cb2d6bbf7055f/tethne/readers/wos.py#L242-L253 | def postprocess_subject(self, entry):
"""
Parse subject keywords.
Subject keywords are usually semicolon-delimited.
"""
if type(entry.subject) not in [str, unicode]:
subject = u' '.join([unicode(k) for k in entry.subject])
else:
subject = entry.s... | [
"def",
"postprocess_subject",
"(",
"self",
",",
"entry",
")",
":",
"if",
"type",
"(",
"entry",
".",
"subject",
")",
"not",
"in",
"[",
"str",
",",
"unicode",
"]",
":",
"subject",
"=",
"u' '",
".",
"join",
"(",
"[",
"unicode",
"(",
"k",
")",
"for",
... | Parse subject keywords.
Subject keywords are usually semicolon-delimited. | [
"Parse",
"subject",
"keywords",
"."
] | python | train |
payplug/payplug-python | payplug/notifications.py | https://github.com/payplug/payplug-python/blob/42dec9d6bff420dd0c26e51a84dd000adff04331/payplug/notifications.py#L8-L34 | def treat(request_body):
"""
Treat a notification and guarantee its authenticity.
:param request_body: The request body in plain text.
:type request_body: string
:return: A safe APIResource
:rtype: APIResource
"""
# Python 3+ support
if isinstance(request_body, six.binary_type):
... | [
"def",
"treat",
"(",
"request_body",
")",
":",
"# Python 3+ support",
"if",
"isinstance",
"(",
"request_body",
",",
"six",
".",
"binary_type",
")",
":",
"request_body",
"=",
"request_body",
".",
"decode",
"(",
"'utf-8'",
")",
"try",
":",
"data",
"=",
"json",... | Treat a notification and guarantee its authenticity.
:param request_body: The request body in plain text.
:type request_body: string
:return: A safe APIResource
:rtype: APIResource | [
"Treat",
"a",
"notification",
"and",
"guarantee",
"its",
"authenticity",
"."
] | python | train |
bastibe/PySoundCard | pysoundcard.py | https://github.com/bastibe/PySoundCard/blob/fb16460b75a1bb416089ebecdf700fa954faa5b7/pysoundcard.py#L427-L438 | def stop(self):
"""Terminate audio processing.
This waits until all pending audio buffers have been played
before it returns. If successful, the stream is considered
inactive.
"""
err = _pa.Pa_StopStream(self._stream)
if err == _pa.paStreamIsStopped:
... | [
"def",
"stop",
"(",
"self",
")",
":",
"err",
"=",
"_pa",
".",
"Pa_StopStream",
"(",
"self",
".",
"_stream",
")",
"if",
"err",
"==",
"_pa",
".",
"paStreamIsStopped",
":",
"return",
"self",
".",
"_handle_error",
"(",
"err",
")"
] | Terminate audio processing.
This waits until all pending audio buffers have been played
before it returns. If successful, the stream is considered
inactive. | [
"Terminate",
"audio",
"processing",
"."
] | python | train |
OnroerendErfgoed/skosprovider_getty | skosprovider_getty/providers.py | https://github.com/OnroerendErfgoed/skosprovider_getty/blob/5aa0b5a8525d607e07b631499ff31bac7a0348b7/skosprovider_getty/providers.py#L227-L275 | def _get_answer(self, query, **kwargs):
# send request to getty
""" Returns the results of the Sparql query to a :class:`lst` of concepts and collections.
The return :class:`lst` can be empty.
:param query (str): Sparql query
:returns: A :class:`lst` of concepts and collect... | [
"def",
"_get_answer",
"(",
"self",
",",
"query",
",",
"*",
"*",
"kwargs",
")",
":",
"# send request to getty",
"request",
"=",
"self",
".",
"base_url",
"+",
"\"sparql.json\"",
"try",
":",
"res",
"=",
"self",
".",
"session",
".",
"get",
"(",
"request",
",... | Returns the results of the Sparql query to a :class:`lst` of concepts and collections.
The return :class:`lst` can be empty.
:param query (str): Sparql query
:returns: A :class:`lst` of concepts and collections. Each of these
is a dict with the following keys:
* id:... | [
"Returns",
"the",
"results",
"of",
"the",
"Sparql",
"query",
"to",
"a",
":",
"class",
":",
"lst",
"of",
"concepts",
"and",
"collections",
".",
"The",
"return",
":",
"class",
":",
"lst",
"can",
"be",
"empty",
"."
] | python | train |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/visuals/transforms/chain.py#L251-L295 | def source_changed(self, event):
"""Generate a simplified chain by joining adjacent transforms.
"""
# bail out early if the chain is empty
transforms = self._chain.transforms[:]
if len(transforms) == 0:
self.transforms = []
return
# If the... | [
"def",
"source_changed",
"(",
"self",
",",
"event",
")",
":",
"# bail out early if the chain is empty",
"transforms",
"=",
"self",
".",
"_chain",
".",
"transforms",
"[",
":",
"]",
"if",
"len",
"(",
"transforms",
")",
"==",
"0",
":",
"self",
".",
"transforms"... | Generate a simplified chain by joining adjacent transforms. | [
"Generate",
"a",
"simplified",
"chain",
"by",
"joining",
"adjacent",
"transforms",
"."
] | python | train |
TissueMAPS/TmDeploy | elasticluster/elasticluster/cluster.py | https://github.com/TissueMAPS/TmDeploy/blob/f891b4ffb21431988bc4a063ae871da3bf284a45/elasticluster/elasticluster/cluster.py#L477-L499 | def _start_node(node):
"""
Start the given node VM.
:return: bool -- True on success, False otherwise
"""
log.debug("_start_node: working on node `%s`", node.name)
# FIXME: the following check is not optimal yet. When a node is still
# in a starting state, it wil... | [
"def",
"_start_node",
"(",
"node",
")",
":",
"log",
".",
"debug",
"(",
"\"_start_node: working on node `%s`\"",
",",
"node",
".",
"name",
")",
"# FIXME: the following check is not optimal yet. When a node is still",
"# in a starting state, it will start another node here, since the... | Start the given node VM.
:return: bool -- True on success, False otherwise | [
"Start",
"the",
"given",
"node",
"VM",
"."
] | python | train |
allenai/allennlp | allennlp/semparse/worlds/wikitables_world.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/worlds/wikitables_world.py#L124-L134 | def _remove_action_from_type(valid_actions: Dict[str, List[str]],
type_: str,
filter_function: Callable[[str], bool]) -> None:
"""
Finds the production rule matching the filter function in the given type's valid action
list, and r... | [
"def",
"_remove_action_from_type",
"(",
"valid_actions",
":",
"Dict",
"[",
"str",
",",
"List",
"[",
"str",
"]",
"]",
",",
"type_",
":",
"str",
",",
"filter_function",
":",
"Callable",
"[",
"[",
"str",
"]",
",",
"bool",
"]",
")",
"->",
"None",
":",
"a... | Finds the production rule matching the filter function in the given type's valid action
list, and removes it. If there is more than one matching function, we crash. | [
"Finds",
"the",
"production",
"rule",
"matching",
"the",
"filter",
"function",
"in",
"the",
"given",
"type",
"s",
"valid",
"action",
"list",
"and",
"removes",
"it",
".",
"If",
"there",
"is",
"more",
"than",
"one",
"matching",
"function",
"we",
"crash",
"."... | python | train |
hughsie/python-appstream | appstream/component.py | https://github.com/hughsie/python-appstream/blob/f2606380278c5728ee7f8e7d19914c54fca05e76/appstream/component.py#L78-L108 | def _parse_tree(self, node):
""" Parse a <review> object """
if 'date' in node.attrib:
dt = dateutil.parser.parse(node.attrib['date'])
self.date = int(dt.strftime("%s"))
if 'id' in node.attrib:
self.id = node.attrib['id']
if 'karma' in node.attrib:
... | [
"def",
"_parse_tree",
"(",
"self",
",",
"node",
")",
":",
"if",
"'date'",
"in",
"node",
".",
"attrib",
":",
"dt",
"=",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"node",
".",
"attrib",
"[",
"'date'",
"]",
")",
"self",
".",
"date",
"=",
"int",
... | Parse a <review> object | [
"Parse",
"a",
"<review",
">",
"object"
] | python | train |
atztogo/phonopy | phonopy/api_phonopy.py | https://github.com/atztogo/phonopy/blob/869cc2ba9e7d495d5f4cf6942415ab3fc9e2a10f/phonopy/api_phonopy.py#L1695-L1717 | def get_partial_DOS(self):
"""Return frequency points and partial DOS as a tuple.
Projection is done to atoms and may be also done along directions
depending on the parameters at run_partial_dos.
Returns
-------
A tuple with (frequency_points, partial_dos).
fre... | [
"def",
"get_partial_DOS",
"(",
"self",
")",
":",
"warnings",
".",
"warn",
"(",
"\"Phonopy.get_partial_DOS is deprecated. \"",
"\"Use Phonopy.get_projected_dos_dict.\"",
",",
"DeprecationWarning",
")",
"pdos",
"=",
"self",
".",
"get_projected_dos_dict",
"(",
")",
"return",... | Return frequency points and partial DOS as a tuple.
Projection is done to atoms and may be also done along directions
depending on the parameters at run_partial_dos.
Returns
-------
A tuple with (frequency_points, partial_dos).
frequency_points: ndarray
sha... | [
"Return",
"frequency",
"points",
"and",
"partial",
"DOS",
"as",
"a",
"tuple",
"."
] | python | train |
adamheins/r12 | r12/shell.py | https://github.com/adamheins/r12/blob/ff78178332140930bf46a94a0b15ee082bb92491/r12/shell.py#L180-L188 | def do_status(self, arg):
''' Print information about the arm. '''
info = self.arm.get_info()
max_len = len(max(info.keys(), key=len))
print(self.style.theme('\nArm Status'))
for key, value in info.items():
print(self.style.help(key.ljust(max_len + 2), str(value)))
... | [
"def",
"do_status",
"(",
"self",
",",
"arg",
")",
":",
"info",
"=",
"self",
".",
"arm",
".",
"get_info",
"(",
")",
"max_len",
"=",
"len",
"(",
"max",
"(",
"info",
".",
"keys",
"(",
")",
",",
"key",
"=",
"len",
")",
")",
"print",
"(",
"self",
... | Print information about the arm. | [
"Print",
"information",
"about",
"the",
"arm",
"."
] | python | train |
freelancer/freelancer-sdk-python | freelancersdk/resources/users/users.py | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L62-L77 | def add_user_jobs(session, job_ids):
"""
Add a list of jobs to the currently authenticated user
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_post_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status_code == 200:
return... | [
"def",
"add_user_jobs",
"(",
"session",
",",
"job_ids",
")",
":",
"jobs_data",
"=",
"{",
"'jobs[]'",
":",
"job_ids",
"}",
"response",
"=",
"make_post_request",
"(",
"session",
",",
"'self/jobs'",
",",
"json_data",
"=",
"jobs_data",
")",
"json_data",
"=",
"re... | Add a list of jobs to the currently authenticated user | [
"Add",
"a",
"list",
"of",
"jobs",
"to",
"the",
"currently",
"authenticated",
"user"
] | python | valid |
brocade/pynos | pynos/versions/base/lldp.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/base/lldp.py#L92-L110 | def get_lldp_neighbors_request(last_ifindex, rbridge_id):
""" Creates a new Netconf request based on the last received or if
rbridge_id is specifed
ifindex when the hasMore flag is true
"""
request_lldp = ET.Element(
'get-lldp-neighbor-detail',
xmlns="urn... | [
"def",
"get_lldp_neighbors_request",
"(",
"last_ifindex",
",",
"rbridge_id",
")",
":",
"request_lldp",
"=",
"ET",
".",
"Element",
"(",
"'get-lldp-neighbor-detail'",
",",
"xmlns",
"=",
"\"urn:brocade.com:mgmt:brocade-lldp-ext\"",
")",
"if",
"rbridge_id",
"is",
"not",
"... | Creates a new Netconf request based on the last received or if
rbridge_id is specifed
ifindex when the hasMore flag is true | [
"Creates",
"a",
"new",
"Netconf",
"request",
"based",
"on",
"the",
"last",
"received",
"or",
"if",
"rbridge_id",
"is",
"specifed",
"ifindex",
"when",
"the",
"hasMore",
"flag",
"is",
"true"
] | python | train |
hasgeek/coaster | coaster/sqlalchemy/mixins.py | https://github.com/hasgeek/coaster/blob/07f7eb5d5f516e22fa14fdf4dc70e0ae13ee398d/coaster/sqlalchemy/mixins.py#L305-L311 | def _set_fields(self, fields):
"""Helper method for :meth:`upsert` in the various subclasses"""
for f in fields:
if hasattr(self, f):
setattr(self, f, fields[f])
else:
raise TypeError("'{arg}' is an invalid argument for {instance_type}".format(arg=... | [
"def",
"_set_fields",
"(",
"self",
",",
"fields",
")",
":",
"for",
"f",
"in",
"fields",
":",
"if",
"hasattr",
"(",
"self",
",",
"f",
")",
":",
"setattr",
"(",
"self",
",",
"f",
",",
"fields",
"[",
"f",
"]",
")",
"else",
":",
"raise",
"TypeError",... | Helper method for :meth:`upsert` in the various subclasses | [
"Helper",
"method",
"for",
":",
"meth",
":",
"upsert",
"in",
"the",
"various",
"subclasses"
] | python | train |
acorg/dark-matter | dark/html.py | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/html.py#L274-L293 | def _writeFASTA(self, i, image):
"""
Write a FASTA file containing the set of reads that hit a sequence.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: A C{str}, either 'fasta' or 'fastq' indicating the format
of t... | [
"def",
"_writeFASTA",
"(",
"self",
",",
"i",
",",
"image",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"_titlesAlignments",
".",
"readsAlignments",
".",
"reads",
",",
"FastqReads",
")",
":",
"format_",
"=",
"'fastq'",
"else",
":",
"format_",
"=",
"'f... | Write a FASTA file containing the set of reads that hit a sequence.
@param i: The number of the image in self._images.
@param image: A member of self._images.
@return: A C{str}, either 'fasta' or 'fastq' indicating the format
of the reads in C{self._titlesAlignments}. | [
"Write",
"a",
"FASTA",
"file",
"containing",
"the",
"set",
"of",
"reads",
"that",
"hit",
"a",
"sequence",
"."
] | python | train |
hvac/hvac | hvac/api/auth_methods/mfa.py | https://github.com/hvac/hvac/blob/cce5b86889193f622c2a72a4a1b7e1c9c8aff1ce/hvac/api/auth_methods/mfa.py#L28-L65 | def configure(self, mount_point, mfa_type='duo', force=False):
"""Configure MFA for a supported method.
This endpoint allows you to turn on multi-factor authentication with a given backend.
Currently only Duo is supported.
Supported methods:
POST: /auth/{mount_point}/mfa_co... | [
"def",
"configure",
"(",
"self",
",",
"mount_point",
",",
"mfa_type",
"=",
"'duo'",
",",
"force",
"=",
"False",
")",
":",
"if",
"mfa_type",
"!=",
"'duo'",
"and",
"not",
"force",
":",
"# The situation described via this exception is not likely to change in the future."... | Configure MFA for a supported method.
This endpoint allows you to turn on multi-factor authentication with a given backend.
Currently only Duo is supported.
Supported methods:
POST: /auth/{mount_point}/mfa_config. Produces: 204 (empty body)
:param mount_point: The "path" t... | [
"Configure",
"MFA",
"for",
"a",
"supported",
"method",
"."
] | python | train |
StackStorm/pybind | pybind/slxos/v17s_1_02/brocade_dot1ag_rpc/__init__.py | https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17s_1_02/brocade_dot1ag_rpc/__init__.py#L95-L116 | def _set_get_show_cfm(self, v, load=False):
"""
Setter method for get_show_cfm, mapped from YANG variable /brocade_dot1ag_rpc/get_show_cfm (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_get_show_cfm is considered as a private
method. Backends looking to popula... | [
"def",
"_set_get_show_cfm",
"(",
"self",
",",
"v",
",",
"load",
"=",
"False",
")",
":",
"if",
"hasattr",
"(",
"v",
",",
"\"_utype\"",
")",
":",
"v",
"=",
"v",
".",
"_utype",
"(",
"v",
")",
"try",
":",
"t",
"=",
"YANGDynClass",
"(",
"v",
",",
"b... | Setter method for get_show_cfm, mapped from YANG variable /brocade_dot1ag_rpc/get_show_cfm (rpc)
If this variable is read-only (config: false) in the
source YANG file, then _set_get_show_cfm is considered as a private
method. Backends looking to populate this variable should
do so via calling thisObj._s... | [
"Setter",
"method",
"for",
"get_show_cfm",
"mapped",
"from",
"YANG",
"variable",
"/",
"brocade_dot1ag_rpc",
"/",
"get_show_cfm",
"(",
"rpc",
")",
"If",
"this",
"variable",
"is",
"read",
"-",
"only",
"(",
"config",
":",
"false",
")",
"in",
"the",
"source",
... | python | train |
dougalsutherland/skl-groups | skl_groups/summaries/bag_of_words.py | https://github.com/dougalsutherland/skl-groups/blob/2584c10a413626c6d5f9078cdbf3dcc84e4e9a5b/skl_groups/summaries/bag_of_words.py#L115-L134 | def fit_transform(self, X):
'''
Compute clustering and transform a list of bag features into its
bag-of-words representation. Like calling fit(X) and then transform(X),
but more efficient.
Parameters
----------
X : :class:`skl_groups.features.Features` or list of... | [
"def",
"fit_transform",
"(",
"self",
",",
"X",
")",
":",
"X",
"=",
"as_features",
"(",
"X",
",",
"stack",
"=",
"True",
")",
"self",
".",
"kmeans_fit_",
"=",
"copy",
"(",
"self",
".",
"kmeans",
")",
"assignments",
"=",
"self",
".",
"kmeans_fit_",
".",... | Compute clustering and transform a list of bag features into its
bag-of-words representation. Like calling fit(X) and then transform(X),
but more efficient.
Parameters
----------
X : :class:`skl_groups.features.Features` or list of bag feature arrays
New data to tran... | [
"Compute",
"clustering",
"and",
"transform",
"a",
"list",
"of",
"bag",
"features",
"into",
"its",
"bag",
"-",
"of",
"-",
"words",
"representation",
".",
"Like",
"calling",
"fit",
"(",
"X",
")",
"and",
"then",
"transform",
"(",
"X",
")",
"but",
"more",
... | python | valid |
StagPython/StagPy | stagpy/rprof.py | https://github.com/StagPython/StagPy/blob/18c4416cc4a1011db2fd736ee8b0ec29aa6e4fd4/stagpy/rprof.py#L165-L196 | def plot_every_step(sdat, lovs):
"""Plot profiles at each time step.
Args:
sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
lovs (nested list of str): nested list of profile names such as
the one produced by :func:`stagpy.misc.list_of_vars`.
Other Parameter... | [
"def",
"plot_every_step",
"(",
"sdat",
",",
"lovs",
")",
":",
"sovs",
"=",
"misc",
".",
"set_of_vars",
"(",
"lovs",
")",
"for",
"step",
"in",
"sdat",
".",
"walk",
".",
"filter",
"(",
"rprof",
"=",
"True",
")",
":",
"rprofs",
"=",
"{",
"}",
"rads",
... | Plot profiles at each time step.
Args:
sdat (:class:`~stagpy.stagyydata.StagyyData`): a StagyyData instance.
lovs (nested list of str): nested list of profile names such as
the one produced by :func:`stagpy.misc.list_of_vars`.
Other Parameters:
conf.core.snapshots: the slic... | [
"Plot",
"profiles",
"at",
"each",
"time",
"step",
"."
] | python | train |
tensorflow/tensor2tensor | tensor2tensor/utils/metrics.py | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/utils/metrics.py#L652-L667 | def create_eager_metrics(metric_names, weights_fn=common_layers.weights_all):
"""Create metrics accumulators and averager for Eager mode.
Args:
metric_names: list<str> from Metrics enum
weights_fn: function that takes labels and returns a weights mask. Defaults
to weights of all 1, i.e. common_layers... | [
"def",
"create_eager_metrics",
"(",
"metric_names",
",",
"weights_fn",
"=",
"common_layers",
".",
"weights_all",
")",
":",
"metric_fns",
"=",
"dict",
"(",
"[",
"(",
"name",
",",
"METRICS_FNS",
"[",
"name",
"]",
")",
"for",
"name",
"in",
"metric_names",
"]",
... | Create metrics accumulators and averager for Eager mode.
Args:
metric_names: list<str> from Metrics enum
weights_fn: function that takes labels and returns a weights mask. Defaults
to weights of all 1, i.e. common_layers.weights_all. Use
common_layers.weights_nonzero if labels have 0-padding.
... | [
"Create",
"metrics",
"accumulators",
"and",
"averager",
"for",
"Eager",
"mode",
"."
] | python | train |
facetoe/zenpy | zenpy/lib/api_objects/__init__.py | https://github.com/facetoe/zenpy/blob/34c54c7e408b9ed01604ddf8b3422204c8bf31ea/zenpy/lib/api_objects/__init__.py#L4228-L4233 | def sharing_agreements(self):
"""
| Comment: The ids of the sharing agreements used for this ticket
"""
if self.api and self.sharing_agreement_ids:
return self.api._get_sharing_agreements(self.sharing_agreement_ids) | [
"def",
"sharing_agreements",
"(",
"self",
")",
":",
"if",
"self",
".",
"api",
"and",
"self",
".",
"sharing_agreement_ids",
":",
"return",
"self",
".",
"api",
".",
"_get_sharing_agreements",
"(",
"self",
".",
"sharing_agreement_ids",
")"
] | | Comment: The ids of the sharing agreements used for this ticket | [
"|",
"Comment",
":",
"The",
"ids",
"of",
"the",
"sharing",
"agreements",
"used",
"for",
"this",
"ticket"
] | python | train |
keepkey/python-keepkey | keepkeylib/transport.py | https://github.com/keepkey/python-keepkey/blob/8318e3a8c4025d499342130ce4305881a325c013/keepkeylib/transport.py#L71-L83 | def read(self):
"""
If there is data available to be read from the transport, reads the data and tries to parse it as a protobuf message. If the parsing succeeds, return a protobuf object.
Otherwise, returns None.
"""
if not self.ready_to_read():
return None
... | [
"def",
"read",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"ready_to_read",
"(",
")",
":",
"return",
"None",
"data",
"=",
"self",
".",
"_read",
"(",
")",
"if",
"data",
"is",
"None",
":",
"return",
"None",
"return",
"self",
".",
"_parse_message",... | If there is data available to be read from the transport, reads the data and tries to parse it as a protobuf message. If the parsing succeeds, return a protobuf object.
Otherwise, returns None. | [
"If",
"there",
"is",
"data",
"available",
"to",
"be",
"read",
"from",
"the",
"transport",
"reads",
"the",
"data",
"and",
"tries",
"to",
"parse",
"it",
"as",
"a",
"protobuf",
"message",
".",
"If",
"the",
"parsing",
"succeeds",
"return",
"a",
"protobuf",
"... | python | train |
ajenhl/tacl | tacl/text.py | https://github.com/ajenhl/tacl/blob/b8a343248e77f1c07a5a4ac133a9ad6e0b4781c2/tacl/text.py#L50-L72 | def get_ngrams(self, minimum, maximum, skip_sizes=None):
"""Returns a generator supplying the n-grams (`minimum` <= n
<= `maximum`) for this text.
Each iteration of the generator supplies a tuple consisting of
the size of the n-grams and a `collections.Counter` of the
n-grams.
... | [
"def",
"get_ngrams",
"(",
"self",
",",
"minimum",
",",
"maximum",
",",
"skip_sizes",
"=",
"None",
")",
":",
"skip_sizes",
"=",
"skip_sizes",
"or",
"[",
"]",
"tokens",
"=",
"self",
".",
"get_tokens",
"(",
")",
"for",
"size",
"in",
"range",
"(",
"minimum... | Returns a generator supplying the n-grams (`minimum` <= n
<= `maximum`) for this text.
Each iteration of the generator supplies a tuple consisting of
the size of the n-grams and a `collections.Counter` of the
n-grams.
:param minimum: minimum n-gram size
:type minimum: `... | [
"Returns",
"a",
"generator",
"supplying",
"the",
"n",
"-",
"grams",
"(",
"minimum",
"<",
"=",
"n",
"<",
"=",
"maximum",
")",
"for",
"this",
"text",
"."
] | python | train |
alex-kostirin/pyatomac | atomac/ldtpd/text.py | https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/text.py#L272-L292 | def appendtext(self, window_name, object_name, data):
"""
Append string sequence.
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either fu... | [
"def",
"appendtext",
"(",
"self",
",",
"window_name",
",",
"object_name",
",",
"data",
")",
":",
"object_handle",
"=",
"self",
".",
"_get_object_handle",
"(",
"window_name",
",",
"object_name",
")",
"if",
"not",
"object_handle",
".",
"AXEnabled",
":",
"raise",... | Append string sequence.
@param window_name: Window name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type window_name: string
@param object_name: Object name to type in, either full name,
LDTP's name convention, or a Unix glob.
@type ob... | [
"Append",
"string",
"sequence",
".",
"@param",
"window_name",
":",
"Window",
"name",
"to",
"type",
"in",
"either",
"full",
"name",
"LDTP",
"s",
"name",
"convention",
"or",
"a",
"Unix",
"glob",
".",
"@type",
"window_name",
":",
"string",
"@param",
"object_nam... | python | valid |
hayd/pep8radius | setup.py | https://github.com/hayd/pep8radius/blob/0c1d14835d390f7feeb602f35a768e52ce306a0a/setup.py#L13-L20 | def version():
"""Return version string."""
with open(os.path.join(os.path.abspath(os.path.dirname(__file__)),
'pep8radius',
'main.py')) as input_file:
for line in input_file:
if line.startswith('__version__'):
return pars... | [
"def",
"version",
"(",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
",",
"'pep8radius'",
",",
"'main.py'",
")",
")",
"as"... | Return version string. | [
"Return",
"version",
"string",
"."
] | python | train |
Duke-GCB/DukeDSClient | ddsc/ddsclient.py | https://github.com/Duke-GCB/DukeDSClient/blob/117f68fb9bae82e4c81ea487ad5d61ac350f3726/ddsc/ddsclient.py#L358-L369 | def run(self, args):
"""
Lists project names.
:param args Namespace arguments parsed from the command line
"""
long_format = args.long_format
# project_name and auth_role args are mutually exclusive
if args.project_name or args.project_id:
project = se... | [
"def",
"run",
"(",
"self",
",",
"args",
")",
":",
"long_format",
"=",
"args",
".",
"long_format",
"# project_name and auth_role args are mutually exclusive",
"if",
"args",
".",
"project_name",
"or",
"args",
".",
"project_id",
":",
"project",
"=",
"self",
".",
"f... | Lists project names.
:param args Namespace arguments parsed from the command line | [
"Lists",
"project",
"names",
".",
":",
"param",
"args",
"Namespace",
"arguments",
"parsed",
"from",
"the",
"command",
"line"
] | python | train |
ECRL/ecabc | ecabc/abc.py | https://github.com/ECRL/ecabc/blob/4e73125ff90bfeeae359a5ab1badba8894d70eaa/ecabc/abc.py#L620-L636 | def save_settings(self, filename):
'''Save settings to a JSON file
Arge:
filename (string): name of the file to save to
'''
data = dict()
data['valueRanges'] = self._value_ranges
data['best_values'] = [str(value) for value in self._best_values]
data[... | [
"def",
"save_settings",
"(",
"self",
",",
"filename",
")",
":",
"data",
"=",
"dict",
"(",
")",
"data",
"[",
"'valueRanges'",
"]",
"=",
"self",
".",
"_value_ranges",
"data",
"[",
"'best_values'",
"]",
"=",
"[",
"str",
"(",
"value",
")",
"for",
"value",
... | Save settings to a JSON file
Arge:
filename (string): name of the file to save to | [
"Save",
"settings",
"to",
"a",
"JSON",
"file"
] | python | train |
CxAalto/gtfspy | gtfspy/gtfs.py | https://github.com/CxAalto/gtfspy/blob/bddba4b74faae6c1b91202f19184811e326547e5/gtfspy/gtfs.py#L1519-L1549 | def get_straight_line_transfer_distances(self, stop_I=None):
"""
Get (straight line) distances to stations that can be transferred to.
Parameters
----------
stop_I : int, optional
If not specified return all possible transfer distances
Returns
------... | [
"def",
"get_straight_line_transfer_distances",
"(",
"self",
",",
"stop_I",
"=",
"None",
")",
":",
"if",
"stop_I",
"is",
"not",
"None",
":",
"query",
"=",
"u\"\"\" SELECT from_stop_I, to_stop_I, d\n FROM stop_distances\n WHERE\n ... | Get (straight line) distances to stations that can be transferred to.
Parameters
----------
stop_I : int, optional
If not specified return all possible transfer distances
Returns
-------
distances: pandas.DataFrame
each row has the following item... | [
"Get",
"(",
"straight",
"line",
")",
"distances",
"to",
"stations",
"that",
"can",
"be",
"transferred",
"to",
"."
] | python | valid |
StyXman/ayrton | ayrton/parser/error.py | https://github.com/StyXman/ayrton/blob/e1eed5c7ef230e3c2340a1f0bf44c72bbdc0debb/ayrton/parser/error.py#L112-L117 | def print_application_traceback(self, space, file=None):
"NOT_RPYTHON: Dump a standard application-level traceback."
if file is None:
file = sys.stderr
self.print_app_tb_only(file)
print >> file, self.errorstr(space) | [
"def",
"print_application_traceback",
"(",
"self",
",",
"space",
",",
"file",
"=",
"None",
")",
":",
"if",
"file",
"is",
"None",
":",
"file",
"=",
"sys",
".",
"stderr",
"self",
".",
"print_app_tb_only",
"(",
"file",
")",
"print",
">>",
"file",
",",
"se... | NOT_RPYTHON: Dump a standard application-level traceback. | [
"NOT_RPYTHON",
":",
"Dump",
"a",
"standard",
"application",
"-",
"level",
"traceback",
"."
] | python | train |
openego/eDisGo | edisgo/grid/components.py | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/components.py#L552-L596 | def timeseries_reactive(self):
"""
Reactive power time series in kvar.
Parameters
-----------
timeseries_reactive : :pandas:`pandas.Seriese<series>`
Series containing reactive power in kvar.
Returns
-------
:pandas:`pandas.Series<series>` or ... | [
"def",
"timeseries_reactive",
"(",
"self",
")",
":",
"if",
"self",
".",
"_timeseries_reactive",
"is",
"None",
":",
"if",
"self",
".",
"grid",
".",
"network",
".",
"timeseries",
".",
"generation_reactive_power",
"is",
"not",
"None",
":",
"try",
":",
"timeseri... | Reactive power time series in kvar.
Parameters
-----------
timeseries_reactive : :pandas:`pandas.Seriese<series>`
Series containing reactive power in kvar.
Returns
-------
:pandas:`pandas.Series<series>` or None
Series containing reactive power t... | [
"Reactive",
"power",
"time",
"series",
"in",
"kvar",
"."
] | python | train |
saltstack/salt | salt/modules/boto_vpc.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_vpc.py#L2471-L2529 | def describe_route_table(route_table_id=None, route_table_name=None,
tags=None, region=None, key=None, keyid=None,
profile=None):
'''
Given route table properties, return route table details if matching table(s) exist.
.. versionadded:: 2015.8.0
CLI Ex... | [
"def",
"describe_route_table",
"(",
"route_table_id",
"=",
"None",
",",
"route_table_name",
"=",
"None",
",",
"tags",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"s... | Given route table properties, return route table details if matching table(s) exist.
.. versionadded:: 2015.8.0
CLI Example:
.. code-block:: bash
salt myminion boto_vpc.describe_route_table route_table_id='rtb-1f382e7d' | [
"Given",
"route",
"table",
"properties",
"return",
"route",
"table",
"details",
"if",
"matching",
"table",
"(",
"s",
")",
"exist",
"."
] | python | train |
andreikop/qutepart | qutepart/syntax/parser.py | https://github.com/andreikop/qutepart/blob/109d76b239751318bcef06f39b2fbbf18687a40b/qutepart/syntax/parser.py#L742-L756 | def _tryMatch(self, textToMatchObject):
"""Try to find themselves in the text.
Returns (count, matchedRule) or (None, None) if doesn't match
"""
for rule in self.context.rules:
ruleTryMatchResult = rule.tryMatch(textToMatchObject)
if ruleTryMatchResult is not None... | [
"def",
"_tryMatch",
"(",
"self",
",",
"textToMatchObject",
")",
":",
"for",
"rule",
"in",
"self",
".",
"context",
".",
"rules",
":",
"ruleTryMatchResult",
"=",
"rule",
".",
"tryMatch",
"(",
"textToMatchObject",
")",
"if",
"ruleTryMatchResult",
"is",
"not",
"... | Try to find themselves in the text.
Returns (count, matchedRule) or (None, None) if doesn't match | [
"Try",
"to",
"find",
"themselves",
"in",
"the",
"text",
".",
"Returns",
"(",
"count",
"matchedRule",
")",
"or",
"(",
"None",
"None",
")",
"if",
"doesn",
"t",
"match"
] | python | train |
bids-standard/pybids | bids/variables/kollekshuns.py | https://github.com/bids-standard/pybids/blob/30d924ce770622bda0e390d613a8da42a2a20c32/bids/variables/kollekshuns.py#L69-L86 | def merge_variables(variables, **kwargs):
''' Concatenates Variables along row axis.
Args:
variables (list): List of Variables to merge. Variables can have
different names (and all Variables that share a name will be
concatenated together).
Returns:
... | [
"def",
"merge_variables",
"(",
"variables",
",",
"*",
"*",
"kwargs",
")",
":",
"var_dict",
"=",
"OrderedDict",
"(",
")",
"for",
"v",
"in",
"variables",
":",
"if",
"v",
".",
"name",
"not",
"in",
"var_dict",
":",
"var_dict",
"[",
"v",
".",
"name",
"]",... | Concatenates Variables along row axis.
Args:
variables (list): List of Variables to merge. Variables can have
different names (and all Variables that share a name will be
concatenated together).
Returns:
A list of Variables. | [
"Concatenates",
"Variables",
"along",
"row",
"axis",
"."
] | python | train |
emory-libraries/eulfedora | eulfedora/syncutil.py | https://github.com/emory-libraries/eulfedora/blob/161826f3fdcdab4007f6fa7dfd9f1ecabc4bcbe4/eulfedora/syncutil.py#L469-L501 | def binarycontent_sections(chunk):
'''Split a chunk of data into sections by start and end binary
content tags.'''
# using string split because it is significantly faster than regex.
# use common text of start and end tags to split the text
# (i.e. without < or </ tag beginning)
binary_content_... | [
"def",
"binarycontent_sections",
"(",
"chunk",
")",
":",
"# using string split because it is significantly faster than regex.",
"# use common text of start and end tags to split the text",
"# (i.e. without < or </ tag beginning)",
"binary_content_tag",
"=",
"BINARY_CONTENT_START",
"[",
"1"... | Split a chunk of data into sections by start and end binary
content tags. | [
"Split",
"a",
"chunk",
"of",
"data",
"into",
"sections",
"by",
"start",
"and",
"end",
"binary",
"content",
"tags",
"."
] | python | train |
portfors-lab/sparkle | sparkle/gui/dialogs/calibration_dlg.py | https://github.com/portfors-lab/sparkle/blob/5fad1cf2bec58ec6b15d91da20f6236a74826110/sparkle/gui/dialogs/calibration_dlg.py#L34-L46 | def maxRange(self):
"""Sets the maximum range for the currently selection calibration,
determined from its range of values store on file
"""
try:
x, freqs = self.datafile.get_calibration(str(self.ui.calChoiceCmbbx.currentText()), self.calf)
self.ui.frangeLowSpnbx.... | [
"def",
"maxRange",
"(",
"self",
")",
":",
"try",
":",
"x",
",",
"freqs",
"=",
"self",
".",
"datafile",
".",
"get_calibration",
"(",
"str",
"(",
"self",
".",
"ui",
".",
"calChoiceCmbbx",
".",
"currentText",
"(",
")",
")",
",",
"self",
".",
"calf",
"... | Sets the maximum range for the currently selection calibration,
determined from its range of values store on file | [
"Sets",
"the",
"maximum",
"range",
"for",
"the",
"currently",
"selection",
"calibration",
"determined",
"from",
"its",
"range",
"of",
"values",
"store",
"on",
"file"
] | python | train |
codenerix/django-codenerix | codenerix/forms.py | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/forms.py#L95-L502 | def get_groups(self, gs=None, processed=[], initial=True):
'''
<--------------------------------------- 12 columns ------------------------------------>
<--- 6 columns ---> <--- 6 columns --->
------------------------------------------ -----------... | [
"def",
"get_groups",
"(",
"self",
",",
"gs",
"=",
"None",
",",
"processed",
"=",
"[",
"]",
",",
"initial",
"=",
"True",
")",
":",
"# Check if language is set",
"if",
"not",
"self",
".",
"__language",
":",
"raise",
"IOError",
"(",
"\"ERROR: No language suplie... | <--------------------------------------- 12 columns ------------------------------------>
<--- 6 columns ---> <--- 6 columns --->
------------------------------------------ ------------------------------------------
| Info ... | [
"<",
"---------------------------------------",
"12",
"columns",
"------------------------------------",
">",
"<",
"---",
"6",
"columns",
"---",
">",
"<",
"---",
"6",
"columns",
"---",
">",
"------------------------------------------",
"-----------------------------------------... | python | train |
sphinx-gallery/sphinx-gallery | sphinx_gallery/py_source_parser.py | https://github.com/sphinx-gallery/sphinx-gallery/blob/b0c1f6701bf3f4cef238757e1105cf3686b5e674/sphinx_gallery/py_source_parser.py#L64-L121 | def get_docstring_and_rest(filename):
"""Separate ``filename`` content between docstring and the rest
Strongly inspired from ast.get_docstring.
Returns
-------
docstring : str
docstring of ``filename``
rest : str
``filename`` content without the docstring
"""
node, cont... | [
"def",
"get_docstring_and_rest",
"(",
"filename",
")",
":",
"node",
",",
"content",
"=",
"parse_source_file",
"(",
"filename",
")",
"if",
"node",
"is",
"None",
":",
"return",
"SYNTAX_ERROR_DOCSTRING",
",",
"content",
",",
"1",
"if",
"not",
"isinstance",
"(",
... | Separate ``filename`` content between docstring and the rest
Strongly inspired from ast.get_docstring.
Returns
-------
docstring : str
docstring of ``filename``
rest : str
``filename`` content without the docstring | [
"Separate",
"filename",
"content",
"between",
"docstring",
"and",
"the",
"rest"
] | python | train |
thebigmunch/google-music | src/google_music/clients/mobileclient.py | https://github.com/thebigmunch/google-music/blob/d8a94dab462a1f063fbc1152187a73dc2f0e2a85/src/google_music/clients/mobileclient.py#L1566-L1588 | def songs_add(self, songs):
"""Add store songs to your library.
Parameters:
songs (list): A list of store song dicts.
Returns:
list: Songs' library IDs.
"""
mutations = [mc_calls.TrackBatch.add(song) for song in songs]
response = self._call(
mc_calls.TrackBatch,
mutations
)
success_ids =... | [
"def",
"songs_add",
"(",
"self",
",",
"songs",
")",
":",
"mutations",
"=",
"[",
"mc_calls",
".",
"TrackBatch",
".",
"add",
"(",
"song",
")",
"for",
"song",
"in",
"songs",
"]",
"response",
"=",
"self",
".",
"_call",
"(",
"mc_calls",
".",
"TrackBatch",
... | Add store songs to your library.
Parameters:
songs (list): A list of store song dicts.
Returns:
list: Songs' library IDs. | [
"Add",
"store",
"songs",
"to",
"your",
"library",
"."
] | python | train |
ncclient/ncclient | ncclient/devices/nexus.py | https://github.com/ncclient/ncclient/blob/2b75f2c6a06bd2a5d1be67b01bb65c5ffd2e2d7a/ncclient/devices/nexus.py#L79-L95 | def get_ssh_subsystem_names(self):
"""
Return a list of possible SSH subsystem names.
Different NXOS versions use different SSH subsystem names for netconf.
Therefore, we return a list so that several can be tried, if necessary.
The Nexus device handler also accepts
""... | [
"def",
"get_ssh_subsystem_names",
"(",
"self",
")",
":",
"preferred_ssh_subsystem",
"=",
"self",
".",
"device_params",
".",
"get",
"(",
"\"ssh_subsystem_name\"",
")",
"name_list",
"=",
"[",
"\"netconf\"",
",",
"\"xmlagent\"",
"]",
"if",
"preferred_ssh_subsystem",
":... | Return a list of possible SSH subsystem names.
Different NXOS versions use different SSH subsystem names for netconf.
Therefore, we return a list so that several can be tried, if necessary.
The Nexus device handler also accepts | [
"Return",
"a",
"list",
"of",
"possible",
"SSH",
"subsystem",
"names",
"."
] | python | train |
alex-kostirin/pyatomac | atomac/ldtpd/__init__.py | https://github.com/alex-kostirin/pyatomac/blob/3f46f6feb4504315eec07abb18bb41be4d257aeb/atomac/ldtpd/__init__.py#L65-L94 | def main(port=4118, parentpid=None):
"""Main entry point. Parse command line options and start up a server."""
if "LDTP_DEBUG" in os.environ:
_ldtp_debug = True
else:
_ldtp_debug = False
_ldtp_debug_file = os.environ.get('LDTP_DEBUG_FILE', None)
if _ldtp_debug:
print("Parent ... | [
"def",
"main",
"(",
"port",
"=",
"4118",
",",
"parentpid",
"=",
"None",
")",
":",
"if",
"\"LDTP_DEBUG\"",
"in",
"os",
".",
"environ",
":",
"_ldtp_debug",
"=",
"True",
"else",
":",
"_ldtp_debug",
"=",
"False",
"_ldtp_debug_file",
"=",
"os",
".",
"environ"... | Main entry point. Parse command line options and start up a server. | [
"Main",
"entry",
"point",
".",
"Parse",
"command",
"line",
"options",
"and",
"start",
"up",
"a",
"server",
"."
] | python | valid |
Clinical-Genomics/scout | scout/adapter/mongo/panel.py | https://github.com/Clinical-Genomics/scout/blob/90a551e2e1653a319e654c2405c2866f93d0ebb9/scout/adapter/mongo/panel.py#L155-L173 | def add_gene_panel(self, panel_obj):
"""Add a gene panel to the database
Args:
panel_obj(dict)
"""
panel_name = panel_obj['panel_name']
panel_version = panel_obj['version']
display_name = panel_obj.get('display_name', panel_name)
if self.gene... | [
"def",
"add_gene_panel",
"(",
"self",
",",
"panel_obj",
")",
":",
"panel_name",
"=",
"panel_obj",
"[",
"'panel_name'",
"]",
"panel_version",
"=",
"panel_obj",
"[",
"'version'",
"]",
"display_name",
"=",
"panel_obj",
".",
"get",
"(",
"'display_name'",
",",
"pan... | Add a gene panel to the database
Args:
panel_obj(dict) | [
"Add",
"a",
"gene",
"panel",
"to",
"the",
"database"
] | python | test |
jtwhite79/pyemu | pyemu/prototypes/da.py | https://github.com/jtwhite79/pyemu/blob/c504d8e7a4097cec07655a6318d275739bd8148a/pyemu/prototypes/da.py#L445-L459 | def model_temporal_evolotion(self, time_index, cycle_files):
"""
- The function prepares the model for this time cycle
- Any time-dependant forcing should be handled here. This includes temporal stresses, boundary conditions, and
initial conditions.
- Two options are availabl... | [
"def",
"model_temporal_evolotion",
"(",
"self",
",",
"time_index",
",",
"cycle_files",
")",
":",
"for",
"file",
"in",
"cycle_files",
":",
"# generate log here about files being updated",
"self",
".",
"update_inputfile",
"(",
"file",
"[",
"0",
"]",
",",
"file",
"["... | - The function prepares the model for this time cycle
- Any time-dependant forcing should be handled here. This includes temporal stresses, boundary conditions, and
initial conditions.
- Two options are available (1) template files to update input parameters
... | [
"-",
"The",
"function",
"prepares",
"the",
"model",
"for",
"this",
"time",
"cycle",
"-",
"Any",
"time",
"-",
"dependant",
"forcing",
"should",
"be",
"handled",
"here",
".",
"This",
"includes",
"temporal",
"stresses",
"boundary",
"conditions",
"and",
"initial",... | python | train |
pawel-kow/domainconnect_python | domainconnect/domainconnect.py | https://github.com/pawel-kow/domainconnect_python/blob/2467093cc4e997234e0fb5c55e71f76b856c1ab1/domainconnect/domainconnect.py#L297-L342 | def get_domain_connect_template_sync_url(self, domain, provider_id, service_id, redirect_uri=None, params=None,
state=None, group_ids=None):
"""Makes full Domain Connect discovery of a domain and returns full url to request sync consent.
:param domain: str
... | [
"def",
"get_domain_connect_template_sync_url",
"(",
"self",
",",
"domain",
",",
"provider_id",
",",
"service_id",
",",
"redirect_uri",
"=",
"None",
",",
"params",
"=",
"None",
",",
"state",
"=",
"None",
",",
"group_ids",
"=",
"None",
")",
":",
"# TODO: support... | Makes full Domain Connect discovery of a domain and returns full url to request sync consent.
:param domain: str
:param provider_id: str
:param service_id: str
:param redirect_uri: str
:param params: dict
:param state: str
:param group_ids: list(str)
:ret... | [
"Makes",
"full",
"Domain",
"Connect",
"discovery",
"of",
"a",
"domain",
"and",
"returns",
"full",
"url",
"to",
"request",
"sync",
"consent",
"."
] | python | train |
Esri/ArcREST | src/arcrest/manageorg/_community.py | https://github.com/Esri/ArcREST/blob/ab240fde2b0200f61d4a5f6df033516e53f2f416/src/arcrest/manageorg/_community.py#L119-L143 | def getGroupIDs(self, groupNames,communityInfo=None):
"""
This function retrieves the group IDs
Inputs:
group_names - tuple of group names
Output:
dict - list of group IDs
"""
group_ids=[]
if communityInfo is None:
... | [
"def",
"getGroupIDs",
"(",
"self",
",",
"groupNames",
",",
"communityInfo",
"=",
"None",
")",
":",
"group_ids",
"=",
"[",
"]",
"if",
"communityInfo",
"is",
"None",
":",
"communityInfo",
"=",
"self",
".",
"communitySelf",
"if",
"isinstance",
"(",
"groupNames"... | This function retrieves the group IDs
Inputs:
group_names - tuple of group names
Output:
dict - list of group IDs | [
"This",
"function",
"retrieves",
"the",
"group",
"IDs"
] | python | train |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Node/__init__.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Node/__init__.py#L1232-L1242 | def add_dependency(self, depend):
"""Adds dependencies."""
try:
self._add_child(self.depends, self.depends_set, depend)
except TypeError as e:
e = e.args[0]
if SCons.Util.is_List(e):
s = list(map(str, e))
else:
s = s... | [
"def",
"add_dependency",
"(",
"self",
",",
"depend",
")",
":",
"try",
":",
"self",
".",
"_add_child",
"(",
"self",
".",
"depends",
",",
"self",
".",
"depends_set",
",",
"depend",
")",
"except",
"TypeError",
"as",
"e",
":",
"e",
"=",
"e",
".",
"args",... | Adds dependencies. | [
"Adds",
"dependencies",
"."
] | python | train |
lsst-sqre/sqre-codekit | codekit/pygithub.py | https://github.com/lsst-sqre/sqre-codekit/blob/98122404cd9065d4d1d570867fe518042669126c/codekit/pygithub.py#L292-L302 | def debug_ratelimit(g):
"""Log debug of github ratelimit information from last API call
Parameters
----------
org: github.MainClass.Github
github object
"""
assert isinstance(g, github.MainClass.Github), type(g)
debug("github ratelimit: {rl}".format(rl=g.rate_limiting)) | [
"def",
"debug_ratelimit",
"(",
"g",
")",
":",
"assert",
"isinstance",
"(",
"g",
",",
"github",
".",
"MainClass",
".",
"Github",
")",
",",
"type",
"(",
"g",
")",
"debug",
"(",
"\"github ratelimit: {rl}\"",
".",
"format",
"(",
"rl",
"=",
"g",
".",
"rate_... | Log debug of github ratelimit information from last API call
Parameters
----------
org: github.MainClass.Github
github object | [
"Log",
"debug",
"of",
"github",
"ratelimit",
"information",
"from",
"last",
"API",
"call"
] | python | train |
pyusb/pyusb | usb/control.py | https://github.com/pyusb/pyusb/blob/ffe6faf42c6ad273880b0b464b9bbf44c1d4b2e9/usb/control.py#L188-L206 | def get_configuration(dev):
r"""Get the current active configuration of the device.
dev is the Device object to which the request will be
sent to.
This function differs from the Device.get_active_configuration
method because the later may use cached data, while this
function always does a devi... | [
"def",
"get_configuration",
"(",
"dev",
")",
":",
"bmRequestType",
"=",
"util",
".",
"build_request_type",
"(",
"util",
".",
"CTRL_IN",
",",
"util",
".",
"CTRL_TYPE_STANDARD",
",",
"util",
".",
"CTRL_RECIPIENT_DEVICE",
")",
"return",
"dev",
".",
"ctrl_transfer",... | r"""Get the current active configuration of the device.
dev is the Device object to which the request will be
sent to.
This function differs from the Device.get_active_configuration
method because the later may use cached data, while this
function always does a device request. | [
"r",
"Get",
"the",
"current",
"active",
"configuration",
"of",
"the",
"device",
"."
] | python | train |
idlesign/django-siteprefs | siteprefs/utils.py | https://github.com/idlesign/django-siteprefs/blob/3d6bf5e64220fe921468a36fce68e15d7947cf92/siteprefs/utils.py#L392-L408 | def import_prefs():
"""Imports preferences modules from packages (apps) and project root."""
# settings.py locals if autodiscover_siteprefs() is in urls.py
settings_locals = get_frame_locals(3)
if 'self' not in settings_locals: # If not SiteprefsConfig.ready()
# Try to import project-wide... | [
"def",
"import_prefs",
"(",
")",
":",
"# settings.py locals if autodiscover_siteprefs() is in urls.py",
"settings_locals",
"=",
"get_frame_locals",
"(",
"3",
")",
"if",
"'self'",
"not",
"in",
"settings_locals",
":",
"# If not SiteprefsConfig.ready()",
"# Try to import project-w... | Imports preferences modules from packages (apps) and project root. | [
"Imports",
"preferences",
"modules",
"from",
"packages",
"(",
"apps",
")",
"and",
"project",
"root",
"."
] | python | valid |
GNS3/gns3-server | gns3server/compute/virtualbox/virtualbox_vm.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/compute/virtualbox/virtualbox_vm.py#L890-L933 | def _create_linked_clone(self):
"""
Creates a new linked clone.
"""
gns3_snapshot_exists = False
vm_info = yield from self._get_vm_info()
for entry, value in vm_info.items():
if entry.startswith("SnapshotName") and value == "GNS3 Linked Base for clones":
... | [
"def",
"_create_linked_clone",
"(",
"self",
")",
":",
"gns3_snapshot_exists",
"=",
"False",
"vm_info",
"=",
"yield",
"from",
"self",
".",
"_get_vm_info",
"(",
")",
"for",
"entry",
",",
"value",
"in",
"vm_info",
".",
"items",
"(",
")",
":",
"if",
"entry",
... | Creates a new linked clone. | [
"Creates",
"a",
"new",
"linked",
"clone",
"."
] | python | train |
rackerlabs/simpl | simpl/incubator/dicts.py | https://github.com/rackerlabs/simpl/blob/60ed3336a931cd6a7a7246e60f26165d9dc7c99c/simpl/incubator/dicts.py#L233-L264 | def merge_lists(dest, source, extend_lists=False):
"""Recursively merge two lists.
:keyword extend_lists: if true, just extends lists instead of merging them.
This applies merge_dictionary if any of the entries are dicts.
Note: This updates dest and returns it.
"""
if not source:
retur... | [
"def",
"merge_lists",
"(",
"dest",
",",
"source",
",",
"extend_lists",
"=",
"False",
")",
":",
"if",
"not",
"source",
":",
"return",
"if",
"not",
"extend_lists",
":",
"# Make them the same size",
"left",
"=",
"dest",
"right",
"=",
"source",
"[",
":",
"]",
... | Recursively merge two lists.
:keyword extend_lists: if true, just extends lists instead of merging them.
This applies merge_dictionary if any of the entries are dicts.
Note: This updates dest and returns it. | [
"Recursively",
"merge",
"two",
"lists",
"."
] | python | train |
phaethon/kamene | kamene/contrib/gsm_um.py | https://github.com/phaethon/kamene/blob/11d4064844f4f68ac5d7546f5633ac7d02082914/kamene/contrib/gsm_um.py#L1860-L1874 | def modifyReject(LowLayerCompatibility_presence=0,
HighLayerCompatibility_presence=0):
"""MODIFY REJECT Section 9.3.15"""
a = TpPd(pd=0x3)
b = MessageType(mesType=0x13) # 00010011
c = BearerCapability()
d = Cause()
packet = a / b / c / d
if LowLayerCompatibility_presence is... | [
"def",
"modifyReject",
"(",
"LowLayerCompatibility_presence",
"=",
"0",
",",
"HighLayerCompatibility_presence",
"=",
"0",
")",
":",
"a",
"=",
"TpPd",
"(",
"pd",
"=",
"0x3",
")",
"b",
"=",
"MessageType",
"(",
"mesType",
"=",
"0x13",
")",
"# 00010011",
"c",
... | MODIFY REJECT Section 9.3.15 | [
"MODIFY",
"REJECT",
"Section",
"9",
".",
"3",
".",
"15"
] | python | train |
nephila/python-taiga | taiga/models/base.py | https://github.com/nephila/python-taiga/blob/5b471d6b8b59e5d410162a6f1c2f0d4188445a56/taiga/models/base.py#L221-L232 | def parse(cls, requester, entry):
"""
Turns a JSON object into a model instance.
"""
if not type(entry) is dict:
return entry
for key_to_parse, cls_to_parse in six.iteritems(cls.parser):
if key_to_parse in entry:
entry[key_to_parse] = cls_t... | [
"def",
"parse",
"(",
"cls",
",",
"requester",
",",
"entry",
")",
":",
"if",
"not",
"type",
"(",
"entry",
")",
"is",
"dict",
":",
"return",
"entry",
"for",
"key_to_parse",
",",
"cls_to_parse",
"in",
"six",
".",
"iteritems",
"(",
"cls",
".",
"parser",
... | Turns a JSON object into a model instance. | [
"Turns",
"a",
"JSON",
"object",
"into",
"a",
"model",
"instance",
"."
] | python | train |
numberoverzero/bloop | bloop/search.py | https://github.com/numberoverzero/bloop/blob/4c95f5a0ff0802443a1c258bfaccecd1758363e7/bloop/search.py#L245-L257 | def prepare(
self, engine=None, mode=None, model=None, index=None, key=None,
filter=None, projection=None, consistent=None, forward=None, parallel=None):
"""Validates the search parameters and builds the base request dict for each Query/Scan call."""
self.prepare_iterator_cls(en... | [
"def",
"prepare",
"(",
"self",
",",
"engine",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"model",
"=",
"None",
",",
"index",
"=",
"None",
",",
"key",
"=",
"None",
",",
"filter",
"=",
"None",
",",
"projection",
"=",
"None",
",",
"consistent",
"=",
... | Validates the search parameters and builds the base request dict for each Query/Scan call. | [
"Validates",
"the",
"search",
"parameters",
"and",
"builds",
"the",
"base",
"request",
"dict",
"for",
"each",
"Query",
"/",
"Scan",
"call",
"."
] | python | train |
Azure/azure-sdk-for-python | azure-servicebus/azure/servicebus/receive_handler.py | https://github.com/Azure/azure-sdk-for-python/blob/d7306fde32f60a293a7567678692bdad31e4b667/azure-servicebus/azure/servicebus/receive_handler.py#L665-L702 | def list_sessions(self, updated_since=None, max_results=100, skip=0):
"""List session IDs.
List the Session IDs with pending messages in the queue where the state of the session
has been updated since the timestamp provided. If no timestamp is provided, all will be returned.
If the stat... | [
"def",
"list_sessions",
"(",
"self",
",",
"updated_since",
"=",
"None",
",",
"max_results",
"=",
"100",
",",
"skip",
"=",
"0",
")",
":",
"if",
"int",
"(",
"max_results",
")",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"\"max_results must be 1 or greater.\"",... | List session IDs.
List the Session IDs with pending messages in the queue where the state of the session
has been updated since the timestamp provided. If no timestamp is provided, all will be returned.
If the state of a Session has never been set, it will not be returned regardless of whether
... | [
"List",
"session",
"IDs",
"."
] | python | test |
python-cmd2/cmd2 | cmd2/rl_utils.py | https://github.com/python-cmd2/cmd2/blob/b22c0bd891ed08c8b09df56df9d91f48166a5e2a/cmd2/rl_utils.py#L151-L162 | def rl_get_point() -> int: # pragma: no cover
"""
Returns the offset of the current cursor position in rl_line_buffer
"""
if rl_type == RlType.GNU:
return ctypes.c_int.in_dll(readline_lib, "rl_point").value
elif rl_type == RlType.PYREADLINE:
return readline.rl.mode.l_buffer.point
... | [
"def",
"rl_get_point",
"(",
")",
"->",
"int",
":",
"# pragma: no cover",
"if",
"rl_type",
"==",
"RlType",
".",
"GNU",
":",
"return",
"ctypes",
".",
"c_int",
".",
"in_dll",
"(",
"readline_lib",
",",
"\"rl_point\"",
")",
".",
"value",
"elif",
"rl_type",
"=="... | Returns the offset of the current cursor position in rl_line_buffer | [
"Returns",
"the",
"offset",
"of",
"the",
"current",
"cursor",
"position",
"in",
"rl_line_buffer"
] | python | train |
lambdamusic/Ontospy | ontospy/extras/hacks/sketch.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/sketch.py#L134-L146 | def __serializedDot(self):
"""
DOT format:
digraph graphname {
a -> b [label=instanceOf];
b -> d [label=isA];
}
"""
temp = ""
for x,y,z in self.rdflib_graph.triples((None, None, None)):
temp += """"%s" -> "%s" [label="%s"];\n""" % (self.namespace_manager.normalizeUri(x), self.namespace_manager... | [
"def",
"__serializedDot",
"(",
"self",
")",
":",
"temp",
"=",
"\"\"",
"for",
"x",
",",
"y",
",",
"z",
"in",
"self",
".",
"rdflib_graph",
".",
"triples",
"(",
"(",
"None",
",",
"None",
",",
"None",
")",
")",
":",
"temp",
"+=",
"\"\"\"\"%s\" -> \"%s\" ... | DOT format:
digraph graphname {
a -> b [label=instanceOf];
b -> d [label=isA];
} | [
"DOT",
"format",
":",
"digraph",
"graphname",
"{",
"a",
"-",
">",
"b",
"[",
"label",
"=",
"instanceOf",
"]",
";",
"b",
"-",
">",
"d",
"[",
"label",
"=",
"isA",
"]",
";",
"}"
] | python | train |
pyca/pyopenssl | src/OpenSSL/crypto.py | https://github.com/pyca/pyopenssl/blob/1fbe064c50fd030948141d7d630673761525b0d0/src/OpenSSL/crypto.py#L1156-L1182 | def sign(self, pkey, digest):
"""
Sign the certificate with this key and digest type.
:param pkey: The key to sign with.
:type pkey: :py:class:`PKey`
:param digest: The name of the message digest to use.
:type digest: :py:class:`bytes`
:return: :py:data:`None`
... | [
"def",
"sign",
"(",
"self",
",",
"pkey",
",",
"digest",
")",
":",
"if",
"not",
"isinstance",
"(",
"pkey",
",",
"PKey",
")",
":",
"raise",
"TypeError",
"(",
"\"pkey must be a PKey instance\"",
")",
"if",
"pkey",
".",
"_only_public",
":",
"raise",
"ValueErro... | Sign the certificate with this key and digest type.
:param pkey: The key to sign with.
:type pkey: :py:class:`PKey`
:param digest: The name of the message digest to use.
:type digest: :py:class:`bytes`
:return: :py:data:`None` | [
"Sign",
"the",
"certificate",
"with",
"this",
"key",
"and",
"digest",
"type",
"."
] | python | test |
alefnula/tea | tea/utils/__init__.py | https://github.com/alefnula/tea/blob/f5a0a724a425ec4f9dd2c7fe966ef06faf3a15a3/tea/utils/__init__.py#L177-L189 | def get_exception():
"""Return full formatted traceback as a string."""
trace = ""
exception = ""
exc_list = traceback.format_exception_only(
sys.exc_info()[0], sys.exc_info()[1]
)
for entry in exc_list:
exception += entry
tb_list = traceback.format_tb(sys.exc_info()[2])
... | [
"def",
"get_exception",
"(",
")",
":",
"trace",
"=",
"\"\"",
"exception",
"=",
"\"\"",
"exc_list",
"=",
"traceback",
".",
"format_exception_only",
"(",
"sys",
".",
"exc_info",
"(",
")",
"[",
"0",
"]",
",",
"sys",
".",
"exc_info",
"(",
")",
"[",
"1",
... | Return full formatted traceback as a string. | [
"Return",
"full",
"formatted",
"traceback",
"as",
"a",
"string",
"."
] | python | train |
stevearc/dql | dql/expressions/constraint.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/expressions/constraint.py#L160-L170 | def _get_fields(self, attr):
""" Get the hash/range fields of all joined constraints """
ret = set()
if "OR" in self.pieces:
return ret
for i in range(0, len(self.pieces), 2):
const = self.pieces[i]
field = getattr(const, attr)
if field is ... | [
"def",
"_get_fields",
"(",
"self",
",",
"attr",
")",
":",
"ret",
"=",
"set",
"(",
")",
"if",
"\"OR\"",
"in",
"self",
".",
"pieces",
":",
"return",
"ret",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"self",
".",
"pieces",
")",
",",
"2"... | Get the hash/range fields of all joined constraints | [
"Get",
"the",
"hash",
"/",
"range",
"fields",
"of",
"all",
"joined",
"constraints"
] | python | train |
mottosso/be | be/cli.py | https://github.com/mottosso/be/blob/0f3d4f3597c71223f616d78c6d9b2c8dffcd8a71/be/cli.py#L614-L620 | def mkdir(dir, enter):
"""Create directory with template for topic of the current environment
"""
if not os.path.exists(dir):
os.makedirs(dir) | [
"def",
"mkdir",
"(",
"dir",
",",
"enter",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"dir",
")",
":",
"os",
".",
"makedirs",
"(",
"dir",
")"
] | Create directory with template for topic of the current environment | [
"Create",
"directory",
"with",
"template",
"for",
"topic",
"of",
"the",
"current",
"environment"
] | python | train |
annoviko/pyclustering | pyclustering/nnet/hhn.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/hhn.py#L465-L549 | def hnn_state(self, inputs, t, argv):
"""!
@brief Returns new values of excitatory and inhibitory parts of oscillator and potential of oscillator.
@param[in] inputs (list): States of oscillator for integration [v, m, h, n] (see description below).
@param[in] t (double): Cur... | [
"def",
"hnn_state",
"(",
"self",
",",
"inputs",
",",
"t",
",",
"argv",
")",
":",
"index",
"=",
"argv",
"v",
"=",
"inputs",
"[",
"0",
"]",
"# membrane potential (v).\r",
"m",
"=",
"inputs",
"[",
"1",
"]",
"# activation conductance of the sodium channel (m).\r",... | !
@brief Returns new values of excitatory and inhibitory parts of oscillator and potential of oscillator.
@param[in] inputs (list): States of oscillator for integration [v, m, h, n] (see description below).
@param[in] t (double): Current time of simulation.
@param[in] argv ... | [
"!"
] | python | valid |
Telefonica/toolium | toolium/selenoid.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/selenoid.py#L75-L109 | def __download_file(self, url, path_file, timeout):
"""
download a file from the server using a request with retries policy
:param url: server url to request
:param path_file: path and file where to download
:param timeout: threshold until the video file is downloaded
:re... | [
"def",
"__download_file",
"(",
"self",
",",
"url",
",",
"path_file",
",",
"timeout",
")",
":",
"status_code",
"=",
"0",
"init_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"driver_wrapper",
".",
"logger",
".",
"info",
"(",
"'Downloading file from... | download a file from the server using a request with retries policy
:param url: server url to request
:param path_file: path and file where to download
:param timeout: threshold until the video file is downloaded
:return boolean | [
"download",
"a",
"file",
"from",
"the",
"server",
"using",
"a",
"request",
"with",
"retries",
"policy",
":",
"param",
"url",
":",
"server",
"url",
"to",
"request",
":",
"param",
"path_file",
":",
"path",
"and",
"file",
"where",
"to",
"download",
":",
"pa... | python | train |
mgedmin/findimports | findimports.py | https://github.com/mgedmin/findimports/blob/c20a50b497390fed15aa3835476f4fad57313e8a/findimports.py#L483-L511 | def findModuleOfName(self, dotted_name, level, filename, extrapath=None):
"""Given a fully qualified name, find what module contains it."""
if dotted_name.endswith('.*'):
return dotted_name[:-2]
name = dotted_name
# extrapath is None only in a couple of test cases; in real l... | [
"def",
"findModuleOfName",
"(",
"self",
",",
"dotted_name",
",",
"level",
",",
"filename",
",",
"extrapath",
"=",
"None",
")",
":",
"if",
"dotted_name",
".",
"endswith",
"(",
"'.*'",
")",
":",
"return",
"dotted_name",
"[",
":",
"-",
"2",
"]",
"name",
"... | Given a fully qualified name, find what module contains it. | [
"Given",
"a",
"fully",
"qualified",
"name",
"find",
"what",
"module",
"contains",
"it",
"."
] | python | train |
david-cortes/costsensitive | costsensitive/__init__.py | https://github.com/david-cortes/costsensitive/blob/355fbf20397ce673ce9e22048b6c52dbeeb354cc/costsensitive/__init__.py#L722-L741 | def fit(self, X, C):
"""
Fit one weighted classifier per class
Parameters
----------
X : array (n_samples, n_features)
The data on which to fit a cost-sensitive classifier.
C : array (n_samples, n_classes)
The cost of predicting each label... | [
"def",
"fit",
"(",
"self",
",",
"X",
",",
"C",
")",
":",
"X",
",",
"C",
"=",
"_check_fit_input",
"(",
"X",
",",
"C",
")",
"C",
"=",
"np",
".",
"asfortranarray",
"(",
"C",
")",
"self",
".",
"nclasses",
"=",
"C",
".",
"shape",
"[",
"1",
"]",
... | Fit one weighted classifier per class
Parameters
----------
X : array (n_samples, n_features)
The data on which to fit a cost-sensitive classifier.
C : array (n_samples, n_classes)
The cost of predicting each label for each observation (more means worse). | [
"Fit",
"one",
"weighted",
"classifier",
"per",
"class",
"Parameters",
"----------",
"X",
":",
"array",
"(",
"n_samples",
"n_features",
")",
"The",
"data",
"on",
"which",
"to",
"fit",
"a",
"cost",
"-",
"sensitive",
"classifier",
".",
"C",
":",
"array",
"(",... | python | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L212-L225 | def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name):
"""Return a function that gives the types in the union type rooted at base_name."""
# When edges point to vertices of type base_name, and base_name is both non-abstract and
# has subclasses, we need to represent t... | [
"def",
"_create_union_types_specification",
"(",
"schema_graph",
",",
"graphql_types",
",",
"hidden_classes",
",",
"base_name",
")",
":",
"# When edges point to vertices of type base_name, and base_name is both non-abstract and",
"# has subclasses, we need to represent the edge endpoint ty... | Return a function that gives the types in the union type rooted at base_name. | [
"Return",
"a",
"function",
"that",
"gives",
"the",
"types",
"in",
"the",
"union",
"type",
"rooted",
"at",
"base_name",
"."
] | python | train |
abingham/docopt-subcommands | docopt_subcommands/subcommands.py | https://github.com/abingham/docopt-subcommands/blob/4b5cd75bb8eed01f9405345446ca58e9a29d67ad/docopt_subcommands/subcommands.py#L90-L96 | def command(self, name=None):
"""A decorator to add subcommands.
"""
def decorator(f):
self.add_command(f, name)
return f
return decorator | [
"def",
"command",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"self",
".",
"add_command",
"(",
"f",
",",
"name",
")",
"return",
"f",
"return",
"decorator"
] | A decorator to add subcommands. | [
"A",
"decorator",
"to",
"add",
"subcommands",
"."
] | python | train |
obriencj/python-javatools | javatools/__init__.py | https://github.com/obriencj/python-javatools/blob/9e2332b452ddc508bed0615937dddcb2cf051557/javatools/__init__.py#L222-L248 | def deref_const(self, index):
"""
returns the dereferenced value from the const pool. For simple
types, this will be a single value indicating the constant.
For more complex types, such as fieldref, methodref, etc, this
will return a tuple.
"""
if not index:
... | [
"def",
"deref_const",
"(",
"self",
",",
"index",
")",
":",
"if",
"not",
"index",
":",
"raise",
"IndexError",
"(",
"\"Requested const 0\"",
")",
"t",
",",
"v",
"=",
"self",
".",
"consts",
"[",
"index",
"]",
"if",
"t",
"in",
"(",
"CONST_Utf8",
",",
"CO... | returns the dereferenced value from the const pool. For simple
types, this will be a single value indicating the constant.
For more complex types, such as fieldref, methodref, etc, this
will return a tuple. | [
"returns",
"the",
"dereferenced",
"value",
"from",
"the",
"const",
"pool",
".",
"For",
"simple",
"types",
"this",
"will",
"be",
"a",
"single",
"value",
"indicating",
"the",
"constant",
".",
"For",
"more",
"complex",
"types",
"such",
"as",
"fieldref",
"method... | python | train |
ilevkivskyi/typing_inspect | typing_inspect.py | https://github.com/ilevkivskyi/typing_inspect/blob/fd81278cc440b6003f8298bcb22d5bc0f82ee3cd/typing_inspect.py#L66-L90 | def is_callable_type(tp):
"""Test if the type is a generic callable type, including subclasses
excluding non-generic types and callables.
Examples::
is_callable_type(int) == False
is_callable_type(type) == False
is_callable_type(Callable) == True
is_callable_type(Callable[..... | [
"def",
"is_callable_type",
"(",
"tp",
")",
":",
"if",
"NEW_TYPING",
":",
"return",
"(",
"tp",
"is",
"Callable",
"or",
"isinstance",
"(",
"tp",
",",
"_GenericAlias",
")",
"and",
"tp",
".",
"__origin__",
"is",
"collections",
".",
"abc",
".",
"Callable",
"o... | Test if the type is a generic callable type, including subclasses
excluding non-generic types and callables.
Examples::
is_callable_type(int) == False
is_callable_type(type) == False
is_callable_type(Callable) == True
is_callable_type(Callable[..., int]) == True
is_calla... | [
"Test",
"if",
"the",
"type",
"is",
"a",
"generic",
"callable",
"type",
"including",
"subclasses",
"excluding",
"non",
"-",
"generic",
"types",
"and",
"callables",
".",
"Examples",
"::"
] | python | train |
watson-developer-cloud/python-sdk | ibm_watson/compare_comply_v1.py | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/compare_comply_v1.py#L3444-L3451 | def _from_dict(cls, _dict):
"""Initialize a KeyValuePair object from a json dictionary."""
args = {}
if 'key' in _dict:
args['key'] = Key._from_dict(_dict.get('key'))
if 'value' in _dict:
args['value'] = Value._from_dict(_dict.get('value'))
return cls(**ar... | [
"def",
"_from_dict",
"(",
"cls",
",",
"_dict",
")",
":",
"args",
"=",
"{",
"}",
"if",
"'key'",
"in",
"_dict",
":",
"args",
"[",
"'key'",
"]",
"=",
"Key",
".",
"_from_dict",
"(",
"_dict",
".",
"get",
"(",
"'key'",
")",
")",
"if",
"'value'",
"in",
... | Initialize a KeyValuePair object from a json dictionary. | [
"Initialize",
"a",
"KeyValuePair",
"object",
"from",
"a",
"json",
"dictionary",
"."
] | python | train |
angr/angr | angr/state_plugins/gdb.py | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/gdb.py#L33-L49 | def set_stack(self, stack_dump, stack_top):
"""
Stack dump is a dump of the stack from gdb, i.e. the result of the following gdb command :
``dump binary memory [stack_dump] [begin_addr] [end_addr]``
We set the stack to the same addresses as the gdb session to avoid pointers corruption.... | [
"def",
"set_stack",
"(",
"self",
",",
"stack_dump",
",",
"stack_top",
")",
":",
"data",
"=",
"self",
".",
"_read_data",
"(",
"stack_dump",
")",
"self",
".",
"real_stack_top",
"=",
"stack_top",
"addr",
"=",
"stack_top",
"-",
"len",
"(",
"data",
")",
"# Ad... | Stack dump is a dump of the stack from gdb, i.e. the result of the following gdb command :
``dump binary memory [stack_dump] [begin_addr] [end_addr]``
We set the stack to the same addresses as the gdb session to avoid pointers corruption.
:param stack_dump: The dump file.
:param stac... | [
"Stack",
"dump",
"is",
"a",
"dump",
"of",
"the",
"stack",
"from",
"gdb",
"i",
".",
"e",
".",
"the",
"result",
"of",
"the",
"following",
"gdb",
"command",
":"
] | python | train |
sbg/sevenbridges-python | sevenbridges/models/project.py | https://github.com/sbg/sevenbridges-python/blob/f62640d1018d959f0b686f2dbe5e183085336607/sevenbridges/models/project.py#L251-L276 | def add_member_email(self, email, permissions=None):
"""
Add a member to the project using member email.
:param email: Member email.
:param permissions: Permissions dictionary.
:return: Member object.
"""
data = {'email': email}
if isinstance(permissions,... | [
"def",
"add_member_email",
"(",
"self",
",",
"email",
",",
"permissions",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'email'",
":",
"email",
"}",
"if",
"isinstance",
"(",
"permissions",
",",
"dict",
")",
":",
"data",
".",
"update",
"(",
"{",
"'permissio... | Add a member to the project using member email.
:param email: Member email.
:param permissions: Permissions dictionary.
:return: Member object. | [
"Add",
"a",
"member",
"to",
"the",
"project",
"using",
"member",
"email",
".",
":",
"param",
"email",
":",
"Member",
"email",
".",
":",
"param",
"permissions",
":",
"Permissions",
"dictionary",
".",
":",
"return",
":",
"Member",
"object",
"."
] | python | train |
FlaskGuys/Flask-Imagine | flask_imagine/filters/rotate.py | https://github.com/FlaskGuys/Flask-Imagine/blob/f79c6517ecb5480b63a2b3b8554edb6e2ac8be8c/flask_imagine/filters/rotate.py#L23-L36 | def apply(self, resource):
"""
Apply filter to resource
:param resource: Image
:return: Image
"""
if not isinstance(resource, Image.Image):
raise ValueError('Unknown resource format')
resource_format = resource.format
resource = resource.rotat... | [
"def",
"apply",
"(",
"self",
",",
"resource",
")",
":",
"if",
"not",
"isinstance",
"(",
"resource",
",",
"Image",
".",
"Image",
")",
":",
"raise",
"ValueError",
"(",
"'Unknown resource format'",
")",
"resource_format",
"=",
"resource",
".",
"format",
"resour... | Apply filter to resource
:param resource: Image
:return: Image | [
"Apply",
"filter",
"to",
"resource",
":",
"param",
"resource",
":",
"Image",
":",
"return",
":",
"Image"
] | python | train |
saltstack/salt | salt/modules/namecheap_domains.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/namecheap_domains.py#L304-L376 | def get_list(list_type=None,
search_term=None,
page=None,
page_size=None,
sort_by=None):
'''
Returns a list of domains for the particular user as a list of objects
offset by ``page`` length of ``page_size``
list_type : ALL
One of ``ALL``, ``EX... | [
"def",
"get_list",
"(",
"list_type",
"=",
"None",
",",
"search_term",
"=",
"None",
",",
"page",
"=",
"None",
",",
"page_size",
"=",
"None",
",",
"sort_by",
"=",
"None",
")",
":",
"opts",
"=",
"salt",
".",
"utils",
".",
"namecheap",
".",
"get_opts",
"... | Returns a list of domains for the particular user as a list of objects
offset by ``page`` length of ``page_size``
list_type : ALL
One of ``ALL``, ``EXPIRING``, ``EXPIRED``
search_term
Keyword to look for on the domain list
page : 1
Number of result page to return
page_siz... | [
"Returns",
"a",
"list",
"of",
"domains",
"for",
"the",
"particular",
"user",
"as",
"a",
"list",
"of",
"objects",
"offset",
"by",
"page",
"length",
"of",
"page_size"
] | python | train |
f3at/feat | src/feat/models/response.py | https://github.com/f3at/feat/blob/15da93fc9d6ec8154f52a9172824e25821195ef8/src/feat/models/response.py#L42-L48 | def deleted(message):
"""Create a Deleted response builder with specified message."""
def deleted(value, _context, **_params):
return Deleted(value, message)
return deleted | [
"def",
"deleted",
"(",
"message",
")",
":",
"def",
"deleted",
"(",
"value",
",",
"_context",
",",
"*",
"*",
"_params",
")",
":",
"return",
"Deleted",
"(",
"value",
",",
"message",
")",
"return",
"deleted"
] | Create a Deleted response builder with specified message. | [
"Create",
"a",
"Deleted",
"response",
"builder",
"with",
"specified",
"message",
"."
] | python | train |
tensorflow/mesh | mesh_tensorflow/auto_mtf/graph_interface.py | https://github.com/tensorflow/mesh/blob/3921196e5e43302e820da0a87329f25d7e2a3016/mesh_tensorflow/auto_mtf/graph_interface.py#L227-L240 | def is_tensor_on_canonical_device(self, tensor_name):
"""Whether the tensor is on the first (canonical) device.
Tensors not assigned to a device are assumed to be on all devices, including
the canonical device.
Args:
tensor_name: a string, name of a tensor in the graph.
Returns:
a boo... | [
"def",
"is_tensor_on_canonical_device",
"(",
"self",
",",
"tensor_name",
")",
":",
"device",
"=",
"self",
".",
"get_tensor_device",
"(",
"tensor_name",
")",
"return",
"not",
"device",
"or",
"device",
"==",
"self",
".",
"canonical_device"
] | Whether the tensor is on the first (canonical) device.
Tensors not assigned to a device are assumed to be on all devices, including
the canonical device.
Args:
tensor_name: a string, name of a tensor in the graph.
Returns:
a boolean indicating whether the tensor is on the first device. | [
"Whether",
"the",
"tensor",
"is",
"on",
"the",
"first",
"(",
"canonical",
")",
"device",
"."
] | python | train |
davebridges/mousedb | mousedb/animal/views.py | https://github.com/davebridges/mousedb/blob/2a33f6d15d88b1540b05f7232b154fdbf8568580/mousedb/animal/views.py#L415-L446 | def multiple_pups(request):
"""This view is used to enter multiple animals at the same time.
It will generate a form containing animal information and a number of mice. It is intended to create several identical animals with the same attributes.
"""
if request.method == "POST":
form = Multipl... | [
"def",
"multiple_pups",
"(",
"request",
")",
":",
"if",
"request",
".",
"method",
"==",
"\"POST\"",
":",
"form",
"=",
"MultipleAnimalForm",
"(",
"request",
".",
"POST",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"count",
"=",
"form",
".",
"clea... | This view is used to enter multiple animals at the same time.
It will generate a form containing animal information and a number of mice. It is intended to create several identical animals with the same attributes. | [
"This",
"view",
"is",
"used",
"to",
"enter",
"multiple",
"animals",
"at",
"the",
"same",
"time",
".",
"It",
"will",
"generate",
"a",
"form",
"containing",
"animal",
"information",
"and",
"a",
"number",
"of",
"mice",
".",
"It",
"is",
"intended",
"to",
"cr... | python | train |
dankelley/nota | nota/notaclass.py | https://github.com/dankelley/nota/blob/245cd575db60daaea6eebd5edc1d048c5fe23c9b/nota/notaclass.py#L756-L797 | def find_by_hash(self, hash=None, book=-1):
'''Search notes for a given (possibly abbreviated) hash'''
if hash:
self.fyi("nota.find_by_hash() with abbreviated hash %s; book=%s" % (hash, book))
try:
if book < 0:
rows = self.cur.execute("SELECT noteId, hash ... | [
"def",
"find_by_hash",
"(",
"self",
",",
"hash",
"=",
"None",
",",
"book",
"=",
"-",
"1",
")",
":",
"if",
"hash",
":",
"self",
".",
"fyi",
"(",
"\"nota.find_by_hash() with abbreviated hash %s; book=%s\"",
"%",
"(",
"hash",
",",
"book",
")",
")",
"try",
"... | Search notes for a given (possibly abbreviated) hash | [
"Search",
"notes",
"for",
"a",
"given",
"(",
"possibly",
"abbreviated",
")",
"hash"
] | python | train |
google/openhtf | openhtf/plugs/usb/adb_protocol.py | https://github.com/google/openhtf/blob/655e85df7134db7bdf8f8fdd6ff9a6bf932e7b09/openhtf/plugs/usb/adb_protocol.py#L596-L642 | def _handle_message_for_stream(self, stream_transport, message, timeout):
"""Handle an incoming message, check if it's for the given stream.
If the message is not for the stream, then add it to the appropriate
message queue.
Args:
stream_transport: AdbStreamTransport currently waiting on a messa... | [
"def",
"_handle_message_for_stream",
"(",
"self",
",",
"stream_transport",
",",
"message",
",",
"timeout",
")",
":",
"if",
"message",
".",
"command",
"not",
"in",
"(",
"'OKAY'",
",",
"'CLSE'",
",",
"'WRTE'",
")",
":",
"raise",
"usb_exceptions",
".",
"AdbProt... | Handle an incoming message, check if it's for the given stream.
If the message is not for the stream, then add it to the appropriate
message queue.
Args:
stream_transport: AdbStreamTransport currently waiting on a message.
message: Message to check and handle.
timeout: Timeout to use for... | [
"Handle",
"an",
"incoming",
"message",
"check",
"if",
"it",
"s",
"for",
"the",
"given",
"stream",
"."
] | python | train |
Erotemic/utool | utool/util_inspect.py | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_inspect.py#L1227-L1247 | def inherit_kwargs(inherit_func):
"""
TODO move to util_decor
inherit_func = inspect_pdfs
func = encoder.visualize.im_func
"""
import utool as ut
keys, is_arbitrary = ut.get_kwargs(inherit_func)
if is_arbitrary:
keys += ['**kwargs']
kwargs_append = '\n'.join(keys)
#from s... | [
"def",
"inherit_kwargs",
"(",
"inherit_func",
")",
":",
"import",
"utool",
"as",
"ut",
"keys",
",",
"is_arbitrary",
"=",
"ut",
".",
"get_kwargs",
"(",
"inherit_func",
")",
"if",
"is_arbitrary",
":",
"keys",
"+=",
"[",
"'**kwargs'",
"]",
"kwargs_append",
"=",... | TODO move to util_decor
inherit_func = inspect_pdfs
func = encoder.visualize.im_func | [
"TODO",
"move",
"to",
"util_decor",
"inherit_func",
"=",
"inspect_pdfs",
"func",
"=",
"encoder",
".",
"visualize",
".",
"im_func"
] | python | train |
Guake/guake | guake/guake_app.py | https://github.com/Guake/guake/blob/4153ef38f9044cbed6494075fce80acd5809df2b/guake/guake_app.py#L1125-L1142 | def execute_hook(self, event_name):
"""Execute shell commands related to current event_name"""
hook = self.settings.hooks.get_string('{!s}'.format(event_name))
if hook is not None and hook != "":
hook = hook.split()
try:
subprocess.Popen(hook)
... | [
"def",
"execute_hook",
"(",
"self",
",",
"event_name",
")",
":",
"hook",
"=",
"self",
".",
"settings",
".",
"hooks",
".",
"get_string",
"(",
"'{!s}'",
".",
"format",
"(",
"event_name",
")",
")",
"if",
"hook",
"is",
"not",
"None",
"and",
"hook",
"!=",
... | Execute shell commands related to current event_name | [
"Execute",
"shell",
"commands",
"related",
"to",
"current",
"event_name"
] | python | train |
Unidata/siphon | siphon/http_util.py | https://github.com/Unidata/siphon/blob/53fb0d84fbce1c18c8e81c9e68bc81620ee0a6ac/siphon/http_util.py#L277-L297 | def time(self, time):
"""Add a request for a specific time to the query.
This modifies the query in-place, but returns `self` so that multiple queries
can be chained together on one line.
This replaces any existing temporal queries that have been set.
Parameters
------... | [
"def",
"time",
"(",
"self",
",",
"time",
")",
":",
"self",
".",
"_set_query",
"(",
"self",
".",
"time_query",
",",
"time",
"=",
"self",
".",
"_format_time",
"(",
"time",
")",
")",
"return",
"self"
] | Add a request for a specific time to the query.
This modifies the query in-place, but returns `self` so that multiple queries
can be chained together on one line.
This replaces any existing temporal queries that have been set.
Parameters
----------
time : datetime.date... | [
"Add",
"a",
"request",
"for",
"a",
"specific",
"time",
"to",
"the",
"query",
"."
] | python | train |
pypa/pipenv | pipenv/vendor/click/decorators.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/vendor/click/decorators.py#L12-L18 | def pass_context(f):
"""Marks a callback as wanting to receive the current context
object as first argument.
"""
def new_func(*args, **kwargs):
return f(get_current_context(), *args, **kwargs)
return update_wrapper(new_func, f) | [
"def",
"pass_context",
"(",
"f",
")",
":",
"def",
"new_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"f",
"(",
"get_current_context",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"update_wrapper",
"(",
... | Marks a callback as wanting to receive the current context
object as first argument. | [
"Marks",
"a",
"callback",
"as",
"wanting",
"to",
"receive",
"the",
"current",
"context",
"object",
"as",
"first",
"argument",
"."
] | python | train |
diamondman/proteusisc | proteusisc/command_queue.py | https://github.com/diamondman/proteusisc/blob/7622b7b04e63f9dc0f5a04429ff78d9a490c9c5c/proteusisc/command_queue.py#L77-L244 | def _compile_device_specific_prims(self, debug=False,
stages=None, stagenames=None):
"""Using the data stored in the CommandQueue, Extract and align compatible sequences of Primitives and compile/optimize the Primitives down into a stream of Level 2 device agnostic primiti... | [
"def",
"_compile_device_specific_prims",
"(",
"self",
",",
"debug",
"=",
"False",
",",
"stages",
"=",
"None",
",",
"stagenames",
"=",
"None",
")",
":",
"############### GROUPING BY EXEC BOUNDARIES!################",
"fences",
"=",
"[",
"]",
"fence",
"=",
"[",
"sel... | Using the data stored in the CommandQueue, Extract and align compatible sequences of Primitives and compile/optimize the Primitives down into a stream of Level 2 device agnostic primitives.
BACKGROUND:
Device Specific primitives present a special opportunity for
optimization. Many JTAG systems ... | [
"Using",
"the",
"data",
"stored",
"in",
"the",
"CommandQueue",
"Extract",
"and",
"align",
"compatible",
"sequences",
"of",
"Primitives",
"and",
"compile",
"/",
"optimize",
"the",
"Primitives",
"down",
"into",
"a",
"stream",
"of",
"Level",
"2",
"device",
"agnos... | python | train |
django-danceschool/django-danceschool | danceschool/guestlist/models.py | https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/guestlist/models.py#L48-L58 | def currentEvent(self):
'''
Return the first event that hasn't ended yet, or if there are no
future events, the last one to end.
'''
currentEvent = self.recentEvents.filter(endTime__gte=timezone.now()).order_by('startTime').first()
if not currentEvent:
curren... | [
"def",
"currentEvent",
"(",
"self",
")",
":",
"currentEvent",
"=",
"self",
".",
"recentEvents",
".",
"filter",
"(",
"endTime__gte",
"=",
"timezone",
".",
"now",
"(",
")",
")",
".",
"order_by",
"(",
"'startTime'",
")",
".",
"first",
"(",
")",
"if",
"not... | Return the first event that hasn't ended yet, or if there are no
future events, the last one to end. | [
"Return",
"the",
"first",
"event",
"that",
"hasn",
"t",
"ended",
"yet",
"or",
"if",
"there",
"are",
"no",
"future",
"events",
"the",
"last",
"one",
"to",
"end",
"."
] | python | train |
aws/sagemaker-containers | src/sagemaker_containers/_encoders.py | https://github.com/aws/sagemaker-containers/blob/0030f07abbaf22a55d986d97274d7a8d1aa1f10c/src/sagemaker_containers/_encoders.py#L104-L118 | def array_to_csv(array_like): # type: (np.array or Iterable or int or float) -> str
"""Convert an array like object to CSV.
To understand better what an array like object is see:
https://docs.scipy.org/doc/numpy/user/basics.creation.html#converting-python-array-like-objects-to-numpy-arrays
Args:
... | [
"def",
"array_to_csv",
"(",
"array_like",
")",
":",
"# type: (np.array or Iterable or int or float) -> str",
"stream",
"=",
"StringIO",
"(",
")",
"np",
".",
"savetxt",
"(",
"stream",
",",
"array_like",
",",
"delimiter",
"=",
"','",
",",
"fmt",
"=",
"'%s'",
")",
... | Convert an array like object to CSV.
To understand better what an array like object is see:
https://docs.scipy.org/doc/numpy/user/basics.creation.html#converting-python-array-like-objects-to-numpy-arrays
Args:
array_like (np.array or Iterable or int or float): array like object to be converted to ... | [
"Convert",
"an",
"array",
"like",
"object",
"to",
"CSV",
"."
] | python | train |
calmjs/calmjs.parse | src/calmjs/parse/parsers/es5.py | https://github.com/calmjs/calmjs.parse/blob/369f0ee346c5a84c4d5c35a7733a0e63b02eac59/src/calmjs/parse/parsers/es5.py#L400-L416 | def p_property_assignment(self, p):
"""property_assignment \
: property_name COLON assignment_expr
| GETPROP property_name LPAREN RPAREN LBRACE function_body RBRACE
| SETPROP property_name LPAREN property_set_parameter_list RPAREN\
LBRACE function_body R... | [
"def",
"p_property_assignment",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"self",
".",
"asttypes",
".",
"Assign",
"(",
"left",
"=",
"p",
"[",
"1",
"]",
",",
"op",
"=",
"p",
"[",
"2... | property_assignment \
: property_name COLON assignment_expr
| GETPROP property_name LPAREN RPAREN LBRACE function_body RBRACE
| SETPROP property_name LPAREN property_set_parameter_list RPAREN\
LBRACE function_body RBRACE | [
"property_assignment",
"\\",
":",
"property_name",
"COLON",
"assignment_expr",
"|",
"GETPROP",
"property_name",
"LPAREN",
"RPAREN",
"LBRACE",
"function_body",
"RBRACE",
"|",
"SETPROP",
"property_name",
"LPAREN",
"property_set_parameter_list",
"RPAREN",
"\\",
"LBRACE",
"fu... | python | train |
androguard/androguard | androguard/core/bytecodes/dvm.py | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L97-L110 | def read_null_terminated_string(f):
"""
Read a null terminated string from a file-like object.
:param f: file-like object
:rtype: bytearray
"""
x = bytearray()
while True:
z = f.read(1)
if ord(z) == 0:
return x
else:
x.append(ord(z)) | [
"def",
"read_null_terminated_string",
"(",
"f",
")",
":",
"x",
"=",
"bytearray",
"(",
")",
"while",
"True",
":",
"z",
"=",
"f",
".",
"read",
"(",
"1",
")",
"if",
"ord",
"(",
"z",
")",
"==",
"0",
":",
"return",
"x",
"else",
":",
"x",
".",
"appen... | Read a null terminated string from a file-like object.
:param f: file-like object
:rtype: bytearray | [
"Read",
"a",
"null",
"terminated",
"string",
"from",
"a",
"file",
"-",
"like",
"object",
"."
] | python | train |
UCBerkeleySETI/blimpy | blimpy/sigproc.py | https://github.com/UCBerkeleySETI/blimpy/blob/b8822d3e3e911944370d84371a91fa0c29e9772e/blimpy/sigproc.py#L160-L196 | def read_header(filename, return_idxs=False):
""" Read blimpy header and return a Python dictionary of key:value pairs
Args:
filename (str): name of file to open
Optional args:
return_idxs (bool): Default False. If true, returns the file offset indexes
for value... | [
"def",
"read_header",
"(",
"filename",
",",
"return_idxs",
"=",
"False",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fh",
":",
"header_dict",
"=",
"{",
"}",
"header_idxs",
"=",
"{",
"}",
"# Check this is a blimpy file",
"keyword",
"... | Read blimpy header and return a Python dictionary of key:value pairs
Args:
filename (str): name of file to open
Optional args:
return_idxs (bool): Default False. If true, returns the file offset indexes
for values
returns | [
"Read",
"blimpy",
"header",
"and",
"return",
"a",
"Python",
"dictionary",
"of",
"key",
":",
"value",
"pairs"
] | python | test |
ecell/ecell4 | ecell4/util/viz.py | https://github.com/ecell/ecell4/blob/a4a1229661c39b2059adbbacae9090e5ba664e01/ecell4/util/viz.py#L1774-L1906 | def plot_movie_with_attractive_mpl(
worlds, marker_size=6, figsize=6, grid=True,
wireframe=False, species_list=None, max_count=None, angle=None, noaxis=False,
interval=0.16, repeat_delay=3000, stride=1, rotate=None,
legend=True, whratio=1.33, scale=1, output=None, crf=10, bitrate='1M', *... | [
"def",
"plot_movie_with_attractive_mpl",
"(",
"worlds",
",",
"marker_size",
"=",
"6",
",",
"figsize",
"=",
"6",
",",
"grid",
"=",
"True",
",",
"wireframe",
"=",
"False",
",",
"species_list",
"=",
"None",
",",
"max_count",
"=",
"None",
",",
"angle",
"=",
... | Generate a move from the received list of instances of World,
and show it on IPython notebook. This function may require ffmpeg.
Parameters
----------
worlds : list or FixedIntervalHDF5Observer
A list of Worlds to render.
marker_size : float, default 3
Marker size for all species. S... | [
"Generate",
"a",
"move",
"from",
"the",
"received",
"list",
"of",
"instances",
"of",
"World",
"and",
"show",
"it",
"on",
"IPython",
"notebook",
".",
"This",
"function",
"may",
"require",
"ffmpeg",
"."
] | python | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.