repo stringlengths 7 55 | path stringlengths 4 223 | url stringlengths 87 315 | code stringlengths 75 104k | code_tokens list | docstring stringlengths 1 46.9k | docstring_tokens list | language stringclasses 1
value | partition stringclasses 3
values | avg_line_len float64 7.91 980 |
|---|---|---|---|---|---|---|---|---|---|
qubole/qds-sdk-py | qds_sdk/qubole.py | https://github.com/qubole/qds-sdk-py/blob/77210fb64e5a7d567aedeea3b742a1d872fd0e5e/qds_sdk/qubole.py#L67-L93 | def agent(cls, version=None):
"""
Returns:
a connection object to make REST calls to QDS
optionally override the `version` of the REST endpoint for advanced
features available only in the newer version of the API available
for certain resource end points eg: ... | [
"def",
"agent",
"(",
"cls",
",",
"version",
"=",
"None",
")",
":",
"reuse_cached_agent",
"=",
"True",
"if",
"version",
":",
"log",
".",
"debug",
"(",
"\"api version changed to %s\"",
"%",
"version",
")",
"cls",
".",
"rest_url",
"=",
"'/'",
".",
"join",
"... | Returns:
a connection object to make REST calls to QDS
optionally override the `version` of the REST endpoint for advanced
features available only in the newer version of the API available
for certain resource end points eg: /v1.3/cluster. When version is
None we ... | [
"Returns",
":",
"a",
"connection",
"object",
"to",
"make",
"REST",
"calls",
"to",
"QDS"
] | python | train | 41.777778 |
jmgilman/Neolib | neolib/pyamf/amf3.py | https://github.com/jmgilman/Neolib/blob/228fafeaed0f3195676137732384a14820ae285c/neolib/pyamf/amf3.py#L1184-L1191 | def writeNumber(self, n):
"""
Writes a float to the stream.
@type n: C{float}
"""
self.stream.write(TYPE_NUMBER)
self.stream.write_double(n) | [
"def",
"writeNumber",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"stream",
".",
"write",
"(",
"TYPE_NUMBER",
")",
"self",
".",
"stream",
".",
"write_double",
"(",
"n",
")"
] | Writes a float to the stream.
@type n: C{float} | [
"Writes",
"a",
"float",
"to",
"the",
"stream",
"."
] | python | train | 22.75 |
GNS3/gns3-server | gns3server/web/web_server.py | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/web/web_server.py#L208-L297 | def run(self):
"""
Starts the server.
"""
server_logger = logging.getLogger('aiohttp.server')
# In debug mode we don't use the standard request log but a more complete in response.py
if log.getEffectiveLevel() == logging.DEBUG:
server_logger.setLevel(logging.... | [
"def",
"run",
"(",
"self",
")",
":",
"server_logger",
"=",
"logging",
".",
"getLogger",
"(",
"'aiohttp.server'",
")",
"# In debug mode we don't use the standard request log but a more complete in response.py",
"if",
"log",
".",
"getEffectiveLevel",
"(",
")",
"==",
"loggin... | Starts the server. | [
"Starts",
"the",
"server",
"."
] | python | train | 41.944444 |
stevearc/dql | dql/grammar/__init__.py | https://github.com/stevearc/dql/blob/e9d3aa22873076dae5ebd02e35318aa996b1e56a/dql/grammar/__init__.py#L60-L65 | def create_throttle():
""" Create a THROTTLE statement """
throttle_amount = "*" | Combine(number + "%") | number
return Group(
function("throttle", throttle_amount, throttle_amount, caseless=True)
).setResultsName("throttle") | [
"def",
"create_throttle",
"(",
")",
":",
"throttle_amount",
"=",
"\"*\"",
"|",
"Combine",
"(",
"number",
"+",
"\"%\"",
")",
"|",
"number",
"return",
"Group",
"(",
"function",
"(",
"\"throttle\"",
",",
"throttle_amount",
",",
"throttle_amount",
",",
"caseless",... | Create a THROTTLE statement | [
"Create",
"a",
"THROTTLE",
"statement"
] | python | train | 40.833333 |
zetaops/pyoko | pyoko/db/queryset.py | https://github.com/zetaops/pyoko/blob/236c509ad85640933ac0f89ad8f7ed95f62adf07/pyoko/db/queryset.py#L158-L176 | def _make_model(self, data, key=None):
"""
Creates a model instance with the given data.
Args:
data: Model data returned from DB.
key: Object key
Returns:
pyoko.Model object.
"""
if data['deleted'] and not self.adapter.want_deleted:
... | [
"def",
"_make_model",
"(",
"self",
",",
"data",
",",
"key",
"=",
"None",
")",
":",
"if",
"data",
"[",
"'deleted'",
"]",
"and",
"not",
"self",
".",
"adapter",
".",
"want_deleted",
":",
"raise",
"ObjectDoesNotExist",
"(",
"'Deleted object returned'",
")",
"m... | Creates a model instance with the given data.
Args:
data: Model data returned from DB.
key: Object key
Returns:
pyoko.Model object. | [
"Creates",
"a",
"model",
"instance",
"with",
"the",
"given",
"data",
"."
] | python | train | 37 |
raiden-network/raiden | raiden/api/python.py | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/api/python.py#L731-L755 | def transfer_and_wait(
self,
registry_address: PaymentNetworkID,
token_address: TokenAddress,
amount: TokenAmount,
target: Address,
identifier: PaymentID = None,
transfer_timeout: int = None,
secret: Secret = None,
... | [
"def",
"transfer_and_wait",
"(",
"self",
",",
"registry_address",
":",
"PaymentNetworkID",
",",
"token_address",
":",
"TokenAddress",
",",
"amount",
":",
"TokenAmount",
",",
"target",
":",
"Address",
",",
"identifier",
":",
"PaymentID",
"=",
"None",
",",
"transf... | Do a transfer with `target` with the given `amount` of `token_address`. | [
"Do",
"a",
"transfer",
"with",
"target",
"with",
"the",
"given",
"amount",
"of",
"token_address",
"."
] | python | train | 34.6 |
pantsbuild/pants | src/python/pants/util/memo.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/util/memo.py#L19-L24 | def equal_args(*args, **kwargs):
"""A memoized key factory that compares the equality (`==`) of a stable sort of the parameters."""
key = args
if kwargs:
key += _kwargs_separator + tuple(sorted(kwargs.items()))
return key | [
"def",
"equal_args",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"args",
"if",
"kwargs",
":",
"key",
"+=",
"_kwargs_separator",
"+",
"tuple",
"(",
"sorted",
"(",
"kwargs",
".",
"items",
"(",
")",
")",
")",
"return",
"key"
] | A memoized key factory that compares the equality (`==`) of a stable sort of the parameters. | [
"A",
"memoized",
"key",
"factory",
"that",
"compares",
"the",
"equality",
"(",
"==",
")",
"of",
"a",
"stable",
"sort",
"of",
"the",
"parameters",
"."
] | python | train | 38 |
molmod/molmod | molmod/transformations.py | https://github.com/molmod/molmod/blob/a7b5b4364ed514ad4c465856c05b5eda1cb561e0/molmod/transformations.py#L153-L161 | def _check_r(self, r):
"""the columns must orthogonal"""
if abs(np.dot(r[:, 0], r[:, 0]) - 1) > eps or \
abs(np.dot(r[:, 0], r[:, 0]) - 1) > eps or \
abs(np.dot(r[:, 0], r[:, 0]) - 1) > eps or \
np.dot(r[:, 0], r[:, 1]) > eps or \
np.dot(r[:, 1], r[:, 2]) ... | [
"def",
"_check_r",
"(",
"self",
",",
"r",
")",
":",
"if",
"abs",
"(",
"np",
".",
"dot",
"(",
"r",
"[",
":",
",",
"0",
"]",
",",
"r",
"[",
":",
",",
"0",
"]",
")",
"-",
"1",
")",
">",
"eps",
"or",
"abs",
"(",
"np",
".",
"dot",
"(",
"r"... | the columns must orthogonal | [
"the",
"columns",
"must",
"orthogonal"
] | python | train | 50.222222 |
bcbio/bcbio-nextgen | bcbio/workflow/template.py | https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/workflow/template.py#L341-L363 | def _handle_special_yaml_cases(v):
"""Handle values that pass integer, boolean, list or dictionary values.
"""
if "::" in v:
out = {}
for part in v.split("::"):
k_part, v_part = part.split(":")
out[k_part] = v_part.split(";")
v = out
elif ";" in v:
... | [
"def",
"_handle_special_yaml_cases",
"(",
"v",
")",
":",
"if",
"\"::\"",
"in",
"v",
":",
"out",
"=",
"{",
"}",
"for",
"part",
"in",
"v",
".",
"split",
"(",
"\"::\"",
")",
":",
"k_part",
",",
"v_part",
"=",
"part",
".",
"split",
"(",
"\":\"",
")",
... | Handle values that pass integer, boolean, list or dictionary values. | [
"Handle",
"values",
"that",
"pass",
"integer",
"boolean",
"list",
"or",
"dictionary",
"values",
"."
] | python | train | 28.521739 |
wroberts/pygermanet | pygermanet/mongo_import.py | https://github.com/wroberts/pygermanet/blob/1818c20a7e8c431c4cfb5a570ed0d850bb6dd515/pygermanet/mongo_import.py#L632-L669 | def main():
'''Main function.'''
usage = ('\n\n %prog [options] XML_PATH\n\nArguments:\n\n '
'XML_PATH the directory containing the '
'GermaNet .xml files')
parser = optparse.OptionParser(usage=usage)
parser.add_option('--host', default=None,
... | [
"def",
"main",
"(",
")",
":",
"usage",
"=",
"(",
"'\\n\\n %prog [options] XML_PATH\\n\\nArguments:\\n\\n '",
"'XML_PATH the directory containing the '",
"'GermaNet .xml files'",
")",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
"usage",
"=",
"usage",
... | Main function. | [
"Main",
"function",
"."
] | python | train | 41.921053 |
apache/spark | python/pyspark/mllib/clustering.py | https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/mllib/clustering.py#L752-L777 | def update(self, data, decayFactor, timeUnit):
"""Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If poi... | [
"def",
"update",
"(",
"self",
",",
"data",
",",
"decayFactor",
",",
"timeUnit",
")",
":",
"if",
"not",
"isinstance",
"(",
"data",
",",
"RDD",
")",
":",
"raise",
"TypeError",
"(",
"\"Data should be of an RDD, got %s.\"",
"%",
"type",
"(",
"data",
")",
")",
... | Update the centroids, according to data
:param data:
RDD with new data for the model update.
:param decayFactor:
Forgetfulness of the previous centroids.
:param timeUnit:
Can be "batches" or "points". If points, then the decay factor
is raised to the powe... | [
"Update",
"the",
"centroids",
"according",
"to",
"data"
] | python | train | 45.076923 |
cloudify-cosmo/wagon | wagon.py | https://github.com/cloudify-cosmo/wagon/blob/9876d33a0aece01df2421a87e3b398d13f660fe6/wagon.py#L247-L282 | def install_package(package,
wheels_path,
venv=None,
requirement_files=None,
upgrade=False,
install_args=None):
"""Install a Python package.
Can specify a specific version.
Can specify a prerelease.
Can ... | [
"def",
"install_package",
"(",
"package",
",",
"wheels_path",
",",
"venv",
"=",
"None",
",",
"requirement_files",
"=",
"None",
",",
"upgrade",
"=",
"False",
",",
"install_args",
"=",
"None",
")",
":",
"requirement_files",
"=",
"requirement_files",
"or",
"[",
... | Install a Python package.
Can specify a specific version.
Can specify a prerelease.
Can specify a venv to install in.
Can specify a list of paths or urls to requirement txt files.
Can specify a local wheels_path to use for offline installation.
Can request an upgrade. | [
"Install",
"a",
"Python",
"package",
"."
] | python | train | 31.361111 |
sdispater/pendulum | pendulum/date.py | https://github.com/sdispater/pendulum/blob/94d28b0d3cb524ae02361bd1ed7ea03e2e655e4e/pendulum/date.py#L59-L67 | def day_of_year(self):
"""
Returns the day of the year (1-366).
:rtype: int
"""
k = 1 if self.is_leap_year() else 2
return (275 * self.month) // 9 - k * ((self.month + 9) // 12) + self.day - 30 | [
"def",
"day_of_year",
"(",
"self",
")",
":",
"k",
"=",
"1",
"if",
"self",
".",
"is_leap_year",
"(",
")",
"else",
"2",
"return",
"(",
"275",
"*",
"self",
".",
"month",
")",
"//",
"9",
"-",
"k",
"*",
"(",
"(",
"self",
".",
"month",
"+",
"9",
")... | Returns the day of the year (1-366).
:rtype: int | [
"Returns",
"the",
"day",
"of",
"the",
"year",
"(",
"1",
"-",
"366",
")",
"."
] | python | train | 26.111111 |
hzdg/django-ecstatic | ecstatic/storage.py | https://github.com/hzdg/django-ecstatic/blob/e2b9bd57ae19938449315457b31130c8df831911/ecstatic/storage.py#L89-L99 | def post_process(self, paths, dry_run=False, **options):
"""
Overridden to allow some files to be excluded (using
``postprocess_exclusions``)
"""
if self.postprocess_exclusions:
paths = dict((k, v) for k, v in paths.items() if not
self.exclude_fil... | [
"def",
"post_process",
"(",
"self",
",",
"paths",
",",
"dry_run",
"=",
"False",
",",
"*",
"*",
"options",
")",
":",
"if",
"self",
".",
"postprocess_exclusions",
":",
"paths",
"=",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
... | Overridden to allow some files to be excluded (using
``postprocess_exclusions``) | [
"Overridden",
"to",
"allow",
"some",
"files",
"to",
"be",
"excluded",
"(",
"using",
"postprocess_exclusions",
")"
] | python | train | 37.818182 |
cslarsen/elv | elv/elv.py | https://github.com/cslarsen/elv/blob/4bacf2093a0dcbe6a2b4d79be0fe339bb2b99097/elv/elv.py#L379-L391 | def balance(self):
"""Returns a tuple of (total amount deposited, total amount
withdrawn)."""
sin = Decimal("0.00")
sout = Decimal("0.00")
for t in self.trans:
if t.amount < Decimal("0.00"):
sout += t.amount
else:
sin += t.... | [
"def",
"balance",
"(",
"self",
")",
":",
"sin",
"=",
"Decimal",
"(",
"\"0.00\"",
")",
"sout",
"=",
"Decimal",
"(",
"\"0.00\"",
")",
"for",
"t",
"in",
"self",
".",
"trans",
":",
"if",
"t",
".",
"amount",
"<",
"Decimal",
"(",
"\"0.00\"",
")",
":",
... | Returns a tuple of (total amount deposited, total amount
withdrawn). | [
"Returns",
"a",
"tuple",
"of",
"(",
"total",
"amount",
"deposited",
"total",
"amount",
"withdrawn",
")",
"."
] | python | train | 26.153846 |
eqcorrscan/EQcorrscan | eqcorrscan/core/subspace.py | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/core/subspace.py#L322-L378 | def write(self, filename):
"""
Write detector to a file - uses HDF5 file format.
Meta-data are stored alongside numpy data arrays. See h5py.org for \
details of the methods.
:type filename: str
:param filename: Filename to save the detector to.
"""
f = h... | [
"def",
"write",
"(",
"self",
",",
"filename",
")",
":",
"f",
"=",
"h5py",
".",
"File",
"(",
"filename",
",",
"\"w\"",
")",
"# Must store eqcorrscan version number, username would be useful too.",
"data_group",
"=",
"f",
".",
"create_group",
"(",
"name",
"=",
"\"... | Write detector to a file - uses HDF5 file format.
Meta-data are stored alongside numpy data arrays. See h5py.org for \
details of the methods.
:type filename: str
:param filename: Filename to save the detector to. | [
"Write",
"detector",
"to",
"a",
"file",
"-",
"uses",
"HDF5",
"file",
"format",
"."
] | python | train | 46.912281 |
chaoss/grimoirelab-sortinghat | sortinghat/cmd/unify.py | https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/cmd/unify.py#L166-L184 | def __unify_unique_identities(self, uidentities, matcher,
fast_matching, interactive):
"""Unify unique identities looking for similar identities."""
self.total = len(uidentities)
self.matched = 0
if self.recovery and self.recovery_file.exists():
... | [
"def",
"__unify_unique_identities",
"(",
"self",
",",
"uidentities",
",",
"matcher",
",",
"fast_matching",
",",
"interactive",
")",
":",
"self",
".",
"total",
"=",
"len",
"(",
"uidentities",
")",
"self",
".",
"matched",
"=",
"0",
"if",
"self",
".",
"recove... | Unify unique identities looking for similar identities. | [
"Unify",
"unique",
"identities",
"looking",
"for",
"similar",
"identities",
"."
] | python | train | 41.736842 |
knipknap/SpiffWorkflow | SpiffWorkflow/task.py | https://github.com/knipknap/SpiffWorkflow/blob/f0af7f59a332e0619e4f3c00a7d4a3d230760e00/SpiffWorkflow/task.py#L405-L419 | def _is_descendant_of(self, parent):
"""
Returns True if parent is in the list of ancestors, returns False
otherwise.
:type parent: Task
:param parent: The parent that is searched in the ancestors.
:rtype: bool
:returns: Whether the parent was found.
""... | [
"def",
"_is_descendant_of",
"(",
"self",
",",
"parent",
")",
":",
"if",
"self",
".",
"parent",
"is",
"None",
":",
"return",
"False",
"if",
"self",
".",
"parent",
"==",
"parent",
":",
"return",
"True",
"return",
"self",
".",
"parent",
".",
"_is_descendant... | Returns True if parent is in the list of ancestors, returns False
otherwise.
:type parent: Task
:param parent: The parent that is searched in the ancestors.
:rtype: bool
:returns: Whether the parent was found. | [
"Returns",
"True",
"if",
"parent",
"is",
"in",
"the",
"list",
"of",
"ancestors",
"returns",
"False",
"otherwise",
"."
] | python | valid | 31.666667 |
erikrose/nose-progressive | noseprogressive/result.py | https://github.com/erikrose/nose-progressive/blob/42853f11290cfaac8aa3d204714b71e27cc4ec07/noseprogressive/result.py#L93-L108 | def _printHeadline(self, kind, test, is_failure=True):
"""Output a 1-line error summary to the stream if appropriate.
The line contains the kind of error and the pathname of the test.
:arg kind: The (string) type of incident the precipitated this call
:arg test: The test that precipita... | [
"def",
"_printHeadline",
"(",
"self",
",",
"kind",
",",
"test",
",",
"is_failure",
"=",
"True",
")",
":",
"if",
"is_failure",
"or",
"self",
".",
"_options",
".",
"show_advisories",
":",
"with",
"self",
".",
"bar",
".",
"dodging",
"(",
")",
":",
"self",... | Output a 1-line error summary to the stream if appropriate.
The line contains the kind of error and the pathname of the test.
:arg kind: The (string) type of incident the precipitated this call
:arg test: The test that precipitated this call | [
"Output",
"a",
"1",
"-",
"line",
"error",
"summary",
"to",
"the",
"stream",
"if",
"appropriate",
"."
] | python | train | 43.125 |
explosion/spaCy | spacy/lang/ja/__init__.py | https://github.com/explosion/spaCy/blob/8ee4100f8ffb336886208a1ea827bf4c745e2709/spacy/lang/ja/__init__.py#L52-L68 | def detailed_tokens(tokenizer, text):
"""Format Mecab output into a nice data structure, based on Janome."""
node = tokenizer.parseToNode(text)
node = node.next # first node is beginning of sentence and empty, skip it
words = []
while node.posid != 0:
surface = node.surface
base = s... | [
"def",
"detailed_tokens",
"(",
"tokenizer",
",",
"text",
")",
":",
"node",
"=",
"tokenizer",
".",
"parseToNode",
"(",
"text",
")",
"node",
"=",
"node",
".",
"next",
"# first node is beginning of sentence and empty, skip it",
"words",
"=",
"[",
"]",
"while",
"nod... | Format Mecab output into a nice data structure, based on Janome. | [
"Format",
"Mecab",
"output",
"into",
"a",
"nice",
"data",
"structure",
"based",
"on",
"Janome",
"."
] | python | train | 40.411765 |
sleibman/python-conduit | conduit/core.py | https://github.com/sleibman/python-conduit/blob/f6002d45c4f25e4418591a72fdac9ac6fb422d80/conduit/core.py#L560-L584 | def block_code(self):
inputs = self._get_all_input_values()
outputs = {}
"""
self.f = self.user_function(**inputs)
try:
outputs = self.f.send(inputs)
except StopIteration:
self.terminate()
"""
if self.first_time:
self.f ... | [
"def",
"block_code",
"(",
"self",
")",
":",
"inputs",
"=",
"self",
".",
"_get_all_input_values",
"(",
")",
"outputs",
"=",
"{",
"}",
"if",
"self",
".",
"first_time",
":",
"self",
".",
"f",
"=",
"self",
".",
"user_function",
"(",
"*",
"*",
"inputs",
"... | self.f = self.user_function(**inputs)
try:
outputs = self.f.send(inputs)
except StopIteration:
self.terminate() | [
"self",
".",
"f",
"=",
"self",
".",
"user_function",
"(",
"**",
"inputs",
")",
"try",
":",
"outputs",
"=",
"self",
".",
"f",
".",
"send",
"(",
"inputs",
")",
"except",
"StopIteration",
":",
"self",
".",
"terminate",
"()"
] | python | train | 32.96 |
CitrineInformatics/pif-dft | dfttopif/parsers/abinit.py | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/abinit.py#L30-L70 | def _get_label(self):
'''Find the label for the output files
for this calculation
'''
if self._label is None:
foundfiles = False
for f in self._files:
if ".files" in f:
foundfiles = True
self._label = f.sp... | [
"def",
"_get_label",
"(",
"self",
")",
":",
"if",
"self",
".",
"_label",
"is",
"None",
":",
"foundfiles",
"=",
"False",
"for",
"f",
"in",
"self",
".",
"_files",
":",
"if",
"\".files\"",
"in",
"f",
":",
"foundfiles",
"=",
"True",
"self",
".",
"_label"... | Find the label for the output files
for this calculation | [
"Find",
"the",
"label",
"for",
"the",
"output",
"files",
"for",
"this",
"calculation"
] | python | train | 41.121951 |
saltstack/salt | salt/cloud/clouds/ec2.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/ec2.py#L3730-L3764 | def show_term_protect(name=None, instance_id=None, call=None, quiet=False):
'''
Show the details from EC2 concerning an instance's termination protection state
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_term_protect action must be called with -a or --action.'
... | [
"def",
"show_term_protect",
"(",
"name",
"=",
"None",
",",
"instance_id",
"=",
"None",
",",
"call",
"=",
"None",
",",
"quiet",
"=",
"False",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The show_term_protect action must... | Show the details from EC2 concerning an instance's termination protection state | [
"Show",
"the",
"details",
"from",
"EC2",
"concerning",
"an",
"instance",
"s",
"termination",
"protection",
"state"
] | python | train | 31.971429 |
tfeldmann/python-raumfeld | raumfeld/__init__.py | https://github.com/tfeldmann/python-raumfeld/blob/801c7c96b49ced982e1acb1743844db037ec09a4/raumfeld/__init__.py#L21-L65 | def discover(timeout=1, retries=1):
"""Discover Raumfeld devices in the network
:param timeout: The timeout in seconds
:param retries: How often the search should be retried
:returns: A list of raumfeld devices, sorted by name
"""
locations = []
group = ('239.255.255.250', 1900)
... | [
"def",
"discover",
"(",
"timeout",
"=",
"1",
",",
"retries",
"=",
"1",
")",
":",
"locations",
"=",
"[",
"]",
"group",
"=",
"(",
"'239.255.255.250'",
",",
"1900",
")",
"service",
"=",
"'ssdp:urn:schemas-upnp-org:device:MediaRenderer:1'",
"# 'ssdp:all'",
"message"... | Discover Raumfeld devices in the network
:param timeout: The timeout in seconds
:param retries: How often the search should be retried
:returns: A list of raumfeld devices, sorted by name | [
"Discover",
"Raumfeld",
"devices",
"in",
"the",
"network"
] | python | train | 40.488889 |
OCR-D/core | ocrd_utils/ocrd_utils/__init__.py | https://github.com/OCR-D/core/blob/57e68c578526cb955fd2e368207f5386c459d91d/ocrd_utils/ocrd_utils/__init__.py#L146-L152 | def unzip_file_to_dir(path_to_zip, output_directory):
"""
Extract a ZIP archive to a directory
"""
z = ZipFile(path_to_zip, 'r')
z.extractall(output_directory)
z.close() | [
"def",
"unzip_file_to_dir",
"(",
"path_to_zip",
",",
"output_directory",
")",
":",
"z",
"=",
"ZipFile",
"(",
"path_to_zip",
",",
"'r'",
")",
"z",
".",
"extractall",
"(",
"output_directory",
")",
"z",
".",
"close",
"(",
")"
] | Extract a ZIP archive to a directory | [
"Extract",
"a",
"ZIP",
"archive",
"to",
"a",
"directory"
] | python | train | 26.714286 |
RiotGames/cloud-inquisitor | plugins/public/cinq-auditor-iam/cinq_auditor_iam/__init__.py | https://github.com/RiotGames/cloud-inquisitor/blob/181dc2566ca59fc855f695b7fcc2c3b934e6ee9f/plugins/public/cinq-auditor-iam/cinq_auditor_iam/__init__.py#L368-L394 | def get_roles(client):
"""Returns a list of all the roles for an account. Returns a list containing all the roles for the account.
Args:
client (:obj:`boto3.session.Session`): A boto3 Session object
Returns:
:obj:`list` of `dict`
"""
done = False
... | [
"def",
"get_roles",
"(",
"client",
")",
":",
"done",
"=",
"False",
"marker",
"=",
"None",
"roles",
"=",
"[",
"]",
"while",
"not",
"done",
":",
"if",
"marker",
":",
"response",
"=",
"client",
".",
"list_roles",
"(",
"Marker",
"=",
"marker",
")",
"else... | Returns a list of all the roles for an account. Returns a list containing all the roles for the account.
Args:
client (:obj:`boto3.session.Session`): A boto3 Session object
Returns:
:obj:`list` of `dict` | [
"Returns",
"a",
"list",
"of",
"all",
"the",
"roles",
"for",
"an",
"account",
".",
"Returns",
"a",
"list",
"containing",
"all",
"the",
"roles",
"for",
"the",
"account",
"."
] | python | train | 25.666667 |
Accelize/pycosio | pycosio/storage/azure.py | https://github.com/Accelize/pycosio/blob/1cc1f8fdf5394d92918b7bae2bfa682169ccc48c/pycosio/storage/azure.py#L235-L261 | def _read_range(self, start, end=0):
"""
Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read
"""
stream ... | [
"def",
"_read_range",
"(",
"self",
",",
"start",
",",
"end",
"=",
"0",
")",
":",
"stream",
"=",
"_BytesIO",
"(",
")",
"try",
":",
"with",
"_handle_azure_exception",
"(",
")",
":",
"self",
".",
"_get_to_stream",
"(",
"stream",
"=",
"stream",
",",
"start... | Read a range of bytes in stream.
Args:
start (int): Start stream position.
end (int): End stream position.
0 To not specify end.
Returns:
bytes: number of bytes read | [
"Read",
"a",
"range",
"of",
"bytes",
"in",
"stream",
"."
] | python | train | 28.259259 |
onecodex/onecodex | onecodex/models/helpers.py | https://github.com/onecodex/onecodex/blob/326a0a1af140e3a57ccf31c3c9c5e17a5775c13d/onecodex/models/helpers.py#L93-L159 | def download(self, path=None, file_obj=None, progressbar=False):
"""Downloads files from One Codex.
Parameters
----------
path : `string`, optional
Full path to save the file to. If omitted, defaults to the original filename
in the current working directory.
... | [
"def",
"download",
"(",
"self",
",",
"path",
"=",
"None",
",",
"file_obj",
"=",
"None",
",",
"progressbar",
"=",
"False",
")",
":",
"if",
"path",
"and",
"file_obj",
":",
"raise",
"OneCodexException",
"(",
"\"Please specify only one of: path, file_obj\"",
")",
... | Downloads files from One Codex.
Parameters
----------
path : `string`, optional
Full path to save the file to. If omitted, defaults to the original filename
in the current working directory.
file_obj : file-like object, optional
Rather than save the f... | [
"Downloads",
"files",
"from",
"One",
"Codex",
"."
] | python | train | 42.253731 |
helixyte/everest | everest/representers/base.py | https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L278-L289 | def configure(self, options=None, attribute_options=None): # pylint: disable=W0221
"""
Configures the options and attribute options of the mapping associated
with this representer with the given dictionaries.
:param dict options: configuration options for the mapping associated
... | [
"def",
"configure",
"(",
"self",
",",
"options",
"=",
"None",
",",
"attribute_options",
"=",
"None",
")",
":",
"# pylint: disable=W0221",
"self",
".",
"_mapping",
".",
"update",
"(",
"options",
"=",
"options",
",",
"attribute_options",
"=",
"attribute_options",
... | Configures the options and attribute options of the mapping associated
with this representer with the given dictionaries.
:param dict options: configuration options for the mapping associated
with this representer.
:param dict attribute_options: attribute options for the mapping
... | [
"Configures",
"the",
"options",
"and",
"attribute",
"options",
"of",
"the",
"mapping",
"associated",
"with",
"this",
"representer",
"with",
"the",
"given",
"dictionaries",
"."
] | python | train | 47.833333 |
pypa/setuptools | pkg_resources/_vendor/pyparsing.py | https://github.com/pypa/setuptools/blob/83c667e0b2a98193851c07115d1af65011ed0fb6/pkg_resources/_vendor/pyparsing.py#L1658-L1727 | def scanString( self, instring, maxMatches=_MAX_INT, overlap=False ):
"""
Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
C{maxMatches} argument, to clip scanning after 'n' match... | [
"def",
"scanString",
"(",
"self",
",",
"instring",
",",
"maxMatches",
"=",
"_MAX_INT",
",",
"overlap",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"streamlined",
":",
"self",
".",
"streamline",
"(",
")",
"for",
"e",
"in",
"self",
".",
"ignoreExpr... | Scan the input string for expression matches. Each match will return the
matching tokens, start location, and end location. May be called with optional
C{maxMatches} argument, to clip scanning after 'n' matches are found. If
C{overlap} is specified, then overlapping matches will be reporte... | [
"Scan",
"the",
"input",
"string",
"for",
"expression",
"matches",
".",
"Each",
"match",
"will",
"return",
"the",
"matching",
"tokens",
"start",
"location",
"and",
"end",
"location",
".",
"May",
"be",
"called",
"with",
"optional",
"C",
"{",
"maxMatches",
"}",... | python | train | 39.185714 |
shaldengeki/python-mal | myanimelist/user.py | https://github.com/shaldengeki/python-mal/blob/2c3356411a74d88ba13f6b970388040d696f8392/myanimelist/user.py#L506-L533 | def parse_clubs(self, clubs_page):
"""Parses the DOM and returns user clubs attributes.
:type clubs_page: :class:`bs4.BeautifulSoup`
:param clubs_page: MAL user clubs page's DOM
:rtype: dict
:return: User clubs attributes.
"""
user_info = self.parse_sidebar(clubs_page)
second_col = cl... | [
"def",
"parse_clubs",
"(",
"self",
",",
"clubs_page",
")",
":",
"user_info",
"=",
"self",
".",
"parse_sidebar",
"(",
"clubs_page",
")",
"second_col",
"=",
"clubs_page",
".",
"find",
"(",
"u'div'",
",",
"{",
"u'id'",
":",
"u'content'",
"}",
")",
".",
"fin... | Parses the DOM and returns user clubs attributes.
:type clubs_page: :class:`bs4.BeautifulSoup`
:param clubs_page: MAL user clubs page's DOM
:rtype: dict
:return: User clubs attributes. | [
"Parses",
"the",
"DOM",
"and",
"returns",
"user",
"clubs",
"attributes",
"."
] | python | train | 32.857143 |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L104-L107 | def visitExactRange(self, ctx: ShExDocParser.ExactRangeContext):
""" repeatRange: '{' INTEGER '}' #exactRange """
self.expression.min = int(ctx.INTEGER().getText())
self.expression.max = self.expression.min | [
"def",
"visitExactRange",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ExactRangeContext",
")",
":",
"self",
".",
"expression",
".",
"min",
"=",
"int",
"(",
"ctx",
".",
"INTEGER",
"(",
")",
".",
"getText",
"(",
")",
")",
"self",
".",
"expressio... | repeatRange: '{' INTEGER '}' #exactRange | [
"repeatRange",
":",
"{",
"INTEGER",
"}",
"#exactRange"
] | python | train | 56.75 |
docker/docker-py | docker/api/client.py | https://github.com/docker/docker-py/blob/613d6aad83acc9931ff2ecfd6a6c7bd8061dc125/docker/api/client.py#L417-L443 | def _disable_socket_timeout(self, socket):
""" Depending on the combination of python version and whether we're
connecting over http or https, we might need to access _sock, which
may or may not exist; or we may need to just settimeout on socket
itself, which also may or may not have set... | [
"def",
"_disable_socket_timeout",
"(",
"self",
",",
"socket",
")",
":",
"sockets",
"=",
"[",
"socket",
",",
"getattr",
"(",
"socket",
",",
"'_sock'",
",",
"None",
")",
"]",
"for",
"s",
"in",
"sockets",
":",
"if",
"not",
"hasattr",
"(",
"s",
",",
"'se... | Depending on the combination of python version and whether we're
connecting over http or https, we might need to access _sock, which
may or may not exist; or we may need to just settimeout on socket
itself, which also may or may not have settimeout on it. To avoid
missing the correct one... | [
"Depending",
"on",
"the",
"combination",
"of",
"python",
"version",
"and",
"whether",
"we",
"re",
"connecting",
"over",
"http",
"or",
"https",
"we",
"might",
"need",
"to",
"access",
"_sock",
"which",
"may",
"or",
"may",
"not",
"exist",
";",
"or",
"we",
"... | python | train | 37.481481 |
pantsbuild/pants | src/python/pants/backend/jvm/tasks/classpath_products.py | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/jvm/tasks/classpath_products.py#L354-L368 | def _validate_classpath_tuples(self, classpath, target):
"""Validates that all files are located within the working directory, to simplify relativization.
:param classpath: The list of classpath tuples. Each tuple is a 2-tuple of ivy_conf and
ClasspathEntry.
:param target: The target ... | [
"def",
"_validate_classpath_tuples",
"(",
"self",
",",
"classpath",
",",
"target",
")",
":",
"for",
"classpath_tuple",
"in",
"classpath",
":",
"conf",
",",
"classpath_entry",
"=",
"classpath_tuple",
"path",
"=",
"classpath_entry",
".",
"path",
"if",
"os",
".",
... | Validates that all files are located within the working directory, to simplify relativization.
:param classpath: The list of classpath tuples. Each tuple is a 2-tuple of ivy_conf and
ClasspathEntry.
:param target: The target that the classpath tuple is being registered for.
:raises: `... | [
"Validates",
"that",
"all",
"files",
"are",
"located",
"within",
"the",
"working",
"directory",
"to",
"simplify",
"relativization",
"."
] | python | train | 53.933333 |
CI-WATER/gsshapy | gsshapy/modeling/model.py | https://github.com/CI-WATER/gsshapy/blob/00fd4af0fd65f1614d75a52fe950a04fb0867f4c/gsshapy/modeling/model.py#L213-L222 | def set_elevation(self, elevation_grid_path, mask_shapefile):
"""
Adds elevation file to project
"""
# ADD ELEVATION FILE
ele_file = ElevationGridFile(project_file=self.project_manager,
session=self.db_session)
ele_file.generateFromRas... | [
"def",
"set_elevation",
"(",
"self",
",",
"elevation_grid_path",
",",
"mask_shapefile",
")",
":",
"# ADD ELEVATION FILE",
"ele_file",
"=",
"ElevationGridFile",
"(",
"project_file",
"=",
"self",
".",
"project_manager",
",",
"session",
"=",
"self",
".",
"db_session",
... | Adds elevation file to project | [
"Adds",
"elevation",
"file",
"to",
"project"
] | python | train | 46.6 |
nerdvegas/rez | src/rez/developer_package.py | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rez/developer_package.py#L159-L237 | def _get_preprocessed(self, data):
"""
Returns:
(DeveloperPackage, new_data) 2-tuple IFF the preprocess function
changed the package; otherwise None.
"""
from rez.serialise import process_python_objects
from rez.utils.data_utils import get_dict_diff_str
... | [
"def",
"_get_preprocessed",
"(",
"self",
",",
"data",
")",
":",
"from",
"rez",
".",
"serialise",
"import",
"process_python_objects",
"from",
"rez",
".",
"utils",
".",
"data_utils",
"import",
"get_dict_diff_str",
"from",
"copy",
"import",
"deepcopy",
"with",
"add... | Returns:
(DeveloperPackage, new_data) 2-tuple IFF the preprocess function
changed the package; otherwise None. | [
"Returns",
":",
"(",
"DeveloperPackage",
"new_data",
")",
"2",
"-",
"tuple",
"IFF",
"the",
"preprocess",
"function",
"changed",
"the",
"package",
";",
"otherwise",
"None",
"."
] | python | train | 36.696203 |
cackharot/suds-py3 | suds/sax/element.py | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/sax/element.py#L649-L664 | def refitPrefixes(self):
"""
Refit namespace qualification by replacing prefixes
with explicit namespaces. Also purges prefix mapping table.
@return: self
@rtype: L{Element}
"""
for c in self.children:
c.refitPrefixes()
if self.prefix is not No... | [
"def",
"refitPrefixes",
"(",
"self",
")",
":",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c",
".",
"refitPrefixes",
"(",
")",
"if",
"self",
".",
"prefix",
"is",
"not",
"None",
":",
"ns",
"=",
"self",
".",
"resolvePrefix",
"(",
"self",
".",
"p... | Refit namespace qualification by replacing prefixes
with explicit namespaces. Also purges prefix mapping table.
@return: self
@rtype: L{Element} | [
"Refit",
"namespace",
"qualification",
"by",
"replacing",
"prefixes",
"with",
"explicit",
"namespaces",
".",
"Also",
"purges",
"prefix",
"mapping",
"table",
"."
] | python | train | 31.375 |
refenv/cijoe | deprecated/modules/cij/spdk.py | https://github.com/refenv/cijoe/blob/21d7b2ed4ff68e0a1457e7df2db27f6334f1a379/deprecated/modules/cij/spdk.py#L76-L81 | def is_closed_chunk(self, chk):
"""Check the chunk is free or not"""
cs = self.get_chunk_status(chk)
if cs & 0x2 != 0:
return True
return False | [
"def",
"is_closed_chunk",
"(",
"self",
",",
"chk",
")",
":",
"cs",
"=",
"self",
".",
"get_chunk_status",
"(",
"chk",
")",
"if",
"cs",
"&",
"0x2",
"!=",
"0",
":",
"return",
"True",
"return",
"False"
] | Check the chunk is free or not | [
"Check",
"the",
"chunk",
"is",
"free",
"or",
"not"
] | python | valid | 31.166667 |
spyder-ide/spyder | spyder/plugins/variableexplorer/widgets/dataframeeditor.py | https://github.com/spyder-ide/spyder/blob/f76836ce1b924bcc4efd3f74f2960d26a4e528e0/spyder/plugins/variableexplorer/widgets/dataframeeditor.py#L1209-L1214 | def resizeColumnsToContents(self):
"""Resize the columns to its contents."""
self._autosized_cols = set()
self._resizeColumnsToContents(self.table_level,
self.table_index, self._max_autosize_ms)
self._update_layout() | [
"def",
"resizeColumnsToContents",
"(",
"self",
")",
":",
"self",
".",
"_autosized_cols",
"=",
"set",
"(",
")",
"self",
".",
"_resizeColumnsToContents",
"(",
"self",
".",
"table_level",
",",
"self",
".",
"table_index",
",",
"self",
".",
"_max_autosize_ms",
")",... | Resize the columns to its contents. | [
"Resize",
"the",
"columns",
"to",
"its",
"contents",
"."
] | python | train | 47.666667 |
sorgerlab/indra | indra/literature/elsevier_client.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/literature/elsevier_client.py#L210-L233 | def get_article(doi, output_format='txt'):
"""Get the full body of an article from Elsevier.
Parameters
----------
doi : str
The doi for the desired article.
output_format : 'txt' or 'xml'
The desired format for the output. Selecting 'txt' (default) strips all
xml tags and j... | [
"def",
"get_article",
"(",
"doi",
",",
"output_format",
"=",
"'txt'",
")",
":",
"xml_string",
"=",
"download_article",
"(",
"doi",
")",
"if",
"output_format",
"==",
"'txt'",
"and",
"xml_string",
"is",
"not",
"None",
":",
"text",
"=",
"extract_text",
"(",
"... | Get the full body of an article from Elsevier.
Parameters
----------
doi : str
The doi for the desired article.
output_format : 'txt' or 'xml'
The desired format for the output. Selecting 'txt' (default) strips all
xml tags and joins the pieces of text in the main text, while 'x... | [
"Get",
"the",
"full",
"body",
"of",
"an",
"article",
"from",
"Elsevier",
"."
] | python | train | 35.25 |
pymupdf/PyMuPDF | fitz/fitz.py | https://github.com/pymupdf/PyMuPDF/blob/917f2d83482510e26ba0ff01fd2392c26f3a8e90/fitz/fitz.py#L2373-L2378 | def _setMetadata(self, text):
"""_setMetadata(self, text) -> PyObject *"""
if self.isClosed or self.isEncrypted:
raise ValueError("operation illegal for closed / encrypted doc")
return _fitz.Document__setMetadata(self, text) | [
"def",
"_setMetadata",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"isClosed",
"or",
"self",
".",
"isEncrypted",
":",
"raise",
"ValueError",
"(",
"\"operation illegal for closed / encrypted doc\"",
")",
"return",
"_fitz",
".",
"Document__setMetadata",
"... | _setMetadata(self, text) -> PyObject * | [
"_setMetadata",
"(",
"self",
"text",
")",
"-",
">",
"PyObject",
"*"
] | python | train | 42.666667 |
sorgerlab/indra | indra/assemblers/cx/assembler.py | https://github.com/sorgerlab/indra/blob/79a70415832c5702d7a820c7c9ccc8e25010124b/indra/assemblers/cx/assembler.py#L160-L170 | def save_model(self, file_name='model.cx'):
"""Save the assembled CX network in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the CX network to. Default: model.cx
"""
with open(file_name, 'wt') as fh:
cx_str ... | [
"def",
"save_model",
"(",
"self",
",",
"file_name",
"=",
"'model.cx'",
")",
":",
"with",
"open",
"(",
"file_name",
",",
"'wt'",
")",
"as",
"fh",
":",
"cx_str",
"=",
"self",
".",
"print_cx",
"(",
")",
"fh",
".",
"write",
"(",
"cx_str",
")"
] | Save the assembled CX network in a file.
Parameters
----------
file_name : Optional[str]
The name of the file to save the CX network to. Default: model.cx | [
"Save",
"the",
"assembled",
"CX",
"network",
"in",
"a",
"file",
"."
] | python | train | 32.363636 |
cmbruns/pyopenvr | src/openvr/__init__.py | https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L5768-L5778 | def updateScreenshotProgress(self, screenshotHandle, flProgress):
"""
Call this if the application is taking the screen shot
will take more than a few ms processing. This will result
in an overlay being presented that shows a completion
bar.
"""
fn = self.func... | [
"def",
"updateScreenshotProgress",
"(",
"self",
",",
"screenshotHandle",
",",
"flProgress",
")",
":",
"fn",
"=",
"self",
".",
"function_table",
".",
"updateScreenshotProgress",
"result",
"=",
"fn",
"(",
"screenshotHandle",
",",
"flProgress",
")",
"return",
"result... | Call this if the application is taking the screen shot
will take more than a few ms processing. This will result
in an overlay being presented that shows a completion
bar. | [
"Call",
"this",
"if",
"the",
"application",
"is",
"taking",
"the",
"screen",
"shot",
"will",
"take",
"more",
"than",
"a",
"few",
"ms",
"processing",
".",
"This",
"will",
"result",
"in",
"an",
"overlay",
"being",
"presented",
"that",
"shows",
"a",
"completi... | python | train | 37.909091 |
mikemaccana/python-docx | docx.py | https://github.com/mikemaccana/python-docx/blob/4c9b46dbebe3d2a9b82dbcd35af36584a36fd9fe/docx.py#L95-L131 | def makeelement(tagname, tagtext=None, nsprefix='w', attributes=None,
attrnsprefix=None):
'''Create an element & return it'''
# Deal with list of nsprefix by making namespacemap
namespacemap = None
if isinstance(nsprefix, list):
namespacemap = {}
for prefix in nsprefix:
... | [
"def",
"makeelement",
"(",
"tagname",
",",
"tagtext",
"=",
"None",
",",
"nsprefix",
"=",
"'w'",
",",
"attributes",
"=",
"None",
",",
"attrnsprefix",
"=",
"None",
")",
":",
"# Deal with list of nsprefix by making namespacemap",
"namespacemap",
"=",
"None",
"if",
... | Create an element & return it | [
"Create",
"an",
"element",
"&",
"return",
"it"
] | python | train | 38.486486 |
ARMmbed/mbed-connector-api-python | mbed_connector_api/mbed_connector_api.py | https://github.com/ARMmbed/mbed-connector-api-python/blob/a5024a01dc67cc192c8bf7a70b251fcf0a3f279b/mbed_connector_api/mbed_connector_api.py#L489-L513 | def putCallback(self,url,headers=""):
'''
Set the callback URL. To be used in place of LongPolling when deploying a webapp.
**note**: make sure you set up a callback URL in your web app
:param str url: complete url, including port, where the callback url is located
:param str headers: Optional - Headers... | [
"def",
"putCallback",
"(",
"self",
",",
"url",
",",
"headers",
"=",
"\"\"",
")",
":",
"result",
"=",
"asyncResult",
"(",
")",
"payloadToSend",
"=",
"{",
"\"url\"",
":",
"url",
"}",
"if",
"headers",
":",
"payload",
"[",
"'headers'",
":",
"headers",
"]",... | Set the callback URL. To be used in place of LongPolling when deploying a webapp.
**note**: make sure you set up a callback URL in your web app
:param str url: complete url, including port, where the callback url is located
:param str headers: Optional - Headers to have Connector send back with all calls
... | [
"Set",
"the",
"callback",
"URL",
".",
"To",
"be",
"used",
"in",
"place",
"of",
"LongPolling",
"when",
"deploying",
"a",
"webapp",
".",
"**",
"note",
"**",
":",
"make",
"sure",
"you",
"set",
"up",
"a",
"callback",
"URL",
"in",
"your",
"web",
"app",
":... | python | train | 37.16 |
sosy-lab/benchexec | benchexec/outputhandler.py | https://github.com/sosy-lab/benchexec/blob/44428f67f41384c03aea13e7e25f884764653617/benchexec/outputhandler.py#L492-L510 | def output_after_run_set(self, runSet, cputime=None, walltime=None, energy={}):
"""
The method output_after_run_set() stores the times of a run set in XML.
@params cputime, walltime: accumulated times of the run set
"""
self.add_values_to_run_set_xml(runSet, cputime, walltime, e... | [
"def",
"output_after_run_set",
"(",
"self",
",",
"runSet",
",",
"cputime",
"=",
"None",
",",
"walltime",
"=",
"None",
",",
"energy",
"=",
"{",
"}",
")",
":",
"self",
".",
"add_values_to_run_set_xml",
"(",
"runSet",
",",
"cputime",
",",
"walltime",
",",
"... | The method output_after_run_set() stores the times of a run set in XML.
@params cputime, walltime: accumulated times of the run set | [
"The",
"method",
"output_after_run_set",
"()",
"stores",
"the",
"times",
"of",
"a",
"run",
"set",
"in",
"XML",
"."
] | python | train | 43.947368 |
mfcloud/python-zvm-sdk | zvmsdk/database.py | https://github.com/mfcloud/python-zvm-sdk/blob/de9994ceca764f5460ce51bd74237986341d8e3c/zvmsdk/database.py#L154-L160 | def switch_delete_record_for_userid(self, userid):
"""Remove userid switch record from switch table."""
with get_network_conn() as conn:
conn.execute("DELETE FROM switch WHERE userid=?",
(userid,))
LOG.debug("Switch record for user %s is removed from "
... | [
"def",
"switch_delete_record_for_userid",
"(",
"self",
",",
"userid",
")",
":",
"with",
"get_network_conn",
"(",
")",
"as",
"conn",
":",
"conn",
".",
"execute",
"(",
"\"DELETE FROM switch WHERE userid=?\"",
",",
"(",
"userid",
",",
")",
")",
"LOG",
".",
"debug... | Remove userid switch record from switch table. | [
"Remove",
"userid",
"switch",
"record",
"from",
"switch",
"table",
"."
] | python | train | 51.142857 |
duniter/duniter-python-api | examples/request_data.py | https://github.com/duniter/duniter-python-api/blob/3a1e5d61a2f72f5afaf29d010c6cf4dff3648165/examples/request_data.py#L16-L72 | async def main():
"""
Main code (synchronous requests)
"""
# Create Client from endpoint string in Duniter format
client = Client(BMAS_ENDPOINT)
# Get the node summary infos by dedicated method (with json schema validation)
print("\nCall bma.node.summary:")
response = await client(bma.n... | [
"async",
"def",
"main",
"(",
")",
":",
"# Create Client from endpoint string in Duniter format",
"client",
"=",
"Client",
"(",
"BMAS_ENDPOINT",
")",
"# Get the node summary infos by dedicated method (with json schema validation)",
"print",
"(",
"\"\\nCall bma.node.summary:\"",
")",... | Main code (synchronous requests) | [
"Main",
"code",
"(",
"synchronous",
"requests",
")"
] | python | train | 29.508772 |
davidmcclure/textplot | textplot/text.py | https://github.com/davidmcclure/textplot/blob/889b949a637d99097ecec44ed4bfee53b1964dee/textplot/text.py#L112-L125 | def term_count_buckets(self):
"""
Returns:
dict: A dictionary that maps occurrence counts to the terms that
appear that many times in the text.
"""
buckets = {}
for term, count in self.term_counts().items():
if count in buckets: buckets[count... | [
"def",
"term_count_buckets",
"(",
"self",
")",
":",
"buckets",
"=",
"{",
"}",
"for",
"term",
",",
"count",
"in",
"self",
".",
"term_counts",
"(",
")",
".",
"items",
"(",
")",
":",
"if",
"count",
"in",
"buckets",
":",
"buckets",
"[",
"count",
"]",
"... | Returns:
dict: A dictionary that maps occurrence counts to the terms that
appear that many times in the text. | [
"Returns",
":",
"dict",
":",
"A",
"dictionary",
"that",
"maps",
"occurrence",
"counts",
"to",
"the",
"terms",
"that",
"appear",
"that",
"many",
"times",
"in",
"the",
"text",
"."
] | python | train | 27.642857 |
RudolfCardinal/pythonlib | cardinal_pythonlib/openxml/find_recovered_openxml.py | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/openxml/find_recovered_openxml.py#L340-L527 | def main() -> None:
"""
Command-line handler for the ``find_recovered_openxml`` tool.
Use the ``--help`` option for help.
"""
parser = ArgumentParser(
formatter_class=RawDescriptionHelpFormatter,
description="""
Tool to recognize and rescue Microsoft Office OpenXML files, even if the... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"parser",
"=",
"ArgumentParser",
"(",
"formatter_class",
"=",
"RawDescriptionHelpFormatter",
",",
"description",
"=",
"\"\"\"\nTool to recognize and rescue Microsoft Office OpenXML files, even if they have\ngarbage appended to them. ... | Command-line handler for the ``find_recovered_openxml`` tool.
Use the ``--help`` option for help. | [
"Command",
"-",
"line",
"handler",
"for",
"the",
"find_recovered_openxml",
"tool",
".",
"Use",
"the",
"--",
"help",
"option",
"for",
"help",
"."
] | python | train | 43.765957 |
matthiask/django-cte-forest | cte_forest/query.py | https://github.com/matthiask/django-cte-forest/blob/7bff29d69eddfcf214e9cf61647c91d28655619c/cte_forest/query.py#L464-L474 | def as_sql(self, *args, **kwargs):
"""
Overrides the :class:`SQLUpdateCompiler` method in order to remove any
CTE-related WHERE clauses, which are not necessary for UPDATE queries,
yet may have been added if this query was cloned from a CTEQuery.
:return:
:rtype:
... | [
"def",
"as_sql",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"CTEQuery",
".",
"_remove_cte_where",
"(",
"self",
".",
"query",
")",
"return",
"super",
"(",
"self",
".",
"__class__",
",",
"self",
")",
".",
"as_sql",
"(",
"*",
"a... | Overrides the :class:`SQLUpdateCompiler` method in order to remove any
CTE-related WHERE clauses, which are not necessary for UPDATE queries,
yet may have been added if this query was cloned from a CTEQuery.
:return:
:rtype: | [
"Overrides",
"the",
":",
"class",
":",
"SQLUpdateCompiler",
"method",
"in",
"order",
"to",
"remove",
"any",
"CTE",
"-",
"related",
"WHERE",
"clauses",
"which",
"are",
"not",
"necessary",
"for",
"UPDATE",
"queries",
"yet",
"may",
"have",
"been",
"added",
"if"... | python | train | 38.909091 |
saltstack/salt | salt/states/grafana_dashboard.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/grafana_dashboard.py#L261-L282 | def _inherited_dashboard(dashboard, base_dashboards_from_pillar, ret):
'''Return a dashboard with properties from parents.'''
base_dashboards = []
for base_dashboard_from_pillar in base_dashboards_from_pillar:
base_dashboard = __salt__['pillar.get'](base_dashboard_from_pillar)
if base_dashbo... | [
"def",
"_inherited_dashboard",
"(",
"dashboard",
",",
"base_dashboards_from_pillar",
",",
"ret",
")",
":",
"base_dashboards",
"=",
"[",
"]",
"for",
"base_dashboard_from_pillar",
"in",
"base_dashboards_from_pillar",
":",
"base_dashboard",
"=",
"__salt__",
"[",
"'pillar.g... | Return a dashboard with properties from parents. | [
"Return",
"a",
"dashboard",
"with",
"properties",
"from",
"parents",
"."
] | python | train | 44.454545 |
Richienb/quilt | src/quilt_lang/__init__.py | https://github.com/Richienb/quilt/blob/4a659cac66f5286ad046d54a12fd850be5606643/src/quilt_lang/__init__.py#L797-L814 | def numlistbetween(num1, num2, option='list', listoption='string'):
"""
List Or Count The Numbers Between Two Numbers
"""
if option == 'list':
if listoption == 'string':
output = ''
output += str(num1)
for currentnum in range(num1 + 1, num2 + 1):
... | [
"def",
"numlistbetween",
"(",
"num1",
",",
"num2",
",",
"option",
"=",
"'list'",
",",
"listoption",
"=",
"'string'",
")",
":",
"if",
"option",
"==",
"'list'",
":",
"if",
"listoption",
"==",
"'string'",
":",
"output",
"=",
"''",
"output",
"+=",
"str",
"... | List Or Count The Numbers Between Two Numbers | [
"List",
"Or",
"Count",
"The",
"Numbers",
"Between",
"Two",
"Numbers"
] | python | train | 33.388889 |
subdownloader/subdownloader | subdownloader/client/configuration.py | https://github.com/subdownloader/subdownloader/blob/bbccedd11b18d925ad4c062b5eb65981e24d0433/subdownloader/client/configuration.py#L95-L115 | def configuration_get_default_folder():
"""
Return the default folder where user-specific data is stored.
This depends of the system on which Python is running,
:return: path to the user-specific configuration data folder
"""
system = platform.system()
if system == 'Linux':
# https:/... | [
"def",
"configuration_get_default_folder",
"(",
")",
":",
"system",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"system",
"==",
"'Linux'",
":",
"# https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html",
"sys_config_path",
"=",
"Path",
"(",
"os",... | Return the default folder where user-specific data is stored.
This depends of the system on which Python is running,
:return: path to the user-specific configuration data folder | [
"Return",
"the",
"default",
"folder",
"where",
"user",
"-",
"specific",
"data",
"is",
"stored",
".",
"This",
"depends",
"of",
"the",
"system",
"on",
"which",
"Python",
"is",
"running",
":",
"return",
":",
"path",
"to",
"the",
"user",
"-",
"specific",
"co... | python | train | 49.333333 |
resync/resync | resync/resource_container.py | https://github.com/resync/resync/blob/98292c17b2c00f2d6f5191c6ab51fef8c292a018/resync/resource_container.py#L179-L186 | def default_capability(self):
"""Set capability name in md.
Every ResourceSync document should have the top-level
capability attributes.
"""
if ('capability' not in self.md and self.capability_name is not None):
self.md['capability'] = self.capability_name | [
"def",
"default_capability",
"(",
"self",
")",
":",
"if",
"(",
"'capability'",
"not",
"in",
"self",
".",
"md",
"and",
"self",
".",
"capability_name",
"is",
"not",
"None",
")",
":",
"self",
".",
"md",
"[",
"'capability'",
"]",
"=",
"self",
".",
"capabil... | Set capability name in md.
Every ResourceSync document should have the top-level
capability attributes. | [
"Set",
"capability",
"name",
"in",
"md",
"."
] | python | train | 37.75 |
kamikaze/webdav | src/webdav/client.py | https://github.com/kamikaze/webdav/blob/6facff7224023d3e28c8e1592f3c58401c91a0e6/src/webdav/client.py#L852-L863 | def parse_get_list_response(content):
"""Parses of response content XML from WebDAV server and extract file and directory names.
:param content: the XML content of HTTP response from WebDAV server for getting list of files by remote path.
:return: list of extracted file or directory names.
... | [
"def",
"parse_get_list_response",
"(",
"content",
")",
":",
"try",
":",
"tree",
"=",
"etree",
".",
"fromstring",
"(",
"content",
")",
"hrees",
"=",
"[",
"Urn",
".",
"separate",
"+",
"unquote",
"(",
"urlsplit",
"(",
"hree",
".",
"text",
")",
".",
"path"... | Parses of response content XML from WebDAV server and extract file and directory names.
:param content: the XML content of HTTP response from WebDAV server for getting list of files by remote path.
:return: list of extracted file or directory names. | [
"Parses",
"of",
"response",
"content",
"XML",
"from",
"WebDAV",
"server",
"and",
"extract",
"file",
"and",
"directory",
"names",
"."
] | python | train | 49.916667 |
pandas-dev/pandas | pandas/plotting/_core.py | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/plotting/_core.py#L3033-L3116 | def bar(self, x=None, y=None, **kwds):
"""
Vertical bar plot.
A bar plot is a plot that presents categorical data with
rectangular bars with lengths proportional to the values that they
represent. A bar plot shows comparisons among discrete categories. One
axis of the pl... | [
"def",
"bar",
"(",
"self",
",",
"x",
"=",
"None",
",",
"y",
"=",
"None",
",",
"*",
"*",
"kwds",
")",
":",
"return",
"self",
"(",
"kind",
"=",
"'bar'",
",",
"x",
"=",
"x",
",",
"y",
"=",
"y",
",",
"*",
"*",
"kwds",
")"
] | Vertical bar plot.
A bar plot is a plot that presents categorical data with
rectangular bars with lengths proportional to the values that they
represent. A bar plot shows comparisons among discrete categories. One
axis of the plot shows the specific categories being compared, and the
... | [
"Vertical",
"bar",
"plot",
"."
] | python | train | 33.261905 |
wonambi-python/wonambi | wonambi/detect/spindle.py | https://github.com/wonambi-python/wonambi/blob/1d8e3d7e53df8017c199f703bcab582914676e76/wonambi/detect/spindle.py#L1728-L1751 | def remove_straddlers(events, time, s_freq, toler=0.1):
"""Reject an event if it straddles a stitch, by comparing its
duration to its timespan.
Parameters
----------
events : ndarray (dtype='int')
N x M matrix with start, ..., end samples
time : ndarray (dtype='float')
vector w... | [
"def",
"remove_straddlers",
"(",
"events",
",",
"time",
",",
"s_freq",
",",
"toler",
"=",
"0.1",
")",
":",
"dur",
"=",
"(",
"events",
"[",
":",
",",
"-",
"1",
"]",
"-",
"1",
"-",
"events",
"[",
":",
",",
"0",
"]",
")",
"/",
"s_freq",
"continuou... | Reject an event if it straddles a stitch, by comparing its
duration to its timespan.
Parameters
----------
events : ndarray (dtype='int')
N x M matrix with start, ..., end samples
time : ndarray (dtype='float')
vector with time points
s_freq : float
sampling frequency
... | [
"Reject",
"an",
"event",
"if",
"it",
"straddles",
"a",
"stitch",
"by",
"comparing",
"its",
"duration",
"to",
"its",
"timespan",
"."
] | python | train | 30.666667 |
sdispater/orator | orator/orm/relations/morph_to.py | https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/orm/relations/morph_to.py#L49-L66 | def _build_dictionary(self, models):
"""
Build a dictionary with the models.
:param models: The models
:type models: Collection
"""
for model in models:
key = getattr(model, self._morph_type, None)
if key:
foreign = getattr(model, ... | [
"def",
"_build_dictionary",
"(",
"self",
",",
"models",
")",
":",
"for",
"model",
"in",
"models",
":",
"key",
"=",
"getattr",
"(",
"model",
",",
"self",
".",
"_morph_type",
",",
"None",
")",
"if",
"key",
":",
"foreign",
"=",
"getattr",
"(",
"model",
... | Build a dictionary with the models.
:param models: The models
:type models: Collection | [
"Build",
"a",
"dictionary",
"with",
"the",
"models",
"."
] | python | train | 32.888889 |
edx/XBlock | xblock/django/request.py | https://github.com/edx/XBlock/blob/368bf46e2c0ee69bbb21817f428c4684936e18ee/xblock/django/request.py#L119-L127 | def environ(self):
"""
Add path_info to the request's META dictionary.
"""
environ = dict(self._request.META)
environ['PATH_INFO'] = self._request.path_info
return environ | [
"def",
"environ",
"(",
"self",
")",
":",
"environ",
"=",
"dict",
"(",
"self",
".",
"_request",
".",
"META",
")",
"environ",
"[",
"'PATH_INFO'",
"]",
"=",
"self",
".",
"_request",
".",
"path_info",
"return",
"environ"
] | Add path_info to the request's META dictionary. | [
"Add",
"path_info",
"to",
"the",
"request",
"s",
"META",
"dictionary",
"."
] | python | train | 23.666667 |
alvarosg/pynverse | pynverse/inverse.py | https://github.com/alvarosg/pynverse/blob/ced4099bcebc49ef341ddccd8d4eccda5a5a7939/pynverse/inverse.py#L9-L203 | def inversefunc(func,
y_values=None,
domain=None,
image=None,
open_domain=None,
args=(),
accuracy=2):
r"""Obtain the inverse of a function.
Returns the numerical inverse of the function `f`. It may return a callable... | [
"def",
"inversefunc",
"(",
"func",
",",
"y_values",
"=",
"None",
",",
"domain",
"=",
"None",
",",
"image",
"=",
"None",
",",
"open_domain",
"=",
"None",
",",
"args",
"=",
"(",
")",
",",
"accuracy",
"=",
"2",
")",
":",
"domain",
",",
"image",
",",
... | r"""Obtain the inverse of a function.
Returns the numerical inverse of the function `f`. It may return a callable
that can be used to calculate the inverse, or the inverse of certain points
depending on the `y_values` argument.
In order for the numerical inverse to exist in its domain, the
input fu... | [
"r",
"Obtain",
"the",
"inverse",
"of",
"a",
"function",
"."
] | python | train | 39.569231 |
inasafe/inasafe | safe/gui/tools/wizard/step_kw44_fields_mapping.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/wizard/step_kw44_fields_mapping.py#L117-L133 | def get_field_mapping(self):
"""Obtain metadata from current state of the widget.
Null or empty list will be removed.
:returns: Dictionary of values by type in this format:
{'fields': {}, 'values': {}}.
:rtype: dict
"""
field_mapping = self.field_mapping_wid... | [
"def",
"get_field_mapping",
"(",
"self",
")",
":",
"field_mapping",
"=",
"self",
".",
"field_mapping_widget",
".",
"get_field_mapping",
"(",
")",
"for",
"k",
",",
"v",
"in",
"list",
"(",
"field_mapping",
"[",
"'values'",
"]",
".",
"items",
"(",
")",
")",
... | Obtain metadata from current state of the widget.
Null or empty list will be removed.
:returns: Dictionary of values by type in this format:
{'fields': {}, 'values': {}}.
:rtype: dict | [
"Obtain",
"metadata",
"from",
"current",
"state",
"of",
"the",
"widget",
"."
] | python | train | 36 |
jaraco/svg.charts | svg/charts/graph.py | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L135-L159 | def burn(self):
"""
Process the template with the data and
config which has been set and return the resulting SVG.
Raises ValueError when no data set has
been added to the graph object.
"""
if not self.data:
raise ValueError("No data available")
if hasattr(self, 'calculations'):
self.calculation... | [
"def",
"burn",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"data",
":",
"raise",
"ValueError",
"(",
"\"No data available\"",
")",
"if",
"hasattr",
"(",
"self",
",",
"'calculations'",
")",
":",
"self",
".",
"calculations",
"(",
")",
"self",
".",
"s... | Process the template with the data and
config which has been set and return the resulting SVG.
Raises ValueError when no data set has
been added to the graph object. | [
"Process",
"the",
"template",
"with",
"the",
"data",
"and",
"config",
"which",
"has",
"been",
"set",
"and",
"return",
"the",
"resulting",
"SVG",
"."
] | python | test | 23 |
calmjs/calmjs | src/calmjs/utils.py | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/utils.py#L83-L100 | def finalize_env(env):
"""
Produce a platform specific env for passing into subprocess.Popen
family of external process calling methods, and the supplied env
will be updated on top of it. Returns a new env.
"""
keys = _PLATFORM_ENV_KEYS.get(sys.platform, [])
if 'PATH' not in keys:
... | [
"def",
"finalize_env",
"(",
"env",
")",
":",
"keys",
"=",
"_PLATFORM_ENV_KEYS",
".",
"get",
"(",
"sys",
".",
"platform",
",",
"[",
"]",
")",
"if",
"'PATH'",
"not",
"in",
"keys",
":",
"# this MUST be available due to Node.js (and others really)",
"# needing somethi... | Produce a platform specific env for passing into subprocess.Popen
family of external process calling methods, and the supplied env
will be updated on top of it. Returns a new env. | [
"Produce",
"a",
"platform",
"specific",
"env",
"for",
"passing",
"into",
"subprocess",
".",
"Popen",
"family",
"of",
"external",
"process",
"calling",
"methods",
"and",
"the",
"supplied",
"env",
"will",
"be",
"updated",
"on",
"top",
"of",
"it",
".",
"Returns... | python | train | 34.055556 |
readbeyond/aeneas | aeneas/audiofile.py | https://github.com/readbeyond/aeneas/blob/9d95535ad63eef4a98530cfdff033b8c35315ee1/aeneas/audiofile.py#L310-L328 | def audio_samples(self):
"""
The audio audio_samples, that is, an array of ``float64`` values,
each representing an audio sample in ``[-1.0, 1.0]``.
Note that this function returns a view into the
first ``self.__samples_length`` elements of ``self.__samples``.
If you wan... | [
"def",
"audio_samples",
"(",
"self",
")",
":",
"if",
"self",
".",
"__samples",
"is",
"None",
":",
"if",
"self",
".",
"file_path",
"is",
"None",
":",
"self",
".",
"log_exc",
"(",
"u\"AudioFile object not initialized\"",
",",
"None",
",",
"True",
",",
"Audio... | The audio audio_samples, that is, an array of ``float64`` values,
each representing an audio sample in ``[-1.0, 1.0]``.
Note that this function returns a view into the
first ``self.__samples_length`` elements of ``self.__samples``.
If you want to clone the values,
you must use e... | [
"The",
"audio",
"audio_samples",
"that",
"is",
"an",
"array",
"of",
"float64",
"values",
"each",
"representing",
"an",
"audio",
"sample",
"in",
"[",
"-",
"1",
".",
"0",
"1",
".",
"0",
"]",
"."
] | python | train | 45.842105 |
robotools/fontParts | Lib/fontParts/base/glyph.py | https://github.com/robotools/fontParts/blob/d2ff106fe95f9d566161d936a645157626568712/Lib/fontParts/base/glyph.py#L1034-L1049 | def _appendComponent(self, baseGlyph, transformation=None, identifier=None, **kwargs):
"""
baseGlyph will be a valid glyph name.
The baseGlyph may or may not be in the layer.
offset will be a valid offset (x, y).
scale will be a valid scale (x, y).
identifier will be a v... | [
"def",
"_appendComponent",
"(",
"self",
",",
"baseGlyph",
",",
"transformation",
"=",
"None",
",",
"identifier",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"pointPen",
"=",
"self",
".",
"getPointPen",
"(",
")",
"pointPen",
".",
"addComponent",
"(",
... | baseGlyph will be a valid glyph name.
The baseGlyph may or may not be in the layer.
offset will be a valid offset (x, y).
scale will be a valid scale (x, y).
identifier will be a valid, nonconflicting identifier.
This must return the new component.
Subclasses may overr... | [
"baseGlyph",
"will",
"be",
"a",
"valid",
"glyph",
"name",
".",
"The",
"baseGlyph",
"may",
"or",
"may",
"not",
"be",
"in",
"the",
"layer",
"."
] | python | train | 38 |
remind101/stacker_blueprints | stacker_blueprints/aws_lambda.py | https://github.com/remind101/stacker_blueprints/blob/71624f6e1bd4ea794dc98fb621a04235e1931cae/stacker_blueprints/aws_lambda.py#L221-L230 | def add_policy_statements(self, statements):
"""Adds statements to the policy.
Args:
statements (:class:`awacs.aws.Statement` or list): Either a single
Statment, or a list of statements.
"""
if isinstance(statements, Statement):
statements = [stat... | [
"def",
"add_policy_statements",
"(",
"self",
",",
"statements",
")",
":",
"if",
"isinstance",
"(",
"statements",
",",
"Statement",
")",
":",
"statements",
"=",
"[",
"statements",
"]",
"self",
".",
"_policy_statements",
".",
"extend",
"(",
"statements",
")"
] | Adds statements to the policy.
Args:
statements (:class:`awacs.aws.Statement` or list): Either a single
Statment, or a list of statements. | [
"Adds",
"statements",
"to",
"the",
"policy",
"."
] | python | train | 36.9 |
cslarsen/crianza | crianza/compiler.py | https://github.com/cslarsen/crianza/blob/fa044f9d491f37cc06892bad14b2c80b8ac5a7cd/crianza/compiler.py#L8-L18 | def make_embedded_push(value):
"""Returns a closure that pushed the given value onto a Machine's stack.
We use this to embed stack pushes in the VM code, so that the interpreter
can assume that all instructions are callable Python functions. This makes
dispatching much faster than checking if an instru... | [
"def",
"make_embedded_push",
"(",
"value",
")",
":",
"push",
"=",
"lambda",
"vm",
":",
"vm",
".",
"push",
"(",
"value",
")",
"push",
".",
"tag",
"=",
"EMBEDDED_PUSH_TAG",
"return",
"push"
] | Returns a closure that pushed the given value onto a Machine's stack.
We use this to embed stack pushes in the VM code, so that the interpreter
can assume that all instructions are callable Python functions. This makes
dispatching much faster than checking if an instruction is a constant
(number, strin... | [
"Returns",
"a",
"closure",
"that",
"pushed",
"the",
"given",
"value",
"onto",
"a",
"Machine",
"s",
"stack",
"."
] | python | train | 42.818182 |
saltstack/salt | salt/modules/yumpkg.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/yumpkg.py#L1926-L1946 | def update(name=None,
pkgs=None,
refresh=True,
skip_verify=False,
normalize=True,
minimal=False,
obsoletes=False,
**kwargs):
'''
.. versionadded:: 2019.2.0
Calls :py:func:`pkg.upgrade <salt.modules.yumpkg.upgrade>` with
``obso... | [
"def",
"update",
"(",
"name",
"=",
"None",
",",
"pkgs",
"=",
"None",
",",
"refresh",
"=",
"True",
",",
"skip_verify",
"=",
"False",
",",
"normalize",
"=",
"True",
",",
"minimal",
"=",
"False",
",",
"obsoletes",
"=",
"False",
",",
"*",
"*",
"kwargs",
... | .. versionadded:: 2019.2.0
Calls :py:func:`pkg.upgrade <salt.modules.yumpkg.upgrade>` with
``obsoletes=False``. Mirrors the CLI behavior of ``yum update``.
See :py:func:`pkg.upgrade <salt.modules.yumpkg.upgrade>` for
further documentation.
.. code-block:: bash
salt '*' pkg.update | [
"..",
"versionadded",
"::",
"2019",
".",
"2",
".",
"0"
] | python | train | 28.904762 |
rasguanabana/ytfs | ytfs/actions.py | https://github.com/rasguanabana/ytfs/blob/67dd9536a1faea09c8394f697529124f78e77cfa/ytfs/actions.py#L388-L475 | def updateResults(self, forward=None):
"""
Reload search results or load another "page".
Parameters
----------
forward : bool or None, optional
Whether move forwards or backwards (``True`` or ``False``). If ``None``, then first page is loaded.
"""
#... | [
"def",
"updateResults",
"(",
"self",
",",
"forward",
"=",
"None",
")",
":",
"# this choses data we need.",
"files",
"=",
"lambda",
"x",
":",
"{",
"i",
"[",
"'snippet'",
"]",
"[",
"'title'",
"]",
".",
"replace",
"(",
"'/'",
",",
"'\\\\'",
")",
":",
"YTS... | Reload search results or load another "page".
Parameters
----------
forward : bool or None, optional
Whether move forwards or backwards (``True`` or ``False``). If ``None``, then first page is loaded. | [
"Reload",
"search",
"results",
"or",
"load",
"another",
"page",
"."
] | python | train | 36.25 |
gaqzi/gocd-cli | gocd_cli/utils.py | https://github.com/gaqzi/gocd-cli/blob/ca8df8ec2274fdc69bce0619aa3794463c4f5a6f/gocd_cli/utils.py#L154-L172 | def get_go_server(settings=None):
"""Returns a `gocd.Server` configured by the `settings`
object.
Args:
settings: a `gocd_cli.settings.Settings` object.
Default: if falsey calls `get_settings`.
Returns:
gocd.Server: a configured gocd.Server instance
"""
if not settings:
... | [
"def",
"get_go_server",
"(",
"settings",
"=",
"None",
")",
":",
"if",
"not",
"settings",
":",
"settings",
"=",
"get_settings",
"(",
")",
"return",
"gocd",
".",
"Server",
"(",
"settings",
".",
"get",
"(",
"'server'",
")",
",",
"user",
"=",
"settings",
"... | Returns a `gocd.Server` configured by the `settings`
object.
Args:
settings: a `gocd_cli.settings.Settings` object.
Default: if falsey calls `get_settings`.
Returns:
gocd.Server: a configured gocd.Server instance | [
"Returns",
"a",
"gocd",
".",
"Server",
"configured",
"by",
"the",
"settings",
"object",
"."
] | python | train | 24.894737 |
blink1073/oct2py | oct2py/demo.py | https://github.com/blink1073/oct2py/blob/bfc69d2168ae3d98258f95bbc55a858c21836b58/oct2py/demo.py#L10-L74 | def demo(delay=1, interactive=True):
"""
Play a demo script showing most of the oct2py api features.
Parameters
==========
delay : float
Time between each command in seconds.
"""
script = """
#########################
# Oct2Py demo
#########################... | [
"def",
"demo",
"(",
"delay",
"=",
"1",
",",
"interactive",
"=",
"True",
")",
":",
"script",
"=",
"\"\"\"\r\n #########################\r\n # Oct2Py demo\r\n #########################\r\n import numpy as np\r\n from oct2py import Oct2Py\r\n oc = Oct2Py()\r\n # basic c... | Play a demo script showing most of the oct2py api features.
Parameters
==========
delay : float
Time between each command in seconds. | [
"Play",
"a",
"demo",
"script",
"showing",
"most",
"of",
"the",
"oct2py",
"api",
"features",
".",
"Parameters",
"==========",
"delay",
":",
"float",
"Time",
"between",
"each",
"command",
"in",
"seconds",
"."
] | python | valid | 27.215385 |
dslackw/slpkg | slpkg/graph.py | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/graph.py#L43-L70 | def dependencies(self, deps_dict):
"""Generate graph file with depenndencies map tree
"""
try:
import pygraphviz as pgv
except ImportError:
graph_easy, comma = "", ""
if (self.image == "ascii" and
not os.path.isfile("/usr/bin/graph-... | [
"def",
"dependencies",
"(",
"self",
",",
"deps_dict",
")",
":",
"try",
":",
"import",
"pygraphviz",
"as",
"pgv",
"except",
"ImportError",
":",
"graph_easy",
",",
"comma",
"=",
"\"\"",
",",
"\"\"",
"if",
"(",
"self",
".",
"image",
"==",
"\"ascii\"",
"and"... | Generate graph file with depenndencies map tree | [
"Generate",
"graph",
"file",
"with",
"depenndencies",
"map",
"tree"
] | python | train | 37.071429 |
maljovec/topopy | topopy/MorseComplex.py | https://github.com/maljovec/topopy/blob/4be598d51c4e4043b73d4ad44beed6d289e2f088/topopy/MorseComplex.py#L88-L101 | def reset(self):
"""
Empties all internal storage containers
"""
super(MorseComplex, self).reset()
self.base_partitions = {}
self.merge_sequence = {}
self.persistences = []
self.max_indices = []
# State properties
self.persistence = ... | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
"MorseComplex",
",",
"self",
")",
".",
"reset",
"(",
")",
"self",
".",
"base_partitions",
"=",
"{",
"}",
"self",
".",
"merge_sequence",
"=",
"{",
"}",
"self",
".",
"persistences",
"=",
"[",
"]",
... | Empties all internal storage containers | [
"Empties",
"all",
"internal",
"storage",
"containers"
] | python | train | 22.071429 |
twilio/twilio-python | twilio/rest/api/v2010/account/sip/domain/auth_types/__init__.py | https://github.com/twilio/twilio-python/blob/c867895f55dcc29f522e6e8b8868d0d18483132f/twilio/rest/api/v2010/account/sip/domain/auth_types/__init__.py#L101-L115 | def get_instance(self, payload):
"""
Build an instance of AuthTypesInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.sip.domain.auth_types.AuthTypesInstance
:rtype: twilio.rest.api.v2010.account.sip.domain.auth_types.AuthTypesIn... | [
"def",
"get_instance",
"(",
"self",
",",
"payload",
")",
":",
"return",
"AuthTypesInstance",
"(",
"self",
".",
"_version",
",",
"payload",
",",
"account_sid",
"=",
"self",
".",
"_solution",
"[",
"'account_sid'",
"]",
",",
"domain_sid",
"=",
"self",
".",
"_... | Build an instance of AuthTypesInstance
:param dict payload: Payload response from the API
:returns: twilio.rest.api.v2010.account.sip.domain.auth_types.AuthTypesInstance
:rtype: twilio.rest.api.v2010.account.sip.domain.auth_types.AuthTypesInstance | [
"Build",
"an",
"instance",
"of",
"AuthTypesInstance"
] | python | train | 34.933333 |
loli/medpy | medpy/graphcut/energy_voxel.py | https://github.com/loli/medpy/blob/95216b9e22e7ce301f0edf953ee2a2f1b6c6aee5/medpy/graphcut/energy_voxel.py#L395-L437 | def boundary_maximum_power(graph, xxx_todo_changeme7):
"""
Boundary term processing adjacent voxels maximum value using a power relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_dif... | [
"def",
"boundary_maximum_power",
"(",
"graph",
",",
"xxx_todo_changeme7",
")",
":",
"(",
"gradient_image",
",",
"sigma",
",",
"spacing",
")",
"=",
"xxx_todo_changeme7",
"gradient_image",
"=",
"scipy",
".",
"asarray",
"(",
"gradient_image",
")",
"def",
"boundary_te... | Boundary term processing adjacent voxels maximum value using a power relationship.
An implementation of a boundary term, suitable to be used with the
`~medpy.graphcut.generate.graph_from_voxels` function.
The same as `boundary_difference_power`, but working on the gradient image instead
of th... | [
"Boundary",
"term",
"processing",
"adjacent",
"voxels",
"maximum",
"value",
"using",
"a",
"power",
"relationship",
".",
"An",
"implementation",
"of",
"a",
"boundary",
"term",
"suitable",
"to",
"be",
"used",
"with",
"the",
"~medpy",
".",
"graphcut",
".",
"gener... | python | train | 38.976744 |
huyingxi/Synonyms | synonyms/synonyms.py | https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/synonyms.py#L125-L133 | def _load_w2v(model_file=_f_model, binary=True):
'''
load word2vec model
'''
if not os.path.exists(model_file):
print("os.path : ", os.path)
raise Exception("Model file [%s] does not exist." % model_file)
return KeyedVectors.load_word2vec_format(
model_file, binary=binary, un... | [
"def",
"_load_w2v",
"(",
"model_file",
"=",
"_f_model",
",",
"binary",
"=",
"True",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"model_file",
")",
":",
"print",
"(",
"\"os.path : \"",
",",
"os",
".",
"path",
")",
"raise",
"Exception",... | load word2vec model | [
"load",
"word2vec",
"model"
] | python | train | 37.111111 |
jantman/awslimitchecker | awslimitchecker/checker.py | https://github.com/jantman/awslimitchecker/blob/e50197f70f3d0abcc5cfc7fde6336f548b790e34/awslimitchecker/checker.py#L431-L484 | def set_threshold_overrides(self, override_dict):
"""
Set manual overrides on the threshold (used for determining
warning/critical status) a dict of limits. See
:py:class:`~.AwsLimitChecker` for information on Warning and
Critical thresholds.
Dict is composed of service ... | [
"def",
"set_threshold_overrides",
"(",
"self",
",",
"override_dict",
")",
":",
"for",
"svc_name",
"in",
"sorted",
"(",
"override_dict",
")",
":",
"for",
"lim_name",
"in",
"sorted",
"(",
"override_dict",
"[",
"svc_name",
"]",
")",
":",
"d",
"=",
"override_dic... | Set manual overrides on the threshold (used for determining
warning/critical status) a dict of limits. See
:py:class:`~.AwsLimitChecker` for information on Warning and
Critical thresholds.
Dict is composed of service name keys (string) to dict of
limit names (string), to dict of... | [
"Set",
"manual",
"overrides",
"on",
"the",
"threshold",
"(",
"used",
"for",
"determining",
"warning",
"/",
"critical",
"status",
")",
"a",
"dict",
"of",
"limits",
".",
"See",
":",
"py",
":",
"class",
":",
"~",
".",
"AwsLimitChecker",
"for",
"information",
... | python | train | 38.12963 |
blockstack/blockstack-core | blockstack/lib/nameset/namedb.py | https://github.com/blockstack/blockstack-core/blob/1dcfdd39b152d29ce13e736a6a1a0981401a0505/blockstack/lib/nameset/namedb.py#L1657-L1691 | def commit_account_debit(self, opcode, account_payment_info, current_block_number, current_vtxindex, current_txid):
"""
Given the account info set by a state-create or state-transition or a token-operation,
debit the relevant account.
Do not call this directly.
Return T... | [
"def",
"commit_account_debit",
"(",
"self",
",",
"opcode",
",",
"account_payment_info",
",",
"current_block_number",
",",
"current_vtxindex",
",",
"current_txid",
")",
":",
"account_address",
"=",
"account_payment_info",
"[",
"'address'",
"]",
"account_payment",
"=",
... | Given the account info set by a state-create or state-transition or a token-operation,
debit the relevant account.
Do not call this directly.
Return True on success
Abort on error | [
"Given",
"the",
"account",
"info",
"set",
"by",
"a",
"state",
"-",
"create",
"or",
"state",
"-",
"transition",
"or",
"a",
"token",
"-",
"operation",
"debit",
"the",
"relevant",
"account",
".",
"Do",
"not",
"call",
"this",
"directly",
"."
] | python | train | 46.914286 |
annoviko/pyclustering | pyclustering/cluster/bang.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/cluster/bang.py#L927-L937 | def __cache_covered_data(self):
"""!
@brief Cache covered data.
"""
self.__cache_points = True
self.__points = []
for index_point in range(len(self.__data)):
if self.__data[index_point] in self.__spatial_block:
self.__cache_point(in... | [
"def",
"__cache_covered_data",
"(",
"self",
")",
":",
"self",
".",
"__cache_points",
"=",
"True",
"self",
".",
"__points",
"=",
"[",
"]",
"for",
"index_point",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"__data",
")",
")",
":",
"if",
"self",
".",
"... | !
@brief Cache covered data. | [
"!"
] | python | valid | 29.090909 |
nicolargo/glances | glances/outdated.py | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/outdated.py#L150-L169 | def _update_pypi_version(self):
"""Get the latest PyPI version (as a string) via the RESTful JSON API"""
logger.debug("Get latest Glances version from the PyPI RESTful API ({})".format(PYPI_API_URL))
# Update the current time
self.data[u'refresh_date'] = datetime.now()
try:
... | [
"def",
"_update_pypi_version",
"(",
"self",
")",
":",
"logger",
".",
"debug",
"(",
"\"Get latest Glances version from the PyPI RESTful API ({})\"",
".",
"format",
"(",
"PYPI_API_URL",
")",
")",
"# Update the current time",
"self",
".",
"data",
"[",
"u'refresh_date'",
"]... | Get the latest PyPI version (as a string) via the RESTful JSON API | [
"Get",
"the",
"latest",
"PyPI",
"version",
"(",
"as",
"a",
"string",
")",
"via",
"the",
"RESTful",
"JSON",
"API"
] | python | train | 42.45 |
biosignalsnotebooks/biosignalsnotebooks | biosignalsnotebooks/biosignalsnotebooks/train_and_classify.py | https://github.com/biosignalsnotebooks/biosignalsnotebooks/blob/aaa01d4125180b3a34f1e26e0d3ff08c23f666d3/biosignalsnotebooks/biosignalsnotebooks/train_and_classify.py#L105-L143 | def features_extraction(windowed_signal, functions):
"""
-----
Brief
-----
Function to extract features given in functions, that returns an array with the set of features
for each time window.
-----------
Description
-----------
Machine learning pipelines usually use features to... | [
"def",
"features_extraction",
"(",
"windowed_signal",
",",
"functions",
")",
":",
"features",
"=",
"np",
".",
"zeros",
"(",
"shape",
"=",
"(",
"windowed_signal",
".",
"shape",
"[",
"0",
"]",
",",
"len",
"(",
"functions",
")",
")",
")",
"for",
"i",
",",... | -----
Brief
-----
Function to extract features given in functions, that returns an array with the set of features
for each time window.
-----------
Description
-----------
Machine learning pipelines usually use features to represent each sample of the input signals.
Those features s... | [
"-----",
"Brief",
"-----",
"Function",
"to",
"extract",
"features",
"given",
"in",
"functions",
"that",
"returns",
"an",
"array",
"with",
"the",
"set",
"of",
"features",
"for",
"each",
"time",
"window",
"."
] | python | train | 35.179487 |
projectatomic/osbs-client | osbs/core.py | https://github.com/projectatomic/osbs-client/blob/571fe035dab3a7c02e1dccd5d65ffd75be750458/osbs/core.py#L926-L986 | def import_image_tags(self, name, stream_import, tags, repository, insecure):
"""
Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported
"""
# Get the JSON for the ImageStream
imagestream_json = self.get_image_stream(name)... | [
"def",
"import_image_tags",
"(",
"self",
",",
"name",
",",
"stream_import",
",",
"tags",
",",
"repository",
",",
"insecure",
")",
":",
"# Get the JSON for the ImageStream",
"imagestream_json",
"=",
"self",
".",
"get_image_stream",
"(",
"name",
")",
".",
"json",
... | Import image tags from a Docker registry into an ImageStream
:return: bool, whether tags were imported | [
"Import",
"image",
"tags",
"from",
"a",
"Docker",
"registry",
"into",
"an",
"ImageStream"
] | python | train | 41.409836 |
nepalicalendar/nepalicalendar-py | nepalicalendar/nepdate.py | https://github.com/nepalicalendar/nepalicalendar-py/blob/a589c28b8e085049f30a7287753476b59eca6f50/nepalicalendar/nepdate.py#L207-L215 | def from_ad_date(cls, date):
""" Gets a NepDate object from gregorian calendar date """
functions.check_valid_ad_range(date)
days = values.START_EN_DATE - date
# Add the required number of days to the start nepali date
start_date = NepDate(values.START_NP_YEAR, 1, 1)
# N... | [
"def",
"from_ad_date",
"(",
"cls",
",",
"date",
")",
":",
"functions",
".",
"check_valid_ad_range",
"(",
"date",
")",
"days",
"=",
"values",
".",
"START_EN_DATE",
"-",
"date",
"# Add the required number of days to the start nepali date",
"start_date",
"=",
"NepDate",
... | Gets a NepDate object from gregorian calendar date | [
"Gets",
"a",
"NepDate",
"object",
"from",
"gregorian",
"calendar",
"date"
] | python | train | 46.555556 |
projecthamster/hamster-lib | hamster_lib/helpers/helpers.py | https://github.com/projecthamster/hamster-lib/blob/bc34c822c239a6fa0cde3a4f90b0d00506fb5a4f/hamster_lib/helpers/helpers.py#L33-L62 | def _load_tmp_fact(filepath):
"""
Load an 'ongoing fact' from a given location.
Args:
filepath: Full path to the tmpfile location.
Returns:
hamster_lib.Fact: ``Fact`` representing the 'ongoing fact'. Returns ``False``
if no file was found.
Raises:
TypeError: If... | [
"def",
"_load_tmp_fact",
"(",
"filepath",
")",
":",
"from",
"hamster_lib",
"import",
"Fact",
"try",
":",
"with",
"open",
"(",
"filepath",
",",
"'rb'",
")",
"as",
"fobj",
":",
"fact",
"=",
"pickle",
".",
"load",
"(",
"fobj",
")",
"except",
"IOError",
":... | Load an 'ongoing fact' from a given location.
Args:
filepath: Full path to the tmpfile location.
Returns:
hamster_lib.Fact: ``Fact`` representing the 'ongoing fact'. Returns ``False``
if no file was found.
Raises:
TypeError: If for some reason our stored instance is no... | [
"Load",
"an",
"ongoing",
"fact",
"from",
"a",
"given",
"location",
"."
] | python | train | 29.333333 |
MoseleyBioinformaticsLab/mwtab | mwtab/converter.py | https://github.com/MoseleyBioinformaticsLab/mwtab/blob/8c0ae8ab2aa621662f99589ed41e481cf8b7152b/mwtab/converter.py#L244-L252 | def _to_zipfile(self, file_generator):
"""Convert files to zip archive.
:return: None
:rtype: :py:obj:`None`
"""
with zipfile.ZipFile(file_generator.to_path, mode="w", compression=zipfile.ZIP_DEFLATED) as outfile:
for f in file_generator:
outpath = sel... | [
"def",
"_to_zipfile",
"(",
"self",
",",
"file_generator",
")",
":",
"with",
"zipfile",
".",
"ZipFile",
"(",
"file_generator",
".",
"to_path",
",",
"mode",
"=",
"\"w\"",
",",
"compression",
"=",
"zipfile",
".",
"ZIP_DEFLATED",
")",
"as",
"outfile",
":",
"fo... | Convert files to zip archive.
:return: None
:rtype: :py:obj:`None` | [
"Convert",
"files",
"to",
"zip",
"archive",
".",
":",
"return",
":",
"None",
":",
"rtype",
":",
":",
"py",
":",
"obj",
":",
"None"
] | python | train | 50.666667 |
tanghaibao/jcvi | jcvi/apps/ks.py | https://github.com/tanghaibao/jcvi/blob/d2e31a77b6ade7f41f3b321febc2b4744d1cdeca/jcvi/apps/ks.py#L729-L792 | def subset(args):
"""
%prog subset pairsfile ksfile1 ksfile2 ... -o pairs.ks
Subset some pre-calculated ks ka values (in ksfile) according to pairs
in tab delimited pairsfile/anchorfile.
"""
p = OptionParser(subset.__doc__)
p.add_option("--noheader", action="store_true",
he... | [
"def",
"subset",
"(",
"args",
")",
":",
"p",
"=",
"OptionParser",
"(",
"subset",
".",
"__doc__",
")",
"p",
".",
"add_option",
"(",
"\"--noheader\"",
",",
"action",
"=",
"\"store_true\"",
",",
"help",
"=",
"\"don't write ksfile header line [default: %default]\"",
... | %prog subset pairsfile ksfile1 ksfile2 ... -o pairs.ks
Subset some pre-calculated ks ka values (in ksfile) according to pairs
in tab delimited pairsfile/anchorfile. | [
"%prog",
"subset",
"pairsfile",
"ksfile1",
"ksfile2",
"...",
"-",
"o",
"pairs",
".",
"ks"
] | python | train | 28.84375 |
bihealth/vcfpy | vcfpy/header.py | https://github.com/bihealth/vcfpy/blob/99e2165df30f11e0c95f3170f31bc5191d9e9e15/vcfpy/header.py#L513-L516 | def copy(self):
"""Return a copy"""
mapping = OrderedDict(self.mapping.items())
return self.__class__(self.key, self.value, mapping) | [
"def",
"copy",
"(",
"self",
")",
":",
"mapping",
"=",
"OrderedDict",
"(",
"self",
".",
"mapping",
".",
"items",
"(",
")",
")",
"return",
"self",
".",
"__class__",
"(",
"self",
".",
"key",
",",
"self",
".",
"value",
",",
"mapping",
")"
] | Return a copy | [
"Return",
"a",
"copy"
] | python | train | 38.25 |
inveniosoftware/invenio-records-files | invenio_records_files/api.py | https://github.com/inveniosoftware/invenio-records-files/blob/c410eba986ea43be7e97082d5dcbbdc19ccec39c/invenio_records_files/api.py#L195-L218 | def rename(self, old_key, new_key):
"""Rename a file.
:param old_key: Old key that holds the object.
:param new_key: New key that will hold the object.
:returns: The object that has been renamed.
"""
assert new_key not in self
assert old_key != new_key
f... | [
"def",
"rename",
"(",
"self",
",",
"old_key",
",",
"new_key",
")",
":",
"assert",
"new_key",
"not",
"in",
"self",
"assert",
"old_key",
"!=",
"new_key",
"file_",
"=",
"self",
"[",
"old_key",
"]",
"old_data",
"=",
"self",
".",
"filesmap",
"[",
"old_key",
... | Rename a file.
:param old_key: Old key that holds the object.
:param new_key: New key that will hold the object.
:returns: The object that has been renamed. | [
"Rename",
"a",
"file",
"."
] | python | train | 28.375 |
bird-house/twitcher | twitcher/tweens.py | https://github.com/bird-house/twitcher/blob/e6a36b3aeeacf44eec537434b0fb87c09ab54b5f/twitcher/tweens.py#L19-L36 | def ows_security_tween_factory(handler, registry):
"""A tween factory which produces a tween which raises an exception
if access to OWS service is not allowed."""
security = owssecurity_factory(registry)
def ows_security_tween(request):
try:
security.check_request(request)
... | [
"def",
"ows_security_tween_factory",
"(",
"handler",
",",
"registry",
")",
":",
"security",
"=",
"owssecurity_factory",
"(",
"registry",
")",
"def",
"ows_security_tween",
"(",
"request",
")",
":",
"try",
":",
"security",
".",
"check_request",
"(",
"request",
")"... | A tween factory which produces a tween which raises an exception
if access to OWS service is not allowed. | [
"A",
"tween",
"factory",
"which",
"produces",
"a",
"tween",
"which",
"raises",
"an",
"exception",
"if",
"access",
"to",
"OWS",
"service",
"is",
"not",
"allowed",
"."
] | python | valid | 33.944444 |
memsql/memsql-python | memsql/common/connection_pool.py | https://github.com/memsql/memsql-python/blob/aac223a1b937d5b348b42af3c601a6c685ca633a/memsql/common/connection_pool.py#L134-L147 | def __potential_connection_failure(self, e):
""" OperationalError's are emitted by the _mysql library for
almost every error code emitted by MySQL. Because of this we
verify that the error is actually a connection error before
terminating the connection and firing off a PoolConnectionEx... | [
"def",
"__potential_connection_failure",
"(",
"self",
",",
"e",
")",
":",
"try",
":",
"self",
".",
"_conn",
".",
"query",
"(",
"'SELECT 1'",
")",
"except",
"(",
"IOError",
",",
"_mysql",
".",
"OperationalError",
")",
":",
"# ok, it's actually an issue.",
"self... | OperationalError's are emitted by the _mysql library for
almost every error code emitted by MySQL. Because of this we
verify that the error is actually a connection error before
terminating the connection and firing off a PoolConnectionException | [
"OperationalError",
"s",
"are",
"emitted",
"by",
"the",
"_mysql",
"library",
"for",
"almost",
"every",
"error",
"code",
"emitted",
"by",
"MySQL",
".",
"Because",
"of",
"this",
"we",
"verify",
"that",
"the",
"error",
"is",
"actually",
"a",
"connection",
"erro... | python | test | 45.214286 |
pypa/warehouse | warehouse/cli/db/current.py | https://github.com/pypa/warehouse/blob/396e77a0caf6efeccb5a5f86e2c8a27e575bf86d/warehouse/cli/db/current.py#L21-L28 | def current(config, **kwargs):
"""
Display the current revision for a database.
"""
with alembic_lock(
config.registry["sqlalchemy.engine"], config.alembic_config()
) as alembic_config:
alembic.command.current(alembic_config, **kwargs) | [
"def",
"current",
"(",
"config",
",",
"*",
"*",
"kwargs",
")",
":",
"with",
"alembic_lock",
"(",
"config",
".",
"registry",
"[",
"\"sqlalchemy.engine\"",
"]",
",",
"config",
".",
"alembic_config",
"(",
")",
")",
"as",
"alembic_config",
":",
"alembic",
".",... | Display the current revision for a database. | [
"Display",
"the",
"current",
"revision",
"for",
"a",
"database",
"."
] | python | train | 33 |
un33k/django-toolware | toolware/utils/generic.py | https://github.com/un33k/django-toolware/blob/973f3e003dc38b812897dab88455bee37dcaf931/toolware/utils/generic.py#L71-L78 | def get_encoded_url_to_dict(string):
"""
Converts an encoded URL to a dict.
Example: given string = 'a=1&b=2' it returns {'a': 1, 'b': 2}
"""
data = urllib.parse.parse_qsl(string, keep_blank_values=True)
data = dict(data)
return data | [
"def",
"get_encoded_url_to_dict",
"(",
"string",
")",
":",
"data",
"=",
"urllib",
".",
"parse",
".",
"parse_qsl",
"(",
"string",
",",
"keep_blank_values",
"=",
"True",
")",
"data",
"=",
"dict",
"(",
"data",
")",
"return",
"data"
] | Converts an encoded URL to a dict.
Example: given string = 'a=1&b=2' it returns {'a': 1, 'b': 2} | [
"Converts",
"an",
"encoded",
"URL",
"to",
"a",
"dict",
".",
"Example",
":",
"given",
"string",
"=",
"a",
"=",
"1&b",
"=",
"2",
"it",
"returns",
"{",
"a",
":",
"1",
"b",
":",
"2",
"}"
] | python | test | 31.75 |
Qiskit/qiskit-terra | qiskit/extensions/standard/ccx.py | https://github.com/Qiskit/qiskit-terra/blob/d4f58d903bc96341b816f7c35df936d6421267d1/qiskit/extensions/standard/ccx.py#L82-L84 | def ccx(self, ctl1, ctl2, tgt):
"""Apply Toffoli to from ctl1 and ctl2 to tgt."""
return self.append(ToffoliGate(), [ctl1, ctl2, tgt], []) | [
"def",
"ccx",
"(",
"self",
",",
"ctl1",
",",
"ctl2",
",",
"tgt",
")",
":",
"return",
"self",
".",
"append",
"(",
"ToffoliGate",
"(",
")",
",",
"[",
"ctl1",
",",
"ctl2",
",",
"tgt",
"]",
",",
"[",
"]",
")"
] | Apply Toffoli to from ctl1 and ctl2 to tgt. | [
"Apply",
"Toffoli",
"to",
"from",
"ctl1",
"and",
"ctl2",
"to",
"tgt",
"."
] | python | test | 48 |
not-na/peng3d | peng3d/keybind.py | https://github.com/not-na/peng3d/blob/1151be665b26cc8a479f6307086ba919e4d32d85/peng3d/keybind.py#L173-L201 | def handle_combo(self,combo,symbol,modifiers,release=False,mod=True):
"""
Handles a key combination and dispatches associated events.
First, all keybind handlers registered via :py:meth:`add` will be handled,
then the pyglet event :peng3d:pgevent:`on_key_combo` with params ``(co... | [
"def",
"handle_combo",
"(",
"self",
",",
"combo",
",",
"symbol",
",",
"modifiers",
",",
"release",
"=",
"False",
",",
"mod",
"=",
"True",
")",
":",
"if",
"self",
".",
"peng",
".",
"cfg",
"[",
"\"controls.keybinds.debug\"",
"]",
":",
"print",
"(",
"\"co... | Handles a key combination and dispatches associated events.
First, all keybind handlers registered via :py:meth:`add` will be handled,
then the pyglet event :peng3d:pgevent:`on_key_combo` with params ``(combo,symbol,modifiers,release,mod)`` is sent to the :py:class:`Peng()` instance.
... | [
"Handles",
"a",
"key",
"combination",
"and",
"dispatches",
"associated",
"events",
".",
"First",
"all",
"keybind",
"handlers",
"registered",
"via",
":",
"py",
":",
"meth",
":",
"add",
"will",
"be",
"handled",
"then",
"the",
"pyglet",
"event",
":",
"peng3d",
... | python | test | 63.931034 |
acutesoftware/AIKIF | scripts/examples/finance_example.py | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/scripts/examples/finance_example.py#L25-L61 | def main():
"""
This is the main body of the process that does the work.
Summary:
- load the raw data
- read in rules list
- create log events for AIKIF according to rules [map]
- create new facts / reports based on rules [report]
OUTPUT =
AIKIF mapping : Date_of_... | [
"def",
"main",
"(",
")",
":",
"print",
"(",
"'AIKIF example: Processing Finance data\\n'",
")",
"data",
"=",
"read_bank_statements",
"(",
"'your_statement.csv'",
")",
"print",
"(",
"data",
")",
"maps",
"=",
"load_column_maps",
"(",
")",
"rules",
"=",
"load_rules",... | This is the main body of the process that does the work.
Summary:
- load the raw data
- read in rules list
- create log events for AIKIF according to rules [map]
- create new facts / reports based on rules [report]
OUTPUT =
AIKIF mapping : Date_of_transaction => event
... | [
"This",
"is",
"the",
"main",
"body",
"of",
"the",
"process",
"that",
"does",
"the",
"work",
"."
] | python | train | 31.837838 |
ozgurgunes/django-manifest | manifest/accounts/utils.py | https://github.com/ozgurgunes/django-manifest/blob/9873bbf2a475b76284ad7e36b2b26c92131e72dd/manifest/accounts/utils.py#L113-L127 | def get_datetime_now():
"""
Returns datetime object with current point in time.
In Django 1.4+ it uses Django's django.utils.timezone.now() which returns
an aware or naive datetime that represents the current point in time
when ``USE_TZ`` in project's settings is True or False respectively.
In ... | [
"def",
"get_datetime_now",
"(",
")",
":",
"try",
":",
"from",
"django",
".",
"utils",
"import",
"timezone",
"return",
"timezone",
".",
"now",
"(",
")",
"except",
"ImportError",
":",
"return",
"datetime",
".",
"datetime",
".",
"now",
"(",
")"
] | Returns datetime object with current point in time.
In Django 1.4+ it uses Django's django.utils.timezone.now() which returns
an aware or naive datetime that represents the current point in time
when ``USE_TZ`` in project's settings is True or False respectively.
In older versions of Django it uses dat... | [
"Returns",
"datetime",
"object",
"with",
"current",
"point",
"in",
"time",
"."
] | python | train | 34.4 |
CellProfiler/centrosome | centrosome/cpmorphology.py | https://github.com/CellProfiler/centrosome/blob/7bd9350a2d4ae1b215b81eabcecfe560bbb1f32a/centrosome/cpmorphology.py#L889-L915 | def triangle_areas(p1,p2,p3):
"""Compute an array of triangle areas given three arrays of triangle pts
p1,p2,p3 - three Nx2 arrays of points
"""
v1 = (p2 - p1).astype(np.float)
v2 = (p3 - p1).astype(np.float)
# Original:
# cross1 = v1[:,1] * v2[:,0]
# cross2 = v2[:,1] * v1[:,0]
... | [
"def",
"triangle_areas",
"(",
"p1",
",",
"p2",
",",
"p3",
")",
":",
"v1",
"=",
"(",
"p2",
"-",
"p1",
")",
".",
"astype",
"(",
"np",
".",
"float",
")",
"v2",
"=",
"(",
"p3",
"-",
"p1",
")",
".",
"astype",
"(",
"np",
".",
"float",
")",
"# Ori... | Compute an array of triangle areas given three arrays of triangle pts
p1,p2,p3 - three Nx2 arrays of points | [
"Compute",
"an",
"array",
"of",
"triangle",
"areas",
"given",
"three",
"arrays",
"of",
"triangle",
"pts",
"p1",
"p2",
"p3",
"-",
"three",
"Nx2",
"arrays",
"of",
"points"
] | python | train | 25.481481 |
Exanis/django-rest-generators | django_rest_generators/steps/http.py | https://github.com/Exanis/django-rest-generators/blob/fb14ccbba8cb029dc056d852bc13d9216dc924e4/django_rest_generators/steps/http.py#L33-L45 | def when_i_send_the_request(context, method):
"""
:type method: str
:type context: behave.runner.Context
"""
data = context.apiRequestData
context.apiRequest = context.apiClient.generic(
method,
data['url'],
data=json.dumps(data['params']),
content_type=... | [
"def",
"when_i_send_the_request",
"(",
"context",
",",
"method",
")",
":",
"data",
"=",
"context",
".",
"apiRequestData",
"context",
".",
"apiRequest",
"=",
"context",
".",
"apiClient",
".",
"generic",
"(",
"method",
",",
"data",
"[",
"'url'",
"]",
",",
"d... | :type method: str
:type context: behave.runner.Context | [
":",
"type",
"method",
":",
"str",
":",
"type",
"context",
":",
"behave",
".",
"runner",
".",
"Context"
] | python | train | 28.307692 |
bfontaine/crosswords | crosswords/dictionnaries.py | https://github.com/bfontaine/crosswords/blob/042b3cdd00a59d193ee559368910a8faa54565f5/crosswords/dictionnaries.py#L20-L41 | def sanitize_word(word):
"""
sanitize a word by removing its accents, special characters, etc
"""
# use an unicode string for `unidecode`
if type(word) == str:
try:
word = word.decode()
except AttributeError:
pass # Python3
# remove trailing spaces
w... | [
"def",
"sanitize_word",
"(",
"word",
")",
":",
"# use an unicode string for `unidecode`",
"if",
"type",
"(",
"word",
")",
"==",
"str",
":",
"try",
":",
"word",
"=",
"word",
".",
"decode",
"(",
")",
"except",
"AttributeError",
":",
"pass",
"# Python3",
"# rem... | sanitize a word by removing its accents, special characters, etc | [
"sanitize",
"a",
"word",
"by",
"removing",
"its",
"accents",
"special",
"characters",
"etc"
] | python | train | 25.090909 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.