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 |
|---|---|---|---|---|---|---|---|---|
PredixDev/predixpy | predix/admin/uaa.py | https://github.com/PredixDev/predixpy/blob/a0cb34cf40f716229351bb6d90d6ecace958c81f/predix/admin/uaa.py#L86-L96 | def authenticate(self):
"""
Authenticate into the UAA instance as the admin user.
"""
# Make sure we've stored uri for use
predix.config.set_env_value(self.use_class, 'uri', self._get_uri())
self.uaac = predix.security.uaa.UserAccountAuthentication()
self.uaac.au... | [
"def",
"authenticate",
"(",
"self",
")",
":",
"# Make sure we've stored uri for use",
"predix",
".",
"config",
".",
"set_env_value",
"(",
"self",
".",
"use_class",
",",
"'uri'",
",",
"self",
".",
"_get_uri",
"(",
")",
")",
"self",
".",
"uaac",
"=",
"predix",... | Authenticate into the UAA instance as the admin user. | [
"Authenticate",
"into",
"the",
"UAA",
"instance",
"as",
"the",
"admin",
"user",
"."
] | python | train |
Hackerfleet/hfos | hfos/ui/clientmanager.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/clientmanager.py#L155-L162 | def client_details(self, *args):
"""Display known details about a given client"""
self.log(_('Client details:', lang='de'))
client = self._clients[args[0]]
self.log('UUID:', client.uuid, 'IP:', client.ip, 'Name:', client.name, 'User:', self._users[client.useruuid],
pre... | [
"def",
"client_details",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"log",
"(",
"_",
"(",
"'Client details:'",
",",
"lang",
"=",
"'de'",
")",
")",
"client",
"=",
"self",
".",
"_clients",
"[",
"args",
"[",
"0",
"]",
"]",
"self",
".",
"l... | Display known details about a given client | [
"Display",
"known",
"details",
"about",
"a",
"given",
"client"
] | python | train |
radjkarl/appBase | appbase/dialogs/FirstStart.py | https://github.com/radjkarl/appBase/blob/72b514e6dee7c083f01a2d0b2cc93d46df55bdcb/appbase/dialogs/FirstStart.py#L56-L92 | def accept(self, evt):
"""
write setting to the preferences
"""
# determine if application is a script file or frozen exe (pyinstaller)
frozen = getattr(sys, 'frozen', False)
if frozen:
app_file = sys.executable
else:
app_file = Pa... | [
"def",
"accept",
"(",
"self",
",",
"evt",
")",
":",
"# determine if application is a script file or frozen exe (pyinstaller)\r",
"frozen",
"=",
"getattr",
"(",
"sys",
",",
"'frozen'",
",",
"False",
")",
"if",
"frozen",
":",
"app_file",
"=",
"sys",
".",
"executable... | write setting to the preferences | [
"write",
"setting",
"to",
"the",
"preferences"
] | python | train |
roboogle/gtkmvc3 | gtkmvco/gtkmvc3/support/utils.py | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/support/utils.py#L112-L136 | def __nt_relpath(path, start=os.curdir):
"""Return a relative version of a path"""
if not path: raise ValueError("no path specified")
start_list = os.path.abspath(start).split(os.sep)
path_list = os.path.abspath(path).split(os.sep)
if start_list[0].lower() != path_list[0].lower():
unc_path... | [
"def",
"__nt_relpath",
"(",
"path",
",",
"start",
"=",
"os",
".",
"curdir",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ValueError",
"(",
"\"no path specified\"",
")",
"start_list",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"start",
")",
".",
"spl... | Return a relative version of a path | [
"Return",
"a",
"relative",
"version",
"of",
"a",
"path"
] | python | train |
markovmodel/msmtools | msmtools/analysis/api.py | https://github.com/markovmodel/msmtools/blob/54dc76dd2113a0e8f3d15d5316abab41402941be/msmtools/analysis/api.py#L1731-L1755 | def stationary_distribution_sensitivity(T, j):
r"""Sensitivity matrix of a stationary distribution element.
Parameters
----------
T : (M, M) ndarray
Transition matrix (stochastic matrix).
j : int
Index of stationary distribution element
for which sensitivity matrix is compute... | [
"def",
"stationary_distribution_sensitivity",
"(",
"T",
",",
"j",
")",
":",
"T",
"=",
"_types",
".",
"ensure_ndarray_or_sparse",
"(",
"T",
",",
"ndim",
"=",
"2",
",",
"uniform",
"=",
"True",
",",
"kind",
"=",
"'numeric'",
")",
"if",
"_issparse",
"(",
"T"... | r"""Sensitivity matrix of a stationary distribution element.
Parameters
----------
T : (M, M) ndarray
Transition matrix (stochastic matrix).
j : int
Index of stationary distribution element
for which sensitivity matrix is computed.
Returns
-------
S : (M, M) ndarray... | [
"r",
"Sensitivity",
"matrix",
"of",
"a",
"stationary",
"distribution",
"element",
"."
] | python | train |
ntoll/microfs | microfs.py | https://github.com/ntoll/microfs/blob/11387109cfc36aaddceb018596ea75d55417ca0c/microfs.py#L175-L191 | def ls(serial=None):
"""
List the files on the micro:bit.
If no serial object is supplied, microfs will attempt to detect the
connection itself.
Returns a list of the files on the connected device or raises an IOError if
there's a problem.
"""
out, err = execute([
'import os',
... | [
"def",
"ls",
"(",
"serial",
"=",
"None",
")",
":",
"out",
",",
"err",
"=",
"execute",
"(",
"[",
"'import os'",
",",
"'print(os.listdir())'",
",",
"]",
",",
"serial",
")",
"if",
"err",
":",
"raise",
"IOError",
"(",
"clean_error",
"(",
"err",
")",
")",... | List the files on the micro:bit.
If no serial object is supplied, microfs will attempt to detect the
connection itself.
Returns a list of the files on the connected device or raises an IOError if
there's a problem. | [
"List",
"the",
"files",
"on",
"the",
"micro",
":",
"bit",
"."
] | python | train |
pyamg/pyamg | pyamg/relaxation/relaxation.py | https://github.com/pyamg/pyamg/blob/89dc54aa27e278f65d2f54bdaf16ab97d7768fa6/pyamg/relaxation/relaxation.py#L747-L825 | def jacobi_ne(A, x, b, iterations=1, omega=1.0):
"""Perform Jacobi iterations on the linear system A A.H x = A.H b.
Also known as Cimmino relaxation
Parameters
----------
A : csr_matrix
Sparse NxN matrix
x : ndarray
Approximate solution (length N)
b : ndarray
Right-... | [
"def",
"jacobi_ne",
"(",
"A",
",",
"x",
",",
"b",
",",
"iterations",
"=",
"1",
",",
"omega",
"=",
"1.0",
")",
":",
"A",
",",
"x",
",",
"b",
"=",
"make_system",
"(",
"A",
",",
"x",
",",
"b",
",",
"formats",
"=",
"[",
"'csr'",
"]",
")",
"swee... | Perform Jacobi iterations on the linear system A A.H x = A.H b.
Also known as Cimmino relaxation
Parameters
----------
A : csr_matrix
Sparse NxN matrix
x : ndarray
Approximate solution (length N)
b : ndarray
Right-hand side (length N)
iterations : int
Number... | [
"Perform",
"Jacobi",
"iterations",
"on",
"the",
"linear",
"system",
"A",
"A",
".",
"H",
"x",
"=",
"A",
".",
"H",
"b",
"."
] | python | train |
zeromake/aiko | aiko/application.py | https://github.com/zeromake/aiko/blob/53b246fa88652466a9e38ac3d1a99a6198195b0f/aiko/application.py#L143-L162 | def run(self, host: str = "0.0.0.0", port: int = 5000) -> None:
"""
debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000``
"""
loop = cast(asyncio.AbstractEventLoop, self._loop)
listen = ... | [
"def",
"run",
"(",
"self",
",",
"host",
":",
"str",
"=",
"\"0.0.0.0\"",
",",
"port",
":",
"int",
"=",
"5000",
")",
"->",
"None",
":",
"loop",
"=",
"cast",
"(",
"asyncio",
".",
"AbstractEventLoop",
",",
"self",
".",
"_loop",
")",
"listen",
"=",
"sel... | debug run
:param host: the hostname to listen on, default is ``'0.0.0.0'``
:param port: the port of the server, default id ``5000`` | [
"debug",
"run",
":",
"param",
"host",
":",
"the",
"hostname",
"to",
"listen",
"on",
"default",
"is",
"0",
".",
"0",
".",
"0",
".",
"0",
":",
"param",
"port",
":",
"the",
"port",
"of",
"the",
"server",
"default",
"id",
"5000"
] | python | train |
rwl/pylon | pylon/dc_pf.py | https://github.com/rwl/pylon/blob/916514255db1ae1661406f0283df756baf960d14/pylon/dc_pf.py#L165-L192 | def _update_model(self, case, B, Bsrc, v_angle, p_srcinj, p_ref, ref_idx):
""" Updates the case with values computed from the voltage phase
angle solution.
"""
iref = ref_idx
base_mva = case.base_mva
buses = case.connected_buses
branches = case.online_branches... | [
"def",
"_update_model",
"(",
"self",
",",
"case",
",",
"B",
",",
"Bsrc",
",",
"v_angle",
",",
"p_srcinj",
",",
"p_ref",
",",
"ref_idx",
")",
":",
"iref",
"=",
"ref_idx",
"base_mva",
"=",
"case",
".",
"base_mva",
"buses",
"=",
"case",
".",
"connected_bu... | Updates the case with values computed from the voltage phase
angle solution. | [
"Updates",
"the",
"case",
"with",
"values",
"computed",
"from",
"the",
"voltage",
"phase",
"angle",
"solution",
"."
] | python | train |
craffel/mir_eval | mir_eval/transcription.py | https://github.com/craffel/mir_eval/blob/f41c8dafaea04b411252a516d1965af43c7d531b/mir_eval/transcription.py#L570-L619 | def average_overlap_ratio(ref_intervals, est_intervals, matching):
"""Compute the Average Overlap Ratio between a reference and estimated
note transcription. Given a reference and corresponding estimated note,
their overlap ratio (OR) is defined as the ratio between the duration of
the time segment in w... | [
"def",
"average_overlap_ratio",
"(",
"ref_intervals",
",",
"est_intervals",
",",
"matching",
")",
":",
"ratios",
"=",
"[",
"]",
"for",
"match",
"in",
"matching",
":",
"ref_int",
"=",
"ref_intervals",
"[",
"match",
"[",
"0",
"]",
"]",
"est_int",
"=",
"est_i... | Compute the Average Overlap Ratio between a reference and estimated
note transcription. Given a reference and corresponding estimated note,
their overlap ratio (OR) is defined as the ratio between the duration of
the time segment in which the two notes overlap and the time segment
spanned by the two not... | [
"Compute",
"the",
"Average",
"Overlap",
"Ratio",
"between",
"a",
"reference",
"and",
"estimated",
"note",
"transcription",
".",
"Given",
"a",
"reference",
"and",
"corresponding",
"estimated",
"note",
"their",
"overlap",
"ratio",
"(",
"OR",
")",
"is",
"defined",
... | python | train |
mozilla/elasticutils | elasticutils/__init__.py | https://github.com/mozilla/elasticutils/blob/b880cc5d51fb1079b0581255ec664c1ec934656e/elasticutils/__init__.py#L1439-L1462 | def get_es(self, default_builder=get_es):
"""Returns the Elasticsearch object to use.
:arg default_builder: The function that takes a bunch of
arguments and generates a elasticsearch Elasticsearch
object.
.. Note::
If you desire special behavior regarding bu... | [
"def",
"get_es",
"(",
"self",
",",
"default_builder",
"=",
"get_es",
")",
":",
"# .es() calls are incremental, so we go through them all and",
"# update bits that are specified.",
"args",
"=",
"{",
"}",
"for",
"action",
",",
"value",
"in",
"self",
".",
"steps",
":",
... | Returns the Elasticsearch object to use.
:arg default_builder: The function that takes a bunch of
arguments and generates a elasticsearch Elasticsearch
object.
.. Note::
If you desire special behavior regarding building the
Elasticsearch object for this S... | [
"Returns",
"the",
"Elasticsearch",
"object",
"to",
"use",
"."
] | python | train |
hollenstein/maspy | maspy/core.py | https://github.com/hollenstein/maspy/blob/f15fcfd24df306d8420540460d902aa3073ec133/maspy/core.py#L344-L354 | def _addSpecfile(self, specfile, path):
"""Adds a new specfile entry to MsrunContainer.info. See also
:class:`MsrunContainer.addSpecfile()`.
:param specfile: the name of an ms-run file
:param path: filedirectory used for loading and saving ``mrc`` files
"""
datatypeStatu... | [
"def",
"_addSpecfile",
"(",
"self",
",",
"specfile",
",",
"path",
")",
":",
"datatypeStatus",
"=",
"{",
"'rm'",
":",
"False",
",",
"'ci'",
":",
"False",
",",
"'smi'",
":",
"False",
",",
"'sai'",
":",
"False",
",",
"'si'",
":",
"False",
"}",
"self",
... | Adds a new specfile entry to MsrunContainer.info. See also
:class:`MsrunContainer.addSpecfile()`.
:param specfile: the name of an ms-run file
:param path: filedirectory used for loading and saving ``mrc`` files | [
"Adds",
"a",
"new",
"specfile",
"entry",
"to",
"MsrunContainer",
".",
"info",
".",
"See",
"also",
":",
"class",
":",
"MsrunContainer",
".",
"addSpecfile",
"()",
"."
] | python | train |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/frontend/qt/console/mainwindow.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/frontend/qt/console/mainwindow.py#L651-L670 | def _get_magic_menu(self,menuidentifier, menulabel=None):
"""return a submagic menu by name, and create it if needed
parameters:
-----------
menulabel : str
Label for the menu
Will infere the menu name from the identifier at creation if menulabel not given.
... | [
"def",
"_get_magic_menu",
"(",
"self",
",",
"menuidentifier",
",",
"menulabel",
"=",
"None",
")",
":",
"menu",
"=",
"self",
".",
"_magic_menu_dict",
".",
"get",
"(",
"menuidentifier",
",",
"None",
")",
"if",
"not",
"menu",
":",
"if",
"not",
"menulabel",
... | return a submagic menu by name, and create it if needed
parameters:
-----------
menulabel : str
Label for the menu
Will infere the menu name from the identifier at creation if menulabel not given.
To do so you have too give menuidentifier as a CamelCassedStr... | [
"return",
"a",
"submagic",
"menu",
"by",
"name",
"and",
"create",
"it",
"if",
"needed",
"parameters",
":",
"-----------"
] | python | test |
barrust/mediawiki | mediawiki/mediawiki.py | https://github.com/barrust/mediawiki/blob/292e0be6c752409062dceed325d74839caf16a9b/mediawiki/mediawiki.py#L136-L140 | def rate_limit(self, rate_limit):
""" Turn on or off rate limiting """
self._rate_limit = bool(rate_limit)
self._rate_limit_last_call = None
self.clear_memoized() | [
"def",
"rate_limit",
"(",
"self",
",",
"rate_limit",
")",
":",
"self",
".",
"_rate_limit",
"=",
"bool",
"(",
"rate_limit",
")",
"self",
".",
"_rate_limit_last_call",
"=",
"None",
"self",
".",
"clear_memoized",
"(",
")"
] | Turn on or off rate limiting | [
"Turn",
"on",
"or",
"off",
"rate",
"limiting"
] | python | train |
XuShaohua/bcloud | bcloud/UploadPage.py | https://github.com/XuShaohua/bcloud/blob/4b54e0fdccf2b3013285fef05c97354cfa31697b/bcloud/UploadPage.py#L416-L485 | def upload_files(self, source_paths, dir_name=None):
'''批量创建上传任务, 会扫描子目录并依次上传.
source_path - 本地文件的绝对路径
dir_name - 文件在服务器上的父目录, 如果为None的话, 会弹出一个
对话框让用户来选择一个目录.
'''
def scan_folders(folder_path):
file_list = os.listdir(folder_path)
... | [
"def",
"upload_files",
"(",
"self",
",",
"source_paths",
",",
"dir_name",
"=",
"None",
")",
":",
"def",
"scan_folders",
"(",
"folder_path",
")",
":",
"file_list",
"=",
"os",
".",
"listdir",
"(",
"folder_path",
")",
"source_paths",
"=",
"[",
"os",
".",
"p... | 批量创建上传任务, 会扫描子目录并依次上传.
source_path - 本地文件的绝对路径
dir_name - 文件在服务器上的父目录, 如果为None的话, 会弹出一个
对话框让用户来选择一个目录. | [
"批量创建上传任务",
"会扫描子目录并依次上传",
"."
] | python | train |
bitesofcode/projexui | projexui/widgets/xpushbutton.py | https://github.com/bitesofcode/projexui/blob/f18a73bec84df90b034ca69b9deea118dbedfc4d/projexui/widgets/xpushbutton.py#L72-L90 | def setShowRichText(self, state):
"""
Sets whether or not to display rich text for this button.
:param state | <bool>
"""
self._showRichText = state
text = self.text()
if state:
label = self.richTextLabel()
... | [
"def",
"setShowRichText",
"(",
"self",
",",
"state",
")",
":",
"self",
".",
"_showRichText",
"=",
"state",
"text",
"=",
"self",
".",
"text",
"(",
")",
"if",
"state",
":",
"label",
"=",
"self",
".",
"richTextLabel",
"(",
")",
"label",
".",
"setText",
... | Sets whether or not to display rich text for this button.
:param state | <bool> | [
"Sets",
"whether",
"or",
"not",
"to",
"display",
"rich",
"text",
"for",
"this",
"button",
".",
":",
"param",
"state",
"|",
"<bool",
">"
] | python | train |
bioidiap/bob.ip.facedetect | bob/ip/facedetect/train/TrainingSet.py | https://github.com/bioidiap/bob.ip.facedetect/blob/601da5141ca7302ad36424d1421b33190ba46779/bob/ip/facedetect/train/TrainingSet.py#L157-L292 | def extract(self, sampler, feature_extractor, number_of_examples_per_scale = (100, 100), similarity_thresholds = (0.5, 0.8), parallel = None, mirror = False, use_every_nth_negative_scale = 1):
"""Extracts features from **all** images in **all** scales and writes them to file.
This function iterates over all im... | [
"def",
"extract",
"(",
"self",
",",
"sampler",
",",
"feature_extractor",
",",
"number_of_examples_per_scale",
"=",
"(",
"100",
",",
"100",
")",
",",
"similarity_thresholds",
"=",
"(",
"0.5",
",",
"0.8",
")",
",",
"parallel",
"=",
"None",
",",
"mirror",
"="... | Extracts features from **all** images in **all** scales and writes them to file.
This function iterates over all images that are present in the internally stored list, and extracts features using the given ``feature_extractor`` for every image patch that the given ``sampler`` returns.
The final features will b... | [
"Extracts",
"features",
"from",
"**",
"all",
"**",
"images",
"in",
"**",
"all",
"**",
"scales",
"and",
"writes",
"them",
"to",
"file",
"."
] | python | train |
inveniosoftware/invenio-search | invenio_search/ext.py | https://github.com/inveniosoftware/invenio-search/blob/19c073d608d4c811f1c5aecb6622402d39715228/invenio_search/ext.py#L285-L314 | def put_templates(self, ignore=None):
"""Yield tuple with registered template and response from client."""
ignore = ignore or []
def _replace_prefix(template_path, body):
"""Replace index prefix in template request body."""
pattern = '__SEARCH_INDEX_PREFIX__'
... | [
"def",
"put_templates",
"(",
"self",
",",
"ignore",
"=",
"None",
")",
":",
"ignore",
"=",
"ignore",
"or",
"[",
"]",
"def",
"_replace_prefix",
"(",
"template_path",
",",
"body",
")",
":",
"\"\"\"Replace index prefix in template request body.\"\"\"",
"pattern",
"=",... | Yield tuple with registered template and response from client. | [
"Yield",
"tuple",
"with",
"registered",
"template",
"and",
"response",
"from",
"client",
"."
] | python | train |
timkpaine/pyEX | pyEX/stocks.py | https://github.com/timkpaine/pyEX/blob/91cf751dafdb208a0c8b5377945e5808b99f94ba/pyEX/stocks.py#L130-L176 | def bulkBatch(symbols, fields=None, range_='1m', last=10, token='', version=''):
'''Optimized batch to fetch as much as possible at once
https://iexcloud.io/docs/api/#batch-requests
Args:
symbols (list); List of tickers to request
fields (list); List of fields to request
range_ (s... | [
"def",
"bulkBatch",
"(",
"symbols",
",",
"fields",
"=",
"None",
",",
"range_",
"=",
"'1m'",
",",
"last",
"=",
"10",
",",
"token",
"=",
"''",
",",
"version",
"=",
"''",
")",
":",
"fields",
"=",
"fields",
"or",
"_BATCH_TYPES",
"args",
"=",
"[",
"]",
... | Optimized batch to fetch as much as possible at once
https://iexcloud.io/docs/api/#batch-requests
Args:
symbols (list); List of tickers to request
fields (list); List of fields to request
range_ (string); Date range for chart
last (int);
token (string); Access token
... | [
"Optimized",
"batch",
"to",
"fetch",
"as",
"much",
"as",
"possible",
"at",
"once"
] | python | valid |
marshmallow-code/marshmallow | src/marshmallow/schema.py | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L776-L870 | def _do_load(
self, data, many=None, partial=None, unknown=None,
postprocess=True,
):
"""Deserialize `data`, returning the deserialized result.
:param data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
v... | [
"def",
"_do_load",
"(",
"self",
",",
"data",
",",
"many",
"=",
"None",
",",
"partial",
"=",
"None",
",",
"unknown",
"=",
"None",
",",
"postprocess",
"=",
"True",
",",
")",
":",
"error_store",
"=",
"ErrorStore",
"(",
")",
"errors",
"=",
"{",
"}",
"m... | Deserialize `data`, returning the deserialized result.
:param data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
value for `self.many` is used.
:param bool|tuple partial: Whether to validate required fields. If its value is... | [
"Deserialize",
"data",
"returning",
"the",
"deserialized",
"result",
"."
] | python | train |
xolox/python-vcs-repo-mgr | vcs_repo_mgr/backends/git.py | https://github.com/xolox/python-vcs-repo-mgr/blob/fdad2441a3e7ba5deeeddfa1c2f5ebc00c393aed/vcs_repo_mgr/backends/git.py#L213-L220 | def find_branches(self):
"""Find information about the branches in the repository."""
for prefix, name, revision_id in self.find_branches_raw():
yield Revision(
branch=name,
repository=self,
revision_id=revision_id,
) | [
"def",
"find_branches",
"(",
"self",
")",
":",
"for",
"prefix",
",",
"name",
",",
"revision_id",
"in",
"self",
".",
"find_branches_raw",
"(",
")",
":",
"yield",
"Revision",
"(",
"branch",
"=",
"name",
",",
"repository",
"=",
"self",
",",
"revision_id",
"... | Find information about the branches in the repository. | [
"Find",
"information",
"about",
"the",
"branches",
"in",
"the",
"repository",
"."
] | python | train |
gitpython-developers/GitPython | git/refs/log.py | https://github.com/gitpython-developers/GitPython/blob/1f66e25c25cde2423917ee18c4704fff83b837d1/git/refs/log.py#L47-L57 | def format(self):
""":return: a string suitable to be placed in a reflog file"""
act = self.actor
time = self.time
return u"{} {} {} <{}> {!s} {}\t{}\n".format(self.oldhexsha,
self.newhexsha,
... | [
"def",
"format",
"(",
"self",
")",
":",
"act",
"=",
"self",
".",
"actor",
"time",
"=",
"self",
".",
"time",
"return",
"u\"{} {} {} <{}> {!s} {}\\t{}\\n\"",
".",
"format",
"(",
"self",
".",
"oldhexsha",
",",
"self",
".",
"newhexsha",
",",
"act",
".",
"nam... | :return: a string suitable to be placed in a reflog file | [
":",
"return",
":",
"a",
"string",
"suitable",
"to",
"be",
"placed",
"in",
"a",
"reflog",
"file"
] | python | train |
NoviceLive/intellicoder | intellicoder/msbuild/locators.py | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/msbuild/locators.py#L103-L116 | def get_lib(self, arch='x86'):
"""
Get lib directories of Visual C++.
"""
if arch == 'x86':
arch = ''
if arch == 'x64':
arch = 'amd64'
lib = os.path.join(self.vc_dir, 'lib', arch)
if os.path.isdir(lib):
logging.info(_('using lib... | [
"def",
"get_lib",
"(",
"self",
",",
"arch",
"=",
"'x86'",
")",
":",
"if",
"arch",
"==",
"'x86'",
":",
"arch",
"=",
"''",
"if",
"arch",
"==",
"'x64'",
":",
"arch",
"=",
"'amd64'",
"lib",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"vc... | Get lib directories of Visual C++. | [
"Get",
"lib",
"directories",
"of",
"Visual",
"C",
"++",
"."
] | python | train |
regebro/svg.path | src/svg/path/path.py | https://github.com/regebro/svg.path/blob/cb58e104e5aa3472be205c75da59690db30aecc9/src/svg/path/path.py#L126-L132 | def is_smooth_from(self, previous):
"""Checks if this segment would be a smooth segment following the previous"""
if isinstance(previous, QuadraticBezier):
return (self.start == previous.end and
(self.control - self.start) == (previous.end - previous.control))
els... | [
"def",
"is_smooth_from",
"(",
"self",
",",
"previous",
")",
":",
"if",
"isinstance",
"(",
"previous",
",",
"QuadraticBezier",
")",
":",
"return",
"(",
"self",
".",
"start",
"==",
"previous",
".",
"end",
"and",
"(",
"self",
".",
"control",
"-",
"self",
... | Checks if this segment would be a smooth segment following the previous | [
"Checks",
"if",
"this",
"segment",
"would",
"be",
"a",
"smooth",
"segment",
"following",
"the",
"previous"
] | python | train |
HHammond/PrettyPandas | prettypandas/summarizer.py | https://github.com/HHammond/PrettyPandas/blob/99a814ffc3aa61f66eaf902afaa4b7802518d33a/prettypandas/summarizer.py#L162-L190 | def _apply_summaries(self):
"""Add all summary rows and columns."""
def as_frame(r):
if isinstance(r, pd.Series):
return r.to_frame()
else:
return r
df = self.data
if df.index.nlevels > 1:
raise ValueError(
... | [
"def",
"_apply_summaries",
"(",
"self",
")",
":",
"def",
"as_frame",
"(",
"r",
")",
":",
"if",
"isinstance",
"(",
"r",
",",
"pd",
".",
"Series",
")",
":",
"return",
"r",
".",
"to_frame",
"(",
")",
"else",
":",
"return",
"r",
"df",
"=",
"self",
".... | Add all summary rows and columns. | [
"Add",
"all",
"summary",
"rows",
"and",
"columns",
"."
] | python | train |
venmo/slouch | slouch/__init__.py | https://github.com/venmo/slouch/blob/000b03bc220a0d7aa5b06f59caf423e2b63a81d7/slouch/__init__.py#L258-L301 | def _handle_long_response(self, res):
"""Splits messages that are too long into multiple events
:param res: a slack response string or dict
"""
is_rtm_message = isinstance(res, basestring)
is_api_message = isinstance(res, dict)
if is_rtm_message:
text = res
... | [
"def",
"_handle_long_response",
"(",
"self",
",",
"res",
")",
":",
"is_rtm_message",
"=",
"isinstance",
"(",
"res",
",",
"basestring",
")",
"is_api_message",
"=",
"isinstance",
"(",
"res",
",",
"dict",
")",
"if",
"is_rtm_message",
":",
"text",
"=",
"res",
... | Splits messages that are too long into multiple events
:param res: a slack response string or dict | [
"Splits",
"messages",
"that",
"are",
"too",
"long",
"into",
"multiple",
"events",
":",
"param",
"res",
":",
"a",
"slack",
"response",
"string",
"or",
"dict"
] | python | train |
materialsproject/pymatgen | pymatgen/analysis/elasticity/elastic.py | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/elasticity/elastic.py#L1020-L1044 | def get_symbol_list(rank, dim=6):
"""
Returns a symbolic representation of the voigt-notation
tensor that places identical symbols for entries related
by index transposition, i. e. C_1121 = C_1211 etc.
Args:
dim (int): dimension of matrix/tensor, e. g. 6 for
voigt notation and 3... | [
"def",
"get_symbol_list",
"(",
"rank",
",",
"dim",
"=",
"6",
")",
":",
"indices",
"=",
"list",
"(",
"itertools",
".",
"combinations_with_replacement",
"(",
"range",
"(",
"dim",
")",
",",
"r",
"=",
"rank",
")",
")",
"c_vec",
"=",
"np",
".",
"zeros",
"... | Returns a symbolic representation of the voigt-notation
tensor that places identical symbols for entries related
by index transposition, i. e. C_1121 = C_1211 etc.
Args:
dim (int): dimension of matrix/tensor, e. g. 6 for
voigt notation and 3 for standard
rank (int): rank of tens... | [
"Returns",
"a",
"symbolic",
"representation",
"of",
"the",
"voigt",
"-",
"notation",
"tensor",
"that",
"places",
"identical",
"symbols",
"for",
"entries",
"related",
"by",
"index",
"transposition",
"i",
".",
"e",
".",
"C_1121",
"=",
"C_1211",
"etc",
"."
] | python | train |
nerdvegas/rez | src/rezplugins/build_system/custom.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezplugins/build_system/custom.py#L87-L176 | def build(self, context, variant, build_path, install_path, install=False,
build_type=BuildType.local):
"""Perform the build.
Note that most of the func args aren't used here - that's because this
info is already passed to the custom build command via environment
variables... | [
"def",
"build",
"(",
"self",
",",
"context",
",",
"variant",
",",
"build_path",
",",
"install_path",
",",
"install",
"=",
"False",
",",
"build_type",
"=",
"BuildType",
".",
"local",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"self",
".",
"write_build_scripts"... | Perform the build.
Note that most of the func args aren't used here - that's because this
info is already passed to the custom build command via environment
variables. | [
"Perform",
"the",
"build",
"."
] | python | train |
allenai/allennlp | allennlp/semparse/domain_languages/wikitables_language.py | https://github.com/allenai/allennlp/blob/648a36f77db7e45784c047176074f98534c76636/allennlp/semparse/domain_languages/wikitables_language.py#L676-L686 | def max_date(self, rows: List[Row], column: DateColumn) -> Date:
"""
Takes a list of rows and a column and returns the max of the values under that column in
those rows.
"""
cell_values = [row.values[column.name] for row in rows]
if not cell_values:
return Dat... | [
"def",
"max_date",
"(",
"self",
",",
"rows",
":",
"List",
"[",
"Row",
"]",
",",
"column",
":",
"DateColumn",
")",
"->",
"Date",
":",
"cell_values",
"=",
"[",
"row",
".",
"values",
"[",
"column",
".",
"name",
"]",
"for",
"row",
"in",
"rows",
"]",
... | Takes a list of rows and a column and returns the max of the values under that column in
those rows. | [
"Takes",
"a",
"list",
"of",
"rows",
"and",
"a",
"column",
"and",
"returns",
"the",
"max",
"of",
"the",
"values",
"under",
"that",
"column",
"in",
"those",
"rows",
"."
] | python | train |
doconix/django-mako-plus | django_mako_plus/management/commands/dmp_collectstatic.py | https://github.com/doconix/django-mako-plus/blob/a90f9b4af19e5fa9f83452989cdcaed21569a181/django_mako_plus/management/commands/dmp_collectstatic.py#L31-L38 | def match(self, fname, flevel, ftype):
'''Returns the result score if the file matches this rule'''
# if filetype is the same
# and level isn't set or level is the same
# and pattern matche the filename
if self.filetype == ftype and (self.level is None or self.level == flevel) an... | [
"def",
"match",
"(",
"self",
",",
"fname",
",",
"flevel",
",",
"ftype",
")",
":",
"# if filetype is the same",
"# and level isn't set or level is the same",
"# and pattern matche the filename",
"if",
"self",
".",
"filetype",
"==",
"ftype",
"and",
"(",
"self",
".",
"... | Returns the result score if the file matches this rule | [
"Returns",
"the",
"result",
"score",
"if",
"the",
"file",
"matches",
"this",
"rule"
] | python | train |
TissueMAPS/TmClient | src/python/tmclient/api.py | https://github.com/TissueMAPS/TmClient/blob/6fb40622af19142cb5169a64b8c2965993a25ab1/src/python/tmclient/api.py#L486-L510 | def delete_plate(self, name):
'''Deletes a plate.
Parameters
----------
name: str
name of the plate that should be deleted
See also
--------
:func:`tmserver.api.plate.delete_plate`
:class:`tmlib.models.plate.Plate`
'''
logger.... | [
"def",
"delete_plate",
"(",
"self",
",",
"name",
")",
":",
"logger",
".",
"info",
"(",
"'delete plate \"%s\" of experiment \"%s\"'",
",",
"name",
",",
"self",
".",
"experiment_name",
")",
"plate_id",
"=",
"self",
".",
"_get_plate_id",
"(",
"name",
")",
"url",
... | Deletes a plate.
Parameters
----------
name: str
name of the plate that should be deleted
See also
--------
:func:`tmserver.api.plate.delete_plate`
:class:`tmlib.models.plate.Plate` | [
"Deletes",
"a",
"plate",
"."
] | python | train |
Kaggle/kaggle-api | kaggle/api/kaggle_api_extended.py | https://github.com/Kaggle/kaggle-api/blob/65f14b1386470c5784d4753e491478e7537660d9/kaggle/api/kaggle_api_extended.py#L740-L749 | def competition_leaderboard_view(self, competition):
""" view a leaderboard based on a competition name
Parameters
==========
competition: the competition name to view leadboard for
"""
result = self.process_response(
self.competition_view_leaderb... | [
"def",
"competition_leaderboard_view",
"(",
"self",
",",
"competition",
")",
":",
"result",
"=",
"self",
".",
"process_response",
"(",
"self",
".",
"competition_view_leaderboard_with_http_info",
"(",
"competition",
")",
")",
"return",
"[",
"LeaderboardEntry",
"(",
"... | view a leaderboard based on a competition name
Parameters
==========
competition: the competition name to view leadboard for | [
"view",
"a",
"leaderboard",
"based",
"on",
"a",
"competition",
"name"
] | python | train |
twisted/axiom | axiom/batch.py | https://github.com/twisted/axiom/blob/7de70bc8fe1bb81f9c2339fba8daec9eb2e92b68/axiom/batch.py#L462-L518 | def processor(forType):
"""
Create an Axiom Item type which is suitable to use as a batch processor for
the given Axiom Item type.
Processors created this way depend on a L{iaxiom.IScheduler} powerup on the
on which store they are installed.
@type forType: L{item.MetaItem}
@param forType: ... | [
"def",
"processor",
"(",
"forType",
")",
":",
"MILLI",
"=",
"1000",
"try",
":",
"processor",
"=",
"_processors",
"[",
"forType",
"]",
"except",
"KeyError",
":",
"def",
"__init__",
"(",
"self",
",",
"*",
"a",
",",
"*",
"*",
"kw",
")",
":",
"item",
"... | Create an Axiom Item type which is suitable to use as a batch processor for
the given Axiom Item type.
Processors created this way depend on a L{iaxiom.IScheduler} powerup on the
on which store they are installed.
@type forType: L{item.MetaItem}
@param forType: The Axiom Item type for which to cre... | [
"Create",
"an",
"Axiom",
"Item",
"type",
"which",
"is",
"suitable",
"to",
"use",
"as",
"a",
"batch",
"processor",
"for",
"the",
"given",
"Axiom",
"Item",
"type",
"."
] | python | train |
epfl-idevelop/epfl-ldap | epflldap/ldap_search.py | https://github.com/epfl-idevelop/epfl-ldap/blob/bebb94da3609d358bd83f31672eeaddcda872c5d/epflldap/ldap_search.py#L7-L15 | def _get_LDAP_connection():
"""
Return a LDAP connection
"""
server = ldap3.Server('ldap://' + get_optional_env('EPFL_LDAP_SERVER_FOR_SEARCH'))
connection = ldap3.Connection(server)
connection.open()
return connection, get_optional_env('EPFL_LDAP_BASE_DN_FOR_SEARCH') | [
"def",
"_get_LDAP_connection",
"(",
")",
":",
"server",
"=",
"ldap3",
".",
"Server",
"(",
"'ldap://'",
"+",
"get_optional_env",
"(",
"'EPFL_LDAP_SERVER_FOR_SEARCH'",
")",
")",
"connection",
"=",
"ldap3",
".",
"Connection",
"(",
"server",
")",
"connection",
".",
... | Return a LDAP connection | [
"Return",
"a",
"LDAP",
"connection"
] | python | train |
jorahn/icy | icy/icy.py | https://github.com/jorahn/icy/blob/d0bd765c933b2d9bff4d7d646c0938348b9c5c25/icy/icy.py#L469-L541 | def merge(data, cfg=None):
""" WORK IN PROGRESS
Concat, merge, join, drop keys in dictionary of pandas.DataFrames
into one pandas.DataFrame (data) and a pandas.Series (labels).
Parameters
----------
data : dict of pandas.DataFrames
Result of icy.read()
cfg : dict or str, op... | [
"def",
"merge",
"(",
"data",
",",
"cfg",
"=",
"None",
")",
":",
"# go from a dict of dataframes (data) to one dataframe (data) and one series (labels)",
"# pd.concat([df1, df2], join, join_axes, ignore_index) and pd.merge(left, right, how, on, suffixes)",
"# should be easy to iterate from no... | WORK IN PROGRESS
Concat, merge, join, drop keys in dictionary of pandas.DataFrames
into one pandas.DataFrame (data) and a pandas.Series (labels).
Parameters
----------
data : dict of pandas.DataFrames
Result of icy.read()
cfg : dict or str, optional
Dictionary of action... | [
"WORK",
"IN",
"PROGRESS",
"Concat",
"merge",
"join",
"drop",
"keys",
"in",
"dictionary",
"of",
"pandas",
".",
"DataFrames",
"into",
"one",
"pandas",
".",
"DataFrame",
"(",
"data",
")",
"and",
"a",
"pandas",
".",
"Series",
"(",
"labels",
")",
".",
"Parame... | python | train |
phodge/homely | homely/_utils.py | https://github.com/phodge/homely/blob/98ddcf3e4f29b0749645817b4866baaea8376085/homely/_utils.py#L112-L197 | def run(cmd, stdout=None, stderr=None, **kwargs):
"""
A blocking wrapper around subprocess.Popen(), but with a simpler interface
for the stdout/stderr arguments:
stdout=False / stderr=False
stdout/stderr will be redirected to /dev/null (or discarded in some
other suitable manner)
st... | [
"def",
"run",
"(",
"cmd",
",",
"stdout",
"=",
"None",
",",
"stderr",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"devnull",
"=",
"None",
"try",
":",
"stdoutfilter",
"=",
"None",
"stderrfilter",
"=",
"None",
"wantstdout",
"=",
"False",
"wantstderr",... | A blocking wrapper around subprocess.Popen(), but with a simpler interface
for the stdout/stderr arguments:
stdout=False / stderr=False
stdout/stderr will be redirected to /dev/null (or discarded in some
other suitable manner)
stdout=True / stderr=True
stdout/stderr will be captured... | [
"A",
"blocking",
"wrapper",
"around",
"subprocess",
".",
"Popen",
"()",
"but",
"with",
"a",
"simpler",
"interface",
"for",
"the",
"stdout",
"/",
"stderr",
"arguments",
":"
] | python | train |
google/mobly | mobly/controllers/monsoon.py | https://github.com/google/mobly/blob/38ba2cf7d29a20e6a2fca1718eecb337df38db26/mobly/controllers/monsoon.py#L422-L437 | def _FlushInput(self):
""" Flush all read data until no more available. """
self.ser.flush()
flushed = 0
while True:
ready_r, ready_w, ready_x = select.select([self.ser], [],
[self.ser], 0)
if len(ready_x) > 0:... | [
"def",
"_FlushInput",
"(",
"self",
")",
":",
"self",
".",
"ser",
".",
"flush",
"(",
")",
"flushed",
"=",
"0",
"while",
"True",
":",
"ready_r",
",",
"ready_w",
",",
"ready_x",
"=",
"select",
".",
"select",
"(",
"[",
"self",
".",
"ser",
"]",
",",
"... | Flush all read data until no more available. | [
"Flush",
"all",
"read",
"data",
"until",
"no",
"more",
"available",
"."
] | python | train |
bierschenk/ode | ode/integrators.py | https://github.com/bierschenk/ode/blob/01fb714874926f0988a4bb250d2a0c8a2429e4f0/ode/integrators.py#L72-L88 | def euler(dfun, xzero, timerange, timestep):
'''Euler method integration. This function wraps the Euler class.
:param dfun:
derivative function of the system.
The differential system arranged as a series of first-order
equations: \\dot{X} = dfun(t, x)
:param xzer... | [
"def",
"euler",
"(",
"dfun",
",",
"xzero",
",",
"timerange",
",",
"timestep",
")",
":",
"return",
"zip",
"(",
"*",
"list",
"(",
"Euler",
"(",
"dfun",
",",
"xzero",
",",
"timerange",
",",
"timestep",
")",
")",
")"
] | Euler method integration. This function wraps the Euler class.
:param dfun:
derivative function of the system.
The differential system arranged as a series of first-order
equations: \\dot{X} = dfun(t, x)
:param xzero:
the initial condition of the system
... | [
"Euler",
"method",
"integration",
".",
"This",
"function",
"wraps",
"the",
"Euler",
"class",
"."
] | python | train |
senaite/senaite.core | bika/lims/browser/partition_magic.py | https://github.com/senaite/senaite.core/blob/7602ce2ea2f9e81eb34e20ce17b98a3e70713f85/bika/lims/browser/partition_magic.py#L162-L167 | def get_container_data(self):
"""Returns a list of Container data
"""
for obj in self.get_containers():
info = self.get_base_info(obj)
yield info | [
"def",
"get_container_data",
"(",
"self",
")",
":",
"for",
"obj",
"in",
"self",
".",
"get_containers",
"(",
")",
":",
"info",
"=",
"self",
".",
"get_base_info",
"(",
"obj",
")",
"yield",
"info"
] | Returns a list of Container data | [
"Returns",
"a",
"list",
"of",
"Container",
"data"
] | python | train |
uuazed/numerapi | numerapi/numerapi.py | https://github.com/uuazed/numerapi/blob/fc9dcc53b32ede95bfda1ceeb62aec1d67d26697/numerapi/numerapi.py#L944-L1003 | def get_payments(self):
"""Get all your payments.
Returns:
list of dicts: payments
For each payout in the list, a dict contains the following items:
* nmrAmount (`decimal.Decimal`)
* usdAmount (`decimal.Decimal`)
* tournament (`s... | [
"def",
"get_payments",
"(",
"self",
")",
":",
"query",
"=",
"\"\"\"\n query {\n user {\n payments {\n nmrAmount\n round {\n number\n openTime\n resolveTime\n resolvedGen... | Get all your payments.
Returns:
list of dicts: payments
For each payout in the list, a dict contains the following items:
* nmrAmount (`decimal.Decimal`)
* usdAmount (`decimal.Decimal`)
* tournament (`str`)
* round (`dict... | [
"Get",
"all",
"your",
"payments",
"."
] | python | train |
ejeschke/ginga | ginga/rv/plugins/Cuts.py | https://github.com/ejeschke/ginga/blob/a78c893ec6f37a837de851947e9bb4625c597915/ginga/rv/plugins/Cuts.py#L995-L1001 | def set_mode_cb(self, mode, tf):
"""Called when one of the Move/Draw/Edit radio buttons is selected."""
if tf:
self.canvas.set_draw_mode(mode)
if mode == 'edit':
self.edit_select_cuts()
return True | [
"def",
"set_mode_cb",
"(",
"self",
",",
"mode",
",",
"tf",
")",
":",
"if",
"tf",
":",
"self",
".",
"canvas",
".",
"set_draw_mode",
"(",
"mode",
")",
"if",
"mode",
"==",
"'edit'",
":",
"self",
".",
"edit_select_cuts",
"(",
")",
"return",
"True"
] | Called when one of the Move/Draw/Edit radio buttons is selected. | [
"Called",
"when",
"one",
"of",
"the",
"Move",
"/",
"Draw",
"/",
"Edit",
"radio",
"buttons",
"is",
"selected",
"."
] | python | train |
klen/zeta-library | zetalibrary/scss/__init__.py | https://github.com/klen/zeta-library/blob/b76f89000f467e10ddcc94aded3f6c6bf4a0e5bd/zetalibrary/scss/__init__.py#L1019-L1072 | def _do_functions(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name):
"""
Implements @mixin and @function
"""
if name:
funct, params, _ = name.partition('(')
funct = funct.strip()
params = split_p... | [
"def",
"_do_functions",
"(",
"self",
",",
"rule",
",",
"p_selectors",
",",
"p_parents",
",",
"p_children",
",",
"scope",
",",
"media",
",",
"c_lineno",
",",
"c_property",
",",
"c_codestr",
",",
"code",
",",
"name",
")",
":",
"if",
"name",
":",
"funct",
... | Implements @mixin and @function | [
"Implements"
] | python | train |
MillionIntegrals/vel | vel/rl/env/classic_control.py | https://github.com/MillionIntegrals/vel/blob/e0726e1f63742b728966ccae0c8b825ea0ba491a/vel/rl/env/classic_control.py#L62-L68 | def create(game, settings=None, presets=None):
""" Vel factory function """
return ClassicControlEnv(
envname=game,
settings=settings,
presets=presets
) | [
"def",
"create",
"(",
"game",
",",
"settings",
"=",
"None",
",",
"presets",
"=",
"None",
")",
":",
"return",
"ClassicControlEnv",
"(",
"envname",
"=",
"game",
",",
"settings",
"=",
"settings",
",",
"presets",
"=",
"presets",
")"
] | Vel factory function | [
"Vel",
"factory",
"function"
] | python | train |
rs/domcheck | domcheck/strategies.py | https://github.com/rs/domcheck/blob/43e10c345320564a1236778e8577e2b8ef825925/domcheck/strategies.py#L16-L30 | def check_dns_txt(domain, prefix, code):
"""
Validates a domain by checking that {prefix}={code} is present in the TXT DNS record
of the domain to check.
Returns true if verification suceeded.
"""
token = '{}={}'.format(prefix, code)
try:
for rr in dns.resolver.query(domain, 'TXT'):... | [
"def",
"check_dns_txt",
"(",
"domain",
",",
"prefix",
",",
"code",
")",
":",
"token",
"=",
"'{}={}'",
".",
"format",
"(",
"prefix",
",",
"code",
")",
"try",
":",
"for",
"rr",
"in",
"dns",
".",
"resolver",
".",
"query",
"(",
"domain",
",",
"'TXT'",
... | Validates a domain by checking that {prefix}={code} is present in the TXT DNS record
of the domain to check.
Returns true if verification suceeded. | [
"Validates",
"a",
"domain",
"by",
"checking",
"that",
"{",
"prefix",
"}",
"=",
"{",
"code",
"}",
"is",
"present",
"in",
"the",
"TXT",
"DNS",
"record",
"of",
"the",
"domain",
"to",
"check",
"."
] | python | train |
tjvr/kurt | kurt/__init__.py | https://github.com/tjvr/kurt/blob/fcccd80cae11dc233f6dd02b40ec9a388c62f259/kurt/__init__.py#L1596-L1599 | def has_conversion(self, plugin):
"""Return True if the plugin supports this block."""
plugin = kurt.plugin.Kurt.get_plugin(plugin)
return plugin.name in self._plugins | [
"def",
"has_conversion",
"(",
"self",
",",
"plugin",
")",
":",
"plugin",
"=",
"kurt",
".",
"plugin",
".",
"Kurt",
".",
"get_plugin",
"(",
"plugin",
")",
"return",
"plugin",
".",
"name",
"in",
"self",
".",
"_plugins"
] | Return True if the plugin supports this block. | [
"Return",
"True",
"if",
"the",
"plugin",
"supports",
"this",
"block",
"."
] | python | train |
MycroftAI/adapt | adapt/entity_tagger.py | https://github.com/MycroftAI/adapt/blob/334f23248b8e09fb9d84a88398424ec5bd3bae4c/adapt/entity_tagger.py#L33-L45 | def _iterate_subsequences(self, tokens):
"""
Using regex invokes this function, which significantly impacts performance of adapt. it is an N! operation.
Args:
tokens(list): list of tokens for Yield results.
Yields:
str: ?
"""
for start_idx in xra... | [
"def",
"_iterate_subsequences",
"(",
"self",
",",
"tokens",
")",
":",
"for",
"start_idx",
"in",
"xrange",
"(",
"len",
"(",
"tokens",
")",
")",
":",
"for",
"end_idx",
"in",
"xrange",
"(",
"start_idx",
"+",
"1",
",",
"len",
"(",
"tokens",
")",
"+",
"1"... | Using regex invokes this function, which significantly impacts performance of adapt. it is an N! operation.
Args:
tokens(list): list of tokens for Yield results.
Yields:
str: ? | [
"Using",
"regex",
"invokes",
"this",
"function",
"which",
"significantly",
"impacts",
"performance",
"of",
"adapt",
".",
"it",
"is",
"an",
"N!",
"operation",
"."
] | python | train |
SeattleTestbed/seash | pyreadline/modes/emacs.py | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/modes/emacs.py#L196-L212 | def _init_digit_argument(self, keyinfo):
"""Initialize search prompt
"""
c = self.console
line = self.l_buffer.get_line_text()
self._digit_argument_oldprompt = self.prompt
queue = self.process_keyevent_queue
queue = self.process_keyevent_queue
queu... | [
"def",
"_init_digit_argument",
"(",
"self",
",",
"keyinfo",
")",
":",
"c",
"=",
"self",
".",
"console",
"line",
"=",
"self",
".",
"l_buffer",
".",
"get_line_text",
"(",
")",
"self",
".",
"_digit_argument_oldprompt",
"=",
"self",
".",
"prompt",
"queue",
"="... | Initialize search prompt | [
"Initialize",
"search",
"prompt"
] | python | train |
openstack/networking-cisco | networking_cisco/plugins/cisco/cfg_agent/device_drivers/asr1k/asr1k_cfg_syncer.py | https://github.com/openstack/networking-cisco/blob/aa58a30aec25b86f9aa5952b0863045975debfa9/networking_cisco/plugins/cisco/cfg_agent/device_drivers/asr1k/asr1k_cfg_syncer.py#L326-L336 | def get_running_config(self, conn):
"""Get the ASR1k's current running config.
:return: Current IOS running config as multiline string
"""
config = conn.get_config(source="running")
if config:
root = ET.fromstring(config._raw)
running_config = root[0][0]
... | [
"def",
"get_running_config",
"(",
"self",
",",
"conn",
")",
":",
"config",
"=",
"conn",
".",
"get_config",
"(",
"source",
"=",
"\"running\"",
")",
"if",
"config",
":",
"root",
"=",
"ET",
".",
"fromstring",
"(",
"config",
".",
"_raw",
")",
"running_config... | Get the ASR1k's current running config.
:return: Current IOS running config as multiline string | [
"Get",
"the",
"ASR1k",
"s",
"current",
"running",
"config",
".",
":",
"return",
":",
"Current",
"IOS",
"running",
"config",
"as",
"multiline",
"string"
] | python | train |
quantmind/pulsar | pulsar/apps/wsgi/content.py | https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/pulsar/apps/wsgi/content.py#L210-L222 | def html_factory(tag, **defaults):
'''Returns an :class:`Html` factory function for ``tag`` and a given
dictionary of ``defaults`` parameters. For example::
>>> input_factory = html_factory('input', type='text')
>>> html = input_factory(value='bla')
'''
def html_input(*children, **params):
... | [
"def",
"html_factory",
"(",
"tag",
",",
"*",
"*",
"defaults",
")",
":",
"def",
"html_input",
"(",
"*",
"children",
",",
"*",
"*",
"params",
")",
":",
"p",
"=",
"defaults",
".",
"copy",
"(",
")",
"p",
".",
"update",
"(",
"params",
")",
"return",
"... | Returns an :class:`Html` factory function for ``tag`` and a given
dictionary of ``defaults`` parameters. For example::
>>> input_factory = html_factory('input', type='text')
>>> html = input_factory(value='bla') | [
"Returns",
"an",
":",
"class",
":",
"Html",
"factory",
"function",
"for",
"tag",
"and",
"a",
"given",
"dictionary",
"of",
"defaults",
"parameters",
".",
"For",
"example",
"::"
] | python | train |
Azure/msrest-for-python | msrest/service_client.py | https://github.com/Azure/msrest-for-python/blob/0732bc90bdb290e5f58c675ffdd7dbfa9acefc93/msrest/service_client.py#L172-L182 | def put(self, url, params=None, headers=None, content=None, form_content=None):
# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -> ClientRequest
"""Create a PUT request object.
:param str url: The request URL.
:param dict params: Request ... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"params",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"content",
"=",
"None",
",",
"form_content",
"=",
"None",
")",
":",
"# type: (str, Optional[Dict[str, str]], Optional[Dict[str, str]], Any, Optional[Dict[str, Any]]) -... | Create a PUT request object.
:param str url: The request URL.
:param dict params: Request URL parameters.
:param dict headers: Headers
:param dict form_content: Form content | [
"Create",
"a",
"PUT",
"request",
"object",
"."
] | python | train |
pennlabs/penn-sdk-python | penn/wharton.py | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L142-L184 | def switch_format(self, gsr):
""" Convert the Wharton GSR format into the studyspaces API format. """
if "error" in gsr:
return gsr
categories = {
"cid": 1,
"name": "Huntsman Hall",
"rooms": []
}
for time in gsr["times"]:
... | [
"def",
"switch_format",
"(",
"self",
",",
"gsr",
")",
":",
"if",
"\"error\"",
"in",
"gsr",
":",
"return",
"gsr",
"categories",
"=",
"{",
"\"cid\"",
":",
"1",
",",
"\"name\"",
":",
"\"Huntsman Hall\"",
",",
"\"rooms\"",
":",
"[",
"]",
"}",
"for",
"time"... | Convert the Wharton GSR format into the studyspaces API format. | [
"Convert",
"the",
"Wharton",
"GSR",
"format",
"into",
"the",
"studyspaces",
"API",
"format",
"."
] | python | train |
mangalam-research/selenic | selenic/builder.py | https://github.com/mangalam-research/selenic/blob/2284c68e15fa3d34b88aa2eec1a2e8ecd37f44ad/selenic/builder.py#L260-L295 | def chromedriver_element_center_patch():
"""
Patch move_to_element on ActionChains to work around a bug present
in Chromedriver 2.14 to 2.20.
Calling this function multiple times in the same process will
install the patch once, and just once.
"""
patch_name = "_selenic_chromedriver_element... | [
"def",
"chromedriver_element_center_patch",
"(",
")",
":",
"patch_name",
"=",
"\"_selenic_chromedriver_element_center_patched\"",
"if",
"getattr",
"(",
"ActionChains",
",",
"patch_name",
",",
"None",
")",
":",
"return",
"# We've patched ActionChains already!!",
"# This is the... | Patch move_to_element on ActionChains to work around a bug present
in Chromedriver 2.14 to 2.20.
Calling this function multiple times in the same process will
install the patch once, and just once. | [
"Patch",
"move_to_element",
"on",
"ActionChains",
"to",
"work",
"around",
"a",
"bug",
"present",
"in",
"Chromedriver",
"2",
".",
"14",
"to",
"2",
".",
"20",
"."
] | python | train |
i3visio/osrframework | osrframework/checkfy.py | https://github.com/i3visio/osrframework/blob/83437f4c14c9c08cb80a896bd9834c77f6567871/osrframework/checkfy.py#L39-L63 | def createEmails(nicks=None, nicksFile=None):
"""
Method that globally permits to generate the emails to be checked.
Args:
-----
nicks: List of aliases.
nicksFile: The filepath to the aliases file.
Returns:
--------
list: list of emails to be checked.
"""
candid... | [
"def",
"createEmails",
"(",
"nicks",
"=",
"None",
",",
"nicksFile",
"=",
"None",
")",
":",
"candidate_emails",
"=",
"set",
"(",
")",
"if",
"nicks",
"!=",
"None",
":",
"for",
"n",
"in",
"nicks",
":",
"for",
"e",
"in",
"email_providers",
".",
"domains",
... | Method that globally permits to generate the emails to be checked.
Args:
-----
nicks: List of aliases.
nicksFile: The filepath to the aliases file.
Returns:
--------
list: list of emails to be checked. | [
"Method",
"that",
"globally",
"permits",
"to",
"generate",
"the",
"emails",
"to",
"be",
"checked",
"."
] | python | train |
ekmmetering/ekmmeters | ekmmeters.py | https://github.com/ekmmetering/ekmmeters/blob/b3748bdf30263bfa46ea40157bdf8df2522e1904/ekmmeters.py#L1574-L1609 | def setMaxDemandPeriod(self, period, password="00000000"):
""" Serial call to set max demand period.
Args:
period (int): : as int.
password (str): Optional password.
Returns:
bool: True on completion with ACK.
"""
result = False
self.... | [
"def",
"setMaxDemandPeriod",
"(",
"self",
",",
"period",
",",
"password",
"=",
"\"00000000\"",
")",
":",
"result",
"=",
"False",
"self",
".",
"setContext",
"(",
"\"setMaxDemandPeriod\"",
")",
"try",
":",
"if",
"period",
"<",
"1",
"or",
"period",
">",
"3",
... | Serial call to set max demand period.
Args:
period (int): : as int.
password (str): Optional password.
Returns:
bool: True on completion with ACK. | [
"Serial",
"call",
"to",
"set",
"max",
"demand",
"period",
"."
] | python | test |
Karaage-Cluster/karaage | karaage/people/emails.py | https://github.com/Karaage-Cluster/karaage/blob/2f4c8b4e2d728b3fcbb151160c49000f1c04f5c9/karaage/people/emails.py#L67-L83 | def send_reset_password_email(person):
"""Sends an email to user allowing them to set their password."""
uid = urlsafe_base64_encode(force_bytes(person.pk)).decode("ascii")
token = default_token_generator.make_token(person)
url = '%s/persons/reset/%s/%s/' % (
settings.REGISTRATION_BASE_URL, uid,... | [
"def",
"send_reset_password_email",
"(",
"person",
")",
":",
"uid",
"=",
"urlsafe_base64_encode",
"(",
"force_bytes",
"(",
"person",
".",
"pk",
")",
")",
".",
"decode",
"(",
"\"ascii\"",
")",
"token",
"=",
"default_token_generator",
".",
"make_token",
"(",
"pe... | Sends an email to user allowing them to set their password. | [
"Sends",
"an",
"email",
"to",
"user",
"allowing",
"them",
"to",
"set",
"their",
"password",
"."
] | python | train |
juju/charm-helpers | charmhelpers/contrib/storage/linux/ceph.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/storage/linux/ceph.py#L392-L413 | def get_mon_map(service):
"""
Returns the current monitor map.
:param service: six.string_types. The Ceph user name to run the command under
:return: json string. :raise: ValueError if the monmap fails to parse.
Also raises CalledProcessError if our ceph command fails
"""
try:
mon_... | [
"def",
"get_mon_map",
"(",
"service",
")",
":",
"try",
":",
"mon_status",
"=",
"check_output",
"(",
"[",
"'ceph'",
",",
"'--id'",
",",
"service",
",",
"'mon_status'",
",",
"'--format=json'",
"]",
")",
"if",
"six",
".",
"PY3",
":",
"mon_status",
"=",
"mon... | Returns the current monitor map.
:param service: six.string_types. The Ceph user name to run the command under
:return: json string. :raise: ValueError if the monmap fails to parse.
Also raises CalledProcessError if our ceph command fails | [
"Returns",
"the",
"current",
"monitor",
"map",
".",
":",
"param",
"service",
":",
"six",
".",
"string_types",
".",
"The",
"Ceph",
"user",
"name",
"to",
"run",
"the",
"command",
"under",
":",
"return",
":",
"json",
"string",
".",
":",
"raise",
":",
"Val... | python | train |
pypa/pipenv | pipenv/cli/command.py | https://github.com/pypa/pipenv/blob/cae8d76c210b9777e90aab76e9c4b0e53bb19cde/pipenv/cli/command.py#L593-L618 | def sync(
ctx,
state,
bare=False,
user=False,
unused=False,
**kwargs
):
"""Installs all packages specified in Pipfile.lock."""
from ..core import do_sync
retcode = do_sync(
ctx=ctx,
dev=state.installstate.dev,
three=state.three,
python=state.python,
... | [
"def",
"sync",
"(",
"ctx",
",",
"state",
",",
"bare",
"=",
"False",
",",
"user",
"=",
"False",
",",
"unused",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
".",
"core",
"import",
"do_sync",
"retcode",
"=",
"do_sync",
"(",
"ctx",
"... | Installs all packages specified in Pipfile.lock. | [
"Installs",
"all",
"packages",
"specified",
"in",
"Pipfile",
".",
"lock",
"."
] | python | train |
saltstack/salt | salt/utils/msgpack.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/msgpack.py#L76-L87 | def unpackb(packed, **kwargs):
'''
.. versionadded:: 2018.3.4
Wraps msgpack.unpack.
By default, this function uses the msgpack module and falls back to
msgpack_pure, if the msgpack is not available. You can pass an alternate
msgpack module using the _msgpack_module argument.
'''
msgpac... | [
"def",
"unpackb",
"(",
"packed",
",",
"*",
"*",
"kwargs",
")",
":",
"msgpack_module",
"=",
"kwargs",
".",
"pop",
"(",
"'_msgpack_module'",
",",
"msgpack",
")",
"return",
"msgpack_module",
".",
"unpackb",
"(",
"packed",
",",
"*",
"*",
"kwargs",
")"
] | .. versionadded:: 2018.3.4
Wraps msgpack.unpack.
By default, this function uses the msgpack module and falls back to
msgpack_pure, if the msgpack is not available. You can pass an alternate
msgpack module using the _msgpack_module argument. | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"4"
] | python | train |
marcomusy/vtkplotter | vtkplotter/shapes.py | https://github.com/marcomusy/vtkplotter/blob/692c3396782722ec525bc1346a26999868c650c6/vtkplotter/shapes.py#L588-L632 | def Polygon(pos=(0, 0, 0), normal=(0, 0, 1), nsides=6, r=1, c="coral",
bc="darkgreen", lw=1, alpha=1, followcam=False):
"""
Build a 2D polygon of `nsides` of radius `r` oriented as `normal`.
:param followcam: if `True` the text will auto-orient itself to the active camera.
A ``vtkCamera... | [
"def",
"Polygon",
"(",
"pos",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
",",
"normal",
"=",
"(",
"0",
",",
"0",
",",
"1",
")",
",",
"nsides",
"=",
"6",
",",
"r",
"=",
"1",
",",
"c",
"=",
"\"coral\"",
",",
"bc",
"=",
"\"darkgreen\"",
",",
"l... | Build a 2D polygon of `nsides` of radius `r` oriented as `normal`.
:param followcam: if `True` the text will auto-orient itself to the active camera.
A ``vtkCamera`` object can also be passed.
:type followcam: bool, vtkCamera
|Polygon| | [
"Build",
"a",
"2D",
"polygon",
"of",
"nsides",
"of",
"radius",
"r",
"oriented",
"as",
"normal",
"."
] | python | train |
mozilla/configman | configman/value_sources/for_getopt.py | https://github.com/mozilla/configman/blob/83159fed61cc4cbbe5a4a6a00d3acad8a0c39c96/configman/value_sources/for_getopt.py#L171-L210 | def getopt_with_ignore(args, shortopts, longopts=[]):
"""my_getopt(args, options[, long_options]) -> opts, args
This function works like gnu_getopt(), except that unknown parameters
are ignored rather than raising an error.
"""
opts = []
prog_args = []
if isinsta... | [
"def",
"getopt_with_ignore",
"(",
"args",
",",
"shortopts",
",",
"longopts",
"=",
"[",
"]",
")",
":",
"opts",
"=",
"[",
"]",
"prog_args",
"=",
"[",
"]",
"if",
"isinstance",
"(",
"longopts",
",",
"str",
")",
":",
"longopts",
"=",
"[",
"longopts",
"]",... | my_getopt(args, options[, long_options]) -> opts, args
This function works like gnu_getopt(), except that unknown parameters
are ignored rather than raising an error. | [
"my_getopt",
"(",
"args",
"options",
"[",
"long_options",
"]",
")",
"-",
">",
"opts",
"args"
] | python | train |
dpkp/kafka-python | kafka/admin/client.py | https://github.com/dpkp/kafka-python/blob/f6a8a38937688ea2cc5dc13d3d1039493be5c9b5/kafka/admin/client.py#L646-L693 | def list_consumer_groups(self, broker_ids=None):
"""List all consumer groups known to the cluster.
This returns a list of Consumer Group tuples. The tuples are
composed of the consumer group name and the consumer group protocol
type.
Only consumer groups that store their offset... | [
"def",
"list_consumer_groups",
"(",
"self",
",",
"broker_ids",
"=",
"None",
")",
":",
"# While we return a list, internally use a set to prevent duplicates",
"# because if a group coordinator fails after being queried, and its",
"# consumer groups move to new brokers that haven't yet been qu... | List all consumer groups known to the cluster.
This returns a list of Consumer Group tuples. The tuples are
composed of the consumer group name and the consumer group protocol
type.
Only consumer groups that store their offsets in Kafka are returned.
The protocol type will be a... | [
"List",
"all",
"consumer",
"groups",
"known",
"to",
"the",
"cluster",
"."
] | python | train |
ianlini/bistiming | bistiming/stopwatch.py | https://github.com/ianlini/bistiming/blob/46a78ec647723c3516fc4fc73f2619ab41f647f2/bistiming/stopwatch.py#L157-L164 | def reset(self):
"""Reset the stopwatch.
"""
self._start_time = None
self._end_time = None
self._elapsed_time = datetime.timedelta()
self._cumulative_elapsed_time = datetime.timedelta()
self.split_elapsed_time = [] | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_start_time",
"=",
"None",
"self",
".",
"_end_time",
"=",
"None",
"self",
".",
"_elapsed_time",
"=",
"datetime",
".",
"timedelta",
"(",
")",
"self",
".",
"_cumulative_elapsed_time",
"=",
"datetime",
".",... | Reset the stopwatch. | [
"Reset",
"the",
"stopwatch",
"."
] | python | train |
mattupstate/flask-security | flask_security/views.py | https://github.com/mattupstate/flask-security/blob/a401fb47018fbbbe0b899ea55afadfd0e3cd847a/flask_security/views.py#L273-L303 | def reset_password(token):
"""View function that handles a reset password request."""
expired, invalid, user = reset_password_token_status(token)
if not user or invalid:
invalid = True
do_flash(*get_message('INVALID_RESET_PASSWORD_TOKEN'))
if expired:
send_reset_password_instr... | [
"def",
"reset_password",
"(",
"token",
")",
":",
"expired",
",",
"invalid",
",",
"user",
"=",
"reset_password_token_status",
"(",
"token",
")",
"if",
"not",
"user",
"or",
"invalid",
":",
"invalid",
"=",
"True",
"do_flash",
"(",
"*",
"get_message",
"(",
"'I... | View function that handles a reset password request. | [
"View",
"function",
"that",
"handles",
"a",
"reset",
"password",
"request",
"."
] | python | train |
bmcfee/pumpp | pumpp/feature/base.py | https://github.com/bmcfee/pumpp/blob/06a17b888271dd1f6cd41bddb22b0eb04d494056/pumpp/feature/base.py#L151-L167 | def n_frames(self, duration):
'''Get the number of frames for a given duration
Parameters
----------
duration : number >= 0
The duration, in seconds
Returns
-------
n_frames : int >= 0
The number of frames at this extractor's sampling rat... | [
"def",
"n_frames",
"(",
"self",
",",
"duration",
")",
":",
"return",
"int",
"(",
"time_to_frames",
"(",
"duration",
",",
"sr",
"=",
"self",
".",
"sr",
",",
"hop_length",
"=",
"self",
".",
"hop_length",
")",
")"
] | Get the number of frames for a given duration
Parameters
----------
duration : number >= 0
The duration, in seconds
Returns
-------
n_frames : int >= 0
The number of frames at this extractor's sampling rate and
hop length | [
"Get",
"the",
"number",
"of",
"frames",
"for",
"a",
"given",
"duration"
] | python | train |
jenisys/parse_type | parse_type/parse_util.py | https://github.com/jenisys/parse_type/blob/7cad3a67a5ca725cb786da31f656fd473084289f/parse_type/parse_util.py#L105-L150 | def extract_format_spec(cls, format):
"""Pull apart the format: [[fill]align][0][width][.precision][type]"""
# -- BASED-ON: parse.extract_format()
# pylint: disable=redefined-builtin, unsubscriptable-object
if not format:
raise ValueError("INVALID-FORMAT: %s (empty-string)" %... | [
"def",
"extract_format_spec",
"(",
"cls",
",",
"format",
")",
":",
"# -- BASED-ON: parse.extract_format()",
"# pylint: disable=redefined-builtin, unsubscriptable-object",
"if",
"not",
"format",
":",
"raise",
"ValueError",
"(",
"\"INVALID-FORMAT: %s (empty-string)\"",
"%",
"form... | Pull apart the format: [[fill]align][0][width][.precision][type] | [
"Pull",
"apart",
"the",
"format",
":",
"[[",
"fill",
"]",
"align",
"]",
"[",
"0",
"]",
"[",
"width",
"]",
"[",
".",
"precision",
"]",
"[",
"type",
"]"
] | python | train |
tensorflow/cleverhans | cleverhans/attacks/carlini_wagner_l2.py | https://github.com/tensorflow/cleverhans/blob/97488e215760547b81afc53f5e5de8ba7da5bd98/cleverhans/attacks/carlini_wagner_l2.py#L293-L415 | def attack_batch(self, imgs, labs):
"""
Run the attack on a batch of instance and labels.
"""
def compare(x, y):
if not isinstance(x, (float, int, np.int64)):
x = np.copy(x)
if self.TARGETED:
x[y] -= self.CONFIDENCE
else:
x[y] += self.CONFIDENCE
... | [
"def",
"attack_batch",
"(",
"self",
",",
"imgs",
",",
"labs",
")",
":",
"def",
"compare",
"(",
"x",
",",
"y",
")",
":",
"if",
"not",
"isinstance",
"(",
"x",
",",
"(",
"float",
",",
"int",
",",
"np",
".",
"int64",
")",
")",
":",
"x",
"=",
"np"... | Run the attack on a batch of instance and labels. | [
"Run",
"the",
"attack",
"on",
"a",
"batch",
"of",
"instance",
"and",
"labels",
"."
] | python | train |
jschaf/pylint-flask | pylint_flask/__init__.py | https://github.com/jschaf/pylint-flask/blob/3851d142679facbc60b4755dc7fb5428aafdebe7/pylint_flask/__init__.py#L112-L132 | def transform_flask_bare_import(node):
'''Translates a flask.ext.wtf bare import into a non-magical import.
Translates:
import flask.ext.admin as admin
Into:
import flask_admin as admin
'''
new_names = []
for (name, as_name) in node.names:
match = re.match(r'flask\.ext\... | [
"def",
"transform_flask_bare_import",
"(",
"node",
")",
":",
"new_names",
"=",
"[",
"]",
"for",
"(",
"name",
",",
"as_name",
")",
"in",
"node",
".",
"names",
":",
"match",
"=",
"re",
".",
"match",
"(",
"r'flask\\.ext\\.(.*)'",
",",
"name",
")",
"from_nam... | Translates a flask.ext.wtf bare import into a non-magical import.
Translates:
import flask.ext.admin as admin
Into:
import flask_admin as admin | [
"Translates",
"a",
"flask",
".",
"ext",
".",
"wtf",
"bare",
"import",
"into",
"a",
"non",
"-",
"magical",
"import",
"."
] | python | train |
pantsbuild/pants | src/python/pants/goal/products.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/goal/products.py#L452-L472 | def get_only(self, product_type, target):
"""If there is exactly one product for the given product type and target, returns the
full filepath of said product.
Otherwise, raises a ProductError.
Useful for retrieving the filepath for the executable of a binary target.
:API: public
"""
produ... | [
"def",
"get_only",
"(",
"self",
",",
"product_type",
",",
"target",
")",
":",
"product_mapping",
"=",
"self",
".",
"get",
"(",
"product_type",
")",
".",
"get",
"(",
"target",
")",
"if",
"len",
"(",
"product_mapping",
")",
"!=",
"1",
":",
"raise",
"Prod... | If there is exactly one product for the given product type and target, returns the
full filepath of said product.
Otherwise, raises a ProductError.
Useful for retrieving the filepath for the executable of a binary target.
:API: public | [
"If",
"there",
"is",
"exactly",
"one",
"product",
"for",
"the",
"given",
"product",
"type",
"and",
"target",
"returns",
"the",
"full",
"filepath",
"of",
"said",
"product",
"."
] | python | train |
Hackerfleet/hfos | hfos/ui/auth.py | https://github.com/Hackerfleet/hfos/blob/b6df14eacaffb6be5c844108873ff8763ec7f0c9/hfos/ui/auth.py#L145-L188 | def _handle_autologin(self, event):
"""Automatic logins for client configurations that allow it"""
self.log("Verifying automatic login request")
# TODO: Check for a common secret
# noinspection PyBroadException
try:
client_config = objectmodels['client'].find_one({... | [
"def",
"_handle_autologin",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"log",
"(",
"\"Verifying automatic login request\"",
")",
"# TODO: Check for a common secret",
"# noinspection PyBroadException",
"try",
":",
"client_config",
"=",
"objectmodels",
"[",
"'client'... | Automatic logins for client configurations that allow it | [
"Automatic",
"logins",
"for",
"client",
"configurations",
"that",
"allow",
"it"
] | python | train |
pandas-dev/pandas | pandas/core/strings.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/strings.py#L2564-L2625 | def zfill(self, width):
"""
Pad strings in the Series/Index by prepending '0' characters.
Strings in the Series/Index are padded with '0' characters on the
left of the string to reach a total string length `width`. Strings
in the Series/Index with length greater or equal to `wi... | [
"def",
"zfill",
"(",
"self",
",",
"width",
")",
":",
"result",
"=",
"str_pad",
"(",
"self",
".",
"_parent",
",",
"width",
",",
"side",
"=",
"'left'",
",",
"fillchar",
"=",
"'0'",
")",
"return",
"self",
".",
"_wrap_result",
"(",
"result",
")"
] | Pad strings in the Series/Index by prepending '0' characters.
Strings in the Series/Index are padded with '0' characters on the
left of the string to reach a total string length `width`. Strings
in the Series/Index with length greater or equal to `width` are
unchanged.
Paramet... | [
"Pad",
"strings",
"in",
"the",
"Series",
"/",
"Index",
"by",
"prepending",
"0",
"characters",
"."
] | python | train |
ungarj/mapchete | mapchete/io/raster.py | https://github.com/ungarj/mapchete/blob/d482918d0e66a5b414dff6aa7cc854e01fc60ee4/mapchete/io/raster.py#L487-L556 | def resample_from_array(
in_raster=None,
in_affine=None,
out_tile=None,
in_crs=None,
resampling="nearest",
nodataval=0
):
"""
Extract and resample from array to target tile.
Parameters
----------
in_raster : array
in_affine : ``Affine``
out_tile : ``BufferedTile``
... | [
"def",
"resample_from_array",
"(",
"in_raster",
"=",
"None",
",",
"in_affine",
"=",
"None",
",",
"out_tile",
"=",
"None",
",",
"in_crs",
"=",
"None",
",",
"resampling",
"=",
"\"nearest\"",
",",
"nodataval",
"=",
"0",
")",
":",
"# TODO rename function",
"if",... | Extract and resample from array to target tile.
Parameters
----------
in_raster : array
in_affine : ``Affine``
out_tile : ``BufferedTile``
resampling : string
one of rasterio's resampling methods (default: nearest)
nodataval : integer or float
raster nodata value (default: 0... | [
"Extract",
"and",
"resample",
"from",
"array",
"to",
"target",
"tile",
"."
] | python | valid |
tensorpack/tensorpack | examples/FasterRCNN/data.py | https://github.com/tensorpack/tensorpack/blob/d7a13cb74c9066bc791d7aafc3b744b60ee79a9f/examples/FasterRCNN/data.py#L30-L50 | def print_class_histogram(roidbs):
"""
Args:
roidbs (list[dict]): the same format as the output of `load_training_roidbs`.
"""
dataset = DetectionDataset()
hist_bins = np.arange(dataset.num_classes + 1)
# Histogram of ground-truth objects
gt_hist = np.zeros((dataset.num_classes,), d... | [
"def",
"print_class_histogram",
"(",
"roidbs",
")",
":",
"dataset",
"=",
"DetectionDataset",
"(",
")",
"hist_bins",
"=",
"np",
".",
"arange",
"(",
"dataset",
".",
"num_classes",
"+",
"1",
")",
"# Histogram of ground-truth objects",
"gt_hist",
"=",
"np",
".",
"... | Args:
roidbs (list[dict]): the same format as the output of `load_training_roidbs`. | [
"Args",
":",
"roidbs",
"(",
"list",
"[",
"dict",
"]",
")",
":",
"the",
"same",
"format",
"as",
"the",
"output",
"of",
"load_training_roidbs",
"."
] | python | train |
tensorforce/tensorforce | tensorforce/models/model.py | https://github.com/tensorforce/tensorforce/blob/520a8d992230e382f08e315ede5fc477f5e26bfb/tensorforce/models/model.py#L237-L368 | def setup(self):
"""
Sets up the TensorFlow model graph, starts the servers (distributed mode), creates summarizers
and savers, initializes (and enters) the TensorFlow session.
"""
# Create/get our graph, setup local model/global model links, set scope and device.
graph_... | [
"def",
"setup",
"(",
"self",
")",
":",
"# Create/get our graph, setup local model/global model links, set scope and device.",
"graph_default_context",
"=",
"self",
".",
"setup_graph",
"(",
")",
"# Start a tf Server (in case of distributed setup). Only start once.",
"if",
"self",
".... | Sets up the TensorFlow model graph, starts the servers (distributed mode), creates summarizers
and savers, initializes (and enters) the TensorFlow session. | [
"Sets",
"up",
"the",
"TensorFlow",
"model",
"graph",
"starts",
"the",
"servers",
"(",
"distributed",
"mode",
")",
"creates",
"summarizers",
"and",
"savers",
"initializes",
"(",
"and",
"enters",
")",
"the",
"TensorFlow",
"session",
"."
] | python | valid |
podio/podio-py | pypodio2/encode.py | https://github.com/podio/podio-py/blob/5ce956034a06c98b0ef18fcd940b36da0908ad6c/pypodio2/encode.py#L195-L219 | def encode_hdr(self, boundary):
"""Returns the header of the encoding of this parameter"""
boundary = encode_and_quote(boundary)
headers = ["--%s" % boundary]
if self.filename:
disposition = 'form-data; name="%s"; filename="%s"' % (self.name,
... | [
"def",
"encode_hdr",
"(",
"self",
",",
"boundary",
")",
":",
"boundary",
"=",
"encode_and_quote",
"(",
"boundary",
")",
"headers",
"=",
"[",
"\"--%s\"",
"%",
"boundary",
"]",
"if",
"self",
".",
"filename",
":",
"disposition",
"=",
"'form-data; name=\"%s\"; fil... | Returns the header of the encoding of this parameter | [
"Returns",
"the",
"header",
"of",
"the",
"encoding",
"of",
"this",
"parameter"
] | python | train |
mitodl/PyLmod | pylmod/gradebook.py | https://github.com/mitodl/PyLmod/blob/b798b86c33d1eb615e7cd4f3457b5c15da1d86e0/pylmod/gradebook.py#L282-L333 | def get_assignment_by_name(self, assignment_name, assignments=None):
"""Get assignment by name.
Get an assignment by name. It works by retrieving all assignments
and returning the first assignment with a matching name. If the
optional parameter ``assignments`` is provided, it uses this
... | [
"def",
"get_assignment_by_name",
"(",
"self",
",",
"assignment_name",
",",
"assignments",
"=",
"None",
")",
":",
"if",
"assignments",
"is",
"None",
":",
"assignments",
"=",
"self",
".",
"get_assignments",
"(",
")",
"for",
"assignment",
"in",
"assignments",
":"... | Get assignment by name.
Get an assignment by name. It works by retrieving all assignments
and returning the first assignment with a matching name. If the
optional parameter ``assignments`` is provided, it uses this
collection rather than retrieving all assignments from the service.
... | [
"Get",
"assignment",
"by",
"name",
"."
] | python | train |
auth0/auth0-python | auth0/v3/management/logs.py | https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/management/logs.py#L27-L71 | def search(self, page=0, per_page=50, sort=None, q=None,
include_totals=True, fields=None, from_param=None, take=None,
include_fields=True):
"""Search log events.
Args:
page (int, optional): The result's page number (zero based).
per_page (int, opt... | [
"def",
"search",
"(",
"self",
",",
"page",
"=",
"0",
",",
"per_page",
"=",
"50",
",",
"sort",
"=",
"None",
",",
"q",
"=",
"None",
",",
"include_totals",
"=",
"True",
",",
"fields",
"=",
"None",
",",
"from_param",
"=",
"None",
",",
"take",
"=",
"N... | Search log events.
Args:
page (int, optional): The result's page number (zero based).
per_page (int, optional): The amount of entries per page.
sort (str, optional): The field to use for sorting.
1 == ascending and -1 == descending. (e.g: date:1)
... | [
"Search",
"log",
"events",
"."
] | python | train |
lambdamusic/Ontospy | ontospy/extras/hacks/matcher.py | https://github.com/lambdamusic/Ontospy/blob/eb46cb13792b2b87f21babdf976996318eec7571/ontospy/extras/hacks/matcher.py#L69-L122 | def matcher(graph1, graph2, confidence=0.5, output_file="matching_results.csv", class_or_prop="classes", verbose=False):
"""
takes two graphs and matches its classes based on qname, label etc..
@todo extend to properties and skos etc..
"""
printDebug("----------\nNow matching...")
f = open(output_file, 'wt')
c... | [
"def",
"matcher",
"(",
"graph1",
",",
"graph2",
",",
"confidence",
"=",
"0.5",
",",
"output_file",
"=",
"\"matching_results.csv\"",
",",
"class_or_prop",
"=",
"\"classes\"",
",",
"verbose",
"=",
"False",
")",
":",
"printDebug",
"(",
"\"----------\\nNow matching...... | takes two graphs and matches its classes based on qname, label etc..
@todo extend to properties and skos etc.. | [
"takes",
"two",
"graphs",
"and",
"matches",
"its",
"classes",
"based",
"on",
"qname",
"label",
"etc",
".."
] | python | train |
sethmlarson/virtualbox-python | virtualbox/library.py | https://github.com/sethmlarson/virtualbox-python/blob/706c8e3f6e3aee17eb06458e73cbb4bc2d37878b/virtualbox/library.py#L26670-L26688 | def get_registers(self, cpu_id):
"""Gets all the registers for the given CPU.
in cpu_id of type int
The identifier of the Virtual CPU.
out names of type str
Array containing the lowercase register names.
out values of type str
Array parallel to the ... | [
"def",
"get_registers",
"(",
"self",
",",
"cpu_id",
")",
":",
"if",
"not",
"isinstance",
"(",
"cpu_id",
",",
"baseinteger",
")",
":",
"raise",
"TypeError",
"(",
"\"cpu_id can only be an instance of type baseinteger\"",
")",
"(",
"names",
",",
"values",
")",
"=",... | Gets all the registers for the given CPU.
in cpu_id of type int
The identifier of the Virtual CPU.
out names of type str
Array containing the lowercase register names.
out values of type str
Array parallel to the names holding the register values as if the
... | [
"Gets",
"all",
"the",
"registers",
"for",
"the",
"given",
"CPU",
"."
] | python | train |
foobarbecue/afterflight | afterflight/af_utils.py | https://github.com/foobarbecue/afterflight/blob/7085f719593f88999dce93f35caec5f15d2991b6/afterflight/af_utils.py#L24-L29 | def logpath2dt(filepath):
"""
given a dataflashlog in the format produced by Mission Planner,
return a datetime which says when the file was downloaded from the APM
"""
return datetime.datetime.strptime(re.match(r'.*/(.*) .*$',filepath).groups()[0],'%Y-%m-%d %H-%M') | [
"def",
"logpath2dt",
"(",
"filepath",
")",
":",
"return",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"re",
".",
"match",
"(",
"r'.*/(.*) .*$'",
",",
"filepath",
")",
".",
"groups",
"(",
")",
"[",
"0",
"]",
",",
"'%Y-%m-%d %H-%M'",
")"
] | given a dataflashlog in the format produced by Mission Planner,
return a datetime which says when the file was downloaded from the APM | [
"given",
"a",
"dataflashlog",
"in",
"the",
"format",
"produced",
"by",
"Mission",
"Planner",
"return",
"a",
"datetime",
"which",
"says",
"when",
"the",
"file",
"was",
"downloaded",
"from",
"the",
"APM"
] | python | train |
zagaran/mongolia | mongolia/mongo_connection.py | https://github.com/zagaran/mongolia/blob/82c499345f0a8610c7289545e19f5f633e8a81c0/mongolia/mongo_connection.py#L180-L203 | def add_user(name, password=None, read_only=None, db=None, **kwargs):
"""
Adds a user that can be used for authentication.
@param name: the name of the user to create
@param passowrd: the password of the user to create. Can not be used with
the userSource argument.
@param read_only: if ... | [
"def",
"add_user",
"(",
"name",
",",
"password",
"=",
"None",
",",
"read_only",
"=",
"None",
",",
"db",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"CONNECTION",
".",
"add_user",
"(",
"name",
",",
"password",
"=",
"password",
",",
"read... | Adds a user that can be used for authentication.
@param name: the name of the user to create
@param passowrd: the password of the user to create. Can not be used with
the userSource argument.
@param read_only: if True the user will be read only
@param db: the database the user is authentica... | [
"Adds",
"a",
"user",
"that",
"can",
"be",
"used",
"for",
"authentication",
"."
] | python | train |
sveetch/py-css-styleguide | py_css_styleguide/serializer.py | https://github.com/sveetch/py-css-styleguide/blob/5acc693f71b2fa7d944d7fed561ae0a7699ccd0f/py_css_styleguide/serializer.py#L71-L94 | def validate_variable_name(self, name):
"""
Validate variable name.
Arguments:
name (string): Property name.
Returns:
bool: ``True`` if variable name is valid.
"""
if not name:
raise SerializerError("Variable name is empty".format(nam... | [
"def",
"validate_variable_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"not",
"name",
":",
"raise",
"SerializerError",
"(",
"\"Variable name is empty\"",
".",
"format",
"(",
"name",
")",
")",
"if",
"name",
"[",
"0",
"]",
"not",
"in",
"PROPERTY_ALLOWED_ST... | Validate variable name.
Arguments:
name (string): Property name.
Returns:
bool: ``True`` if variable name is valid. | [
"Validate",
"variable",
"name",
"."
] | python | train |
the01/python-flotils | flotils/runable.py | https://github.com/the01/python-flotils/blob/5954712776bb590107e5b2f4362d010bf74f77a1/flotils/runable.py#L118-L135 | def start(self, blocking=False):
"""
Start the interface
:param blocking: Should the call block until stop() is called
(default: False)
:type blocking: bool
:rtype: None
"""
super(StartStopable, self).start()
self._is_running = True
# ... | [
"def",
"start",
"(",
"self",
",",
"blocking",
"=",
"False",
")",
":",
"super",
"(",
"StartStopable",
",",
"self",
")",
".",
"start",
"(",
")",
"self",
".",
"_is_running",
"=",
"True",
"# blocking",
"try",
":",
"while",
"blocking",
"and",
"self",
".",
... | Start the interface
:param blocking: Should the call block until stop() is called
(default: False)
:type blocking: bool
:rtype: None | [
"Start",
"the",
"interface"
] | python | train |
niloch/iplotter | iplotter/c3_plotter.py | https://github.com/niloch/iplotter/blob/0403486d8633f601a33c4d2b9c9fa3ec88e9327b/iplotter/c3_plotter.py#L34-L44 | def render(self, data, div_id="chart", head=""):
"""Render the data in HTML template."""
if not self.is_valid_name(div_id):
raise ValueError(
"Name {} is invalid. Only letters, numbers, '_', and '-' are permitted ".format(
div_id))
return Template... | [
"def",
"render",
"(",
"self",
",",
"data",
",",
"div_id",
"=",
"\"chart\"",
",",
"head",
"=",
"\"\"",
")",
":",
"if",
"not",
"self",
".",
"is_valid_name",
"(",
"div_id",
")",
":",
"raise",
"ValueError",
"(",
"\"Name {} is invalid. Only letters, numbers, '_', a... | Render the data in HTML template. | [
"Render",
"the",
"data",
"in",
"HTML",
"template",
"."
] | python | train |
miyakogi/wdom | wdom/server/base.py | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/server/base.py#L64-L74 | def open_browser(url: str, browser: str = None) -> None:
"""Open web browser."""
if '--open-browser' in sys.argv:
# Remove open browser to prevent making new tab on autoreload
sys.argv.remove('--open-browser')
if browser is None:
browser = config.browser
if browser in _browsers:
... | [
"def",
"open_browser",
"(",
"url",
":",
"str",
",",
"browser",
":",
"str",
"=",
"None",
")",
"->",
"None",
":",
"if",
"'--open-browser'",
"in",
"sys",
".",
"argv",
":",
"# Remove open browser to prevent making new tab on autoreload",
"sys",
".",
"argv",
".",
"... | Open web browser. | [
"Open",
"web",
"browser",
"."
] | python | train |
koehlma/pygrooveshark | src/grooveshark/classes/album.py | https://github.com/koehlma/pygrooveshark/blob/17673758ac12f54dc26ac879c30ea44f13b81057/src/grooveshark/classes/album.py#L76-L82 | def cover(self):
"""
album cover as :class:`Picture` object
"""
if not self._cover:
self._cover = Picture(self._cover_url, self._connection)
return self._cover | [
"def",
"cover",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_cover",
":",
"self",
".",
"_cover",
"=",
"Picture",
"(",
"self",
".",
"_cover_url",
",",
"self",
".",
"_connection",
")",
"return",
"self",
".",
"_cover"
] | album cover as :class:`Picture` object | [
"album",
"cover",
"as",
":",
"class",
":",
"Picture",
"object"
] | python | train |
tensorflow/probability | tensorflow_probability/python/optimizer/linesearch/internal/hager_zhang_lib.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/optimizer/linesearch/internal/hager_zhang_lib.py#L666-L730 | def _satisfies_wolfe(val_0,
val_c,
f_lim,
sufficient_decrease_param,
curvature_param):
"""Checks whether the Wolfe or approx Wolfe conditions are satisfied.
The Wolfe conditions are a set of stopping criteria for an inexact line se... | [
"def",
"_satisfies_wolfe",
"(",
"val_0",
",",
"val_c",
",",
"f_lim",
",",
"sufficient_decrease_param",
",",
"curvature_param",
")",
":",
"exact_wolfe_suff_dec",
"=",
"(",
"sufficient_decrease_param",
"*",
"val_0",
".",
"df",
">=",
"(",
"val_c",
".",
"f",
"-",
... | Checks whether the Wolfe or approx Wolfe conditions are satisfied.
The Wolfe conditions are a set of stopping criteria for an inexact line search
algorithm. Let f(a) be the function value along the search direction and
df(a) the derivative along the search direction evaluated a distance 'a'.
Here 'a' is the di... | [
"Checks",
"whether",
"the",
"Wolfe",
"or",
"approx",
"Wolfe",
"conditions",
"are",
"satisfied",
"."
] | python | test |
nkgilley/python-ecobee-api | pyecobee/__init__.py | https://github.com/nkgilley/python-ecobee-api/blob/cc8d90d20abcb9ef5b66ec9cb035bae2f06ba174/pyecobee/__init__.py#L295-L305 | def send_message(self, index, message="Hello from python-ecobee!"):
''' Send a message to the thermostat '''
body = {"selection": {
"selectionType": "thermostats",
"selectionMatch": self.thermostats[index]['identifier']},
"functions": [{"type": "se... | [
"def",
"send_message",
"(",
"self",
",",
"index",
",",
"message",
"=",
"\"Hello from python-ecobee!\"",
")",
":",
"body",
"=",
"{",
"\"selection\"",
":",
"{",
"\"selectionType\"",
":",
"\"thermostats\"",
",",
"\"selectionMatch\"",
":",
"self",
".",
"thermostats",
... | Send a message to the thermostat | [
"Send",
"a",
"message",
"to",
"the",
"thermostat"
] | python | test |
mwickert/scikit-dsp-comm | sk_dsp_comm/fec_conv.py | https://github.com/mwickert/scikit-dsp-comm/blob/5c1353412a4d81a8d7da169057564ecf940f8b5b/sk_dsp_comm/fec_conv.py#L790-L847 | def conv_Pb_bound(R,dfree,Ck,SNRdB,hard_soft,M=2):
"""
Coded bit error probabilty
Convolution coding bit error probability upper bound
according to Ziemer & Peterson 7-16, p. 507
Mark Wickert November 2014
Parameters
----------
R: Code rate
dfree: Free distance of ... | [
"def",
"conv_Pb_bound",
"(",
"R",
",",
"dfree",
",",
"Ck",
",",
"SNRdB",
",",
"hard_soft",
",",
"M",
"=",
"2",
")",
":",
"Pb",
"=",
"np",
".",
"zeros_like",
"(",
"SNRdB",
")",
"SNR",
"=",
"10.",
"**",
"(",
"SNRdB",
"/",
"10.",
")",
"for",
"n",
... | Coded bit error probabilty
Convolution coding bit error probability upper bound
according to Ziemer & Peterson 7-16, p. 507
Mark Wickert November 2014
Parameters
----------
R: Code rate
dfree: Free distance of the code
Ck: Weight coefficient
SNRdB: Signal to noise ... | [
"Coded",
"bit",
"error",
"probabilty",
"Convolution",
"coding",
"bit",
"error",
"probability",
"upper",
"bound",
"according",
"to",
"Ziemer",
"&",
"Peterson",
"7",
"-",
"16",
"p",
".",
"507",
"Mark",
"Wickert",
"November",
"2014",
"Parameters",
"----------",
"... | python | valid |
Telefonica/toolium | toolium/selenoid.py | https://github.com/Telefonica/toolium/blob/56847c243b3a98876df74c184b75e43f8810e475/toolium/selenoid.py#L206-L220 | def download_file(self, filename, timeout=5):
"""
download a file from remote selenoid and removing the file in the server.
request: http://<username>:<password>@<ggr_host>:<ggr_port>/download/<ggr_session_id>/<filename>
:param filename: file name with extension to download
:para... | [
"def",
"download_file",
"(",
"self",
",",
"filename",
",",
"timeout",
"=",
"5",
")",
":",
"path_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"output_directory",
",",
"DOWNLOADS_PATH",
",",
"self",
".",
"session_id",
"[",
"-",
"8",
":",... | download a file from remote selenoid and removing the file in the server.
request: http://<username>:<password>@<ggr_host>:<ggr_port>/download/<ggr_session_id>/<filename>
:param filename: file name with extension to download
:param timeout: threshold until the video file is downloaded
:r... | [
"download",
"a",
"file",
"from",
"remote",
"selenoid",
"and",
"removing",
"the",
"file",
"in",
"the",
"server",
".",
"request",
":",
"http",
":",
"//",
"<username",
">",
":",
"<password",
">"
] | python | train |
oceanprotocol/aquarius | aquarius/app/assets.py | https://github.com/oceanprotocol/aquarius/blob/9fb094b1ac01f0604d0c854166dd324e476a010e/aquarius/app/assets.py#L631-L649 | def retire_all():
"""Retire metadata of all the assets.
---
tags:
- ddo
responses:
200:
description: successfully deleted
500:
description: Error
"""
try:
all_ids = [a['id'] for a in dao.get_all_assets()]
for i in all_ids:
dao.delete(... | [
"def",
"retire_all",
"(",
")",
":",
"try",
":",
"all_ids",
"=",
"[",
"a",
"[",
"'id'",
"]",
"for",
"a",
"in",
"dao",
".",
"get_all_assets",
"(",
")",
"]",
"for",
"i",
"in",
"all_ids",
":",
"dao",
".",
"delete",
"(",
"i",
")",
"return",
"'All ddo ... | Retire metadata of all the assets.
---
tags:
- ddo
responses:
200:
description: successfully deleted
500:
description: Error | [
"Retire",
"metadata",
"of",
"all",
"the",
"assets",
".",
"---",
"tags",
":",
"-",
"ddo",
"responses",
":",
"200",
":",
"description",
":",
"successfully",
"deleted",
"500",
":",
"description",
":",
"Error"
] | python | train |
saltstack/salt | salt/states/keystone.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/keystone.py#L98-L298 | def user_present(name,
password,
email,
tenant=None,
enabled=True,
roles=None,
profile=None,
password_reset=True,
project=None,
**connection_args):
'''
Ensure ... | [
"def",
"user_present",
"(",
"name",
",",
"password",
",",
"email",
",",
"tenant",
"=",
"None",
",",
"enabled",
"=",
"True",
",",
"roles",
"=",
"None",
",",
"profile",
"=",
"None",
",",
"password_reset",
"=",
"True",
",",
"project",
"=",
"None",
",",
... | Ensure that the keystone user is present with the specified properties.
name
The name of the user to manage
password
The password to use for this user.
.. note::
If the user already exists and a different password was set for
the user than the one specified he... | [
"Ensure",
"that",
"the",
"keystone",
"user",
"is",
"present",
"with",
"the",
"specified",
"properties",
"."
] | python | train |
anthill/koala | koala/reader.py | https://github.com/anthill/koala/blob/393089fe081380506e73235db18a32b4e078d222/koala/reader.py#L231-L244 | def read_rels(archive):
"""Read relationships for a workbook"""
xml_source = archive.read(ARC_WORKBOOK_RELS)
tree = fromstring(xml_source)
for element in safe_iterator(tree, '{%s}Relationship' % PKG_REL_NS):
rId = element.get('Id')
pth = element.get("Target")
typ = element.get('T... | [
"def",
"read_rels",
"(",
"archive",
")",
":",
"xml_source",
"=",
"archive",
".",
"read",
"(",
"ARC_WORKBOOK_RELS",
")",
"tree",
"=",
"fromstring",
"(",
"xml_source",
")",
"for",
"element",
"in",
"safe_iterator",
"(",
"tree",
",",
"'{%s}Relationship'",
"%",
"... | Read relationships for a workbook | [
"Read",
"relationships",
"for",
"a",
"workbook"
] | python | train |
bitprophet/ssh | ssh/file.py | https://github.com/bitprophet/ssh/blob/e8bdad4c82a50158a749233dca58c29e47c60b76/ssh/file.py#L391-L429 | def _set_mode(self, mode='r', bufsize=-1):
"""
Subclasses call this method to initialize the BufferedFile.
"""
# set bufsize in any event, because it's used for readline().
self._bufsize = self._DEFAULT_BUFSIZE
if bufsize < 0:
# do no buffering by default, bec... | [
"def",
"_set_mode",
"(",
"self",
",",
"mode",
"=",
"'r'",
",",
"bufsize",
"=",
"-",
"1",
")",
":",
"# set bufsize in any event, because it's used for readline().",
"self",
".",
"_bufsize",
"=",
"self",
".",
"_DEFAULT_BUFSIZE",
"if",
"bufsize",
"<",
"0",
":",
"... | Subclasses call this method to initialize the BufferedFile. | [
"Subclasses",
"call",
"this",
"method",
"to",
"initialize",
"the",
"BufferedFile",
"."
] | python | train |
zhelev/python-afsapi | afsapi/__init__.py | https://github.com/zhelev/python-afsapi/blob/bb1990cf1460ae42f2dde75f2291625ddac2c0e4/afsapi/__init__.py#L228-L232 | def set_power(self, value=False):
"""Power on or off the device."""
power = (yield from self.handle_set(
self.API.get('power'), int(value)))
return bool(power) | [
"def",
"set_power",
"(",
"self",
",",
"value",
"=",
"False",
")",
":",
"power",
"=",
"(",
"yield",
"from",
"self",
".",
"handle_set",
"(",
"self",
".",
"API",
".",
"get",
"(",
"'power'",
")",
",",
"int",
"(",
"value",
")",
")",
")",
"return",
"bo... | Power on or off the device. | [
"Power",
"on",
"or",
"off",
"the",
"device",
"."
] | python | valid |
mehmetg/streak_client | streak_client/streak_client.py | https://github.com/mehmetg/streak_client/blob/46575510b4e4163a4a3cc06f7283a1ae377cdce6/streak_client/streak_client.py#L561-L583 | def _create_field(self, uri , name, field_type, **kwargs):
'''Creates a field with the provided attributes.
Args:
uri base uri for the field (pipeline or box uri)
name required name string
field_type required type string [TEXT_INPUT, DATE or PERSON]
kwargs {}
return (status code, field dict)
'''
... | [
"def",
"_create_field",
"(",
"self",
",",
"uri",
",",
"name",
",",
"field_type",
",",
"*",
"*",
"kwargs",
")",
":",
"#req sanity check",
"if",
"not",
"(",
"name",
"and",
"(",
"field_type",
"in",
"[",
"'TEXT_INPUT'",
",",
"'DATE'",
",",
"'PERSON'",
"]",
... | Creates a field with the provided attributes.
Args:
uri base uri for the field (pipeline or box uri)
name required name string
field_type required type string [TEXT_INPUT, DATE or PERSON]
kwargs {}
return (status code, field dict) | [
"Creates",
"a",
"field",
"with",
"the",
"provided",
"attributes",
".",
"Args",
":",
"uri",
"base",
"uri",
"for",
"the",
"field",
"(",
"pipeline",
"or",
"box",
"uri",
")",
"name",
"required",
"name",
"string",
"field_type",
"required",
"type",
"string",
"["... | python | train |
AndrewAnnex/SpiceyPy | spiceypy/spiceypy.py | https://github.com/AndrewAnnex/SpiceyPy/blob/fc20a9b9de68b58eed5b332f0c051fb343a6e335/spiceypy/spiceypy.py#L9423-L9440 | def pcpool(name, cvals):
"""
This entry point provides toolkit programmers a method for
programmatically inserting character data into the
kernel pool.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pcpool_c.html
:param name: The kernel pool name to associate with cvals.
:type nam... | [
"def",
"pcpool",
"(",
"name",
",",
"cvals",
")",
":",
"name",
"=",
"stypes",
".",
"stringToCharP",
"(",
"name",
")",
"lenvals",
"=",
"ctypes",
".",
"c_int",
"(",
"len",
"(",
"max",
"(",
"cvals",
",",
"key",
"=",
"len",
")",
")",
"+",
"1",
")",
... | This entry point provides toolkit programmers a method for
programmatically inserting character data into the
kernel pool.
http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/pcpool_c.html
:param name: The kernel pool name to associate with cvals.
:type name: str
:param cvals: An array of ... | [
"This",
"entry",
"point",
"provides",
"toolkit",
"programmers",
"a",
"method",
"for",
"programmatically",
"inserting",
"character",
"data",
"into",
"the",
"kernel",
"pool",
"."
] | python | train |
hydraplatform/hydra-base | hydra_base/lib/data.py | https://github.com/hydraplatform/hydra-base/blob/9251ff7946505f7a272c87837390acd1c435bc6e/hydra_base/lib/data.py#L406-L462 | def update_dataset(dataset_id, name, data_type, val, unit_id, metadata={}, flush=True, **kwargs):
"""
Update an existing dataset
"""
if dataset_id is None:
raise HydraError("Dataset must have an ID to be updated.")
user_id = kwargs.get('user_id')
dataset = db.DBSession.query(Datas... | [
"def",
"update_dataset",
"(",
"dataset_id",
",",
"name",
",",
"data_type",
",",
"val",
",",
"unit_id",
",",
"metadata",
"=",
"{",
"}",
",",
"flush",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"dataset_id",
"is",
"None",
":",
"raise",
"Hydr... | Update an existing dataset | [
"Update",
"an",
"existing",
"dataset"
] | python | train |
refinery29/chassis | chassis/util/encoders.py | https://github.com/refinery29/chassis/blob/1238d5214cbb8f3e1fe7c0dc2fa72f45bf085192/chassis/util/encoders.py#L9-L18 | def default(self, obj): # pylint: disable=method-hidden
"""Use the default behavior unless the object to be encoded has a
`strftime` attribute."""
if hasattr(obj, 'strftime'):
return obj.strftime("%Y-%m-%dT%H:%M:%SZ")
elif hasattr(obj, 'get_public_dict'):
return... | [
"def",
"default",
"(",
"self",
",",
"obj",
")",
":",
"# pylint: disable=method-hidden",
"if",
"hasattr",
"(",
"obj",
",",
"'strftime'",
")",
":",
"return",
"obj",
".",
"strftime",
"(",
"\"%Y-%m-%dT%H:%M:%SZ\"",
")",
"elif",
"hasattr",
"(",
"obj",
",",
"'get_... | Use the default behavior unless the object to be encoded has a
`strftime` attribute. | [
"Use",
"the",
"default",
"behavior",
"unless",
"the",
"object",
"to",
"be",
"encoded",
"has",
"a",
"strftime",
"attribute",
"."
] | python | train |
hyperledger/indy-sdk | wrappers/python/indy/crypto.py | https://github.com/hyperledger/indy-sdk/blob/55240dc170308d7883c48f03f308130a6d077be6/wrappers/python/indy/crypto.py#L453-L501 | async def unpack_message(wallet_handle: int,
jwe: bytes) -> bytes:
"""
Unpacks a JWE-like formatted message outputted by pack_message (Experimental)
#Params
command_handle: command handle to map callback to user context.
wallet_handle: wallet handler (created by open_wallet... | [
"async",
"def",
"unpack_message",
"(",
"wallet_handle",
":",
"int",
",",
"jwe",
":",
"bytes",
")",
"->",
"bytes",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
")",
"logger",
".",
"debug",
"(",
"\"unpack_message: >>> wallet_handle: %r, jwe: %... | Unpacks a JWE-like formatted message outputted by pack_message (Experimental)
#Params
command_handle: command handle to map callback to user context.
wallet_handle: wallet handler (created by open_wallet)
message: the output of a pack message
#Returns -> See HIPE 0028 for details
(Authcrypt mo... | [
"Unpacks",
"a",
"JWE",
"-",
"like",
"formatted",
"message",
"outputted",
"by",
"pack_message",
"(",
"Experimental",
")"
] | python | train |
Jajcus/pyxmpp2 | pyxmpp2/ext/muc/muc.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/ext/muc/muc.py#L909-L921 | def forget(self,rs):
"""
Remove a room from the list of managed rooms.
:Parameters:
- `rs`: the state object of the room.
:Types:
- `rs`: `MucRoomState`
"""
try:
del self.rooms[rs.room_jid.bare().as_unicode()]
except KeyError:
... | [
"def",
"forget",
"(",
"self",
",",
"rs",
")",
":",
"try",
":",
"del",
"self",
".",
"rooms",
"[",
"rs",
".",
"room_jid",
".",
"bare",
"(",
")",
".",
"as_unicode",
"(",
")",
"]",
"except",
"KeyError",
":",
"pass"
] | Remove a room from the list of managed rooms.
:Parameters:
- `rs`: the state object of the room.
:Types:
- `rs`: `MucRoomState` | [
"Remove",
"a",
"room",
"from",
"the",
"list",
"of",
"managed",
"rooms",
"."
] | python | valid |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.