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 |
|---|---|---|---|---|---|---|---|---|---|
zhebrak/raftos | raftos/state.py | https://github.com/zhebrak/raftos/blob/0d6f9e049b526279b1035f597291a96cf50c9b40/raftos/state.py#L597-L601 | async def wait_for_election_success(cls):
"""Await this function if your cluster must have a leader"""
if cls.leader is None:
cls.leader_future = asyncio.Future(loop=cls.loop)
await cls.leader_future | [
"async",
"def",
"wait_for_election_success",
"(",
"cls",
")",
":",
"if",
"cls",
".",
"leader",
"is",
"None",
":",
"cls",
".",
"leader_future",
"=",
"asyncio",
".",
"Future",
"(",
"loop",
"=",
"cls",
".",
"loop",
")",
"await",
"cls",
".",
"leader_future"
... | Await this function if your cluster must have a leader | [
"Await",
"this",
"function",
"if",
"your",
"cluster",
"must",
"have",
"a",
"leader"
] | python | train | 47 |
mitsei/dlkit | dlkit/json_/repository/sessions.py | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/repository/sessions.py#L5273-L5298 | def alias_repository(self, repository_id, alias_id):
"""Adds an ``Id`` to a ``Repository`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Repository`` is determined by the
provider. The new ``Id`` is an alias to the primary ``Id``. If
the alias is a pointer to an... | [
"def",
"alias_repository",
"(",
"self",
",",
"repository_id",
",",
"alias_id",
")",
":",
"# Implemented from template for",
"# osid.resource.BinLookupSession.alias_bin_template",
"if",
"self",
".",
"_catalog_session",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_c... | Adds an ``Id`` to a ``Repository`` for the purpose of creating compatibility.
The primary ``Id`` of the ``Repository`` is determined by the
provider. The new ``Id`` is an alias to the primary ``Id``. If
the alias is a pointer to another repository, it is reassigned
to the given reposito... | [
"Adds",
"an",
"Id",
"to",
"a",
"Repository",
"for",
"the",
"purpose",
"of",
"creating",
"compatibility",
"."
] | python | train | 49 |
Netflix-Skunkworks/cloudaux | cloudaux/orchestration/aws/iam/group.py | https://github.com/Netflix-Skunkworks/cloudaux/blob/c4b0870c3ac68b1c69e71d33cf78b6a8bdf437ea/cloudaux/orchestration/aws/iam/group.py#L36-L45 | def get_managed_policies(group, **conn):
"""Get a list of the managed policy names that are attached to the group."""
managed_policies = list_attached_group_managed_policies(group['GroupName'], **conn)
managed_policy_names = []
for policy in managed_policies:
managed_policy_names.append(policy... | [
"def",
"get_managed_policies",
"(",
"group",
",",
"*",
"*",
"conn",
")",
":",
"managed_policies",
"=",
"list_attached_group_managed_policies",
"(",
"group",
"[",
"'GroupName'",
"]",
",",
"*",
"*",
"conn",
")",
"managed_policy_names",
"=",
"[",
"]",
"for",
"pol... | Get a list of the managed policy names that are attached to the group. | [
"Get",
"a",
"list",
"of",
"the",
"managed",
"policy",
"names",
"that",
"are",
"attached",
"to",
"the",
"group",
"."
] | python | valid | 35.9 |
bububa/pyTOP | pyTOP/logistics.py | https://github.com/bububa/pyTOP/blob/1e48009bcfe886be392628244b370e6374e1f2b2/pyTOP/logistics.py#L73-L80 | def delete(self, template_id, session):
'''taobao.delivery.template.delete 删除运费模板
根据用户指定的模板ID删除指定的模板'''
request = TOPRequest('taobao.delivery.template.delete')
request['template_id'] = template_id
self.create(self.execute(request, session), fields=['complete', ])
... | [
"def",
"delete",
"(",
"self",
",",
"template_id",
",",
"session",
")",
":",
"request",
"=",
"TOPRequest",
"(",
"'taobao.delivery.template.delete'",
")",
"request",
"[",
"'template_id'",
"]",
"=",
"template_id",
"self",
".",
"create",
"(",
"self",
".",
"execute... | taobao.delivery.template.delete 删除运费模板
根据用户指定的模板ID删除指定的模板 | [
"taobao",
".",
"delivery",
".",
"template",
".",
"delete",
"删除运费模板",
"根据用户指定的模板ID删除指定的模板"
] | python | train | 41.75 |
PmagPy/PmagPy | pmagpy/builder2.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/builder2.py#L1600-L1609 | def set_parent(self, new_site):
"""
Set self.site as either an empty string, or with a new Site.
"""
if new_site:
if not isinstance(new_site, Site):
raise Exception
self.site = new_site
self.propagate_data()
return new_site | [
"def",
"set_parent",
"(",
"self",
",",
"new_site",
")",
":",
"if",
"new_site",
":",
"if",
"not",
"isinstance",
"(",
"new_site",
",",
"Site",
")",
":",
"raise",
"Exception",
"self",
".",
"site",
"=",
"new_site",
"self",
".",
"propagate_data",
"(",
")",
... | Set self.site as either an empty string, or with a new Site. | [
"Set",
"self",
".",
"site",
"as",
"either",
"an",
"empty",
"string",
"or",
"with",
"a",
"new",
"Site",
"."
] | python | train | 29.8 |
PmagPy/PmagPy | pmagpy/contribution_builder.py | https://github.com/PmagPy/PmagPy/blob/c7984f8809bf40fe112e53dcc311a33293b62d0b/pmagpy/contribution_builder.py#L1635-L1644 | def add_blank_row(self, label):
"""
Add a blank row with only an index value to self.df.
This is done inplace.
"""
col_labels = self.df.columns
blank_item = pd.Series({}, index=col_labels, name=label)
# use .loc to add in place (append won't do that)
self.... | [
"def",
"add_blank_row",
"(",
"self",
",",
"label",
")",
":",
"col_labels",
"=",
"self",
".",
"df",
".",
"columns",
"blank_item",
"=",
"pd",
".",
"Series",
"(",
"{",
"}",
",",
"index",
"=",
"col_labels",
",",
"name",
"=",
"label",
")",
"# use .loc to ad... | Add a blank row with only an index value to self.df.
This is done inplace. | [
"Add",
"a",
"blank",
"row",
"with",
"only",
"an",
"index",
"value",
"to",
"self",
".",
"df",
".",
"This",
"is",
"done",
"inplace",
"."
] | python | train | 37 |
NatLibFi/Skosify | skosify/check.py | https://github.com/NatLibFi/Skosify/blob/1d269987f10df08e706272dcf6a86aef4abebcde/skosify/check.py#L37-L58 | def hierarchy_cycles(rdf, fix=False):
"""Check if the graph contains skos:broader cycles and optionally break these.
:param Graph rdf: An rdflib.graph.Graph object.
:param bool fix: Fix the problem by removing any skos:broader that overlaps
with skos:broaderTransitive.
"""
top_concepts = so... | [
"def",
"hierarchy_cycles",
"(",
"rdf",
",",
"fix",
"=",
"False",
")",
":",
"top_concepts",
"=",
"sorted",
"(",
"rdf",
".",
"subject_objects",
"(",
"SKOS",
".",
"hasTopConcept",
")",
")",
"status",
"=",
"{",
"}",
"for",
"cs",
",",
"root",
"in",
"top_con... | Check if the graph contains skos:broader cycles and optionally break these.
:param Graph rdf: An rdflib.graph.Graph object.
:param bool fix: Fix the problem by removing any skos:broader that overlaps
with skos:broaderTransitive. | [
"Check",
"if",
"the",
"graph",
"contains",
"skos",
":",
"broader",
"cycles",
"and",
"optionally",
"break",
"these",
"."
] | python | train | 40.136364 |
cabalgata/cabalgata-silla-de-montar | cabalgata/silla/util/disk.py | https://github.com/cabalgata/cabalgata-silla-de-montar/blob/6f1de56f207e55d788d56636f623c0e3ce1aa750/cabalgata/silla/util/disk.py#L27-L36 | def temp_directory(*args, **kwargs):
"""
Context manager returns a path created by mkdtemp and cleans it up afterwards.
"""
path = tempfile.mkdtemp(*args, **kwargs)
try:
yield path
finally:
shutil.rmtree(path) | [
"def",
"temp_directory",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"path",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"try",
":",
"yield",
"path",
"finally",
":",
"shutil",
".",
"rmtree",
"(",
"path"... | Context manager returns a path created by mkdtemp and cleans it up afterwards. | [
"Context",
"manager",
"returns",
"a",
"path",
"created",
"by",
"mkdtemp",
"and",
"cleans",
"it",
"up",
"afterwards",
"."
] | python | train | 24.1 |
klen/adrest | adrest/views.py | https://github.com/klen/adrest/blob/8b75c67123cffabe5ed98c222bb7ab43c904d89c/adrest/views.py#L232-L246 | def as_url(cls, api=None, name_prefix='', url_prefix=''):
""" Generate url for resource.
:return RegexURLPattern: Django URL
"""
url_prefix = url_prefix and "%s/" % url_prefix
name_prefix = name_prefix and "%s-" % name_prefix
url_regex = '^%s%s/?$' % (
url_... | [
"def",
"as_url",
"(",
"cls",
",",
"api",
"=",
"None",
",",
"name_prefix",
"=",
"''",
",",
"url_prefix",
"=",
"''",
")",
":",
"url_prefix",
"=",
"url_prefix",
"and",
"\"%s/\"",
"%",
"url_prefix",
"name_prefix",
"=",
"name_prefix",
"and",
"\"%s-\"",
"%",
"... | Generate url for resource.
:return RegexURLPattern: Django URL | [
"Generate",
"url",
"for",
"resource",
"."
] | python | train | 35.866667 |
ska-sa/spead2 | spead2/__init__.py | https://github.com/ska-sa/spead2/blob/cac95fd01d8debaa302d2691bd26da64b7828bc6/spead2/__init__.py#L81-L97 | def parse_range_list(ranges):
"""Split a string like 2,3-5,8,9-11 into a list of integers. This is
intended to ease adding command-line options for dealing with affinity.
"""
if not ranges:
return []
parts = ranges.split(',')
out = []
for part in parts:
fields = part.split('-... | [
"def",
"parse_range_list",
"(",
"ranges",
")",
":",
"if",
"not",
"ranges",
":",
"return",
"[",
"]",
"parts",
"=",
"ranges",
".",
"split",
"(",
"','",
")",
"out",
"=",
"[",
"]",
"for",
"part",
"in",
"parts",
":",
"fields",
"=",
"part",
".",
"split",... | Split a string like 2,3-5,8,9-11 into a list of integers. This is
intended to ease adding command-line options for dealing with affinity. | [
"Split",
"a",
"string",
"like",
"2",
"3",
"-",
"5",
"8",
"9",
"-",
"11",
"into",
"a",
"list",
"of",
"integers",
".",
"This",
"is",
"intended",
"to",
"ease",
"adding",
"command",
"-",
"line",
"options",
"for",
"dealing",
"with",
"affinity",
"."
] | python | train | 30.588235 |
saltstack/salt | salt/modules/hosts.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/hosts.py#L157-L212 | def set_host(ip, alias):
'''
Set the host entry in the hosts file for the given ip, this will overwrite
any previous entry for the given ip
.. versionchanged:: 2016.3.0
If ``alias`` does not include any host names (it is the empty
string or contains only whitespace), all entries for the... | [
"def",
"set_host",
"(",
"ip",
",",
"alias",
")",
":",
"hfn",
"=",
"_get_or_create_hostfile",
"(",
")",
"ovr",
"=",
"False",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"hfn",
")",
":",
"return",
"False",
"# Make sure future calls to _list_hosts() wil... | Set the host entry in the hosts file for the given ip, this will overwrite
any previous entry for the given ip
.. versionchanged:: 2016.3.0
If ``alias`` does not include any host names (it is the empty
string or contains only whitespace), all entries for the given
IP address are removed... | [
"Set",
"the",
"host",
"entry",
"in",
"the",
"hosts",
"file",
"for",
"the",
"given",
"ip",
"this",
"will",
"overwrite",
"any",
"previous",
"entry",
"for",
"the",
"given",
"ip"
] | python | train | 30.892857 |
django-fluent/django-fluent-dashboard | fluent_dashboard/items.py | https://github.com/django-fluent/django-fluent-dashboard/blob/aee7ef39e0586cd160036b13b7944b69cd2b4b8c/fluent_dashboard/items.py#L27-L50 | def init_with_context(self, context):
"""
Initialize the menu.
"""
# Apply the include/exclude patterns:
listitems = self._visible_models(context['request'])
# Convert to a similar data structure like the dashboard icons have.
# This allows sorting the items iden... | [
"def",
"init_with_context",
"(",
"self",
",",
"context",
")",
":",
"# Apply the include/exclude patterns:",
"listitems",
"=",
"self",
".",
"_visible_models",
"(",
"context",
"[",
"'request'",
"]",
")",
"# Convert to a similar data structure like the dashboard icons have.",
... | Initialize the menu. | [
"Initialize",
"the",
"menu",
"."
] | python | train | 35.5 |
aisthesis/pynance | pynance/pf.py | https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/pf.py#L13-L69 | def optimize(exp_rets, covs):
"""
Return parameters for portfolio optimization.
Parameters
----------
exp_rets : ndarray
Vector of expected returns for each investment..
covs : ndarray
Covariance matrix for the given investments.
Returns
---------
a : ndarray
... | [
"def",
"optimize",
"(",
"exp_rets",
",",
"covs",
")",
":",
"_cov_inv",
"=",
"np",
".",
"linalg",
".",
"inv",
"(",
"covs",
")",
"# unit vector",
"_u",
"=",
"np",
".",
"ones",
"(",
"(",
"len",
"(",
"exp_rets",
")",
")",
")",
"# compute some dot products ... | Return parameters for portfolio optimization.
Parameters
----------
exp_rets : ndarray
Vector of expected returns for each investment..
covs : ndarray
Covariance matrix for the given investments.
Returns
---------
a : ndarray
The first vector (to be combined with ta... | [
"Return",
"parameters",
"for",
"portfolio",
"optimization",
"."
] | python | train | 33.894737 |
cjdrake/pyeda | pyeda/boolalg/bdd.py | https://github.com/cjdrake/pyeda/blob/554ee53aa678f4b61bcd7e07ba2c74ddc749d665/pyeda/boolalg/bdd.py#L456-L480 | def _ite(f, g, h):
"""Return node that results from recursively applying ITE(f, g, h)."""
# ITE(f, 1, 0) = f
if g is BDDNODEONE and h is BDDNODEZERO:
return f
# ITE(f, 0, 1) = f'
elif g is BDDNODEZERO and h is BDDNODEONE:
return _neg(f)
# ITE(1, g, h) = g
elif f is BDDNODEONE... | [
"def",
"_ite",
"(",
"f",
",",
"g",
",",
"h",
")",
":",
"# ITE(f, 1, 0) = f",
"if",
"g",
"is",
"BDDNODEONE",
"and",
"h",
"is",
"BDDNODEZERO",
":",
"return",
"f",
"# ITE(f, 0, 1) = f'",
"elif",
"g",
"is",
"BDDNODEZERO",
"and",
"h",
"is",
"BDDNODEONE",
":",... | Return node that results from recursively applying ITE(f, g, h). | [
"Return",
"node",
"that",
"results",
"from",
"recursively",
"applying",
"ITE",
"(",
"f",
"g",
"h",
")",
"."
] | python | train | 35.16 |
kubernetes-client/python | kubernetes/client/apis/storage_v1beta1_api.py | https://github.com/kubernetes-client/python/blob/5e512ff564c244c50cab780d821542ed56aa965a/kubernetes/client/apis/storage_v1beta1_api.py#L2914-L2937 | def replace_csi_driver(self, name, body, **kwargs):
"""
replace the specified CSIDriver
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_csi_driver(name, body, async_req=True)
... | [
"def",
"replace_csi_driver",
"(",
"self",
",",
"name",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"replace_... | replace the specified CSIDriver
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_csi_driver(name, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:para... | [
"replace",
"the",
"specified",
"CSIDriver",
"This",
"method",
"makes",
"a",
"synchronous",
"HTTP",
"request",
"by",
"default",
".",
"To",
"make",
"an",
"asynchronous",
"HTTP",
"request",
"please",
"pass",
"async_req",
"=",
"True",
">>>",
"thread",
"=",
"api",
... | python | train | 63.041667 |
secdev/scapy | scapy/data.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/data.py#L269-L288 | def load_manuf(filename):
"""Load manuf file from Wireshark.
param:
- filename: the file to load the manuf file from"""
manufdb = ManufDA(_name=filename)
with open(filename, "rb") as fdesc:
for line in fdesc:
try:
line = line.strip()
if not line o... | [
"def",
"load_manuf",
"(",
"filename",
")",
":",
"manufdb",
"=",
"ManufDA",
"(",
"_name",
"=",
"filename",
")",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"fdesc",
":",
"for",
"line",
"in",
"fdesc",
":",
"try",
":",
"line",
"=",
"line"... | Load manuf file from Wireshark.
param:
- filename: the file to load the manuf file from | [
"Load",
"manuf",
"file",
"from",
"Wireshark",
".",
"param",
":",
"-",
"filename",
":",
"the",
"file",
"to",
"load",
"the",
"manuf",
"file",
"from"
] | python | train | 40.25 |
fy0/slim | slim/utils/__init__.py | https://github.com/fy0/slim/blob/9951a910750888dbe7dd3e98acae9c40efae0689/slim/utils/__init__.py#L44-L51 | def get_bytes_from_blob(val) -> bytes:
""" 不同数据库从blob拿出的数据有所差别,有的是memoryview有的是bytes """
if isinstance(val, bytes):
return val
elif isinstance(val, memoryview):
return val.tobytes()
else:
raise TypeError('invalid type for get bytes') | [
"def",
"get_bytes_from_blob",
"(",
"val",
")",
"->",
"bytes",
":",
"if",
"isinstance",
"(",
"val",
",",
"bytes",
")",
":",
"return",
"val",
"elif",
"isinstance",
"(",
"val",
",",
"memoryview",
")",
":",
"return",
"val",
".",
"tobytes",
"(",
")",
"else"... | 不同数据库从blob拿出的数据有所差别,有的是memoryview有的是bytes | [
"不同数据库从blob拿出的数据有所差别,有的是memoryview有的是bytes"
] | python | valid | 33.25 |
eonpatapon/contrail-api-cli | contrail_api_cli/resource.py | https://github.com/eonpatapon/contrail-api-cli/blob/1571bf523fa054f3d6bf83dba43a224fea173a73/contrail_api_cli/resource.py#L550-L560 | def parent(self, resource):
"""Set parent resource
:param resource: parent resource
:type resource: Resource
:raises ResourceNotFound: resource not found on the API
"""
resource.check()
self['parent_type'] = resource.type
self['parent_uuid'] = resource.u... | [
"def",
"parent",
"(",
"self",
",",
"resource",
")",
":",
"resource",
".",
"check",
"(",
")",
"self",
"[",
"'parent_type'",
"]",
"=",
"resource",
".",
"type",
"self",
"[",
"'parent_uuid'",
"]",
"=",
"resource",
".",
"uuid"
] | Set parent resource
:param resource: parent resource
:type resource: Resource
:raises ResourceNotFound: resource not found on the API | [
"Set",
"parent",
"resource"
] | python | train | 28.454545 |
pyQode/pyqode.core | pyqode/core/widgets/_pty.py | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/widgets/_pty.py#L129-L148 | def _copy(master_fd, master_read=_read, stdin_read=_read):
"""Parent copy loop.
Copies
pty master -> standard output (master_read)
standard input -> pty master (stdin_read)"""
fds = [master_fd, STDIN_FILENO]
while True:
rfds, wfds, xfds = select(fds, [], [])
... | [
"def",
"_copy",
"(",
"master_fd",
",",
"master_read",
"=",
"_read",
",",
"stdin_read",
"=",
"_read",
")",
":",
"fds",
"=",
"[",
"master_fd",
",",
"STDIN_FILENO",
"]",
"while",
"True",
":",
"rfds",
",",
"wfds",
",",
"xfds",
"=",
"select",
"(",
"fds",
... | Parent copy loop.
Copies
pty master -> standard output (master_read)
standard input -> pty master (stdin_read) | [
"Parent",
"copy",
"loop",
".",
"Copies",
"pty",
"master",
"-",
">",
"standard",
"output",
"(",
"master_read",
")",
"standard",
"input",
"-",
">",
"pty",
"master",
"(",
"stdin_read",
")"
] | python | train | 34.7 |
tensorflow/datasets | tensorflow_datasets/image/image_folder.py | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/image_folder.py#L156-L164 | def _generate_examples(self, label_images):
"""Generate example for each image in the dict."""
for label, image_paths in label_images.items():
for image_path in image_paths:
yield {
"image": image_path,
"label": label,
} | [
"def",
"_generate_examples",
"(",
"self",
",",
"label_images",
")",
":",
"for",
"label",
",",
"image_paths",
"in",
"label_images",
".",
"items",
"(",
")",
":",
"for",
"image_path",
"in",
"image_paths",
":",
"yield",
"{",
"\"image\"",
":",
"image_path",
",",
... | Generate example for each image in the dict. | [
"Generate",
"example",
"for",
"each",
"image",
"in",
"the",
"dict",
"."
] | python | train | 29.666667 |
gabstopper/smc-python | smc/core/node.py | https://github.com/gabstopper/smc-python/blob/e027b8a5dcfaf884eada32d113d41c1e56b32457/smc/core/node.py#L132-L145 | def bind_license(self, license_item_id=None):
"""
Auto bind license, uses dynamic if POS is not found
:param str license_item_id: license id
:raises LicenseError: binding license failed, possibly no licenses
:return: None
"""
params = {'license_item_id': license_... | [
"def",
"bind_license",
"(",
"self",
",",
"license_item_id",
"=",
"None",
")",
":",
"params",
"=",
"{",
"'license_item_id'",
":",
"license_item_id",
"}",
"self",
".",
"make_request",
"(",
"LicenseError",
",",
"method",
"=",
"'create'",
",",
"resource",
"=",
"... | Auto bind license, uses dynamic if POS is not found
:param str license_item_id: license id
:raises LicenseError: binding license failed, possibly no licenses
:return: None | [
"Auto",
"bind",
"license",
"uses",
"dynamic",
"if",
"POS",
"is",
"not",
"found"
] | python | train | 32.357143 |
cloud9ers/gurumate | environment/lib/python2.7/site-packages/IPython/lib/pretty.py | https://github.com/cloud9ers/gurumate/blob/075dc74d1ee62a8c6b7a8bf2b271364f01629d1e/environment/lib/python2.7/site-packages/IPython/lib/pretty.py#L568-L575 | def _super_pprint(obj, p, cycle):
"""The pprint for the super type."""
p.begin_group(8, '<super: ')
p.pretty(obj.__self_class__)
p.text(',')
p.breakable()
p.pretty(obj.__self__)
p.end_group(8, '>') | [
"def",
"_super_pprint",
"(",
"obj",
",",
"p",
",",
"cycle",
")",
":",
"p",
".",
"begin_group",
"(",
"8",
",",
"'<super: '",
")",
"p",
".",
"pretty",
"(",
"obj",
".",
"__self_class__",
")",
"p",
".",
"text",
"(",
"','",
")",
"p",
".",
"breakable",
... | The pprint for the super type. | [
"The",
"pprint",
"for",
"the",
"super",
"type",
"."
] | python | test | 27.25 |
secdev/scapy | scapy/layers/ipsec.py | https://github.com/secdev/scapy/blob/3ffe757c184017dd46464593a8f80f85abc1e79a/scapy/layers/ipsec.py#L341-L366 | def encrypt(self, sa, esp, key):
"""
Encrypt an ESP packet
@param sa: the SecurityAssociation associated with the ESP packet.
@param esp: an unencrypted _ESPPlain packet with valid padding
@param key: the secret key used for encryption
@return: a valid ESP packet... | [
"def",
"encrypt",
"(",
"self",
",",
"sa",
",",
"esp",
",",
"key",
")",
":",
"data",
"=",
"esp",
".",
"data_for_encryption",
"(",
")",
"if",
"self",
".",
"cipher",
":",
"mode_iv",
"=",
"self",
".",
"_format_mode_iv",
"(",
"algo",
"=",
"self",
",",
"... | Encrypt an ESP packet
@param sa: the SecurityAssociation associated with the ESP packet.
@param esp: an unencrypted _ESPPlain packet with valid padding
@param key: the secret key used for encryption
@return: a valid ESP packet encrypted with this algorithm | [
"Encrypt",
"an",
"ESP",
"packet"
] | python | train | 38.230769 |
goerz/clusterjob | clusterjob/backends/slurm.py | https://github.com/goerz/clusterjob/blob/361760d1a6dd3cbde49c5c2158a3acd0c314a749/clusterjob/backends/slurm.py#L93-L99 | def get_status(self, response, finished=False):
"""Given the stdout from the command returned by :meth:`cmd_status`,
return one of the status code defined in :mod:`clusterjob.status`"""
for line in response.split("\n"):
if line.strip() in self.status_mapping:
return s... | [
"def",
"get_status",
"(",
"self",
",",
"response",
",",
"finished",
"=",
"False",
")",
":",
"for",
"line",
"in",
"response",
".",
"split",
"(",
"\"\\n\"",
")",
":",
"if",
"line",
".",
"strip",
"(",
")",
"in",
"self",
".",
"status_mapping",
":",
"retu... | Given the stdout from the command returned by :meth:`cmd_status`,
return one of the status code defined in :mod:`clusterjob.status` | [
"Given",
"the",
"stdout",
"from",
"the",
"command",
"returned",
"by",
":",
"meth",
":",
"cmd_status",
"return",
"one",
"of",
"the",
"status",
"code",
"defined",
"in",
":",
"mod",
":",
"clusterjob",
".",
"status"
] | python | train | 52.285714 |
tritemio/PyBroMo | pybromo/iter_chunks.py | https://github.com/tritemio/PyBroMo/blob/b75f82a4551ff37e7c7a7e6954c536451f3e6d06/pybromo/iter_chunks.py#L54-L60 | def reduce_chunk(func, array):
"""Reduce with `func`, chunk by chunk, the passed pytable `array`.
"""
res = []
for slice in iter_chunk_slice(array.shape[-1], array.chunkshape[-1]):
res.append(func(array[..., slice]))
return func(res) | [
"def",
"reduce_chunk",
"(",
"func",
",",
"array",
")",
":",
"res",
"=",
"[",
"]",
"for",
"slice",
"in",
"iter_chunk_slice",
"(",
"array",
".",
"shape",
"[",
"-",
"1",
"]",
",",
"array",
".",
"chunkshape",
"[",
"-",
"1",
"]",
")",
":",
"res",
".",... | Reduce with `func`, chunk by chunk, the passed pytable `array`. | [
"Reduce",
"with",
"func",
"chunk",
"by",
"chunk",
"the",
"passed",
"pytable",
"array",
"."
] | python | valid | 36.428571 |
crackinglandia/pype32 | pype32/pype32.py | https://github.com/crackinglandia/pype32/blob/192fd14dfc0dd36d953739a81c17fbaf5e3d6076/pype32/pype32.py#L1617-L1656 | def parse(readDataInstance):
"""
Returns a new L{DosHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{DosHeader} object.
@rtype: L{DosHeader}
@return: A new L{DosHeader} object... | [
"def",
"parse",
"(",
"readDataInstance",
")",
":",
"dosHdr",
"=",
"DosHeader",
"(",
")",
"dosHdr",
".",
"e_magic",
".",
"value",
"=",
"readDataInstance",
".",
"readWord",
"(",
")",
"dosHdr",
".",
"e_cblp",
".",
"value",
"=",
"readDataInstance",
".",
"readW... | Returns a new L{DosHeader} object.
@type readDataInstance: L{ReadData}
@param readDataInstance: A L{ReadData} object with data to be parsed as a L{DosHeader} object.
@rtype: L{DosHeader}
@return: A new L{DosHeader} object. | [
"Returns",
"a",
"new",
"L",
"{",
"DosHeader",
"}",
"object",
"."
] | python | train | 43.075 |
inasafe/inasafe | safe/gui/tools/metadata_converter_dialog.py | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/safe/gui/tools/metadata_converter_dialog.py#L264-L295 | def accept(self):
"""Method invoked when OK button is clicked."""
output_path = self.output_path_line_edit.text()
if not output_path:
display_warning_message_box(
self,
tr('Empty Output Path'),
tr('Output path can not be empty'))
... | [
"def",
"accept",
"(",
"self",
")",
":",
"output_path",
"=",
"self",
".",
"output_path_line_edit",
".",
"text",
"(",
")",
"if",
"not",
"output_path",
":",
"display_warning_message_box",
"(",
"self",
",",
"tr",
"(",
"'Empty Output Path'",
")",
",",
"tr",
"(",
... | Method invoked when OK button is clicked. | [
"Method",
"invoked",
"when",
"OK",
"button",
"is",
"clicked",
"."
] | python | train | 33.625 |
apache/incubator-mxnet | python/mxnet/ndarray/ndarray.py | https://github.com/apache/incubator-mxnet/blob/1af29e9c060a4c7d60eeaacba32afdb9a7775ba7/python/mxnet/ndarray/ndarray.py#L2050-L2094 | def copyto(self, other):
"""Copies the value of this array to another array.
If ``other`` is a ``NDArray`` object, then ``other.shape`` and
``self.shape`` should be the same. This function copies the value from
``self`` to ``other``.
If ``other`` is a context, a new ``NDArray``... | [
"def",
"copyto",
"(",
"self",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"NDArray",
")",
":",
"if",
"other",
".",
"handle",
"is",
"self",
".",
"handle",
":",
"warnings",
".",
"warn",
"(",
"'You are attempting to copy an array to itself'",... | Copies the value of this array to another array.
If ``other`` is a ``NDArray`` object, then ``other.shape`` and
``self.shape`` should be the same. This function copies the value from
``self`` to ``other``.
If ``other`` is a context, a new ``NDArray`` will be first created on
th... | [
"Copies",
"the",
"value",
"of",
"this",
"array",
"to",
"another",
"array",
"."
] | python | train | 35.533333 |
fhs/pyhdf | pyhdf/V.py | https://github.com/fhs/pyhdf/blob/dbdc1810a74a38df50dcad81fe903e239d2b388d/pyhdf/V.py#L994-L1017 | def insert(self, inst):
"""Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert
"""
... | [
"def",
"insert",
"(",
"self",
",",
"inst",
")",
":",
"if",
"isinstance",
"(",
"inst",
",",
"VD",
")",
":",
"id",
"=",
"inst",
".",
"_id",
"elif",
"isinstance",
"(",
"inst",
",",
"VG",
")",
":",
"id",
"=",
"inst",
".",
"_id",
"else",
":",
"raise... | Insert a vdata or a vgroup in the vgroup.
Args::
inst vdata or vgroup instance to add
Returns::
index of the inserted vdata or vgroup (0 based)
C library equivalent : Vinsert | [
"Insert",
"a",
"vdata",
"or",
"a",
"vgroup",
"in",
"the",
"vgroup",
"."
] | python | train | 25.041667 |
saltstack/salt | salt/minion.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/minion.py#L460-L729 | def eval_master(self,
opts,
timeout=60,
safe=True,
failed=False,
failback=False):
'''
Evaluates and returns a tuple of the current master address and the pub_channel.
In standard mode, just creat... | [
"def",
"eval_master",
"(",
"self",
",",
"opts",
",",
"timeout",
"=",
"60",
",",
"safe",
"=",
"True",
",",
"failed",
"=",
"False",
",",
"failback",
"=",
"False",
")",
":",
"# return early if we are not connecting to a master",
"if",
"opts",
"[",
"'master_type'"... | Evaluates and returns a tuple of the current master address and the pub_channel.
In standard mode, just creates a pub_channel with the given master address.
With master_type=func evaluates the current master address from the given
module and then creates a pub_channel.
With master_typ... | [
"Evaluates",
"and",
"returns",
"a",
"tuple",
"of",
"the",
"current",
"master",
"address",
"and",
"the",
"pub_channel",
"."
] | python | train | 51.155556 |
square/pylink | pylink/jlink.py | https://github.com/square/pylink/blob/81dda0a191d923a8b2627c52cb778aba24d279d7/pylink/jlink.py#L4661-L4681 | def swo_supported_speeds(self, cpu_speed, num_speeds=3):
"""Retrives a list of SWO speeds supported by both the target and the
connected J-Link.
The supported speeds are returned in order from highest to lowest.
Args:
self (JLink): the ``JLink`` instance
cpu_speed (... | [
"def",
"swo_supported_speeds",
"(",
"self",
",",
"cpu_speed",
",",
"num_speeds",
"=",
"3",
")",
":",
"buf_size",
"=",
"num_speeds",
"buf",
"=",
"(",
"ctypes",
".",
"c_uint32",
"*",
"buf_size",
")",
"(",
")",
"res",
"=",
"self",
".",
"_dll",
".",
"JLINK... | Retrives a list of SWO speeds supported by both the target and the
connected J-Link.
The supported speeds are returned in order from highest to lowest.
Args:
self (JLink): the ``JLink`` instance
cpu_speed (int): the target's CPU speed in Hz
num_speeds (int): the n... | [
"Retrives",
"a",
"list",
"of",
"SWO",
"speeds",
"supported",
"by",
"both",
"the",
"target",
"and",
"the",
"connected",
"J",
"-",
"Link",
"."
] | python | train | 36.809524 |
dourvaris/nano-python | src/nano/rpc.py | https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/rpc.py#L1739-L1766 | def payment_end(self, account, wallet):
"""
End a payment session. Marks the account as available for use in a
payment session.
:param account: Account to mark available
:type account: str
:param wallet: Wallet to end payment session for
:type wallet: str
... | [
"def",
"payment_end",
"(",
"self",
",",
"account",
",",
"wallet",
")",
":",
"account",
"=",
"self",
".",
"_process_value",
"(",
"account",
",",
"'account'",
")",
"wallet",
"=",
"self",
".",
"_process_value",
"(",
"wallet",
",",
"'wallet'",
")",
"payload",
... | End a payment session. Marks the account as available for use in a
payment session.
:param account: Account to mark available
:type account: str
:param wallet: Wallet to end payment session for
:type wallet: str
:raises: :py:exc:`nano.rpc.RPCException`
>>> rp... | [
"End",
"a",
"payment",
"session",
".",
"Marks",
"the",
"account",
"as",
"available",
"for",
"use",
"in",
"a",
"payment",
"session",
"."
] | python | train | 29.892857 |
xiaocong/uiautomator | uiautomator/__init__.py | https://github.com/xiaocong/uiautomator/blob/9a0c892ffd056713f91aa2153d1533c5b0553a1c/uiautomator/__init__.py#L842-L859 | def wait(self):
'''
Waits for the current application to idle or window update event occurs.
Usage:
d.wait.idle(timeout=1000)
d.wait.update(timeout=1000, package_name="com.android.settings")
'''
@param_to_property(action=["idle", "update"])
def _wait(actio... | [
"def",
"wait",
"(",
"self",
")",
":",
"@",
"param_to_property",
"(",
"action",
"=",
"[",
"\"idle\"",
",",
"\"update\"",
"]",
")",
"def",
"_wait",
"(",
"action",
",",
"timeout",
"=",
"1000",
",",
"package_name",
"=",
"None",
")",
":",
"if",
"timeout",
... | Waits for the current application to idle or window update event occurs.
Usage:
d.wait.idle(timeout=1000)
d.wait.update(timeout=1000, package_name="com.android.settings") | [
"Waits",
"for",
"the",
"current",
"application",
"to",
"idle",
"or",
"window",
"update",
"event",
"occurs",
".",
"Usage",
":",
"d",
".",
"wait",
".",
"idle",
"(",
"timeout",
"=",
"1000",
")",
"d",
".",
"wait",
".",
"update",
"(",
"timeout",
"=",
"100... | python | train | 47.555556 |
happyleavesaoc/python-limitlessled | limitlessled/bridge.py | https://github.com/happyleavesaoc/python-limitlessled/blob/70307c2bf8c91430a99579d2ad18b228ec7a8488/limitlessled/bridge.py#L309-L315 | def close(self):
"""
Closes the connection to the bridge.
"""
self.is_closed = True
self.is_ready = False
self._command_queue.put(None) | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"is_closed",
"=",
"True",
"self",
".",
"is_ready",
"=",
"False",
"self",
".",
"_command_queue",
".",
"put",
"(",
"None",
")"
] | Closes the connection to the bridge. | [
"Closes",
"the",
"connection",
"to",
"the",
"bridge",
"."
] | python | train | 25.285714 |
pyscaffold/configupdater | src/configupdater/configupdater.py | https://github.com/pyscaffold/configupdater/blob/6ebac0b1fa7b8222baacdd4991d18cfc61659f84/src/configupdater/configupdater.py#L153-L174 | def section(self, section):
"""Creates a section block
Args:
section (str or :class:`Section`): name of section or object
Returns:
self for chaining
"""
if not isinstance(self._container, ConfigUpdater):
raise ValueError("Sections can only be... | [
"def",
"section",
"(",
"self",
",",
"section",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"_container",
",",
"ConfigUpdater",
")",
":",
"raise",
"ValueError",
"(",
"\"Sections can only be added at section level!\"",
")",
"if",
"isinstance",
"(",
"sec... | Creates a section block
Args:
section (str or :class:`Section`): name of section or object
Returns:
self for chaining | [
"Creates",
"a",
"section",
"block"
] | python | train | 39.636364 |
AkihikoITOH/capybara | capybara/virtualenv/lib/python2.7/site-packages/lxml/html/diff.py | https://github.com/AkihikoITOH/capybara/blob/e86c2173ea386654f4ae061148e8fbe3f25e715c/capybara/virtualenv/lib/python2.7/site-packages/lxml/html/diff.py#L230-L248 | def merge_insert(ins_chunks, doc):
""" doc is the already-handled document (as a list of text chunks);
here we add <ins>ins_chunks</ins> to the end of that. """
# Though we don't throw away unbalanced_start or unbalanced_end
# (we assume there is accompanying markup later or earlier in the
# docume... | [
"def",
"merge_insert",
"(",
"ins_chunks",
",",
"doc",
")",
":",
"# Though we don't throw away unbalanced_start or unbalanced_end",
"# (we assume there is accompanying markup later or earlier in the",
"# document), we only put <ins> around the balanced portion.",
"unbalanced_start",
",",
"b... | doc is the already-handled document (as a list of text chunks);
here we add <ins>ins_chunks</ins> to the end of that. | [
"doc",
"is",
"the",
"already",
"-",
"handled",
"document",
"(",
"as",
"a",
"list",
"of",
"text",
"chunks",
")",
";",
"here",
"we",
"add",
"<ins",
">",
"ins_chunks<",
"/",
"ins",
">",
"to",
"the",
"end",
"of",
"that",
"."
] | python | test | 45.263158 |
depl0y/ritassist-py | ritassist/api.py | https://github.com/depl0y/ritassist-py/blob/360393da513c104c7462bdf3623fc5a3a7197ab5/ritassist/api.py#L52-L63 | def parse_devices(self, json):
"""Parse result from API."""
result = []
for json_device in json:
license_plate = json_device['EquipmentHeader']['SerialNumber']
device = Device(self, license_plate)
device.update_from_json(json_device)
result.appen... | [
"def",
"parse_devices",
"(",
"self",
",",
"json",
")",
":",
"result",
"=",
"[",
"]",
"for",
"json_device",
"in",
"json",
":",
"license_plate",
"=",
"json_device",
"[",
"'EquipmentHeader'",
"]",
"[",
"'SerialNumber'",
"]",
"device",
"=",
"Device",
"(",
"sel... | Parse result from API. | [
"Parse",
"result",
"from",
"API",
"."
] | python | train | 28.416667 |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/ilink32.py | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/ilink32.py#L36-L48 | def generate(env):
"""Add Builders and construction variables for Borland ilink to an
Environment."""
SCons.Tool.createSharedLibBuilder(env)
SCons.Tool.createProgBuilder(env)
env['LINK'] = '$CC'
env['LINKFLAGS'] = SCons.Util.CLVar('')
env['LINKCOM'] = '$LINK -q $LINKFLAGS -e$TA... | [
"def",
"generate",
"(",
"env",
")",
":",
"SCons",
".",
"Tool",
".",
"createSharedLibBuilder",
"(",
"env",
")",
"SCons",
".",
"Tool",
".",
"createProgBuilder",
"(",
"env",
")",
"env",
"[",
"'LINK'",
"]",
"=",
"'$CC'",
"env",
"[",
"'LINKFLAGS'",
"]",
"="... | Add Builders and construction variables for Borland ilink to an
Environment. | [
"Add",
"Builders",
"and",
"construction",
"variables",
"for",
"Borland",
"ilink",
"to",
"an",
"Environment",
"."
] | python | train | 34.461538 |
dmlc/gluon-nlp | src/gluonnlp/model/train/language_model.py | https://github.com/dmlc/gluon-nlp/blob/4b83eb6bcc8881e5f1081a3675adaa19fac5c0ba/src/gluonnlp/model/train/language_model.py#L238-L276 | def forward(self, inputs, begin_state=None): # pylint: disable=arguments-differ
"""Defines the forward computation. Arguments can be either
:py:class:`NDArray` or :py:class:`Symbol`.
Parameters
-----------
inputs : NDArray
input tensor with shape `(sequence_length, b... | [
"def",
"forward",
"(",
"self",
",",
"inputs",
",",
"begin_state",
"=",
"None",
")",
":",
"# pylint: disable=arguments-differ",
"encoded",
"=",
"self",
".",
"embedding",
"(",
"inputs",
")",
"if",
"not",
"begin_state",
":",
"begin_state",
"=",
"self",
".",
"be... | Defines the forward computation. Arguments can be either
:py:class:`NDArray` or :py:class:`Symbol`.
Parameters
-----------
inputs : NDArray
input tensor with shape `(sequence_length, batch_size)`
when `layout` is "TNC".
begin_state : list
init... | [
"Defines",
"the",
"forward",
"computation",
".",
"Arguments",
"can",
"be",
"either",
":",
"py",
":",
"class",
":",
"NDArray",
"or",
":",
"py",
":",
"class",
":",
"Symbol",
"."
] | python | train | 44.384615 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/AnyValueMap.py | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/AnyValueMap.py#L199-L208 | def get_as_nullable_boolean(self, key):
"""
Converts map element into a boolean or returns None if conversion is not possible
:param key: an index of element to get.
:return: boolean value of the element or None if conversion is not supported.
"""
value = self.get(key)
... | [
"def",
"get_as_nullable_boolean",
"(",
"self",
",",
"key",
")",
":",
"value",
"=",
"self",
".",
"get",
"(",
"key",
")",
"return",
"BooleanConverter",
".",
"to_nullable_boolean",
"(",
"value",
")"
] | Converts map element into a boolean or returns None if conversion is not possible
:param key: an index of element to get.
:return: boolean value of the element or None if conversion is not supported. | [
"Converts",
"map",
"element",
"into",
"a",
"boolean",
"or",
"returns",
"None",
"if",
"conversion",
"is",
"not",
"possible"
] | python | train | 36.9 |
3ll3d00d/vibe | backend/src/analyser/resources/measurements.py | https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/resources/measurements.py#L29-L39 | def get(self):
"""
Reloads the measurements from the backing store.
:return: 200 if success.
"""
try:
self._measurementController.reloadCompletedMeasurements()
return None, 200
except:
logger.exception("Failed to reload measurements")
... | [
"def",
"get",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_measurementController",
".",
"reloadCompletedMeasurements",
"(",
")",
"return",
"None",
",",
"200",
"except",
":",
"logger",
".",
"exception",
"(",
"\"Failed to reload measurements\"",
")",
"return"... | Reloads the measurements from the backing store.
:return: 200 if success. | [
"Reloads",
"the",
"measurements",
"from",
"the",
"backing",
"store",
".",
":",
"return",
":",
"200",
"if",
"success",
"."
] | python | train | 32 |
michael-lazar/rtv | rtv/packages/praw/__init__.py | https://github.com/michael-lazar/rtv/blob/ccef2af042566ad384977028cf0bde01bc524dda/rtv/packages/praw/__init__.py#L1479-L1519 | def login(self, username=None, password=None, **kwargs):
"""Login to a reddit site.
**DEPRECATED**. Will be removed in a future version of PRAW.
https://www.reddit.com/comments/2ujhkr/
https://www.reddit.com/comments/37e2mv/
Look for username first in parameter, then praw.ini ... | [
"def",
"login",
"(",
"self",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"password",
"and",
"not",
"username",
":",
"raise",
"Exception",
"(",
"'Username must be provided when password is.'",
")",
"use... | Login to a reddit site.
**DEPRECATED**. Will be removed in a future version of PRAW.
https://www.reddit.com/comments/2ujhkr/
https://www.reddit.com/comments/37e2mv/
Look for username first in parameter, then praw.ini and finally if both
were empty get it from stdin. Look for p... | [
"Login",
"to",
"a",
"reddit",
"site",
"."
] | python | train | 39.341463 |
NoviceLive/intellicoder | intellicoder/synthesizers.py | https://github.com/NoviceLive/intellicoder/blob/6cac5ebfce65c370dbebe47756a1789b120ef982/intellicoder/synthesizers.py#L231-L243 | def c_module_relocs(self):
"""Build relocation for the module variable."""
if self.opts.no_structs or self.opts.windll:
return '', ''
x86 = reloc_var(
self.name, self._c_struct_names()[1],
self.opts.reloc_delta,
self._c_uses_pointer()
)
... | [
"def",
"c_module_relocs",
"(",
"self",
")",
":",
"if",
"self",
".",
"opts",
".",
"no_structs",
"or",
"self",
".",
"opts",
".",
"windll",
":",
"return",
"''",
",",
"''",
"x86",
"=",
"reloc_var",
"(",
"self",
".",
"name",
",",
"self",
".",
"_c_struct_n... | Build relocation for the module variable. | [
"Build",
"relocation",
"for",
"the",
"module",
"variable",
"."
] | python | train | 35.769231 |
gwastro/pycbc-glue | pycbc_glue/ligolw/utils/segments.py | https://github.com/gwastro/pycbc-glue/blob/a3e906bae59fbfd707c3ff82e5d008d939ec5e24/pycbc_glue/ligolw/utils/segments.py#L401-L481 | def finalize(self, process_row = None):
"""
Restore the LigolwSegmentList objects to the XML tables in
preparation for output. All segments from all segment
lists are inserted into the tables in time order, but this
is NOT behaviour external applications should rely on.
This is done simply in the belief th... | [
"def",
"finalize",
"(",
"self",
",",
"process_row",
"=",
"None",
")",
":",
"if",
"process_row",
"is",
"not",
"None",
":",
"process_id",
"=",
"process_row",
".",
"process_id",
"elif",
"self",
".",
"process",
"is",
"not",
"None",
":",
"process_id",
"=",
"s... | Restore the LigolwSegmentList objects to the XML tables in
preparation for output. All segments from all segment
lists are inserted into the tables in time order, but this
is NOT behaviour external applications should rely on.
This is done simply in the belief that it might assist in
constructing well balanc... | [
"Restore",
"the",
"LigolwSegmentList",
"objects",
"to",
"the",
"XML",
"tables",
"in",
"preparation",
"for",
"output",
".",
"All",
"segments",
"from",
"all",
"segment",
"lists",
"are",
"inserted",
"into",
"the",
"tables",
"in",
"time",
"order",
"but",
"this",
... | python | train | 34.037037 |
jonathanj/txspinneret | txspinneret/resource.py | https://github.com/jonathanj/txspinneret/blob/717008a2c313698984a23e3f3fc62ea3675ed02d/txspinneret/resource.py#L221-L238 | def _negotiateHandler(self, request):
"""
Negotiate a handler based on the content types acceptable to the
client.
:rtype: 2-`tuple` of `twisted.web.iweb.IResource` and `bytes`
:return: Pair of a resource and the content type.
"""
accept = _parseAccept(request.re... | [
"def",
"_negotiateHandler",
"(",
"self",
",",
"request",
")",
":",
"accept",
"=",
"_parseAccept",
"(",
"request",
".",
"requestHeaders",
".",
"getRawHeaders",
"(",
"'Accept'",
")",
")",
"for",
"contentType",
"in",
"accept",
".",
"keys",
"(",
")",
":",
"han... | Negotiate a handler based on the content types acceptable to the
client.
:rtype: 2-`tuple` of `twisted.web.iweb.IResource` and `bytes`
:return: Pair of a resource and the content type. | [
"Negotiate",
"a",
"handler",
"based",
"on",
"the",
"content",
"types",
"acceptable",
"to",
"the",
"client",
"."
] | python | valid | 38.388889 |
projectshift/shift-schema | shiftschema/property.py | https://github.com/projectshift/shift-schema/blob/07787b540d3369bb37217ffbfbe629118edaf0eb/shiftschema/property.py#L125-L133 | def filter_with_schema(self, model=None, context=None):
""" Perform model filtering with schema """
if model is None or self.schema is None:
return
self._schema.filter(
model=model,
context=context if self.use_context else None
) | [
"def",
"filter_with_schema",
"(",
"self",
",",
"model",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"model",
"is",
"None",
"or",
"self",
".",
"schema",
"is",
"None",
":",
"return",
"self",
".",
"_schema",
".",
"filter",
"(",
"model",
"=... | Perform model filtering with schema | [
"Perform",
"model",
"filtering",
"with",
"schema"
] | python | train | 32.222222 |
saltstack/salt | salt/cli/batch.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/batch.py#L29-L46 | def get_bnum(opts, minions, quiet):
'''
Return the active number of minions to maintain
'''
partition = lambda x: float(x) / 100.0 * len(minions)
try:
if '%' in opts['batch']:
res = partition(float(opts['batch'].strip('%')))
if res < 1:
return int(math... | [
"def",
"get_bnum",
"(",
"opts",
",",
"minions",
",",
"quiet",
")",
":",
"partition",
"=",
"lambda",
"x",
":",
"float",
"(",
"x",
")",
"/",
"100.0",
"*",
"len",
"(",
"minions",
")",
"try",
":",
"if",
"'%'",
"in",
"opts",
"[",
"'batch'",
"]",
":",
... | Return the active number of minions to maintain | [
"Return",
"the",
"active",
"number",
"of",
"minions",
"to",
"maintain"
] | python | train | 34.888889 |
twisted/vertex | vertex/sigma.py | https://github.com/twisted/vertex/blob/feb591aa1b9a3b2b8fdcf53e4962dad2a0bc38ca/vertex/sigma.py#L268-L320 | def sendSomeData(self, howMany):
"""
Send some DATA commands to my peer(s) to relay some data.
@param howMany: an int, the number of chunks to send out.
"""
# print 'sending some data', howMany
if self.transport is None:
return
peer = self.transport.g... | [
"def",
"sendSomeData",
"(",
"self",
",",
"howMany",
")",
":",
"# print 'sending some data', howMany",
"if",
"self",
".",
"transport",
"is",
"None",
":",
"return",
"peer",
"=",
"self",
".",
"transport",
".",
"getQ2QPeer",
"(",
")",
"while",
"howMany",
">",
"0... | Send some DATA commands to my peer(s) to relay some data.
@param howMany: an int, the number of chunks to send out. | [
"Send",
"some",
"DATA",
"commands",
"to",
"my",
"peer",
"(",
"s",
")",
"to",
"relay",
"some",
"data",
"."
] | python | train | 36.54717 |
mushkevych/scheduler | launch.py | https://github.com/mushkevych/scheduler/blob/6740331360f49083c208085fb5a60ce80ebf418b/launch.py#L148-L155 | def install_virtualenv(parser_args):
""" Installs virtual environment """
python_version = '.'.join(str(v) for v in sys.version_info[:2])
sys.stdout.write('Installing Python {0} virtualenv into {1} \n'.format(python_version, VE_ROOT))
if sys.version_info < (3, 3):
install_virtualenv_p2(VE_ROOT, ... | [
"def",
"install_virtualenv",
"(",
"parser_args",
")",
":",
"python_version",
"=",
"'.'",
".",
"join",
"(",
"str",
"(",
"v",
")",
"for",
"v",
"in",
"sys",
".",
"version_info",
"[",
":",
"2",
"]",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"'Install... | Installs virtual environment | [
"Installs",
"virtual",
"environment"
] | python | train | 49.125 |
digidotcom/python-devicecloud | devicecloud/devicecore.py | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L136-L167 | def get_groups(self, condition=None, page_size=1000):
"""Return an iterator over all groups in this device cloud account
Optionally, a condition can be specified to limit the number of
groups returned.
Examples::
# Get all groups and print information about them
... | [
"def",
"get_groups",
"(",
"self",
",",
"condition",
"=",
"None",
",",
"page_size",
"=",
"1000",
")",
":",
"query_kwargs",
"=",
"{",
"}",
"if",
"condition",
"is",
"not",
"None",
":",
"query_kwargs",
"[",
"\"condition\"",
"]",
"=",
"condition",
".",
"compi... | Return an iterator over all groups in this device cloud account
Optionally, a condition can be specified to limit the number of
groups returned.
Examples::
# Get all groups and print information about them
for group in dc.devicecore.get_groups():
print ... | [
"Return",
"an",
"iterator",
"over",
"all",
"groups",
"in",
"this",
"device",
"cloud",
"account"
] | python | train | 43.59375 |
splunk/splunk-sdk-python | examples/analytics/bottle.py | https://github.com/splunk/splunk-sdk-python/blob/a245a4eeb93b3621730418008e31715912bcdcd8/examples/analytics/bottle.py#L493-L497 | def close(self):
''' Close the application and all installed plugins. '''
for plugin in self.plugins:
if hasattr(plugin, 'close'): plugin.close()
self.stopped = True | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"plugin",
"in",
"self",
".",
"plugins",
":",
"if",
"hasattr",
"(",
"plugin",
",",
"'close'",
")",
":",
"plugin",
".",
"close",
"(",
")",
"self",
".",
"stopped",
"=",
"True"
] | Close the application and all installed plugins. | [
"Close",
"the",
"application",
"and",
"all",
"installed",
"plugins",
"."
] | python | train | 39.4 |
Rikanishu/static-bundle | static_bundle/bundles.py | https://github.com/Rikanishu/static-bundle/blob/2f6458cb9d9d9049b4fd829f7d6951a45d547c68/static_bundle/bundles.py#L84-L92 | def add_path_object(self, *args):
"""
Add custom path objects
:type: path_object: static_bundle.paths.AbstractPath
"""
for obj in args:
obj.bundle = self
self.files.append(obj) | [
"def",
"add_path_object",
"(",
"self",
",",
"*",
"args",
")",
":",
"for",
"obj",
"in",
"args",
":",
"obj",
".",
"bundle",
"=",
"self",
"self",
".",
"files",
".",
"append",
"(",
"obj",
")"
] | Add custom path objects
:type: path_object: static_bundle.paths.AbstractPath | [
"Add",
"custom",
"path",
"objects"
] | python | valid | 25.888889 |
guyzmo/pyparts | pyparts/parts.py | https://github.com/guyzmo/pyparts/blob/cc7f225e6f7f2e9f2edc42fbd02e5d49d3595a78/pyparts/parts.py#L170-L210 | def part_search(self, part_query):
'''
handles the part lookup/search for the given part query
part_query: part string to search as product name
outputs result on stdout
'''
limit = 100
results = self._e.parts_search(q=part_query,
... | [
"def",
"part_search",
"(",
"self",
",",
"part_query",
")",
":",
"limit",
"=",
"100",
"results",
"=",
"self",
".",
"_e",
".",
"parts_search",
"(",
"q",
"=",
"part_query",
",",
"limit",
"=",
"limit",
")",
"start",
"=",
"0",
"hits",
"=",
"results",
"[",... | handles the part lookup/search for the given part query
part_query: part string to search as product name
outputs result on stdout | [
"handles",
"the",
"part",
"lookup",
"/",
"search",
"for",
"the",
"given",
"part",
"query"
] | python | train | 33.487805 |
apache/airflow | airflow/utils/log/gcs_task_handler.py | https://github.com/apache/airflow/blob/b69c686ad8a0c89b9136bb4b31767257eb7b2597/airflow/utils/log/gcs_task_handler.py#L166-L177 | def parse_gcs_url(gsurl):
"""
Given a Google Cloud Storage URL (gs://<bucket>/<blob>), returns a
tuple containing the corresponding bucket and blob.
"""
parsed_url = urlparse(gsurl)
if not parsed_url.netloc:
raise AirflowException('Please provide a bucket name... | [
"def",
"parse_gcs_url",
"(",
"gsurl",
")",
":",
"parsed_url",
"=",
"urlparse",
"(",
"gsurl",
")",
"if",
"not",
"parsed_url",
".",
"netloc",
":",
"raise",
"AirflowException",
"(",
"'Please provide a bucket name'",
")",
"else",
":",
"bucket",
"=",
"parsed_url",
... | Given a Google Cloud Storage URL (gs://<bucket>/<blob>), returns a
tuple containing the corresponding bucket and blob. | [
"Given",
"a",
"Google",
"Cloud",
"Storage",
"URL",
"(",
"gs",
":",
"//",
"<bucket",
">",
"/",
"<blob",
">",
")",
"returns",
"a",
"tuple",
"containing",
"the",
"corresponding",
"bucket",
"and",
"blob",
"."
] | python | test | 36.833333 |
eyurtsev/FlowCytometryTools | FlowCytometryTools/core/containers.py | https://github.com/eyurtsev/FlowCytometryTools/blob/4355632508b875273d68c7e2972c17668bcf7b40/FlowCytometryTools/core/containers.py#L41-L51 | def read_data(self, **kwargs):
'''
Read the datafile specified in Sample.datafile and
return the resulting object.
Does NOT assign the data to self.data
It's advised not to use this method, but instead to access
the data through the FCMeasurement.data attribute.
... | [
"def",
"read_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"meta",
",",
"data",
"=",
"parse_fcs",
"(",
"self",
".",
"datafile",
",",
"*",
"*",
"kwargs",
")",
"return",
"data"
] | Read the datafile specified in Sample.datafile and
return the resulting object.
Does NOT assign the data to self.data
It's advised not to use this method, but instead to access
the data through the FCMeasurement.data attribute. | [
"Read",
"the",
"datafile",
"specified",
"in",
"Sample",
".",
"datafile",
"and",
"return",
"the",
"resulting",
"object",
".",
"Does",
"NOT",
"assign",
"the",
"data",
"to",
"self",
".",
"data"
] | python | train | 35.363636 |
fedora-infra/fedora-messaging | fedora_messaging/twisted/protocol.py | https://github.com/fedora-infra/fedora-messaging/blob/be3e88534e2b15d579bcd24f9c4b7e795cb7e0b7/fedora_messaging/twisted/protocol.py#L131-L145 | def _allocate_channel(self):
"""
Allocate a new AMQP channel.
Raises:
NoFreeChannels: If this connection has reached its maximum number of channels.
"""
try:
channel = yield self.channel()
except pika.exceptions.NoFreeChannels:
raise N... | [
"def",
"_allocate_channel",
"(",
"self",
")",
":",
"try",
":",
"channel",
"=",
"yield",
"self",
".",
"channel",
"(",
")",
"except",
"pika",
".",
"exceptions",
".",
"NoFreeChannels",
":",
"raise",
"NoFreeChannels",
"(",
")",
"_std_log",
".",
"debug",
"(",
... | Allocate a new AMQP channel.
Raises:
NoFreeChannels: If this connection has reached its maximum number of channels. | [
"Allocate",
"a",
"new",
"AMQP",
"channel",
"."
] | python | train | 33.666667 |
naphatkrit/easyci | easyci/history.py | https://github.com/naphatkrit/easyci/blob/7aee8d7694fe4e2da42ce35b0f700bc840c8b95f/easyci/history.py#L141-L149 | def clear_history(vcs):
"""Clear (committed) test run history from this project.
Args:
vcs (easyci.vcs.base.Vcs)
"""
evidence_path = _get_committed_history_path(vcs)
if os.path.exists(evidence_path):
os.remove(evidence_path) | [
"def",
"clear_history",
"(",
"vcs",
")",
":",
"evidence_path",
"=",
"_get_committed_history_path",
"(",
"vcs",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"evidence_path",
")",
":",
"os",
".",
"remove",
"(",
"evidence_path",
")"
] | Clear (committed) test run history from this project.
Args:
vcs (easyci.vcs.base.Vcs) | [
"Clear",
"(",
"committed",
")",
"test",
"run",
"history",
"from",
"this",
"project",
"."
] | python | train | 28.111111 |
nickmckay/LiPD-utilities | Python/lipd/lpd_noaa.py | https://github.com/nickmckay/LiPD-utilities/blob/5dab6bbeffc5effd68e3a6beaca6b76aa928e860/Python/lipd/lpd_noaa.py#L1288-L1309 | def __write_data(self, idx):
"""
Write out the measurement tables found in paleoData and chronData
:return:
"""
pair = self.noaa_data_sorted["Data"][idx]
# Run once for each pair (paleo+chron) of tables that was gathered earlier.
# for idx, pair in enumerate(self.... | [
"def",
"__write_data",
"(",
"self",
",",
"idx",
")",
":",
"pair",
"=",
"self",
".",
"noaa_data_sorted",
"[",
"\"Data\"",
"]",
"[",
"idx",
"]",
"# Run once for each pair (paleo+chron) of tables that was gathered earlier.",
"# for idx, pair in enumerate(self.noaa_data_sorted[\"... | Write out the measurement tables found in paleoData and chronData
:return: | [
"Write",
"out",
"the",
"measurement",
"tables",
"found",
"in",
"paleoData",
"and",
"chronData",
":",
"return",
":"
] | python | train | 39.909091 |
gbiggs/rtctree | rtctree/ports.py | https://github.com/gbiggs/rtctree/blob/bd725a47ac87c259c8bce06156ccc9ab71111c26/rtctree/ports.py#L36-L56 | def parse_port(port_obj, owner):
'''Create a port object of the correct type.
The correct port object type is chosen based on the port.port_type
property of port_obj.
@param port_obj The CORBA PortService object to wrap.
@param owner The owner of this port. Should be a Component object or None.
... | [
"def",
"parse_port",
"(",
"port_obj",
",",
"owner",
")",
":",
"profile",
"=",
"port_obj",
".",
"get_port_profile",
"(",
")",
"props",
"=",
"utils",
".",
"nvlist_to_dict",
"(",
"profile",
".",
"properties",
")",
"if",
"props",
"[",
"'port.port_type'",
"]",
... | Create a port object of the correct type.
The correct port object type is chosen based on the port.port_type
property of port_obj.
@param port_obj The CORBA PortService object to wrap.
@param owner The owner of this port. Should be a Component object or None.
@return The created port object. | [
"Create",
"a",
"port",
"object",
"of",
"the",
"correct",
"type",
"."
] | python | train | 36.285714 |
juju/charm-helpers | charmhelpers/contrib/openstack/cert_utils.py | https://github.com/juju/charm-helpers/blob/aa785c40c3b7a8c69dbfbc7921d6b9f30142e171/charmhelpers/contrib/openstack/cert_utils.py#L266-L287 | def get_bundle_for_cn(cn, relation_name=None):
"""Extract certificates for the given cn.
:param cn: str Canonical Name on certificate.
:param relation_name: str Relation to check for certificates down.
:returns: Dictionary of certificate data,
:rtype: dict.
"""
entries = get_requests_for_lo... | [
"def",
"get_bundle_for_cn",
"(",
"cn",
",",
"relation_name",
"=",
"None",
")",
":",
"entries",
"=",
"get_requests_for_local_unit",
"(",
"relation_name",
")",
"cert_bundle",
"=",
"{",
"}",
"for",
"entry",
"in",
"entries",
":",
"for",
"_cn",
",",
"bundle",
"in... | Extract certificates for the given cn.
:param cn: str Canonical Name on certificate.
:param relation_name: str Relation to check for certificates down.
:returns: Dictionary of certificate data,
:rtype: dict. | [
"Extract",
"certificates",
"for",
"the",
"given",
"cn",
"."
] | python | train | 33.409091 |
ioos/compliance-checker | compliance_checker/cf/cf.py | https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cf/cf.py#L3345-L3357 | def check_hints(self, ds):
'''
Checks for potentially mislabeled metadata and makes suggestions for how to correct
:param netCDF4.Dataset ds: An open netCDF dataset
:rtype: list
:return: List of results
'''
ret_val = []
ret_val.extend(self._check_hint_bo... | [
"def",
"check_hints",
"(",
"self",
",",
"ds",
")",
":",
"ret_val",
"=",
"[",
"]",
"ret_val",
".",
"extend",
"(",
"self",
".",
"_check_hint_bounds",
"(",
"ds",
")",
")",
"return",
"ret_val"
] | Checks for potentially mislabeled metadata and makes suggestions for how to correct
:param netCDF4.Dataset ds: An open netCDF dataset
:rtype: list
:return: List of results | [
"Checks",
"for",
"potentially",
"mislabeled",
"metadata",
"and",
"makes",
"suggestions",
"for",
"how",
"to",
"correct"
] | python | train | 26.230769 |
pyroscope/pyrocore | src/pyrocore/torrent/formatting.py | https://github.com/pyroscope/pyrocore/blob/89ad01346a570943d20311a0b488440975876612/src/pyrocore/torrent/formatting.py#L214-L226 | def preparse(output_format):
""" Do any special processing of a template, and return the result.
"""
try:
return templating.preparse(output_format, lambda path: os.path.join(config.config_dir, "templates", path))
except ImportError as exc:
if "tempita" in str(exc):
raise erro... | [
"def",
"preparse",
"(",
"output_format",
")",
":",
"try",
":",
"return",
"templating",
".",
"preparse",
"(",
"output_format",
",",
"lambda",
"path",
":",
"os",
".",
"path",
".",
"join",
"(",
"config",
".",
"config_dir",
",",
"\"templates\"",
",",
"path",
... | Do any special processing of a template, and return the result. | [
"Do",
"any",
"special",
"processing",
"of",
"a",
"template",
"and",
"return",
"the",
"result",
"."
] | python | train | 51.076923 |
SteveMcGrath/pySecurityCenter | examples/sc5/software_change/swchange/population.py | https://github.com/SteveMcGrath/pySecurityCenter/blob/f0b10b1bcd4fd23a8d4d09ca6774cdf5e1cfd880/examples/sc5/software_change/swchange/population.py#L4-L157 | def gen(sc, asset, expire):
'''
Database population function.
What we are doing here is trying to interpret the output of plugin ID 20811
and use that information to help populate the database with individualized
entries of the software that is installed on the host. This information will
late... | [
"def",
"gen",
"(",
"sc",
",",
"asset",
",",
"expire",
")",
":",
"# The following regex patters are used to pull out the needed fields from",
"# Plugin ID 20811",
"redate",
"=",
"re",
".",
"compile",
"(",
"r'\\[installed on (\\d{4})/(\\d{1,2})/(\\d{1,2})\\]'",
")",
"reinvdate"... | Database population function.
What we are doing here is trying to interpret the output of plugin ID 20811
and use that information to help populate the database with individualized
entries of the software that is installed on the host. This information will
later be used to build the report. | [
"Database",
"population",
"function",
"."
] | python | train | 38.935065 |
googleapis/google-cloud-python | speech/google/cloud/speech_v1p1beta1/gapic/speech_client.py | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/speech/google/cloud/speech_v1p1beta1/gapic/speech_client.py#L170-L240 | def recognize(
self,
config,
audio,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
):
"""
Performs synchronous speech recognition: receive results after all audio
has been sent and... | [
"def",
"recognize",
"(",
"self",
",",
"config",
",",
"audio",
",",
"retry",
"=",
"google",
".",
"api_core",
".",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
",",
"timeout",
"=",
"google",
".",
"api_core",
".",
"gapic_v1",
".",
"method",
".",
"DEFAULT",
... | Performs synchronous speech recognition: receive results after all audio
has been sent and processed.
Example:
>>> from google.cloud import speech_v1p1beta1
>>> from google.cloud.speech_v1p1beta1 import enums
>>>
>>> client = speech_v1p1beta1.SpeechClient... | [
"Performs",
"synchronous",
"speech",
"recognition",
":",
"receive",
"results",
"after",
"all",
"audio",
"has",
"been",
"sent",
"and",
"processed",
"."
] | python | train | 46.704225 |
plandes/actioncli | src/python/zensols/actioncli/config.py | https://github.com/plandes/actioncli/blob/d1c4ea27e6f3394b30a1652ddd4b916160662773/src/python/zensols/actioncli/config.py#L165-L188 | def get_options(self, section='default', opt_keys=None, vars=None):
"""
Get all options for a section. If ``opt_keys`` is given return
only options with those keys.
"""
vars = vars if vars else self.default_vars
conf = self.parser
opts = {}
if opt_keys is... | [
"def",
"get_options",
"(",
"self",
",",
"section",
"=",
"'default'",
",",
"opt_keys",
"=",
"None",
",",
"vars",
"=",
"None",
")",
":",
"vars",
"=",
"vars",
"if",
"vars",
"else",
"self",
".",
"default_vars",
"conf",
"=",
"self",
".",
"parser",
"opts",
... | Get all options for a section. If ``opt_keys`` is given return
only options with those keys. | [
"Get",
"all",
"options",
"for",
"a",
"section",
".",
"If",
"opt_keys",
"is",
"given",
"return",
"only",
"options",
"with",
"those",
"keys",
"."
] | python | train | 37.833333 |
sernst/cauldron | cauldron/runner/python_file.py | https://github.com/sernst/cauldron/blob/4086aec9c038c402ea212c79fe8bd0d27104f9cf/cauldron/runner/python_file.py#L29-L42 | def set_executing(on: bool):
"""
Toggle whether or not the current thread is executing a step file. This
will only apply when the current thread is a CauldronThread. This function
has no effect when run on a Main thread.
:param on:
Whether or not the thread should be annotated as executing ... | [
"def",
"set_executing",
"(",
"on",
":",
"bool",
")",
":",
"my_thread",
"=",
"threading",
".",
"current_thread",
"(",
")",
"if",
"isinstance",
"(",
"my_thread",
",",
"threads",
".",
"CauldronThread",
")",
":",
"my_thread",
".",
"is_executing",
"=",
"on"
] | Toggle whether or not the current thread is executing a step file. This
will only apply when the current thread is a CauldronThread. This function
has no effect when run on a Main thread.
:param on:
Whether or not the thread should be annotated as executing a step file. | [
"Toggle",
"whether",
"or",
"not",
"the",
"current",
"thread",
"is",
"executing",
"a",
"step",
"file",
".",
"This",
"will",
"only",
"apply",
"when",
"the",
"current",
"thread",
"is",
"a",
"CauldronThread",
".",
"This",
"function",
"has",
"no",
"effect",
"wh... | python | train | 33 |
gwastro/pycbc | pycbc/cosmology.py | https://github.com/gwastro/pycbc/blob/7a64cdd104d263f1b6ea0b01e6841837d05a4cb3/pycbc/cosmology.py#L289-L317 | def redshift(distance, **kwargs):
r"""Returns the redshift associated with the given luminosity distance.
If the requested cosmology is one of the pre-defined ones in
:py:attr:`astropy.cosmology.parameters.available`, :py:class:`DistToZ` is
used to provide a fast interpolation. This takes a few seconds... | [
"def",
"redshift",
"(",
"distance",
",",
"*",
"*",
"kwargs",
")",
":",
"cosmology",
"=",
"get_cosmology",
"(",
"*",
"*",
"kwargs",
")",
"try",
":",
"z",
"=",
"_d2zs",
"[",
"cosmology",
".",
"name",
"]",
"(",
"distance",
")",
"except",
"KeyError",
":"... | r"""Returns the redshift associated with the given luminosity distance.
If the requested cosmology is one of the pre-defined ones in
:py:attr:`astropy.cosmology.parameters.available`, :py:class:`DistToZ` is
used to provide a fast interpolation. This takes a few seconds to setup
on the first call.
... | [
"r",
"Returns",
"the",
"redshift",
"associated",
"with",
"the",
"given",
"luminosity",
"distance",
"."
] | python | train | 32.586207 |
zerotk/easyfs | zerotk/easyfs/_easyfs.py | https://github.com/zerotk/easyfs/blob/140923db51fb91d5a5847ad17412e8bce51ba3da/zerotk/easyfs/_easyfs.py#L1411-L1429 | def ListMappedNetworkDrives():
'''
On Windows, returns a list of mapped network drives
:return: tuple(string, string, bool)
For each mapped netword drive, return 3 values tuple:
- the local drive
- the remote path-
- True if the mapping is enabled (warning: not r... | [
"def",
"ListMappedNetworkDrives",
"(",
")",
":",
"if",
"sys",
".",
"platform",
"!=",
"'win32'",
":",
"raise",
"NotImplementedError",
"drives_list",
"=",
"[",
"]",
"netuse",
"=",
"_CallWindowsNetCommand",
"(",
"[",
"'use'",
"]",
")",
"for",
"line",
"in",
"net... | On Windows, returns a list of mapped network drives
:return: tuple(string, string, bool)
For each mapped netword drive, return 3 values tuple:
- the local drive
- the remote path-
- True if the mapping is enabled (warning: not reliable) | [
"On",
"Windows",
"returns",
"a",
"list",
"of",
"mapped",
"network",
"drives"
] | python | valid | 36.473684 |
scheibler/khard | khard/khard.py | https://github.com/scheibler/khard/blob/0f69430c2680f1ff5f073a977a3c5b753b96cc17/khard/khard.py#L866-L918 | def birthdays_subcommand(vcard_list, parsable):
"""Print birthday contact table.
:param vcard_list: the vcards to search for matching entries which should
be printed
:type vcard_list: list of carddav_object.CarddavObject
:param parsable: machine readable output: columns devided by tabulator (\t... | [
"def",
"birthdays_subcommand",
"(",
"vcard_list",
",",
"parsable",
")",
":",
"# filter out contacts without a birthday date",
"vcard_list",
"=",
"[",
"vcard",
"for",
"vcard",
"in",
"vcard_list",
"if",
"vcard",
".",
"get_birthday",
"(",
")",
"is",
"not",
"None",
"]... | Print birthday contact table.
:param vcard_list: the vcards to search for matching entries which should
be printed
:type vcard_list: list of carddav_object.CarddavObject
:param parsable: machine readable output: columns devided by tabulator (\t)
:type parsable: bool
:returns: None
:rtyp... | [
"Print",
"birthday",
"contact",
"table",
"."
] | python | test | 40.981132 |
shoebot/shoebot | lib/photobot/__init__.py | https://github.com/shoebot/shoebot/blob/d554c1765c1899fa25727c9fc6805d221585562b/lib/photobot/__init__.py#L421-L431 | def up(self):
"""Moves the layer up in the stacking order.
"""
i = self.index()
if i != None:
del self.canvas.layers[i]
i = min(len(self.canvas.layers), i+1)
self.canvas.layers.insert(i, self) | [
"def",
"up",
"(",
"self",
")",
":",
"i",
"=",
"self",
".",
"index",
"(",
")",
"if",
"i",
"!=",
"None",
":",
"del",
"self",
".",
"canvas",
".",
"layers",
"[",
"i",
"]",
"i",
"=",
"min",
"(",
"len",
"(",
"self",
".",
"canvas",
".",
"layers",
... | Moves the layer up in the stacking order. | [
"Moves",
"the",
"layer",
"up",
"in",
"the",
"stacking",
"order",
"."
] | python | valid | 25.181818 |
architv/harvey | harvey/harvey.py | https://github.com/architv/harvey/blob/2b96d57b7a1e0dd706f1f00aba3d92a7ae702960/harvey/harvey.py#L70-L94 | def _get_license_description(license_code):
""" Gets the body for a license based on a license code """
req = requests.get("{base_url}/licenses/{license_code}".format(
base_url=BASE_URL, license_code=license_code), headers=_HEADERS)
if req.status_code == requests.codes.ok:
s = req.json()["body"]
se... | [
"def",
"_get_license_description",
"(",
"license_code",
")",
":",
"req",
"=",
"requests",
".",
"get",
"(",
"\"{base_url}/licenses/{license_code}\"",
".",
"format",
"(",
"base_url",
"=",
"BASE_URL",
",",
"license_code",
"=",
"license_code",
")",
",",
"headers",
"="... | Gets the body for a license based on a license code | [
"Gets",
"the",
"body",
"for",
"a",
"license",
"based",
"on",
"a",
"license",
"code"
] | python | train | 34.04 |
aiogram/aiogram | aiogram/utils/parts.py | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/utils/parts.py#L18-L43 | def safe_split_text(text: str, length: int = MAX_MESSAGE_LENGTH) -> typing.List[str]:
"""
Split long text
:param text:
:param length:
:return:
"""
# TODO: More informative description
temp_text = text
parts = []
while temp_text:
if len(temp_text) > length:
t... | [
"def",
"safe_split_text",
"(",
"text",
":",
"str",
",",
"length",
":",
"int",
"=",
"MAX_MESSAGE_LENGTH",
")",
"->",
"typing",
".",
"List",
"[",
"str",
"]",
":",
"# TODO: More informative description",
"temp_text",
"=",
"text",
"parts",
"=",
"[",
"]",
"while"... | Split long text
:param text:
:param length:
:return: | [
"Split",
"long",
"text"
] | python | train | 26.538462 |
danielhrisca/asammdf | asammdf/mdf.py | https://github.com/danielhrisca/asammdf/blob/3c7a1fd19c957ceebe4dcdbb2abf00806c2bdb66/asammdf/mdf.py#L1770-L1818 | def iter_get(
self,
name=None,
group=None,
index=None,
raster=None,
samples_only=False,
raw=False,
):
""" iterator over a channel
This is usefull in case of large files with a small number of channels.
If the *raster* keyword argument... | [
"def",
"iter_get",
"(",
"self",
",",
"name",
"=",
"None",
",",
"group",
"=",
"None",
",",
"index",
"=",
"None",
",",
"raster",
"=",
"None",
",",
"samples_only",
"=",
"False",
",",
"raw",
"=",
"False",
",",
")",
":",
"gp_nr",
",",
"ch_nr",
"=",
"s... | iterator over a channel
This is usefull in case of large files with a small number of channels.
If the *raster* keyword argument is not *None* the output is
interpolated accordingly
Parameters
----------
name : string
name of channel
group : int
... | [
"iterator",
"over",
"a",
"channel"
] | python | train | 26.040816 |
saltstack/salt | salt/states/apache_conf.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/apache_conf.py#L33-L64 | def enabled(name):
'''
Ensure an Apache conf is enabled.
name
Name of the Apache conf
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
is_enabled = __salt__['apache.check_conf_enabled'](name)
if not is_enabled:
if __opts__['test']:
msg = 'A... | [
"def",
"enabled",
"(",
"name",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'comment'",
":",
"''",
",",
"'changes'",
":",
"{",
"}",
"}",
"is_enabled",
"=",
"__salt__",
"[",
"'apache.check_conf_enabled'",
"]",
"(... | Ensure an Apache conf is enabled.
name
Name of the Apache conf | [
"Ensure",
"an",
"Apache",
"conf",
"is",
"enabled",
"."
] | python | train | 35 |
selectel/pyte | pyte/screens.py | https://github.com/selectel/pyte/blob/8adad489f86da1788a7995720c344a2fa44f244e/pyte/screens.py#L972-L1018 | def select_graphic_rendition(self, *attrs):
"""Set display attributes.
:param list attrs: a list of display attributes to set.
"""
replace = {}
# Fast path for resetting all attributes.
if not attrs or attrs == (0, ):
self.cursor.attrs = self.default_char
... | [
"def",
"select_graphic_rendition",
"(",
"self",
",",
"*",
"attrs",
")",
":",
"replace",
"=",
"{",
"}",
"# Fast path for resetting all attributes.",
"if",
"not",
"attrs",
"or",
"attrs",
"==",
"(",
"0",
",",
")",
":",
"self",
".",
"cursor",
".",
"attrs",
"="... | Set display attributes.
:param list attrs: a list of display attributes to set. | [
"Set",
"display",
"attributes",
"."
] | python | train | 39.340426 |
fastai/fastai | fastai/layers.py | https://github.com/fastai/fastai/blob/9fb84a5cdefe5a766cdb792b8f5d8971737b7e67/fastai/layers.py#L124-L126 | def relu(inplace:bool=False, leaky:float=None):
"Return a relu activation, maybe `leaky` and `inplace`."
return nn.LeakyReLU(inplace=inplace, negative_slope=leaky) if leaky is not None else nn.ReLU(inplace=inplace) | [
"def",
"relu",
"(",
"inplace",
":",
"bool",
"=",
"False",
",",
"leaky",
":",
"float",
"=",
"None",
")",
":",
"return",
"nn",
".",
"LeakyReLU",
"(",
"inplace",
"=",
"inplace",
",",
"negative_slope",
"=",
"leaky",
")",
"if",
"leaky",
"is",
"not",
"None... | Return a relu activation, maybe `leaky` and `inplace`. | [
"Return",
"a",
"relu",
"activation",
"maybe",
"leaky",
"and",
"inplace",
"."
] | python | train | 73.333333 |
klmitch/framer | framer/transport.py | https://github.com/klmitch/framer/blob/bd34cee9737793dab61d1d8973930b64bd08acb4/framer/transport.py#L358-L374 | def resume_reading(self):
"""
Called by the client protocol to resume the receiving end.
The protocol's ``frame_received()`` method will be called once
again if some data is available for reading.
"""
# Clear the read pause status
self._recv_paused = False
... | [
"def",
"resume_reading",
"(",
"self",
")",
":",
"# Clear the read pause status",
"self",
".",
"_recv_paused",
"=",
"False",
"# Call resume_reading() on the transport",
"self",
".",
"_transport",
".",
"resume_reading",
"(",
")",
"# If there's data in the receive buffer, pass i... | Called by the client protocol to resume the receiving end.
The protocol's ``frame_received()`` method will be called once
again if some data is available for reading. | [
"Called",
"by",
"the",
"client",
"protocol",
"to",
"resume",
"the",
"receiving",
"end",
".",
"The",
"protocol",
"s",
"frame_received",
"()",
"method",
"will",
"be",
"called",
"once",
"again",
"if",
"some",
"data",
"is",
"available",
"for",
"reading",
"."
] | python | train | 32.058824 |
MLAB-project/pymlab | src/pymlab/sensors/iic.py | https://github.com/MLAB-project/pymlab/blob/d18d858ae83b203defcf2aead0dbd11b3c444658/src/pymlab/sensors/iic.py#L105-L117 | def write_byte_data(self, address, register, value):
"""
SMBus Read Byte: i2c_smbus_read_byte_data()
============================================
This reads a single byte from a device, from a designated register.
The register is specified through the Comm byte.
S Addr... | [
"def",
"write_byte_data",
"(",
"self",
",",
"address",
",",
"register",
",",
"value",
")",
":",
"return",
"self",
".",
"smbus",
".",
"write_byte_data",
"(",
"address",
",",
"register",
",",
"value",
")"
] | SMBus Read Byte: i2c_smbus_read_byte_data()
============================================
This reads a single byte from a device, from a designated register.
The register is specified through the Comm byte.
S Addr Wr [A] Comm [A] S Addr Rd [A] [Data] NA P
Functionality flag: I... | [
"SMBus",
"Read",
"Byte",
":",
"i2c_smbus_read_byte_data",
"()",
"============================================"
] | python | train | 37.615385 |
caseyjlaw/rtpipe | rtpipe/parsesdm.py | https://github.com/caseyjlaw/rtpipe/blob/ac33e4332cf215091a63afbb3137850876d73ec0/rtpipe/parsesdm.py#L518-L559 | def read_scans(sdmfile, bdfdir=''):
""" Use sdmpy to get all scans and info needed for rtpipe as dict """
sdm = getsdm(sdmfile, bdfdir=bdfdir)
scandict = {}
skippedscans = []
for scan in sdm.scans():
scannum = int(scan.idx)
scandict[scannum] = {}
intentstr = ' '.join(scan.... | [
"def",
"read_scans",
"(",
"sdmfile",
",",
"bdfdir",
"=",
"''",
")",
":",
"sdm",
"=",
"getsdm",
"(",
"sdmfile",
",",
"bdfdir",
"=",
"bdfdir",
")",
"scandict",
"=",
"{",
"}",
"skippedscans",
"=",
"[",
"]",
"for",
"scan",
"in",
"sdm",
".",
"scans",
"(... | Use sdmpy to get all scans and info needed for rtpipe as dict | [
"Use",
"sdmpy",
"to",
"get",
"all",
"scans",
"and",
"info",
"needed",
"for",
"rtpipe",
"as",
"dict"
] | python | train | 34.97619 |
maartenbreddels/ipyvolume | ipyvolume/pylab.py | https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L168-L222 | def figure(
key=None,
width=400,
height=500,
lighting=True,
controls=True,
controls_vr=False,
controls_light=False,
debug=False,
**kwargs
):
"""Create a new figure if no key is given, or return the figure associated with key.
:param key: Python object that identifies this fi... | [
"def",
"figure",
"(",
"key",
"=",
"None",
",",
"width",
"=",
"400",
",",
"height",
"=",
"500",
",",
"lighting",
"=",
"True",
",",
"controls",
"=",
"True",
",",
"controls_vr",
"=",
"False",
",",
"controls_light",
"=",
"False",
",",
"debug",
"=",
"Fals... | Create a new figure if no key is given, or return the figure associated with key.
:param key: Python object that identifies this figure
:param int width: pixel width of WebGL canvas
:param int height: .. height ..
:param bool lighting: use lighting or not
:param bool controls: show controls or not... | [
"Create",
"a",
"new",
"figure",
"if",
"no",
"key",
"is",
"given",
"or",
"return",
"the",
"figure",
"associated",
"with",
"key",
"."
] | python | train | 44.381818 |
solvebio/solvebio-python | solvebio/query.py | https://github.com/solvebio/solvebio-python/blob/b29614643043afd19c1d8074e8f25c6700d51a73/solvebio/query.py#L656-L683 | def execute(self, offset=0, **query):
"""
Executes a query. Additional query parameters can be passed
as keyword arguments.
Returns: The request parameters and the raw query response.
"""
_params = self._build_query(**query)
self._page_offset = offset
_p... | [
"def",
"execute",
"(",
"self",
",",
"offset",
"=",
"0",
",",
"*",
"*",
"query",
")",
":",
"_params",
"=",
"self",
".",
"_build_query",
"(",
"*",
"*",
"query",
")",
"self",
".",
"_page_offset",
"=",
"offset",
"_params",
".",
"update",
"(",
"offset",
... | Executes a query. Additional query parameters can be passed
as keyword arguments.
Returns: The request parameters and the raw query response. | [
"Executes",
"a",
"query",
".",
"Additional",
"query",
"parameters",
"can",
"be",
"passed",
"as",
"keyword",
"arguments",
"."
] | python | test | 33.035714 |
DecBayComp/RWA-python | rwa/generic.py | https://github.com/DecBayComp/RWA-python/blob/734a52e15a0e8c244d84d74acf3fd64721074732/rwa/generic.py#L241-L274 | def pokeStorable(self, storable, objname, obj, container, visited=None, _stack=None, **kwargs):
"""
Arguments:
storable (StorableHandler): storable instance.
objname (any): record reference.
obj (any): object to be serialized.
container (any): containe... | [
"def",
"pokeStorable",
"(",
"self",
",",
"storable",
",",
"objname",
",",
"obj",
",",
"container",
",",
"visited",
"=",
"None",
",",
"_stack",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"#print((objname, storable.storable_type)) # debug",
"storable",
".",... | Arguments:
storable (StorableHandler): storable instance.
objname (any): record reference.
obj (any): object to be serialized.
container (any): container.
visited (dict): map of the previously serialized objects that are
passed by referenc... | [
"Arguments",
":"
] | python | train | 39.264706 |
trevisanj/f311 | f311/hapi.py | https://github.com/trevisanj/f311/blob/9e502a3d1e1f74d4290a8a0bae9a34ef8d7b29f7/f311/hapi.py#L11840-L11853 | def SLIT_DIFFRACTION(x,g):
"""
Instrumental (slit) function.
"""
y = zeros(len(x))
index_zero = x==0
index_nonzero = ~index_zero
dk_ = pi/g
x_ = dk_*x[index_nonzero]
w_ = sin(x_)
r_ = w_**2/x_**2
y[index_zero] = 1
y[index_nonzero] = r_/g
return y | [
"def",
"SLIT_DIFFRACTION",
"(",
"x",
",",
"g",
")",
":",
"y",
"=",
"zeros",
"(",
"len",
"(",
"x",
")",
")",
"index_zero",
"=",
"x",
"==",
"0",
"index_nonzero",
"=",
"~",
"index_zero",
"dk_",
"=",
"pi",
"/",
"g",
"x_",
"=",
"dk_",
"*",
"x",
"[",... | Instrumental (slit) function. | [
"Instrumental",
"(",
"slit",
")",
"function",
"."
] | python | train | 20.357143 |
saltstack/salt | salt/modules/moosefs.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/moosefs.py#L92-L124 | def mounts():
'''
Return a list of current MooseFS mounts
CLI Example:
.. code-block:: bash
salt '*' moosefs.mounts
'''
cmd = 'mount'
ret = {}
out = __salt__['cmd.run_all'](cmd)
output = out['stdout'].splitlines()
for line in output:
if not line:
c... | [
"def",
"mounts",
"(",
")",
":",
"cmd",
"=",
"'mount'",
"ret",
"=",
"{",
"}",
"out",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"cmd",
")",
"output",
"=",
"out",
"[",
"'stdout'",
"]",
".",
"splitlines",
"(",
")",
"for",
"line",
"in",
"output",... | Return a list of current MooseFS mounts
CLI Example:
.. code-block:: bash
salt '*' moosefs.mounts | [
"Return",
"a",
"list",
"of",
"current",
"MooseFS",
"mounts"
] | python | train | 24.939394 |
brunato/lograptor | lograptor/timedate.py | https://github.com/brunato/lograptor/blob/b1f09fe1b429ed15110610092704ef12d253f3c9/lograptor/timedate.py#L168-L178 | def between(self, time_):
"""
Compare if the parameter HH:MM is in the time range.
"""
hour = int(time_[0:2])
minute = int(time_[3:5])
return not (
hour < self.h1 or hour > self.h2 or
(hour == self.h1 and minute < self.m1) or
(hour == s... | [
"def",
"between",
"(",
"self",
",",
"time_",
")",
":",
"hour",
"=",
"int",
"(",
"time_",
"[",
"0",
":",
"2",
"]",
")",
"minute",
"=",
"int",
"(",
"time_",
"[",
"3",
":",
"5",
"]",
")",
"return",
"not",
"(",
"hour",
"<",
"self",
".",
"h1",
"... | Compare if the parameter HH:MM is in the time range. | [
"Compare",
"if",
"the",
"parameter",
"HH",
":",
"MM",
"is",
"in",
"the",
"time",
"range",
"."
] | python | train | 31.636364 |
gem/oq-engine | openquake/calculators/export/risk.py | https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/calculators/export/risk.py#L316-L369 | def export_agg_losses_ebr(ekey, dstore):
"""
:param ekey: export key, i.e. a pair (datastore key, fmt)
:param dstore: datastore object
"""
if 'ruptures' not in dstore:
logging.warning('There are no ruptures in the datastore')
return []
name, ext = export.keyfunc(ekey)
agg_los... | [
"def",
"export_agg_losses_ebr",
"(",
"ekey",
",",
"dstore",
")",
":",
"if",
"'ruptures'",
"not",
"in",
"dstore",
":",
"logging",
".",
"warning",
"(",
"'There are no ruptures in the datastore'",
")",
"return",
"[",
"]",
"name",
",",
"ext",
"=",
"export",
".",
... | :param ekey: export key, i.e. a pair (datastore key, fmt)
:param dstore: datastore object | [
":",
"param",
"ekey",
":",
"export",
"key",
"i",
".",
"e",
".",
"a",
"pair",
"(",
"datastore",
"key",
"fmt",
")",
":",
"param",
"dstore",
":",
"datastore",
"object"
] | python | train | 39.722222 |
c-soft/satel_integra | satel_integra/satel_integra.py | https://github.com/c-soft/satel_integra/blob/3b6d2020d1e10dc5aa40f30ee4ecc0f3a053eb3c/satel_integra/satel_integra.py#L445-L450 | def close(self):
"""Stop monitoring and close connection."""
_LOGGER.debug("Closing...")
self.closed = True
if self.connected:
self._writer.close() | [
"def",
"close",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Closing...\"",
")",
"self",
".",
"closed",
"=",
"True",
"if",
"self",
".",
"connected",
":",
"self",
".",
"_writer",
".",
"close",
"(",
")"
] | Stop monitoring and close connection. | [
"Stop",
"monitoring",
"and",
"close",
"connection",
"."
] | python | test | 31 |
jssimporter/python-jss | jss/jamf_software_server.py | https://github.com/jssimporter/python-jss/blob/b95185d74e0c0531b0b563f280d4129e21d5fe5d/jss/jamf_software_server.py#L292-L314 | def delete(self, url_path, data=None):
"""Delete an object from the JSS.
In general, it is better to use a higher level interface for
deleting objects, namely, using a JSSObject's delete method.
Args:
url_path: String API endpoint path to DEL, with ID (e.g.
... | [
"def",
"delete",
"(",
"self",
",",
"url_path",
",",
"data",
"=",
"None",
")",
":",
"request_url",
"=",
"\"%s%s\"",
"%",
"(",
"self",
".",
"_url",
",",
"url_path",
")",
"if",
"data",
":",
"response",
"=",
"self",
".",
"session",
".",
"delete",
"(",
... | Delete an object from the JSS.
In general, it is better to use a higher level interface for
deleting objects, namely, using a JSSObject's delete method.
Args:
url_path: String API endpoint path to DEL, with ID (e.g.
"/packages/id/<object ID>")
Raises:
... | [
"Delete",
"an",
"object",
"from",
"the",
"JSS",
"."
] | python | train | 36.304348 |
basho/riak-python-client | riak/codecs/http.py | https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L223-L252 | def _normalize_json_search_response(self, json):
"""
Normalizes a JSON search response so that PB and HTTP have the
same return value
"""
result = {}
if 'facet_counts' in json:
result['facet_counts'] = json[u'facet_counts']
if 'grouped' in json:
... | [
"def",
"_normalize_json_search_response",
"(",
"self",
",",
"json",
")",
":",
"result",
"=",
"{",
"}",
"if",
"'facet_counts'",
"in",
"json",
":",
"result",
"[",
"'facet_counts'",
"]",
"=",
"json",
"[",
"u'facet_counts'",
"]",
"if",
"'grouped'",
"in",
"json",... | Normalizes a JSON search response so that PB and HTTP have the
same return value | [
"Normalizes",
"a",
"JSON",
"search",
"response",
"so",
"that",
"PB",
"and",
"HTTP",
"have",
"the",
"same",
"return",
"value"
] | python | train | 39.2 |
saltstack/salt | salt/modules/boto_secgroup.py | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_secgroup.py#L319-L342 | def convert_to_group_ids(groups, vpc_id=None, vpc_name=None, region=None, key=None,
keyid=None, profile=None):
'''
Given a list of security groups and a vpc_id, convert_to_group_ids will
convert all list items in the given list to security group ids.
CLI example::
salt... | [
"def",
"convert_to_group_ids",
"(",
"groups",
",",
"vpc_id",
"=",
"None",
",",
"vpc_name",
"=",
"None",
",",
"region",
"=",
"None",
",",
"key",
"=",
"None",
",",
"keyid",
"=",
"None",
",",
"profile",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
... | Given a list of security groups and a vpc_id, convert_to_group_ids will
convert all list items in the given list to security group ids.
CLI example::
salt myminion boto_secgroup.convert_to_group_ids mysecgroup vpc-89yhh7h | [
"Given",
"a",
"list",
"of",
"security",
"groups",
"and",
"a",
"vpc_id",
"convert_to_group_ids",
"will",
"convert",
"all",
"list",
"items",
"in",
"the",
"given",
"list",
"to",
"security",
"group",
"ids",
"."
] | python | train | 46.166667 |
titusjan/argos | argos/inspector/qtplugins/table.py | https://github.com/titusjan/argos/blob/20d0a3cae26c36ea789a5d219c02ca7df21279dd/argos/inspector/qtplugins/table.py#L404-L446 | def updateState(self, slicedArray, rtiInfo, separateFields):
""" Sets the slicedArray and rtiInfo and other members. This will reset the model.
Will be called from the tableInspector._drawContents.
"""
self.beginResetModel()
try:
# The sliced array can be a maske... | [
"def",
"updateState",
"(",
"self",
",",
"slicedArray",
",",
"rtiInfo",
",",
"separateFields",
")",
":",
"self",
".",
"beginResetModel",
"(",
")",
"try",
":",
"# The sliced array can be a masked array or a (regular) numpy array.",
"# The table works fine with masked arrays, no... | Sets the slicedArray and rtiInfo and other members. This will reset the model.
Will be called from the tableInspector._drawContents. | [
"Sets",
"the",
"slicedArray",
"and",
"rtiInfo",
"and",
"other",
"members",
".",
"This",
"will",
"reset",
"the",
"model",
"."
] | python | train | 43.186047 |
CalebBell/ht | ht/conv_internal.py | https://github.com/CalebBell/ht/blob/3097ef9524c4cf0068ad453c17b10ec9ce551eee/ht/conv_internal.py#L336-L383 | def turbulent_Sieder_Tate(Re, Pr, mu=None, mu_w=None):
r'''Calculates internal convection Nusselt number for turbulent flows
in pipe according to [1]_ and supposedly [2]_.
.. math::
Nu = 0.027Re^{4/5}Pr^{1/3}\left(\frac{\mu}{\mu_s}\right)^{0.14}
Parameters
----------
Re : float
... | [
"def",
"turbulent_Sieder_Tate",
"(",
"Re",
",",
"Pr",
",",
"mu",
"=",
"None",
",",
"mu_w",
"=",
"None",
")",
":",
"Nu",
"=",
"0.027",
"*",
"Re",
"**",
"0.8",
"*",
"Pr",
"**",
"(",
"1",
"/",
"3.",
")",
"if",
"mu_w",
"and",
"mu",
":",
"Nu",
"*=... | r'''Calculates internal convection Nusselt number for turbulent flows
in pipe according to [1]_ and supposedly [2]_.
.. math::
Nu = 0.027Re^{4/5}Pr^{1/3}\left(\frac{\mu}{\mu_s}\right)^{0.14}
Parameters
----------
Re : float
Reynolds number, [-]
Pr : float
Prandtl number... | [
"r",
"Calculates",
"internal",
"convection",
"Nusselt",
"number",
"for",
"turbulent",
"flows",
"in",
"pipe",
"according",
"to",
"[",
"1",
"]",
"_",
"and",
"supposedly",
"[",
"2",
"]",
"_",
"."
] | python | train | 29.916667 |
globality-corp/microcosm | microcosm/scoping/factories.py | https://github.com/globality-corp/microcosm/blob/6856200ca295da4269c8c1c9de7db0b97c1f4523/microcosm/scoping/factories.py#L96-L110 | def infect(cls, graph, key, default_scope=None):
"""
Forcibly convert an entry-point based factory to a ScopedFactory.
Must be invoked before resolving the entry point.
:raises AlreadyBoundError: for non entry-points; these should be declared with @scoped_binding
"""
f... | [
"def",
"infect",
"(",
"cls",
",",
"graph",
",",
"key",
",",
"default_scope",
"=",
"None",
")",
":",
"func",
"=",
"graph",
".",
"factory_for",
"(",
"key",
")",
"if",
"isinstance",
"(",
"func",
",",
"cls",
")",
":",
"func",
"=",
"func",
".",
"func",
... | Forcibly convert an entry-point based factory to a ScopedFactory.
Must be invoked before resolving the entry point.
:raises AlreadyBoundError: for non entry-points; these should be declared with @scoped_binding | [
"Forcibly",
"convert",
"an",
"entry",
"-",
"point",
"based",
"factory",
"to",
"a",
"ScopedFactory",
"."
] | python | train | 34.466667 |
unt-libraries/pypairtree | pypairtree/pairtree.py | https://github.com/unt-libraries/pypairtree/blob/2107b46718bbf9ef7ef3d5c63d557d1f772e5d69/pypairtree/pairtree.py#L51-L62 | def pair_tree_creator(meta_id):
"""Splits string into a pairtree path."""
chunks = []
for x in range(0, len(meta_id)):
if x % 2:
continue
if (len(meta_id) - 1) == x:
chunk = meta_id[x]
else:
chunk = meta_id[x: x + 2]
chunks.append(chunk)
... | [
"def",
"pair_tree_creator",
"(",
"meta_id",
")",
":",
"chunks",
"=",
"[",
"]",
"for",
"x",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"meta_id",
")",
")",
":",
"if",
"x",
"%",
"2",
":",
"continue",
"if",
"(",
"len",
"(",
"meta_id",
")",
"-",
"1"... | Splits string into a pairtree path. | [
"Splits",
"string",
"into",
"a",
"pairtree",
"path",
"."
] | python | train | 29.583333 |
fermiPy/fermipy | fermipy/jobs/link.py | https://github.com/fermiPy/fermipy/blob/9df5e7e3728307fd58c5bba36fd86783c39fbad4/fermipy/jobs/link.py#L427-L461 | def _create_job_details(self, key, job_config, logfile, status):
"""Create a `JobDetails` for a single job
Parameters
----------
key : str
Key used to identify this particular job
job_config : dict
Dictionary with arguements passed to this particular jo... | [
"def",
"_create_job_details",
"(",
"self",
",",
"key",
",",
"job_config",
",",
"logfile",
",",
"status",
")",
":",
"self",
".",
"update_args",
"(",
"job_config",
")",
"job_details",
"=",
"JobDetails",
"(",
"jobname",
"=",
"self",
".",
"full_linkname",
",",
... | Create a `JobDetails` for a single job
Parameters
----------
key : str
Key used to identify this particular job
job_config : dict
Dictionary with arguements passed to this particular job
logfile : str
Name of the associated log file
... | [
"Create",
"a",
"JobDetails",
"for",
"a",
"single",
"job"
] | python | train | 33 |
tensorflow/probability | tensorflow_probability/python/distributions/internal/correlation_matrix_volumes_lib.py | https://github.com/tensorflow/probability/blob/e87fe34111d68c35db0f9eeb4935f1ece9e1a8f5/tensorflow_probability/python/distributions/internal/correlation_matrix_volumes_lib.py#L77-L104 | def _psd_mask(x):
"""Computes whether each square matrix in the input is positive semi-definite.
Args:
x: A floating-point `Tensor` of shape `[B1, ..., Bn, M, M]`.
Returns:
mask: A floating-point `Tensor` of shape `[B1, ... Bn]`. Each
scalar is 1 if the corresponding matrix was PSD, otherwise 0.
... | [
"def",
"_psd_mask",
"(",
"x",
")",
":",
"# Allegedly",
"# https://scicomp.stackexchange.com/questions/12979/testing-if-a-matrix-is-positive-semi-definite",
"# it is more efficient to test for positive semi-definiteness by",
"# trying to compute the Cholesky decomposition -- the matrix is PSD",
"... | Computes whether each square matrix in the input is positive semi-definite.
Args:
x: A floating-point `Tensor` of shape `[B1, ..., Bn, M, M]`.
Returns:
mask: A floating-point `Tensor` of shape `[B1, ... Bn]`. Each
scalar is 1 if the corresponding matrix was PSD, otherwise 0. | [
"Computes",
"whether",
"each",
"square",
"matrix",
"in",
"the",
"input",
"is",
"positive",
"semi",
"-",
"definite",
"."
] | python | test | 47.071429 |
Jajcus/pyxmpp2 | pyxmpp2/mainloop/events.py | https://github.com/Jajcus/pyxmpp2/blob/14a40a3950910a9cd008b55f0d8905aa0186ce18/pyxmpp2/mainloop/events.py#L105-L116 | def _update_handlers(self):
"""Update `_handler_map` after `handlers` have been
modified."""
handler_map = defaultdict(list)
for i, obj in enumerate(self.handlers):
for dummy, handler in inspect.getmembers(obj, callable):
if not hasattr(handler, "_pyxmpp_event... | [
"def",
"_update_handlers",
"(",
"self",
")",
":",
"handler_map",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"i",
",",
"obj",
"in",
"enumerate",
"(",
"self",
".",
"handlers",
")",
":",
"for",
"dummy",
",",
"handler",
"in",
"inspect",
".",
"getmembers",
... | Update `_handler_map` after `handlers` have been
modified. | [
"Update",
"_handler_map",
"after",
"handlers",
"have",
"been",
"modified",
"."
] | python | valid | 46.416667 |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_sec_services.py | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_sec_services.py#L230-L241 | def ssh_sa_ssh_client_mac(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
ssh_sa = ET.SubElement(config, "ssh-sa", xmlns="urn:brocade.com:mgmt:brocade-sec-services")
ssh = ET.SubElement(ssh_sa, "ssh")
client = ET.SubElement(ssh, "client")
... | [
"def",
"ssh_sa_ssh_client_mac",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"ssh_sa",
"=",
"ET",
".",
"SubElement",
"(",
"config",
",",
"\"ssh-sa\"",
",",
"xmlns",
"=",
"\"urn:brocade.com:mgm... | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | python | train | 39.333333 |
annoviko/pyclustering | pyclustering/nnet/dynamic_visualizer.py | https://github.com/annoviko/pyclustering/blob/98aa0dd89fd36f701668fb1eb29c8fb5662bf7d0/pyclustering/nnet/dynamic_visualizer.py#L195-L210 | def set_canvas_properties(self, canvas, x_title=None, y_title=None, x_lim=None, y_lim=None, x_labels=True, y_labels=True):
"""!
@brief Set properties for specified canvas.
@param[in] canvas (uint): Index of canvas whose properties should changed.
@param[in] x_title (string): Title ... | [
"def",
"set_canvas_properties",
"(",
"self",
",",
"canvas",
",",
"x_title",
"=",
"None",
",",
"y_title",
"=",
"None",
",",
"x_lim",
"=",
"None",
",",
"y_lim",
"=",
"None",
",",
"x_labels",
"=",
"True",
",",
"y_labels",
"=",
"True",
")",
":",
"self",
... | !
@brief Set properties for specified canvas.
@param[in] canvas (uint): Index of canvas whose properties should changed.
@param[in] x_title (string): Title for X axis, if 'None', then nothing is displayed.
@param[in] y_title (string): Title for Y axis, if 'None', then nothing is di... | [
"!"
] | python | valid | 65.8125 |
NuGrid/NuGridPy | nugridpy/grain.py | https://github.com/NuGrid/NuGridPy/blob/eee8047446e398be77362d82c1d8b3310054fab0/nugridpy/grain.py#L1144-L1153 | def iso_name_converter(iso):
'''
Converts the name of the given isotope (input), e.g., 'N-14' to
14N as used later to compare w/ grain database.
'''
sp = iso.split('-')
output = sp[1] + sp[0]
return output.lower() | [
"def",
"iso_name_converter",
"(",
"iso",
")",
":",
"sp",
"=",
"iso",
".",
"split",
"(",
"'-'",
")",
"output",
"=",
"sp",
"[",
"1",
"]",
"+",
"sp",
"[",
"0",
"]",
"return",
"output",
".",
"lower",
"(",
")"
] | Converts the name of the given isotope (input), e.g., 'N-14' to
14N as used later to compare w/ grain database. | [
"Converts",
"the",
"name",
"of",
"the",
"given",
"isotope",
"(",
"input",
")",
"e",
".",
"g",
".",
"N",
"-",
"14",
"to",
"14N",
"as",
"used",
"later",
"to",
"compare",
"w",
"/",
"grain",
"database",
"."
] | python | train | 23.4 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.