repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
pybel/pybel-artifactory | src/pybel_artifactory/utils.py | get_namespace_url | def get_namespace_url(module, version):
"""Get a BEL namespace file from Artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_namespace_module_url(module),
name=g... | python | def get_namespace_url(module, version):
"""Get a BEL namespace file from Artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_namespace_module_url(module),
name=g... | [
"def",
"get_namespace_url",
"(",
"module",
",",
"version",
")",
":",
"module",
"=",
"module",
".",
"strip",
"(",
"'/'",
")",
"return",
"'{module}/{name}'",
".",
"format",
"(",
"module",
"=",
"get_namespace_module_url",
"(",
"module",
")",
",",
"name",
"=",
... | Get a BEL namespace file from Artifactory given the name and version.
:param str module:
:param str version:
:type: str | [
"Get",
"a",
"BEL",
"namespace",
"file",
"from",
"Artifactory",
"given",
"the",
"name",
"and",
"version",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/utils.py#L20-L32 |
pybel/pybel-artifactory | src/pybel_artifactory/utils.py | get_annotation_url | def get_annotation_url(module, version):
"""Get a BEL annotation file from artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_annotation_module_url(module),
nam... | python | def get_annotation_url(module, version):
"""Get a BEL annotation file from artifactory given the name and version.
:param str module:
:param str version:
:type: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_annotation_module_url(module),
nam... | [
"def",
"get_annotation_url",
"(",
"module",
",",
"version",
")",
":",
"module",
"=",
"module",
".",
"strip",
"(",
"'/'",
")",
"return",
"'{module}/{name}'",
".",
"format",
"(",
"module",
"=",
"get_annotation_module_url",
"(",
"module",
")",
",",
"name",
"=",... | Get a BEL annotation file from artifactory given the name and version.
:param str module:
:param str version:
:type: str | [
"Get",
"a",
"BEL",
"annotation",
"file",
"from",
"artifactory",
"given",
"the",
"name",
"and",
"version",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/utils.py#L35-L47 |
pybel/pybel-artifactory | src/pybel_artifactory/utils.py | get_knowledge_url | def get_knowledge_url(module, version):
"""Get a BEL knowledge file from Artifactory given the name and version.
:param str module:
:param str version:
:rtype: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_knowledge_module_url(module),
name=... | python | def get_knowledge_url(module, version):
"""Get a BEL knowledge file from Artifactory given the name and version.
:param str module:
:param str version:
:rtype: str
"""
module = module.strip('/')
return '{module}/{name}'.format(
module=get_knowledge_module_url(module),
name=... | [
"def",
"get_knowledge_url",
"(",
"module",
",",
"version",
")",
":",
"module",
"=",
"module",
".",
"strip",
"(",
"'/'",
")",
"return",
"'{module}/{name}'",
".",
"format",
"(",
"module",
"=",
"get_knowledge_module_url",
"(",
"module",
")",
",",
"name",
"=",
... | Get a BEL knowledge file from Artifactory given the name and version.
:param str module:
:param str version:
:rtype: str | [
"Get",
"a",
"BEL",
"knowledge",
"file",
"from",
"Artifactory",
"given",
"the",
"name",
"and",
"version",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/utils.py#L50-L62 |
xaptum/xtt-python | _build_xtt.py | local_path | def local_path(path):
"""
Return the absolute path relative to the root of this project
"""
current = os.path.dirname(__file__)
root = current
return os.path.abspath(os.path.join(root, path)) | python | def local_path(path):
"""
Return the absolute path relative to the root of this project
"""
current = os.path.dirname(__file__)
root = current
return os.path.abspath(os.path.join(root, path)) | [
"def",
"local_path",
"(",
"path",
")",
":",
"current",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
"root",
"=",
"current",
"return",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"root",
",",
"path",... | Return the absolute path relative to the root of this project | [
"Return",
"the",
"absolute",
"path",
"relative",
"to",
"the",
"root",
"of",
"this",
"project"
] | train | https://github.com/xaptum/xtt-python/blob/23ee469488d710d730314bec1136c4dd7ac2cd5c/_build_xtt.py#L42-L48 |
quasipedia/swaggery | swaggery/application.py | Swaggery._register_resources | def _register_resources(self, api_dirs, do_checks):
'''Register all Apis, Resources and Models with the application.'''
msg = 'Looking-up for APIs in the following directories: {}'
log.debug(msg.format(api_dirs))
if do_checks:
check_and_load(api_dirs)
else:
... | python | def _register_resources(self, api_dirs, do_checks):
'''Register all Apis, Resources and Models with the application.'''
msg = 'Looking-up for APIs in the following directories: {}'
log.debug(msg.format(api_dirs))
if do_checks:
check_and_load(api_dirs)
else:
... | [
"def",
"_register_resources",
"(",
"self",
",",
"api_dirs",
",",
"do_checks",
")",
":",
"msg",
"=",
"'Looking-up for APIs in the following directories: {}'",
"log",
".",
"debug",
"(",
"msg",
".",
"format",
"(",
"api_dirs",
")",
")",
"if",
"do_checks",
":",
"chec... | Register all Apis, Resources and Models with the application. | [
"Register",
"all",
"Apis",
"Resources",
"and",
"Models",
"with",
"the",
"application",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/application.py#L35-L46 |
quasipedia/swaggery | swaggery/application.py | Swaggery._mount_resources | def _mount_resources(self):
'''Mount all registered resources onto the application.'''
rules = []
self.callback_map = {}
for ep in Resource:
for rule, callback in ep.get_routing_tuples():
log.debug('Path "{}" mapped to "{}"'.format(
rule.ru... | python | def _mount_resources(self):
'''Mount all registered resources onto the application.'''
rules = []
self.callback_map = {}
for ep in Resource:
for rule, callback in ep.get_routing_tuples():
log.debug('Path "{}" mapped to "{}"'.format(
rule.ru... | [
"def",
"_mount_resources",
"(",
"self",
")",
":",
"rules",
"=",
"[",
"]",
"self",
".",
"callback_map",
"=",
"{",
"}",
"for",
"ep",
"in",
"Resource",
":",
"for",
"rule",
",",
"callback",
"in",
"ep",
".",
"get_routing_tuples",
"(",
")",
":",
"log",
"."... | Mount all registered resources onto the application. | [
"Mount",
"all",
"registered",
"resources",
"onto",
"the",
"application",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/application.py#L48-L58 |
quasipedia/swaggery | swaggery/application.py | Swaggery._get_coroutine | def _get_coroutine(self, request, start_response):
'''Try to dispapch the request and get the matching coroutine.'''
adapter = self.url_map.bind_to_environ(request.environ)
resource, kwargs = adapter.match()
callback = self.callback_map[resource]
inject_extra_args(callback, reque... | python | def _get_coroutine(self, request, start_response):
'''Try to dispapch the request and get the matching coroutine.'''
adapter = self.url_map.bind_to_environ(request.environ)
resource, kwargs = adapter.match()
callback = self.callback_map[resource]
inject_extra_args(callback, reque... | [
"def",
"_get_coroutine",
"(",
"self",
",",
"request",
",",
"start_response",
")",
":",
"adapter",
"=",
"self",
".",
"url_map",
".",
"bind_to_environ",
"(",
"request",
".",
"environ",
")",
"resource",
",",
"kwargs",
"=",
"adapter",
".",
"match",
"(",
")",
... | Try to dispapch the request and get the matching coroutine. | [
"Try",
"to",
"dispapch",
"the",
"request",
"and",
"get",
"the",
"matching",
"coroutine",
"."
] | train | https://github.com/quasipedia/swaggery/blob/89a2e1b2bebbc511c781c9e63972f65aef73cc2f/swaggery/application.py#L60-L66 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.SetAuth | def SetAuth(self, style, user=None, password=None):
'''Change auth style, return object to user.
'''
self.auth_style, self.auth_user, self.auth_pass = \
style, user, password
return self | python | def SetAuth(self, style, user=None, password=None):
'''Change auth style, return object to user.
'''
self.auth_style, self.auth_user, self.auth_pass = \
style, user, password
return self | [
"def",
"SetAuth",
"(",
"self",
",",
"style",
",",
"user",
"=",
"None",
",",
"password",
"=",
"None",
")",
":",
"self",
".",
"auth_style",
",",
"self",
".",
"auth_user",
",",
"self",
".",
"auth_pass",
"=",
"style",
",",
"user",
",",
"password",
"retur... | Change auth style, return object to user. | [
"Change",
"auth",
"style",
"return",
"object",
"to",
"user",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L139-L144 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.AddHeader | def AddHeader(self, header, value):
'''Add a header to send.
'''
self.user_headers.append((header, value))
return self | python | def AddHeader(self, header, value):
'''Add a header to send.
'''
self.user_headers.append((header, value))
return self | [
"def",
"AddHeader",
"(",
"self",
",",
"header",
",",
"value",
")",
":",
"self",
".",
"user_headers",
".",
"append",
"(",
"(",
"header",
",",
"value",
")",
")",
"return",
"self"
] | Add a header to send. | [
"Add",
"a",
"header",
"to",
"send",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L163-L167 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.__addcookies | def __addcookies(self):
'''Add cookies from self.cookies to request in self.h
'''
for cname, morsel in self.cookies.items():
attrs = []
value = morsel.get('version', '')
if value != '' and value != '0':
attrs.append('$Version=%s' % value)
... | python | def __addcookies(self):
'''Add cookies from self.cookies to request in self.h
'''
for cname, morsel in self.cookies.items():
attrs = []
value = morsel.get('version', '')
if value != '' and value != '0':
attrs.append('$Version=%s' % value)
... | [
"def",
"__addcookies",
"(",
"self",
")",
":",
"for",
"cname",
",",
"morsel",
"in",
"self",
".",
"cookies",
".",
"items",
"(",
")",
":",
"attrs",
"=",
"[",
"]",
"value",
"=",
"morsel",
".",
"get",
"(",
"'version'",
",",
"''",
")",
"if",
"value",
"... | Add cookies from self.cookies to request in self.h | [
"Add",
"cookies",
"from",
"self",
".",
"cookies",
"to",
"request",
"in",
"self",
".",
"h"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L169-L184 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.RPC | def RPC(self, url, opname, obj, replytype=None, **kw):
'''Send a request, return the reply. See Send() and Recieve()
docstrings for details.
'''
self.Send(url, opname, obj, **kw)
return self.Receive(replytype, **kw) | python | def RPC(self, url, opname, obj, replytype=None, **kw):
'''Send a request, return the reply. See Send() and Recieve()
docstrings for details.
'''
self.Send(url, opname, obj, **kw)
return self.Receive(replytype, **kw) | [
"def",
"RPC",
"(",
"self",
",",
"url",
",",
"opname",
",",
"obj",
",",
"replytype",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"Send",
"(",
"url",
",",
"opname",
",",
"obj",
",",
"*",
"*",
"kw",
")",
"return",
"self",
".",
"Rece... | Send a request, return the reply. See Send() and Recieve()
docstrings for details. | [
"Send",
"a",
"request",
"return",
"the",
"reply",
".",
"See",
"Send",
"()",
"and",
"Recieve",
"()",
"docstrings",
"for",
"details",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L186-L191 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.Send | def Send(self, url, opname, obj, nsdict={}, soapaction=None, wsaction=None,
endPointReference=None, soapheaders=(), **kw):
'''Send a message. If url is None, use the value from the
constructor (else error). obj is the object (data) to send.
Data may be described with a requesttype... | python | def Send(self, url, opname, obj, nsdict={}, soapaction=None, wsaction=None,
endPointReference=None, soapheaders=(), **kw):
'''Send a message. If url is None, use the value from the
constructor (else error). obj is the object (data) to send.
Data may be described with a requesttype... | [
"def",
"Send",
"(",
"self",
",",
"url",
",",
"opname",
",",
"obj",
",",
"nsdict",
"=",
"{",
"}",
",",
"soapaction",
"=",
"None",
",",
"wsaction",
"=",
"None",
",",
"endPointReference",
"=",
"None",
",",
"soapheaders",
"=",
"(",
")",
",",
"*",
"*",
... | Send a message. If url is None, use the value from the
constructor (else error). obj is the object (data) to send.
Data may be described with a requesttypecode keyword, the default
is the class's typecode (if there is one), else Any.
Try to serialize as a Struct, if this is not possib... | [
"Send",
"a",
"message",
".",
"If",
"url",
"is",
"None",
"use",
"the",
"value",
"from",
"the",
"constructor",
"(",
"else",
"error",
")",
".",
"obj",
"is",
"the",
"object",
"(",
"data",
")",
"to",
"send",
".",
"Data",
"may",
"be",
"described",
"with",
... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L193-L292 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.SendSOAPDataHTTPDigestAuth | def SendSOAPDataHTTPDigestAuth(self, response, soapdata, url, request_uri, soapaction, **kw):
'''Resend the initial request w/http digest authorization headers.
The SOAP server has requested authorization. Fetch the challenge,
generate the authdict for building a response.
'''
... | python | def SendSOAPDataHTTPDigestAuth(self, response, soapdata, url, request_uri, soapaction, **kw):
'''Resend the initial request w/http digest authorization headers.
The SOAP server has requested authorization. Fetch the challenge,
generate the authdict for building a response.
'''
... | [
"def",
"SendSOAPDataHTTPDigestAuth",
"(",
"self",
",",
"response",
",",
"soapdata",
",",
"url",
",",
"request_uri",
",",
"soapaction",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"trace",
":",
"print",
">>",
"self",
".",
"trace",
",",
"\"------ Dig... | Resend the initial request w/http digest authorization headers.
The SOAP server has requested authorization. Fetch the challenge,
generate the authdict for building a response. | [
"Resend",
"the",
"initial",
"request",
"w",
"/",
"http",
"digest",
"authorization",
"headers",
".",
"The",
"SOAP",
"server",
"has",
"requested",
"authorization",
".",
"Fetch",
"the",
"challenge",
"generate",
"the",
"authdict",
"for",
"building",
"a",
"response",... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L331-L365 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.ReceiveRaw | def ReceiveRaw(self, **kw):
'''Read a server reply, unconverted to any format and return it.
'''
if self.data: return self.data
trace = self.trace
while 1:
response = self.h.getresponse()
self.reply_code, self.reply_msg, self.reply_headers, self.data = \
... | python | def ReceiveRaw(self, **kw):
'''Read a server reply, unconverted to any format and return it.
'''
if self.data: return self.data
trace = self.trace
while 1:
response = self.h.getresponse()
self.reply_code, self.reply_msg, self.reply_headers, self.data = \
... | [
"def",
"ReceiveRaw",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"data",
":",
"return",
"self",
".",
"data",
"trace",
"=",
"self",
".",
"trace",
"while",
"1",
":",
"response",
"=",
"self",
".",
"h",
".",
"getresponse",
"(",
")"... | Read a server reply, unconverted to any format and return it. | [
"Read",
"a",
"server",
"reply",
"unconverted",
"to",
"any",
"format",
"and",
"return",
"it",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L367-L402 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.ReceiveSOAP | def ReceiveSOAP(self, readerclass=None, **kw):
'''Get back a SOAP message.
'''
if self.ps: return self.ps
if not self.IsSOAP():
raise TypeError(
'Response is "%s", not "text/xml"' % self.reply_headers.type)
if len(self.data) == 0:
raise Typ... | python | def ReceiveSOAP(self, readerclass=None, **kw):
'''Get back a SOAP message.
'''
if self.ps: return self.ps
if not self.IsSOAP():
raise TypeError(
'Response is "%s", not "text/xml"' % self.reply_headers.type)
if len(self.data) == 0:
raise Typ... | [
"def",
"ReceiveSOAP",
"(",
"self",
",",
"readerclass",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"if",
"self",
".",
"ps",
":",
"return",
"self",
".",
"ps",
"if",
"not",
"self",
".",
"IsSOAP",
"(",
")",
":",
"raise",
"TypeError",
"(",
"'Response i... | Get back a SOAP message. | [
"Get",
"back",
"a",
"SOAP",
"message",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L410-L427 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.ReceiveFault | def ReceiveFault(self, **kw):
'''Parse incoming message as a fault. Raise TypeError if no
fault found.
'''
self.ReceiveSOAP(**kw)
if not self.ps.IsAFault():
raise TypeError("Expected SOAP Fault not found")
return FaultFromFaultMessage(self.ps) | python | def ReceiveFault(self, **kw):
'''Parse incoming message as a fault. Raise TypeError if no
fault found.
'''
self.ReceiveSOAP(**kw)
if not self.ps.IsAFault():
raise TypeError("Expected SOAP Fault not found")
return FaultFromFaultMessage(self.ps) | [
"def",
"ReceiveFault",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"ReceiveSOAP",
"(",
"*",
"*",
"kw",
")",
"if",
"not",
"self",
".",
"ps",
".",
"IsAFault",
"(",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected SOAP Fault not found\"",
")"... | Parse incoming message as a fault. Raise TypeError if no
fault found. | [
"Parse",
"incoming",
"message",
"as",
"a",
"fault",
".",
"Raise",
"TypeError",
"if",
"no",
"fault",
"found",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L435-L442 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.Receive | def Receive(self, replytype, **kw):
'''Parse message, create Python object.
KeyWord data:
faults -- list of WSDL operation.fault typecodes
wsaction -- If using WS-Address, must specify Action value we expect to
receive.
'''
self.ReceiveSOAP(**kw... | python | def Receive(self, replytype, **kw):
'''Parse message, create Python object.
KeyWord data:
faults -- list of WSDL operation.fault typecodes
wsaction -- If using WS-Address, must specify Action value we expect to
receive.
'''
self.ReceiveSOAP(**kw... | [
"def",
"Receive",
"(",
"self",
",",
"replytype",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"ReceiveSOAP",
"(",
"*",
"*",
"kw",
")",
"if",
"self",
".",
"ps",
".",
"IsAFault",
"(",
")",
":",
"msg",
"=",
"FaultFromFaultMessage",
"(",
"self",
".",
... | Parse message, create Python object.
KeyWord data:
faults -- list of WSDL operation.fault typecodes
wsaction -- If using WS-Address, must specify Action value we expect to
receive. | [
"Parse",
"message",
"create",
"Python",
"object",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L444-L464 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | Binding.__parse_child | def __parse_child(self, node):
'''for rpc-style map each message part to a class in typesmodule
'''
try:
tc = self.gettypecode(self.typesmodule, node)
except:
self.logger.debug('didnt find typecode for "%s" in typesmodule: %s',
node.localName, sel... | python | def __parse_child(self, node):
'''for rpc-style map each message part to a class in typesmodule
'''
try:
tc = self.gettypecode(self.typesmodule, node)
except:
self.logger.debug('didnt find typecode for "%s" in typesmodule: %s',
node.localName, sel... | [
"def",
"__parse_child",
"(",
"self",
",",
"node",
")",
":",
"try",
":",
"tc",
"=",
"self",
".",
"gettypecode",
"(",
"self",
".",
"typesmodule",
",",
"node",
")",
"except",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'didnt find typecode for \"%s\" in t... | for rpc-style map each message part to a class in typesmodule | [
"for",
"rpc",
"-",
"style",
"map",
"each",
"message",
"part",
"to",
"a",
"class",
"in",
"typesmodule"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L503-L521 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | Binding.Receive | def Receive(self, replytype, **kw):
'''Parse message, create Python object.
KeyWord data:
faults -- list of WSDL operation.fault typecodes
wsaction -- If using WS-Address, must specify Action value we expect to
receive.
'''
self.ReceiveSOAP(**k... | python | def Receive(self, replytype, **kw):
'''Parse message, create Python object.
KeyWord data:
faults -- list of WSDL operation.fault typecodes
wsaction -- If using WS-Address, must specify Action value we expect to
receive.
'''
self.ReceiveSOAP(**k... | [
"def",
"Receive",
"(",
"self",
",",
"replytype",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"ReceiveSOAP",
"(",
"*",
"*",
"kw",
")",
"ps",
"=",
"self",
".",
"ps",
"tp",
"=",
"_find_type",
"(",
"ps",
".",
"body_root",
")",
"isarray",
"=",
"(",
... | Parse message, create Python object.
KeyWord data:
faults -- list of WSDL operation.fault typecodes
wsaction -- If using WS-Address, must specify Action value we expect to
receive. | [
"Parse",
"message",
"create",
"Python",
"object",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L523-L555 |
sassoo/goldman | goldman/middleware/basicauth/__init__.py | Middleware._get_creds | def _get_creds(self, req):
""" Get the username & password from the Authorization header
If the header is actually malformed where Basic Auth was
indicated by the request then an InvalidAuthSyntax exception
is raised. Otherwise an AuthRequired exception since it's
unclear in thi... | python | def _get_creds(self, req):
""" Get the username & password from the Authorization header
If the header is actually malformed where Basic Auth was
indicated by the request then an InvalidAuthSyntax exception
is raised. Otherwise an AuthRequired exception since it's
unclear in thi... | [
"def",
"_get_creds",
"(",
"self",
",",
"req",
")",
":",
"self",
".",
"_validate_auth_scheme",
"(",
"req",
")",
"try",
":",
"creds",
"=",
"naked",
"(",
"req",
".",
"auth",
".",
"split",
"(",
"' '",
")",
"[",
"1",
"]",
")",
"creds",
"=",
"b64decode",... | Get the username & password from the Authorization header
If the header is actually malformed where Basic Auth was
indicated by the request then an InvalidAuthSyntax exception
is raised. Otherwise an AuthRequired exception since it's
unclear in this scenario if the requestor was even aw... | [
"Get",
"the",
"username",
"&",
"password",
"from",
"the",
"Authorization",
"header"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/basicauth/__init__.py#L81-L129 |
sassoo/goldman | goldman/middleware/basicauth/__init__.py | Middleware.process_request | def process_request(self, req, resp): # pylint: disable=unused-argument
""" Process the request before routing it. """
try:
creds = self._get_creds(req)
self.auth_creds(*creds)
except (AuthRejected, AuthRequired, InvalidAuthSyntax) as exc:
exc.headers = self... | python | def process_request(self, req, resp): # pylint: disable=unused-argument
""" Process the request before routing it. """
try:
creds = self._get_creds(req)
self.auth_creds(*creds)
except (AuthRejected, AuthRequired, InvalidAuthSyntax) as exc:
exc.headers = self... | [
"def",
"process_request",
"(",
"self",
",",
"req",
",",
"resp",
")",
":",
"# pylint: disable=unused-argument",
"try",
":",
"creds",
"=",
"self",
".",
"_get_creds",
"(",
"req",
")",
"self",
".",
"auth_creds",
"(",
"*",
"creds",
")",
"except",
"(",
"AuthReje... | Process the request before routing it. | [
"Process",
"the",
"request",
"before",
"routing",
"it",
"."
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/basicauth/__init__.py#L131-L140 |
nanvel/c2p2 | c2p2/models.py | Site._update_page | def _update_page(self, uri, path):
"""Update page content."""
if uri in self._pages:
self._pages[uri].update()
else:
self._pages[uri] = Page(uri=uri, path=path) | python | def _update_page(self, uri, path):
"""Update page content."""
if uri in self._pages:
self._pages[uri].update()
else:
self._pages[uri] = Page(uri=uri, path=path) | [
"def",
"_update_page",
"(",
"self",
",",
"uri",
",",
"path",
")",
":",
"if",
"uri",
"in",
"self",
".",
"_pages",
":",
"self",
".",
"_pages",
"[",
"uri",
"]",
".",
"update",
"(",
")",
"else",
":",
"self",
".",
"_pages",
"[",
"uri",
"]",
"=",
"Pa... | Update page content. | [
"Update",
"page",
"content",
"."
] | train | https://github.com/nanvel/c2p2/blob/3900a9bb54d35e1332b92d6560f3cb1e77943209/c2p2/models.py#L189-L194 |
nanvel/c2p2 | c2p2/models.py | Site._update_labels | def _update_labels(self):
"""Updates list of available labels."""
labels = set()
for page in self.get_pages():
for label in page.labels:
labels.add(label)
to_delete = self._labels - labels
for label in labels:
self._labels.add(label)
... | python | def _update_labels(self):
"""Updates list of available labels."""
labels = set()
for page in self.get_pages():
for label in page.labels:
labels.add(label)
to_delete = self._labels - labels
for label in labels:
self._labels.add(label)
... | [
"def",
"_update_labels",
"(",
"self",
")",
":",
"labels",
"=",
"set",
"(",
")",
"for",
"page",
"in",
"self",
".",
"get_pages",
"(",
")",
":",
"for",
"label",
"in",
"page",
".",
"labels",
":",
"labels",
".",
"add",
"(",
"label",
")",
"to_delete",
"=... | Updates list of available labels. | [
"Updates",
"list",
"of",
"available",
"labels",
"."
] | train | https://github.com/nanvel/c2p2/blob/3900a9bb54d35e1332b92d6560f3cb1e77943209/c2p2/models.py#L201-L211 |
nanvel/c2p2 | c2p2/models.py | Site.get_pages | def get_pages(self, label=None):
"""Returns list of pages with specified label."""
return (
page for page in sorted(
self._pages.values(), key=lambda i: i.created, reverse=True
) if ((not label or label in page.labels) and page.visible)
) | python | def get_pages(self, label=None):
"""Returns list of pages with specified label."""
return (
page for page in sorted(
self._pages.values(), key=lambda i: i.created, reverse=True
) if ((not label or label in page.labels) and page.visible)
) | [
"def",
"get_pages",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"return",
"(",
"page",
"for",
"page",
"in",
"sorted",
"(",
"self",
".",
"_pages",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
"i",
":",
"i",
".",
"created",
",",
"rever... | Returns list of pages with specified label. | [
"Returns",
"list",
"of",
"pages",
"with",
"specified",
"label",
"."
] | train | https://github.com/nanvel/c2p2/blob/3900a9bb54d35e1332b92d6560f3cb1e77943209/c2p2/models.py#L216-L222 |
collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient._requests | def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):
''' a helper method for relaying requests from client to api '''
title = '%s._requests' % self.__class__.__name__
# import dependencies
from time import time
import requests
# valid... | python | def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):
''' a helper method for relaying requests from client to api '''
title = '%s._requests' % self.__class__.__name__
# import dependencies
from time import time
import requests
# valid... | [
"def",
"_requests",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'GET'",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"title",
"=",
"'%s._requests'",
"%",
"self",
".",
"__... | a helper method for relaying requests from client to api | [
"a",
"helper",
"method",
"for",
"relaying",
"requests",
"from",
"client",
"to",
"api"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L230-L297 |
collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient._get_products | def _get_products(self):
''' a method to retrieve account product details at initialization '''
# request product list
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
# construct list of produc... | python | def _get_products(self):
''' a method to retrieve account product details at initialization '''
# request product list
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
# construct list of produc... | [
"def",
"_get_products",
"(",
"self",
")",
":",
"# request product list",
"products_request",
"=",
"self",
".",
"account_products",
"(",
")",
"if",
"products_request",
"[",
"'error'",
"]",
":",
"raise",
"Exception",
"(",
"products_request",
"[",
"'error'",
"]",
"... | a method to retrieve account product details at initialization | [
"a",
"method",
"to",
"retrieve",
"account",
"product",
"details",
"at",
"initialization"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L299-L323 |
collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient.access_token | def access_token(self):
''' a method to acquire an oauth access token '''
title = '%s.access_token' % self.__class__.__name__
# import dependencies
from time import time
import requests
# construct request kwargs
request_kwargs = {
'url': self.token_en... | python | def access_token(self):
''' a method to acquire an oauth access token '''
title = '%s.access_token' % self.__class__.__name__
# import dependencies
from time import time
import requests
# construct request kwargs
request_kwargs = {
'url': self.token_en... | [
"def",
"access_token",
"(",
"self",
")",
":",
"title",
"=",
"'%s.access_token'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# import dependencies",
"from",
"time",
"import",
"time",
"import",
"requests",
"# construct request kwargs",
"request_kwargs",
"=",
"{"... | a method to acquire an oauth access token | [
"a",
"method",
"to",
"acquire",
"an",
"oauth",
"access",
"token"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L325-L364 |
collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient.account_products | def account_products(self):
''' a method to retrieve a list of the account products
returns:
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"jso... | python | def account_products(self):
''' a method to retrieve a list of the account products
returns:
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"jso... | [
"def",
"account_products",
"(",
"self",
")",
":",
"title",
"=",
"'%s.account_products'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# construct url",
"url",
"=",
"self",
".",
"deposits_endpoint",
"+",
"'account-products'",
"# send request",
"details",
"=",
"... | a method to retrieve a list of the account products
returns:
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"json": {
"entries": [
... | [
"a",
"method",
"to",
"retrieve",
"a",
"list",
"of",
"the",
"account",
"products"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L366-L396 |
collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient.account_product | def account_product(self, product_id):
''' a method to retrieve details about a particular account product
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"json": {
... | python | def account_product(self, product_id):
''' a method to retrieve details about a particular account product
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"json": {
... | [
"def",
"account_product",
"(",
"self",
",",
"product_id",
")",
":",
"title",
"=",
"'%s.account_product'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# validate inputs",
"input_fields",
"=",
"{",
"'product_id'",
":",
"product_id",
"}",
"for",
"key",
",",
... | a method to retrieve details about a particular account product
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"json": {
"productId": "3300",
"productName": "Capital... | [
"a",
"method",
"to",
"retrieve",
"details",
"about",
"a",
"particular",
"account",
"product",
"{",
"error",
":",
"code",
":",
"200",
"method",
":",
"GET",
"url",
":",
"https",
":",
"//",
"...",
"headers",
":",
"{",
"}",
"json",
":",
"{",
"productId",
... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L398-L465 |
collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient.account_application | def account_application(self, customer_ip, first_name, last_name, tax_id, date_of_birth, address_line_1, city_name, state_code, postal_code, phone_number, email_address, citizenship_country, employment_status, product_id, funding_amount, account_number, routing_number, backup_withholding=False, phone_type='mobile', acc... | python | def account_application(self, customer_ip, first_name, last_name, tax_id, date_of_birth, address_line_1, city_name, state_code, postal_code, phone_number, email_address, citizenship_country, employment_status, product_id, funding_amount, account_number, routing_number, backup_withholding=False, phone_type='mobile', acc... | [
"def",
"account_application",
"(",
"self",
",",
"customer_ip",
",",
"first_name",
",",
"last_name",
",",
"tax_id",
",",
"date_of_birth",
",",
"address_line_1",
",",
"city_name",
",",
"state_code",
",",
"postal_code",
",",
"phone_number",
",",
"email_address",
",",... | a method to submit application for new account
:param customer_ip: string with ip address of applicant
:param first_name: string with first name of applicant
:param last_name: string with last name of applicant
:param tax_id: string with tax id number of applicant
:p... | [
"a",
"method",
"to",
"submit",
"application",
"for",
"new",
"account",
":",
"param",
"customer_ip",
":",
"string",
"with",
"ip",
"address",
"of",
"applicant",
":",
"param",
"first_name",
":",
"string",
"with",
"first",
"name",
"of",
"applicant",
":",
"param"... | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L467-L729 |
joausaga/ideascaly | ideascaly/models.py | Model.parse_list | def parse_list(cls, api, json_list):
"""
Parse a list of JSON objects into
a result set of model instances.
"""
results = []
for json_obj in json_list:
if json_obj:
obj = cls.parse(api, json_obj)
results.append(obj)
... | python | def parse_list(cls, api, json_list):
"""
Parse a list of JSON objects into
a result set of model instances.
"""
results = []
for json_obj in json_list:
if json_obj:
obj = cls.parse(api, json_obj)
results.append(obj)
... | [
"def",
"parse_list",
"(",
"cls",
",",
"api",
",",
"json_list",
")",
":",
"results",
"=",
"[",
"]",
"for",
"json_obj",
"in",
"json_list",
":",
"if",
"json_obj",
":",
"obj",
"=",
"cls",
".",
"parse",
"(",
"api",
",",
"json_obj",
")",
"results",
".",
... | Parse a list of JSON objects into
a result set of model instances. | [
"Parse",
"a",
"list",
"of",
"JSON",
"objects",
"into",
"a",
"result",
"set",
"of",
"model",
"instances",
"."
] | train | https://github.com/joausaga/ideascaly/blob/8aabb7bb1ed058406a8d352a7844e183ab64e008/ideascaly/models.py#L28-L39 |
uw-it-aca/uw-restclients-mailman | uw_mailman/instructor_term_list.py | get_instructor_term_list_name | def get_instructor_term_list_name(instructor_netid, year, quarter):
"""
Return the list address of UW instructor email list for
the given year and quarter
"""
return "{uwnetid}_{quarter}{year}".format(
uwnetid=instructor_netid,
quarter=quarter.lower()[:2],
year=str(year)[-2:]... | python | def get_instructor_term_list_name(instructor_netid, year, quarter):
"""
Return the list address of UW instructor email list for
the given year and quarter
"""
return "{uwnetid}_{quarter}{year}".format(
uwnetid=instructor_netid,
quarter=quarter.lower()[:2],
year=str(year)[-2:]... | [
"def",
"get_instructor_term_list_name",
"(",
"instructor_netid",
",",
"year",
",",
"quarter",
")",
":",
"return",
"\"{uwnetid}_{quarter}{year}\"",
".",
"format",
"(",
"uwnetid",
"=",
"instructor_netid",
",",
"quarter",
"=",
"quarter",
".",
"lower",
"(",
")",
"[",
... | Return the list address of UW instructor email list for
the given year and quarter | [
"Return",
"the",
"list",
"address",
"of",
"UW",
"instructor",
"email",
"list",
"for",
"the",
"given",
"year",
"and",
"quarter"
] | train | https://github.com/uw-it-aca/uw-restclients-mailman/blob/ef077f2cc945871422fcd66391e82264e2384b2c/uw_mailman/instructor_term_list.py#L8-L16 |
wooyek/django-pascal-templates | src/pascal_templates/views.py | TemplatePathMixin.get_template_path | def get_template_path(self, meta=None, **kwargs):
"""
Formats template_name_path_pattern with kwargs given.
"""
if 'template_name_suffix' not in kwargs or kwargs.get('template_name_suffix') is None:
kwargs['template_name_suffix'] = self.get_template_name_suffix()
... | python | def get_template_path(self, meta=None, **kwargs):
"""
Formats template_name_path_pattern with kwargs given.
"""
if 'template_name_suffix' not in kwargs or kwargs.get('template_name_suffix') is None:
kwargs['template_name_suffix'] = self.get_template_name_suffix()
... | [
"def",
"get_template_path",
"(",
"self",
",",
"meta",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'template_name_suffix'",
"not",
"in",
"kwargs",
"or",
"kwargs",
".",
"get",
"(",
"'template_name_suffix'",
")",
"is",
"None",
":",
"kwargs",
"[",
... | Formats template_name_path_pattern with kwargs given. | [
"Formats",
"template_name_path_pattern",
"with",
"kwargs",
"given",
"."
] | train | https://github.com/wooyek/django-pascal-templates/blob/4c2216de7f7e53c7db6c2ab1f75f0b9065ce580e/src/pascal_templates/views.py#L14-L20 |
wooyek/django-pascal-templates | src/pascal_templates/views.py | SinglePascalCaseTemplateMixin.get_template_name | def get_template_name(self, template_name_suffix=None):
"""
Generates a template path name based on model and app.
:param template_name_suffix: pass a custom suffix or leave empty for default
:return: template path
"""
if isinstance(self.object, models.Model):
... | python | def get_template_name(self, template_name_suffix=None):
"""
Generates a template path name based on model and app.
:param template_name_suffix: pass a custom suffix or leave empty for default
:return: template path
"""
if isinstance(self.object, models.Model):
... | [
"def",
"get_template_name",
"(",
"self",
",",
"template_name_suffix",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"object",
",",
"models",
".",
"Model",
")",
":",
"meta",
"=",
"self",
".",
"object",
".",
"_meta",
"return",
"self",
".",
... | Generates a template path name based on model and app.
:param template_name_suffix: pass a custom suffix or leave empty for default
:return: template path | [
"Generates",
"a",
"template",
"path",
"name",
"based",
"on",
"model",
"and",
"app",
".",
":",
"param",
"template_name_suffix",
":",
"pass",
"a",
"custom",
"suffix",
"or",
"leave",
"empty",
"for",
"default",
":",
"return",
":",
"template",
"path"
] | train | https://github.com/wooyek/django-pascal-templates/blob/4c2216de7f7e53c7db6c2ab1f75f0b9065ce580e/src/pascal_templates/views.py#L39-L50 |
wooyek/django-pascal-templates | src/pascal_templates/views.py | MultiplePascalCaseTemplateMixin.get_template_name | def get_template_name(self, template_name_suffix=None):
"""
Generates a template path name based on model and app.
:param template_name_suffix: pass a custom suffix or leave empty for default
:return: template path
"""
if hasattr(self.object_list, 'model'):
... | python | def get_template_name(self, template_name_suffix=None):
"""
Generates a template path name based on model and app.
:param template_name_suffix: pass a custom suffix or leave empty for default
:return: template path
"""
if hasattr(self.object_list, 'model'):
... | [
"def",
"get_template_name",
"(",
"self",
",",
"template_name_suffix",
"=",
"None",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"object_list",
",",
"'model'",
")",
":",
"meta",
"=",
"self",
".",
"object_list",
".",
"model",
".",
"_meta",
"return",
"self",
... | Generates a template path name based on model and app.
:param template_name_suffix: pass a custom suffix or leave empty for default
:return: template path | [
"Generates",
"a",
"template",
"path",
"name",
"based",
"on",
"model",
"and",
"app",
".",
":",
"param",
"template_name_suffix",
":",
"pass",
"a",
"custom",
"suffix",
"or",
"leave",
"empty",
"for",
"default",
":",
"return",
":",
"template",
"path"
] | train | https://github.com/wooyek/django-pascal-templates/blob/4c2216de7f7e53c7db6c2ab1f75f0b9065ce580e/src/pascal_templates/views.py#L61-L69 |
sliem/barrett | barrett/util.py | threenum | def threenum(h5file, var, post_col='mult'):
""" Calculates the three number summary for a variable.
The three number summary is the minimum, maximum and the mean
of the data. Traditionally one would summerise data with the
five number summary: max, min, 1st, 2nd (median), 3rd quartile.
But quantile... | python | def threenum(h5file, var, post_col='mult'):
""" Calculates the three number summary for a variable.
The three number summary is the minimum, maximum and the mean
of the data. Traditionally one would summerise data with the
five number summary: max, min, 1st, 2nd (median), 3rd quartile.
But quantile... | [
"def",
"threenum",
"(",
"h5file",
",",
"var",
",",
"post_col",
"=",
"'mult'",
")",
":",
"f",
"=",
"h5py",
".",
"File",
"(",
"h5file",
",",
"'r'",
")",
"d",
"=",
"f",
"[",
"var",
"]",
"w",
"=",
"f",
"[",
"post_col",
"]",
"s",
"=",
"d",
".",
... | Calculates the three number summary for a variable.
The three number summary is the minimum, maximum and the mean
of the data. Traditionally one would summerise data with the
five number summary: max, min, 1st, 2nd (median), 3rd quartile.
But quantiles are hard to calculate without sorting the data
... | [
"Calculates",
"the",
"three",
"number",
"summary",
"for",
"a",
"variable",
"."
] | train | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/barrett/util.py#L6-L45 |
sliem/barrett | barrett/util.py | filechunk | def filechunk(f, chunksize):
"""Iterator that allow for piecemeal processing of a file."""
while True:
chunk = tuple(itertools.islice(f, chunksize))
if not chunk:
return
yield np.loadtxt(iter(chunk), dtype=np.float64) | python | def filechunk(f, chunksize):
"""Iterator that allow for piecemeal processing of a file."""
while True:
chunk = tuple(itertools.islice(f, chunksize))
if not chunk:
return
yield np.loadtxt(iter(chunk), dtype=np.float64) | [
"def",
"filechunk",
"(",
"f",
",",
"chunksize",
")",
":",
"while",
"True",
":",
"chunk",
"=",
"tuple",
"(",
"itertools",
".",
"islice",
"(",
"f",
",",
"chunksize",
")",
")",
"if",
"not",
"chunk",
":",
"return",
"yield",
"np",
".",
"loadtxt",
"(",
"... | Iterator that allow for piecemeal processing of a file. | [
"Iterator",
"that",
"allow",
"for",
"piecemeal",
"processing",
"of",
"a",
"file",
"."
] | train | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/barrett/util.py#L48-L54 |
sliem/barrett | barrett/util.py | convert_chain | def convert_chain(
txtfiles,
headers,
h5file,
chunksize):
"""Converts chain in plain text format into HDF5 format.
Keyword arguments:
txtfiles -- list of paths to the plain text chains.
headers -- name of each column.
h5file -- where to put the resulting HDF5 file.
... | python | def convert_chain(
txtfiles,
headers,
h5file,
chunksize):
"""Converts chain in plain text format into HDF5 format.
Keyword arguments:
txtfiles -- list of paths to the plain text chains.
headers -- name of each column.
h5file -- where to put the resulting HDF5 file.
... | [
"def",
"convert_chain",
"(",
"txtfiles",
",",
"headers",
",",
"h5file",
",",
"chunksize",
")",
":",
"h5",
"=",
"h5py",
".",
"File",
"(",
"h5file",
",",
"'w'",
")",
"for",
"h",
"in",
"headers",
":",
"h5",
".",
"create_dataset",
"(",
"h",
",",
"shape",... | Converts chain in plain text format into HDF5 format.
Keyword arguments:
txtfiles -- list of paths to the plain text chains.
headers -- name of each column.
h5file -- where to put the resulting HDF5 file.
chunksize -- how large the HDF5 chunk, i.e. number of rows.
Chunking - How to pick a chun... | [
"Converts",
"chain",
"in",
"plain",
"text",
"format",
"into",
"HDF5",
"format",
"."
] | train | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/barrett/util.py#L57-L102 |
sassoo/goldman | goldman/types/datetime.py | Type.to_primitive | def to_primitive(self, value, context=None):
""" Schematics serializer override
If epoch_date is true then convert the `datetime.datetime`
object into an epoch `int`.
"""
if context and context.get('epoch_date'):
epoch = dt(1970, 1, 1)
value = (value - e... | python | def to_primitive(self, value, context=None):
""" Schematics serializer override
If epoch_date is true then convert the `datetime.datetime`
object into an epoch `int`.
"""
if context and context.get('epoch_date'):
epoch = dt(1970, 1, 1)
value = (value - e... | [
"def",
"to_primitive",
"(",
"self",
",",
"value",
",",
"context",
"=",
"None",
")",
":",
"if",
"context",
"and",
"context",
".",
"get",
"(",
"'epoch_date'",
")",
":",
"epoch",
"=",
"dt",
"(",
"1970",
",",
"1",
",",
"1",
")",
"value",
"=",
"(",
"v... | Schematics serializer override
If epoch_date is true then convert the `datetime.datetime`
object into an epoch `int`. | [
"Schematics",
"serializer",
"override"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/types/datetime.py#L21-L35 |
radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getAvailableClassesInModule | def getAvailableClassesInModule(prooveModule):
"""
return a list of all classes in the given module
that dont begin with '_'
"""
l = tuple(x[1] for x in inspect.getmembers(prooveModule, inspect.isclass))
l = [x for x in l if x.__name__[0] != "_"]
return l | python | def getAvailableClassesInModule(prooveModule):
"""
return a list of all classes in the given module
that dont begin with '_'
"""
l = tuple(x[1] for x in inspect.getmembers(prooveModule, inspect.isclass))
l = [x for x in l if x.__name__[0] != "_"]
return l | [
"def",
"getAvailableClassesInModule",
"(",
"prooveModule",
")",
":",
"l",
"=",
"tuple",
"(",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"inspect",
".",
"getmembers",
"(",
"prooveModule",
",",
"inspect",
".",
"isclass",
")",
")",
"l",
"=",
"[",
"x",
"for",
... | return a list of all classes in the given module
that dont begin with '_' | [
"return",
"a",
"list",
"of",
"all",
"classes",
"in",
"the",
"given",
"module",
"that",
"dont",
"begin",
"with",
"_"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L11-L18 |
radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getAvailableClassesInPackage | def getAvailableClassesInPackage(package):
"""
return a list of all classes in the given package
whose modules dont begin with '_'
"""
l = list(x[1] for x in inspect.getmembers(package, inspect.isclass))
modules = list(x[1] for x in inspect.getmembers(package, inspect.ismodule))
for m in mo... | python | def getAvailableClassesInPackage(package):
"""
return a list of all classes in the given package
whose modules dont begin with '_'
"""
l = list(x[1] for x in inspect.getmembers(package, inspect.isclass))
modules = list(x[1] for x in inspect.getmembers(package, inspect.ismodule))
for m in mo... | [
"def",
"getAvailableClassesInPackage",
"(",
"package",
")",
":",
"l",
"=",
"list",
"(",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"inspect",
".",
"getmembers",
"(",
"package",
",",
"inspect",
".",
"isclass",
")",
")",
"modules",
"=",
"list",
"(",
"x",
"[... | return a list of all classes in the given package
whose modules dont begin with '_' | [
"return",
"a",
"list",
"of",
"all",
"classes",
"in",
"the",
"given",
"package",
"whose",
"modules",
"dont",
"begin",
"with",
"_"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L21-L39 |
radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getClassInPackageFromName | def getClassInPackageFromName(className, pkg):
"""
get a class from name within a package
"""
# TODO: more efficiency!
n = getAvClassNamesInPackage(pkg)
i = n.index(className)
c = getAvailableClassesInPackage(pkg)
return c[i] | python | def getClassInPackageFromName(className, pkg):
"""
get a class from name within a package
"""
# TODO: more efficiency!
n = getAvClassNamesInPackage(pkg)
i = n.index(className)
c = getAvailableClassesInPackage(pkg)
return c[i] | [
"def",
"getClassInPackageFromName",
"(",
"className",
",",
"pkg",
")",
":",
"# TODO: more efficiency!",
"n",
"=",
"getAvClassNamesInPackage",
"(",
"pkg",
")",
"i",
"=",
"n",
".",
"index",
"(",
"className",
")",
"c",
"=",
"getAvailableClassesInPackage",
"(",
"pkg... | get a class from name within a package | [
"get",
"a",
"class",
"from",
"name",
"within",
"a",
"package"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L54-L62 |
radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getClassInModuleFromName | def getClassInModuleFromName(className, module):
"""
get a class from name within a module
"""
n = getAvClassNamesInModule(module)
i = n.index(className)
c = getAvailableClassesInModule(module)
return c[i] | python | def getClassInModuleFromName(className, module):
"""
get a class from name within a module
"""
n = getAvClassNamesInModule(module)
i = n.index(className)
c = getAvailableClassesInModule(module)
return c[i] | [
"def",
"getClassInModuleFromName",
"(",
"className",
",",
"module",
")",
":",
"n",
"=",
"getAvClassNamesInModule",
"(",
"module",
")",
"i",
"=",
"n",
".",
"index",
"(",
"className",
")",
"c",
"=",
"getAvailableClassesInModule",
"(",
"module",
")",
"return",
... | get a class from name within a module | [
"get",
"a",
"class",
"from",
"name",
"within",
"a",
"module"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L65-L72 |
rikrd/inspire | inspirespeech/htk_model_utils.py | create_prototype | def create_prototype(sample_dimension,
parameter_kind_base='user',
parameter_kind_options=[],
state_stay_probabilities=[0.6, 0.6, 0.7]):
"""Create a prototype HTK model file using a feature file.
"""
parameter_kind = create_parameter_kind(base=p... | python | def create_prototype(sample_dimension,
parameter_kind_base='user',
parameter_kind_options=[],
state_stay_probabilities=[0.6, 0.6, 0.7]):
"""Create a prototype HTK model file using a feature file.
"""
parameter_kind = create_parameter_kind(base=p... | [
"def",
"create_prototype",
"(",
"sample_dimension",
",",
"parameter_kind_base",
"=",
"'user'",
",",
"parameter_kind_options",
"=",
"[",
"]",
",",
"state_stay_probabilities",
"=",
"[",
"0.6",
",",
"0.6",
",",
"0.7",
"]",
")",
":",
"parameter_kind",
"=",
"create_p... | Create a prototype HTK model file using a feature file. | [
"Create",
"a",
"prototype",
"HTK",
"model",
"file",
"using",
"a",
"feature",
"file",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk_model_utils.py#L140-L168 |
rikrd/inspire | inspirespeech/htk_model_utils.py | map_hmms | def map_hmms(input_model, mapping):
"""Create a new HTK HMM model given a model and a mapping dictionary.
:param input_model: The model to transform of type dict
:param mapping: A dictionary from string -> list(string)
:return: The transformed model of type dict
"""
output_model = copy.copy(in... | python | def map_hmms(input_model, mapping):
"""Create a new HTK HMM model given a model and a mapping dictionary.
:param input_model: The model to transform of type dict
:param mapping: A dictionary from string -> list(string)
:return: The transformed model of type dict
"""
output_model = copy.copy(in... | [
"def",
"map_hmms",
"(",
"input_model",
",",
"mapping",
")",
":",
"output_model",
"=",
"copy",
".",
"copy",
"(",
"input_model",
")",
"o_hmms",
"=",
"[",
"]",
"for",
"i_hmm",
"in",
"input_model",
"[",
"'hmms'",
"]",
":",
"i_hmm_name",
"=",
"i_hmm",
"[",
... | Create a new HTK HMM model given a model and a mapping dictionary.
:param input_model: The model to transform of type dict
:param mapping: A dictionary from string -> list(string)
:return: The transformed model of type dict | [
"Create",
"a",
"new",
"HTK",
"HMM",
"model",
"given",
"a",
"model",
"and",
"a",
"mapping",
"dictionary",
"."
] | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk_model_utils.py#L185-L208 |
rikrd/inspire | inspirespeech/htk_model_utils.py | transform_to_semi_hmm | def transform_to_semi_hmm(model, repetition_count=4, min_repetitions=1, max_repetitions=np.inf):
"""This function expands and HMM model into a semi HMM model by multiplying the number of states repetition_coutn:
times and modify the transition matrices accordingly to only allow between min_repetitions: and max_... | python | def transform_to_semi_hmm(model, repetition_count=4, min_repetitions=1, max_repetitions=np.inf):
"""This function expands and HMM model into a semi HMM model by multiplying the number of states repetition_coutn:
times and modify the transition matrices accordingly to only allow between min_repetitions: and max_... | [
"def",
"transform_to_semi_hmm",
"(",
"model",
",",
"repetition_count",
"=",
"4",
",",
"min_repetitions",
"=",
"1",
",",
"max_repetitions",
"=",
"np",
".",
"inf",
")",
":",
"def",
"transform_transition",
"(",
"definition",
")",
":",
"\"\"\"Transform in place the de... | This function expands and HMM model into a semi HMM model by multiplying the number of states repetition_coutn:
times and modify the transition matrices accordingly to only allow between min_repetitions: and max_repetitions:
repetitions.
:param model: The model to transform in place
:param repetition_c... | [
"This",
"function",
"expands",
"and",
"HMM",
"model",
"into",
"a",
"semi",
"HMM",
"model",
"by",
"multiplying",
"the",
"number",
"of",
"states",
"repetition_coutn",
":",
"times",
"and",
"modify",
"the",
"transition",
"matrices",
"accordingly",
"to",
"only",
"a... | train | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk_model_utils.py#L211-L324 |
fusionbox/django-decoratormixins | decoratormixins/__init__.py | DecoratorMixin | def DecoratorMixin(decorator):
"""
Converts a decorator written for a function view into a mixin for a
class-based view.
::
LoginRequiredMixin = DecoratorMixin(login_required)
class MyView(LoginRequiredMixin):
pass
class SomeView(DecoratorMixin(some_decorator),
... | python | def DecoratorMixin(decorator):
"""
Converts a decorator written for a function view into a mixin for a
class-based view.
::
LoginRequiredMixin = DecoratorMixin(login_required)
class MyView(LoginRequiredMixin):
pass
class SomeView(DecoratorMixin(some_decorator),
... | [
"def",
"DecoratorMixin",
"(",
"decorator",
")",
":",
"class",
"Mixin",
"(",
"object",
")",
":",
"__doc__",
"=",
"decorator",
".",
"__doc__",
"@",
"classmethod",
"def",
"as_view",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"view",
... | Converts a decorator written for a function view into a mixin for a
class-based view.
::
LoginRequiredMixin = DecoratorMixin(login_required)
class MyView(LoginRequiredMixin):
pass
class SomeView(DecoratorMixin(some_decorator),
DecoratorMixin(somethi... | [
"Converts",
"a",
"decorator",
"written",
"for",
"a",
"function",
"view",
"into",
"a",
"mixin",
"for",
"a",
"class",
"-",
"based",
"view",
"."
] | train | https://github.com/fusionbox/django-decoratormixins/blob/d1c9b193532d9904e288bb6471f2e7abc4a5b707/decoratormixins/__init__.py#L3-L30 |
mbodenhamer/syn | syn/base_utils/tree.py | seq_list_nested | def seq_list_nested(b, d, x=0, top_level=True):
'''
Create a nested list of iteratively increasing values.
b: branching factor
d: max depth
x: starting value (default = 0)
'''
x += 1
if d == 0:
ret = [x]
else:
val = x
ret = []
for i in range(b):
... | python | def seq_list_nested(b, d, x=0, top_level=True):
'''
Create a nested list of iteratively increasing values.
b: branching factor
d: max depth
x: starting value (default = 0)
'''
x += 1
if d == 0:
ret = [x]
else:
val = x
ret = []
for i in range(b):
... | [
"def",
"seq_list_nested",
"(",
"b",
",",
"d",
",",
"x",
"=",
"0",
",",
"top_level",
"=",
"True",
")",
":",
"x",
"+=",
"1",
"if",
"d",
"==",
"0",
":",
"ret",
"=",
"[",
"x",
"]",
"else",
":",
"val",
"=",
"x",
"ret",
"=",
"[",
"]",
"for",
"i... | Create a nested list of iteratively increasing values.
b: branching factor
d: max depth
x: starting value (default = 0) | [
"Create",
"a",
"nested",
"list",
"of",
"iteratively",
"increasing",
"values",
"."
] | train | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/tree.py#L4-L27 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | Opaque | def Opaque(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as a string.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']: return source.read()
data = StringIO.StringIO()
mimetools.decode(source, data, enc)
... | python | def Opaque(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as a string.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']: return source.read()
data = StringIO.StringIO()
mimetools.decode(source, data, enc)
... | [
"def",
"Opaque",
"(",
"uri",
",",
"tc",
",",
"ps",
",",
"*",
"*",
"keywords",
")",
":",
"source",
"=",
"urllib",
".",
"urlopen",
"(",
"uri",
",",
"*",
"*",
"keywords",
")",
"enc",
"=",
"source",
".",
"info",
"(",
")",
".",
"getencoding",
"(",
"... | Resolve a URI and return its content as a string. | [
"Resolve",
"a",
"URI",
"and",
"return",
"its",
"content",
"as",
"a",
"string",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L12-L21 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | XML | def XML(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as an XML DOM.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']:
data = source
else:
data = StringIO.StringIO()
mimetools.decode(so... | python | def XML(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as an XML DOM.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']:
data = source
else:
data = StringIO.StringIO()
mimetools.decode(so... | [
"def",
"XML",
"(",
"uri",
",",
"tc",
",",
"ps",
",",
"*",
"*",
"keywords",
")",
":",
"source",
"=",
"urllib",
".",
"urlopen",
"(",
"uri",
",",
"*",
"*",
"keywords",
")",
"enc",
"=",
"source",
".",
"info",
"(",
")",
".",
"getencoding",
"(",
")",... | Resolve a URI and return its content as an XML DOM. | [
"Resolve",
"a",
"URI",
"and",
"return",
"its",
"content",
"as",
"an",
"XML",
"DOM",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L24-L36 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | MIMEResolver.GetSOAPPart | def GetSOAPPart(self):
'''Get the SOAP body part.
'''
head, part = self.parts[0]
return StringIO.StringIO(part.getvalue()) | python | def GetSOAPPart(self):
'''Get the SOAP body part.
'''
head, part = self.parts[0]
return StringIO.StringIO(part.getvalue()) | [
"def",
"GetSOAPPart",
"(",
"self",
")",
":",
"head",
",",
"part",
"=",
"self",
".",
"parts",
"[",
"0",
"]",
"return",
"StringIO",
".",
"StringIO",
"(",
"part",
".",
"getvalue",
"(",
")",
")"
] | Get the SOAP body part. | [
"Get",
"the",
"SOAP",
"body",
"part",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L105-L109 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | MIMEResolver.get | def get(self, uri):
'''Get the content for the bodypart identified by the uri.
'''
if uri.startswith('cid:'):
# Content-ID, so raise exception if not found.
head, part = self.id_dict[uri[4:]]
return StringIO.StringIO(part.getvalue())
if self.loc_dict.h... | python | def get(self, uri):
'''Get the content for the bodypart identified by the uri.
'''
if uri.startswith('cid:'):
# Content-ID, so raise exception if not found.
head, part = self.id_dict[uri[4:]]
return StringIO.StringIO(part.getvalue())
if self.loc_dict.h... | [
"def",
"get",
"(",
"self",
",",
"uri",
")",
":",
"if",
"uri",
".",
"startswith",
"(",
"'cid:'",
")",
":",
"# Content-ID, so raise exception if not found.",
"head",
",",
"part",
"=",
"self",
".",
"id_dict",
"[",
"uri",
"[",
"4",
":",
"]",
"]",
"return",
... | Get the content for the bodypart identified by the uri. | [
"Get",
"the",
"content",
"for",
"the",
"bodypart",
"identified",
"by",
"the",
"uri",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L111-L121 |
ravenac95/lxc4u | lxc4u/meta.py | LXCMeta.load_from_file | def load_from_file(cls, file_path):
"""Load the meta data given a file_path or empty meta data"""
data = None
if os.path.exists(file_path):
metadata_file = open(file_path)
data = json.loads(metadata_file.read())
return cls(initial=data) | python | def load_from_file(cls, file_path):
"""Load the meta data given a file_path or empty meta data"""
data = None
if os.path.exists(file_path):
metadata_file = open(file_path)
data = json.loads(metadata_file.read())
return cls(initial=data) | [
"def",
"load_from_file",
"(",
"cls",
",",
"file_path",
")",
":",
"data",
"=",
"None",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_path",
")",
":",
"metadata_file",
"=",
"open",
"(",
"file_path",
")",
"data",
"=",
"json",
".",
"loads",
"(",
"me... | Load the meta data given a file_path or empty meta data | [
"Load",
"the",
"meta",
"data",
"given",
"a",
"file_path",
"or",
"empty",
"meta",
"data"
] | train | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/meta.py#L10-L16 |
ravenac95/lxc4u | lxc4u/meta.py | LXCMeta.bind_and_save | def bind_and_save(self, lxc):
"""Binds metadata to an LXC and saves it"""
bound_meta = self.bind(lxc)
bound_meta.save()
return bound_meta | python | def bind_and_save(self, lxc):
"""Binds metadata to an LXC and saves it"""
bound_meta = self.bind(lxc)
bound_meta.save()
return bound_meta | [
"def",
"bind_and_save",
"(",
"self",
",",
"lxc",
")",
":",
"bound_meta",
"=",
"self",
".",
"bind",
"(",
"lxc",
")",
"bound_meta",
".",
"save",
"(",
")",
"return",
"bound_meta"
] | Binds metadata to an LXC and saves it | [
"Binds",
"metadata",
"to",
"an",
"LXC",
"and",
"saves",
"it"
] | train | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/meta.py#L41-L45 |
jeroyang/txttk | txttk/report.py | Report.update | def update(self, report):
"""
Add the items from the given report.
"""
self.tp.extend(pack_boxes(report.tp, self.title))
self.fp.extend(pack_boxes(report.fp, self.title))
self.fn.extend(pack_boxes(report.fn, self.title)) | python | def update(self, report):
"""
Add the items from the given report.
"""
self.tp.extend(pack_boxes(report.tp, self.title))
self.fp.extend(pack_boxes(report.fp, self.title))
self.fn.extend(pack_boxes(report.fn, self.title)) | [
"def",
"update",
"(",
"self",
",",
"report",
")",
":",
"self",
".",
"tp",
".",
"extend",
"(",
"pack_boxes",
"(",
"report",
".",
"tp",
",",
"self",
".",
"title",
")",
")",
"self",
".",
"fp",
".",
"extend",
"(",
"pack_boxes",
"(",
"report",
".",
"f... | Add the items from the given report. | [
"Add",
"the",
"items",
"from",
"the",
"given",
"report",
"."
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/report.py#L117-L123 |
jeroyang/txttk | txttk/report.py | Report.from_scale | def from_scale(cls, gold_number, precision, recall, title):
"""
deprecated, for backward compactbility
try to use from_score
"""
tp_count = get_numerator(recall, gold_number)
positive_count = get_denominator(precision, tp_count)
fp_count = positive_count - tp_coun... | python | def from_scale(cls, gold_number, precision, recall, title):
"""
deprecated, for backward compactbility
try to use from_score
"""
tp_count = get_numerator(recall, gold_number)
positive_count = get_denominator(precision, tp_count)
fp_count = positive_count - tp_coun... | [
"def",
"from_scale",
"(",
"cls",
",",
"gold_number",
",",
"precision",
",",
"recall",
",",
"title",
")",
":",
"tp_count",
"=",
"get_numerator",
"(",
"recall",
",",
"gold_number",
")",
"positive_count",
"=",
"get_denominator",
"(",
"precision",
",",
"tp_count",... | deprecated, for backward compactbility
try to use from_score | [
"deprecated",
"for",
"backward",
"compactbility",
"try",
"to",
"use",
"from_score"
] | train | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/report.py#L150-L163 |
dossier/dossier.models | dossier/models/linker/worker.py | worker | def worker(work_unit):
'''Expects a WorkUnit from coordinated, obtains a config, and runs
traverse_extract_fetch
'''
if 'config' not in work_unit.spec:
raise coordinate.exceptions.ProgrammerError(
'could not run extraction without global config')
web_conf = Config()
unitcon... | python | def worker(work_unit):
'''Expects a WorkUnit from coordinated, obtains a config, and runs
traverse_extract_fetch
'''
if 'config' not in work_unit.spec:
raise coordinate.exceptions.ProgrammerError(
'could not run extraction without global config')
web_conf = Config()
unitcon... | [
"def",
"worker",
"(",
"work_unit",
")",
":",
"if",
"'config'",
"not",
"in",
"work_unit",
".",
"spec",
":",
"raise",
"coordinate",
".",
"exceptions",
".",
"ProgrammerError",
"(",
"'could not run extraction without global config'",
")",
"web_conf",
"=",
"Config",
"(... | Expects a WorkUnit from coordinated, obtains a config, and runs
traverse_extract_fetch | [
"Expects",
"a",
"WorkUnit",
"from",
"coordinated",
"obtains",
"a",
"config",
"and",
"runs",
"traverse_extract_fetch"
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L38-L52 |
dossier/dossier.models | dossier/models/linker/worker.py | traverse_extract_fetch | def traverse_extract_fetch(config, wukey, stop_after_extraction=False):
'''Given a config and a
`wukey=cbor.dumps((folder_name,subfolder_name))`, traverse the
folders to generate queries, issue them to Google, fetch the
results, and ingest them.
'''
config.kvlclient.setup_namespace({'openquery... | python | def traverse_extract_fetch(config, wukey, stop_after_extraction=False):
'''Given a config and a
`wukey=cbor.dumps((folder_name,subfolder_name))`, traverse the
folders to generate queries, issue them to Google, fetch the
results, and ingest them.
'''
config.kvlclient.setup_namespace({'openquery... | [
"def",
"traverse_extract_fetch",
"(",
"config",
",",
"wukey",
",",
"stop_after_extraction",
"=",
"False",
")",
":",
"config",
".",
"kvlclient",
".",
"setup_namespace",
"(",
"{",
"'openquery'",
":",
"(",
"str",
",",
")",
"}",
")",
"try",
":",
"data",
"=",
... | Given a config and a
`wukey=cbor.dumps((folder_name,subfolder_name))`, traverse the
folders to generate queries, issue them to Google, fetch the
results, and ingest them. | [
"Given",
"a",
"config",
"and",
"a",
"wukey",
"=",
"cbor",
".",
"dumps",
"((",
"folder_name",
"subfolder_name",
"))",
"traverse",
"the",
"folders",
"to",
"generate",
"queries",
"issue",
"them",
"to",
"Google",
"fetch",
"the",
"results",
"and",
"ingest",
"them... | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L55-L167 |
dossier/dossier.models | dossier/models/linker/worker.py | get_subfolder_queries | def get_subfolder_queries(store, label_store, folders, fid, sid):
'''Returns [unicode].
This returns a list of queries that can be passed on to "other"
search engines. The list of queries is derived from the subfolder
identified by ``fid/sid``.
'''
queries = []
for cid, subid, url, stype, ... | python | def get_subfolder_queries(store, label_store, folders, fid, sid):
'''Returns [unicode].
This returns a list of queries that can be passed on to "other"
search engines. The list of queries is derived from the subfolder
identified by ``fid/sid``.
'''
queries = []
for cid, subid, url, stype, ... | [
"def",
"get_subfolder_queries",
"(",
"store",
",",
"label_store",
",",
"folders",
",",
"fid",
",",
"sid",
")",
":",
"queries",
"=",
"[",
"]",
"for",
"cid",
",",
"subid",
",",
"url",
",",
"stype",
",",
"data",
"in",
"subtopics",
"(",
"store",
",",
"fo... | Returns [unicode].
This returns a list of queries that can be passed on to "other"
search engines. The list of queries is derived from the subfolder
identified by ``fid/sid``. | [
"Returns",
"[",
"unicode",
"]",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L169-L181 |
dossier/dossier.models | dossier/models/linker/worker.py | extract_keyword_queries | def extract_keyword_queries(store, label_store, folders, fid, sid, include_original=False):
'''Transforms a folder structure into positive and negative examples
to feed to ``linker.model.extract``. This transforms SortingDesk's
foldering structure into *supervision* data for the extractor.
This works ... | python | def extract_keyword_queries(store, label_store, folders, fid, sid, include_original=False):
'''Transforms a folder structure into positive and negative examples
to feed to ``linker.model.extract``. This transforms SortingDesk's
foldering structure into *supervision* data for the extractor.
This works ... | [
"def",
"extract_keyword_queries",
"(",
"store",
",",
"label_store",
",",
"folders",
",",
"fid",
",",
"sid",
",",
"include_original",
"=",
"False",
")",
":",
"keyword_feature_keys",
"=",
"[",
"]",
"query_names",
"=",
"fid",
".",
"split",
"(",
"'_'",
")",
"#... | Transforms a folder structure into positive and negative examples
to feed to ``linker.model.extract``. This transforms SortingDesk's
foldering structure into *supervision* data for the extractor.
This works best if folder name (``fid``) is the ``name`` of an entity
in question or, more generally, a qu... | [
"Transforms",
"a",
"folder",
"structure",
"into",
"positive",
"and",
"negative",
"examples",
"to",
"feed",
"to",
"linker",
".",
"model",
".",
"extract",
".",
"This",
"transforms",
"SortingDesk",
"s",
"foldering",
"structure",
"into",
"*",
"supervision",
"*",
"... | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L184-L297 |
dossier/dossier.models | dossier/models/linker/worker.py | name_filter | def name_filter(keywords, names):
'''
Returns the first keyword from the list, unless
that keyword is one of the names in names, in which case
it continues to the next keyword.
Since keywords consists of tuples, it just returns the first
element of the tuple, the keyword. It also adds double
... | python | def name_filter(keywords, names):
'''
Returns the first keyword from the list, unless
that keyword is one of the names in names, in which case
it continues to the next keyword.
Since keywords consists of tuples, it just returns the first
element of the tuple, the keyword. It also adds double
... | [
"def",
"name_filter",
"(",
"keywords",
",",
"names",
")",
":",
"name_set",
"=",
"set",
"(",
"name",
".",
"lower",
"(",
")",
"for",
"name",
"in",
"names",
")",
"for",
"key_tuple",
"in",
"keywords",
":",
"if",
"not",
"key_tuple",
"[",
"0",
"]",
"in",
... | Returns the first keyword from the list, unless
that keyword is one of the names in names, in which case
it continues to the next keyword.
Since keywords consists of tuples, it just returns the first
element of the tuple, the keyword. It also adds double
quotes around the keywords, as is appropriat... | [
"Returns",
"the",
"first",
"keyword",
"from",
"the",
"list",
"unless",
"that",
"keyword",
"is",
"one",
"of",
"the",
"names",
"in",
"names",
"in",
"which",
"case",
"it",
"continues",
"to",
"the",
"next",
"keyword",
"."
] | train | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L300-L321 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _find_attrNS | def _find_attrNS(E, namespaceURI, localName):
'''namespaceURI
localName
'''
try:
v = E.getAttributeNS(namespaceURI, localName)
if v: return v
except: pass
return None | python | def _find_attrNS(E, namespaceURI, localName):
'''namespaceURI
localName
'''
try:
v = E.getAttributeNS(namespaceURI, localName)
if v: return v
except: pass
return None | [
"def",
"_find_attrNS",
"(",
"E",
",",
"namespaceURI",
",",
"localName",
")",
":",
"try",
":",
"v",
"=",
"E",
".",
"getAttributeNS",
"(",
"namespaceURI",
",",
"localName",
")",
"if",
"v",
":",
"return",
"v",
"except",
":",
"pass",
"return",
"None"
] | namespaceURI
localName | [
"namespaceURI",
"localName"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L192-L200 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _find_attrNodeNS | def _find_attrNodeNS(E, namespaceURI, localName):
'''Must grab the attribute Node to distinquish between
an unspecified attribute(None) and one set to empty string("").
namespaceURI
localName
'''
attr = E.getAttributeNodeNS(namespaceURI, localName)
if attr is None: return None
try:... | python | def _find_attrNodeNS(E, namespaceURI, localName):
'''Must grab the attribute Node to distinquish between
an unspecified attribute(None) and one set to empty string("").
namespaceURI
localName
'''
attr = E.getAttributeNodeNS(namespaceURI, localName)
if attr is None: return None
try:... | [
"def",
"_find_attrNodeNS",
"(",
"E",
",",
"namespaceURI",
",",
"localName",
")",
":",
"attr",
"=",
"E",
".",
"getAttributeNodeNS",
"(",
"namespaceURI",
",",
"localName",
")",
"if",
"attr",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"attr",
... | Must grab the attribute Node to distinquish between
an unspecified attribute(None) and one set to empty string("").
namespaceURI
localName | [
"Must",
"grab",
"the",
"attribute",
"Node",
"to",
"distinquish",
"between",
"an",
"unspecified",
"attribute",
"(",
"None",
")",
"and",
"one",
"set",
"to",
"empty",
"string",
"(",
")",
".",
"namespaceURI",
"localName"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L203-L214 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _resolve_prefix | def _resolve_prefix(celt, prefix):
'''resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
Parameters:
celt -- element node
prefix -- xmlns:prefix, or empty str or None
'''
namespace = None
while _is_element(celt):
if prefix:
... | python | def _resolve_prefix(celt, prefix):
'''resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
Parameters:
celt -- element node
prefix -- xmlns:prefix, or empty str or None
'''
namespace = None
while _is_element(celt):
if prefix:
... | [
"def",
"_resolve_prefix",
"(",
"celt",
",",
"prefix",
")",
":",
"namespace",
"=",
"None",
"while",
"_is_element",
"(",
"celt",
")",
":",
"if",
"prefix",
":",
"namespaceURI",
"=",
"_find_xmlns_prefix",
"(",
"celt",
",",
"prefix",
")",
"else",
":",
"namespac... | resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
Parameters:
celt -- element node
prefix -- xmlns:prefix, or empty str or None | [
"resolve",
"prefix",
"to",
"a",
"namespaceURI",
".",
"If",
"None",
"or",
"empty",
"str",
"return",
"default",
"namespace",
"or",
"None",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L235-L254 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _valid_encoding | def _valid_encoding(elt):
'''Does this node have a valid encoding?
'''
enc = _find_encstyle(elt)
if not enc or enc == _SOAP.ENC: return 1
for e in enc.split():
if e.startswith(_SOAP.ENC):
# XXX Is this correct? Once we find a Sec5 compatible
# XXX encoding, should we... | python | def _valid_encoding(elt):
'''Does this node have a valid encoding?
'''
enc = _find_encstyle(elt)
if not enc or enc == _SOAP.ENC: return 1
for e in enc.split():
if e.startswith(_SOAP.ENC):
# XXX Is this correct? Once we find a Sec5 compatible
# XXX encoding, should we... | [
"def",
"_valid_encoding",
"(",
"elt",
")",
":",
"enc",
"=",
"_find_encstyle",
"(",
"elt",
")",
"if",
"not",
"enc",
"or",
"enc",
"==",
"_SOAP",
".",
"ENC",
":",
"return",
"1",
"for",
"e",
"in",
"enc",
".",
"split",
"(",
")",
":",
"if",
"e",
".",
... | Does this node have a valid encoding? | [
"Does",
"this",
"node",
"have",
"a",
"valid",
"encoding?"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L256-L268 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _backtrace | def _backtrace(elt, dom):
'''Return a "backtrace" from the given element to the DOM root,
in XPath syntax.
'''
s = ''
while elt != dom:
name, parent = elt.nodeName, elt.parentNode
if parent is None: break
matches = [ c for c in _child_elements(parent)
... | python | def _backtrace(elt, dom):
'''Return a "backtrace" from the given element to the DOM root,
in XPath syntax.
'''
s = ''
while elt != dom:
name, parent = elt.nodeName, elt.parentNode
if parent is None: break
matches = [ c for c in _child_elements(parent)
... | [
"def",
"_backtrace",
"(",
"elt",
",",
"dom",
")",
":",
"s",
"=",
"''",
"while",
"elt",
"!=",
"dom",
":",
"name",
",",
"parent",
"=",
"elt",
".",
"nodeName",
",",
"elt",
".",
"parentNode",
"if",
"parent",
"is",
"None",
":",
"break",
"matches",
"=",
... | Return a "backtrace" from the given element to the DOM root,
in XPath syntax. | [
"Return",
"a",
"backtrace",
"from",
"the",
"given",
"element",
"to",
"the",
"DOM",
"root",
"in",
"XPath",
"syntax",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L270-L286 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _get_postvalue_from_absoluteURI | def _get_postvalue_from_absoluteURI(url):
"""Bug [ 1513000 ] POST Request-URI not limited to "abs_path"
Request-URI = "*" | absoluteURI | abs_path | authority
Not a complete solution, but it seems to work with all known
implementations. ValueError thrown if bad uri.
"""
cache = _get_postva... | python | def _get_postvalue_from_absoluteURI(url):
"""Bug [ 1513000 ] POST Request-URI not limited to "abs_path"
Request-URI = "*" | absoluteURI | abs_path | authority
Not a complete solution, but it seems to work with all known
implementations. ValueError thrown if bad uri.
"""
cache = _get_postva... | [
"def",
"_get_postvalue_from_absoluteURI",
"(",
"url",
")",
":",
"cache",
"=",
"_get_postvalue_from_absoluteURI",
".",
"cache",
"path",
"=",
"cache",
".",
"get",
"(",
"url",
",",
"''",
")",
"if",
"not",
"path",
":",
"scheme",
",",
"authpath",
"=",
"url",
".... | Bug [ 1513000 ] POST Request-URI not limited to "abs_path"
Request-URI = "*" | absoluteURI | abs_path | authority
Not a complete solution, but it seems to work with all known
implementations. ValueError thrown if bad uri. | [
"Bug",
"[",
"1513000",
"]",
"POST",
"Request",
"-",
"URI",
"not",
"limited",
"to",
"abs_path",
"Request",
"-",
"URI",
"=",
"*",
"|",
"absoluteURI",
"|",
"abs_path",
"|",
"authority",
"Not",
"a",
"complete",
"solution",
"but",
"it",
"seems",
"to",
"work",... | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L298-L313 |
sarenji/pyrc | pyrc/bots.py | Bot.connect | def connect(self):
'''
Connects to the IRC server with the options defined in `config`
'''
self._connect()
try:
self._listen()
except (KeyboardInterrupt, SystemExit):
pass
finally:
self.close() | python | def connect(self):
'''
Connects to the IRC server with the options defined in `config`
'''
self._connect()
try:
self._listen()
except (KeyboardInterrupt, SystemExit):
pass
finally:
self.close() | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_connect",
"(",
")",
"try",
":",
"self",
".",
"_listen",
"(",
")",
"except",
"(",
"KeyboardInterrupt",
",",
"SystemExit",
")",
":",
"pass",
"finally",
":",
"self",
".",
"close",
"(",
")"
] | Connects to the IRC server with the options defined in `config` | [
"Connects",
"to",
"the",
"IRC",
"server",
"with",
"the",
"options",
"defined",
"in",
"config"
] | train | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L43-L54 |
sarenji/pyrc | pyrc/bots.py | Bot._listen | def _listen(self):
"""
Constantly listens to the input from the server. Since the messages come
in pieces, we wait until we receive 1 or more full lines to start parsing.
A new line is defined as ending in \r\n in the RFC, but some servers
separate by \n. This script takes care ... | python | def _listen(self):
"""
Constantly listens to the input from the server. Since the messages come
in pieces, we wait until we receive 1 or more full lines to start parsing.
A new line is defined as ending in \r\n in the RFC, but some servers
separate by \n. This script takes care ... | [
"def",
"_listen",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"_inbuffer",
"=",
"self",
".",
"_inbuffer",
"+",
"self",
".",
"socket",
".",
"recv",
"(",
"1024",
")",
"# Some IRC servers disregard the RFC and split lines by \\n rather than \\r\\n.",
"t... | Constantly listens to the input from the server. Since the messages come
in pieces, we wait until we receive 1 or more full lines to start parsing.
A new line is defined as ending in \r\n in the RFC, but some servers
separate by \n. This script takes care of both. | [
"Constantly",
"listens",
"to",
"the",
"input",
"from",
"the",
"server",
".",
"Since",
"the",
"messages",
"come",
"in",
"pieces",
"we",
"wait",
"until",
"we",
"receive",
"1",
"or",
"more",
"full",
"lines",
"to",
"start",
"parsing",
"."
] | train | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L62-L81 |
sarenji/pyrc | pyrc/bots.py | Bot._run_listeners | def _run_listeners(self, line):
"""
Each listener's associated regular expression is matched against raw IRC
input. If there is a match, the listener's associated function is called
with all the regular expression's matched subgroups.
"""
for regex, callbacks in self.list... | python | def _run_listeners(self, line):
"""
Each listener's associated regular expression is matched against raw IRC
input. If there is a match, the listener's associated function is called
with all the regular expression's matched subgroups.
"""
for regex, callbacks in self.list... | [
"def",
"_run_listeners",
"(",
"self",
",",
"line",
")",
":",
"for",
"regex",
",",
"callbacks",
"in",
"self",
".",
"listeners",
".",
"iteritems",
"(",
")",
":",
"match",
"=",
"regex",
".",
"match",
"(",
"line",
")",
"if",
"not",
"match",
":",
"continu... | Each listener's associated regular expression is matched against raw IRC
input. If there is a match, the listener's associated function is called
with all the regular expression's matched subgroups. | [
"Each",
"listener",
"s",
"associated",
"regular",
"expression",
"is",
"matched",
"against",
"raw",
"IRC",
"input",
".",
"If",
"there",
"is",
"a",
"match",
"the",
"listener",
"s",
"associated",
"function",
"is",
"called",
"with",
"all",
"the",
"regular",
"exp... | train | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L83-L96 |
sarenji/pyrc | pyrc/bots.py | Bot._strip_prefix | def _strip_prefix(self, message):
"""
Checks if the bot was called by a user.
Returns the suffix if so.
Prefixes include the bot's nick as well as a set symbol.
"""
if not hasattr(self, "name_regex"):
"""
regex example:
^(((BotA|BotB)... | python | def _strip_prefix(self, message):
"""
Checks if the bot was called by a user.
Returns the suffix if so.
Prefixes include the bot's nick as well as a set symbol.
"""
if not hasattr(self, "name_regex"):
"""
regex example:
^(((BotA|BotB)... | [
"def",
"_strip_prefix",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"name_regex\"",
")",
":",
"\"\"\"\n regex example:\n ^(((BotA|BotB)[,:]?\\s+)|%)(.+)$\n \n names = [BotA, BotB]\n prefix... | Checks if the bot was called by a user.
Returns the suffix if so.
Prefixes include the bot's nick as well as a set symbol. | [
"Checks",
"if",
"the",
"bot",
"was",
"called",
"by",
"a",
"user",
".",
"Returns",
"the",
"suffix",
"if",
"so",
"."
] | train | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L144-L171 |
sarenji/pyrc | pyrc/bots.py | Bot._connect | def _connect(self):
"Connects a socket to the server using options defined in `config`."
self.socket = socket.socket()
self.socket.connect((self.config['host'], self.config['port']))
self.cmd("NICK %s" % self.config['nick'])
self.cmd("USER %s %s bla :%s" %
(self.c... | python | def _connect(self):
"Connects a socket to the server using options defined in `config`."
self.socket = socket.socket()
self.socket.connect((self.config['host'], self.config['port']))
self.cmd("NICK %s" % self.config['nick'])
self.cmd("USER %s %s bla :%s" %
(self.c... | [
"def",
"_connect",
"(",
"self",
")",
":",
"self",
".",
"socket",
"=",
"socket",
".",
"socket",
"(",
")",
"self",
".",
"socket",
".",
"connect",
"(",
"(",
"self",
".",
"config",
"[",
"'host'",
"]",
",",
"self",
".",
"config",
"[",
"'port'",
"]",
"... | Connects a socket to the server using options defined in `config`. | [
"Connects",
"a",
"socket",
"to",
"the",
"server",
"using",
"options",
"defined",
"in",
"config",
"."
] | train | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L173-L179 |
sampottinger/pycotracer | pycotracer/report_interpreters.py | parse_yes_no_str | def parse_yes_no_str(bool_str):
"""Parse a string serialization of boolean data as yes (Y) or no (N).
Prase a string serialization of boolean data where True is "Y" and False is
"N" case-insensitive.
@param bool_str: The string to parse.
@type bool_str: str
@return: The interpreted string.
... | python | def parse_yes_no_str(bool_str):
"""Parse a string serialization of boolean data as yes (Y) or no (N).
Prase a string serialization of boolean data where True is "Y" and False is
"N" case-insensitive.
@param bool_str: The string to parse.
@type bool_str: str
@return: The interpreted string.
... | [
"def",
"parse_yes_no_str",
"(",
"bool_str",
")",
":",
"lower_bool_str",
"=",
"bool_str",
".",
"lower",
"(",
")",
"if",
"lower_bool_str",
"==",
"'n'",
":",
"return",
"False",
"elif",
"lower_bool_str",
"==",
"'y'",
":",
"return",
"True",
"else",
":",
"raise",
... | Parse a string serialization of boolean data as yes (Y) or no (N).
Prase a string serialization of boolean data where True is "Y" and False is
"N" case-insensitive.
@param bool_str: The string to parse.
@type bool_str: str
@return: The interpreted string.
@rtype: bool
@raise ValueError: Ra... | [
"Parse",
"a",
"string",
"serialization",
"of",
"boolean",
"data",
"as",
"yes",
"(",
"Y",
")",
"or",
"no",
"(",
"N",
")",
"."
] | train | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L32-L51 |
sampottinger/pycotracer | pycotracer/report_interpreters.py | interpret_contribution_entry | def interpret_contribution_entry(entry):
"""Interpret data fields within a CO-TRACER contributions report.
Interpret the contribution amount, contribution date, filed date, amended,
and amendment fields of the provided entry. All dates (contribution and
filed) are interpreted together and, if any fails... | python | def interpret_contribution_entry(entry):
"""Interpret data fields within a CO-TRACER contributions report.
Interpret the contribution amount, contribution date, filed date, amended,
and amendment fields of the provided entry. All dates (contribution and
filed) are interpreted together and, if any fails... | [
"def",
"interpret_contribution_entry",
"(",
"entry",
")",
":",
"try",
":",
"new_contribution_amount",
"=",
"float",
"(",
"entry",
"[",
"'ContributionAmount'",
"]",
")",
"entry",
"[",
"'AmountsInterpreted'",
"]",
"=",
"True",
"entry",
"[",
"'ContributionAmount'",
"... | Interpret data fields within a CO-TRACER contributions report.
Interpret the contribution amount, contribution date, filed date, amended,
and amendment fields of the provided entry. All dates (contribution and
filed) are interpreted together and, if any fails, all will retain their
original value. Like... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"contributions",
"report",
"."
] | train | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L54-L119 |
sampottinger/pycotracer | pycotracer/report_interpreters.py | interpret_expenditure_entry | def interpret_expenditure_entry(entry):
"""Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all w... | python | def interpret_expenditure_entry(entry):
"""Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all w... | [
"def",
"interpret_expenditure_entry",
"(",
"entry",
")",
":",
"try",
":",
"expenditure_amount",
"=",
"float",
"(",
"entry",
"[",
"'ExpenditureAmount'",
"]",
")",
"entry",
"[",
"'AmountsInterpreted'",
"]",
"=",
"True",
"entry",
"[",
"'ExpenditureAmount'",
"]",
"=... | Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all will retain their
original value. Likewise, ... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"expediture",
"report",
"."
] | train | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L156-L209 |
sampottinger/pycotracer | pycotracer/report_interpreters.py | interpret_loan_entry | def interpret_loan_entry(entry):
"""Interpret data fields within a CO-TRACER loan report.
Interpret the payment amount, loan amount, interest rate, interest payment,
loan balance, payment date, filed date, loan date, amended, and amendment
fields of the provided entry. All dates (payment, filed, and lo... | python | def interpret_loan_entry(entry):
"""Interpret data fields within a CO-TRACER loan report.
Interpret the payment amount, loan amount, interest rate, interest payment,
loan balance, payment date, filed date, loan date, amended, and amendment
fields of the provided entry. All dates (payment, filed, and lo... | [
"def",
"interpret_loan_entry",
"(",
"entry",
")",
":",
"try",
":",
"payment_amount",
"=",
"float",
"(",
"entry",
"[",
"'PaymentAmount'",
"]",
")",
"loan_amount",
"=",
"float",
"(",
"entry",
"[",
"'LoanAmount'",
"]",
")",
"interest_rate",
"=",
"float",
"(",
... | Interpret data fields within a CO-TRACER loan report.
Interpret the payment amount, loan amount, interest rate, interest payment,
loan balance, payment date, filed date, loan date, amended, and amendment
fields of the provided entry. All dates (payment, filed, and loan) are
interpreted together and, if... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"loan",
"report",
"."
] | train | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L246-L315 |
RonenNess/Fileter | fileter/iterators/add_header.py | AddHeader.process_file | def process_file(self, path, dryrun):
"""
Add header to all files.
"""
if dryrun:
return path
# get file's current header
with open(path, "r") as infile:
head = infile.read(len(self.__header))
# normalize line breaks
if self.__nor... | python | def process_file(self, path, dryrun):
"""
Add header to all files.
"""
if dryrun:
return path
# get file's current header
with open(path, "r") as infile:
head = infile.read(len(self.__header))
# normalize line breaks
if self.__nor... | [
"def",
"process_file",
"(",
"self",
",",
"path",
",",
"dryrun",
")",
":",
"if",
"dryrun",
":",
"return",
"path",
"# get file's current header",
"with",
"open",
"(",
"path",
",",
"\"r\"",
")",
"as",
"infile",
":",
"head",
"=",
"infile",
".",
"read",
"(",
... | Add header to all files. | [
"Add",
"header",
"to",
"all",
"files",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/iterators/add_header.py#L40-L63 |
RonenNess/Fileter | fileter/iterators/add_header.py | AddHeader.push_header | def push_header(self, filename):
"""
Push the header to a given filename
:param filename: the file path to push into.
"""
# open file and read it all
with open(filename, "r") as infile:
content = infile.read()
# push header
content = self.__he... | python | def push_header(self, filename):
"""
Push the header to a given filename
:param filename: the file path to push into.
"""
# open file and read it all
with open(filename, "r") as infile:
content = infile.read()
# push header
content = self.__he... | [
"def",
"push_header",
"(",
"self",
",",
"filename",
")",
":",
"# open file and read it all",
"with",
"open",
"(",
"filename",
",",
"\"r\"",
")",
"as",
"infile",
":",
"content",
"=",
"infile",
".",
"read",
"(",
")",
"# push header",
"content",
"=",
"self",
... | Push the header to a given filename
:param filename: the file path to push into. | [
"Push",
"the",
"header",
"to",
"a",
"given",
"filename",
":",
"param",
"filename",
":",
"the",
"file",
"path",
"to",
"push",
"into",
"."
] | train | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/iterators/add_header.py#L65-L79 |
ppo/django-guitar | guitar/utils/admin.py | csv_list | def csv_list(models, attr, link=False, separator=", "):
"""Return a comma-separated list of models, optionaly with a link."""
values = []
for model in models:
value = getattr(model, attr)
if link and hasattr(model, "get_admin_url") and callable(model.get_admin_url):
value = get_a... | python | def csv_list(models, attr, link=False, separator=", "):
"""Return a comma-separated list of models, optionaly with a link."""
values = []
for model in models:
value = getattr(model, attr)
if link and hasattr(model, "get_admin_url") and callable(model.get_admin_url):
value = get_a... | [
"def",
"csv_list",
"(",
"models",
",",
"attr",
",",
"link",
"=",
"False",
",",
"separator",
"=",
"\", \"",
")",
":",
"values",
"=",
"[",
"]",
"for",
"model",
"in",
"models",
":",
"value",
"=",
"getattr",
"(",
"model",
",",
"attr",
")",
"if",
"link"... | Return a comma-separated list of models, optionaly with a link. | [
"Return",
"a",
"comma",
"-",
"separated",
"list",
"of",
"models",
"optionaly",
"with",
"a",
"link",
"."
] | train | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L15-L23 |
ppo/django-guitar | guitar/utils/admin.py | get_admin_url | def get_admin_url(obj, page=None):
"""Return the URL to admin pages for this object."""
if obj is None:
return None
if page is None:
page = "change"
if page not in ADMIN_ALL_PAGES:
raise ValueError("Invalid page name '{}'. Available pages are: {}.".format(page, ADMIN_ALL_PAGES))... | python | def get_admin_url(obj, page=None):
"""Return the URL to admin pages for this object."""
if obj is None:
return None
if page is None:
page = "change"
if page not in ADMIN_ALL_PAGES:
raise ValueError("Invalid page name '{}'. Available pages are: {}.".format(page, ADMIN_ALL_PAGES))... | [
"def",
"get_admin_url",
"(",
"obj",
",",
"page",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"None",
"if",
"page",
"is",
"None",
":",
"page",
"=",
"\"change\"",
"if",
"page",
"not",
"in",
"ADMIN_ALL_PAGES",
":",
"raise",
"ValueErro... | Return the URL to admin pages for this object. | [
"Return",
"the",
"URL",
"to",
"admin",
"pages",
"for",
"this",
"object",
"."
] | train | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L26-L54 |
ppo/django-guitar | guitar/utils/admin.py | get_fieldset_index | def get_fieldset_index(fieldsets, index_or_name):
"""
Return the index of a fieldset in the ``fieldsets`` list.
Args:
fieldsets (list): The original ``fieldsets`` list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int)... | python | def get_fieldset_index(fieldsets, index_or_name):
"""
Return the index of a fieldset in the ``fieldsets`` list.
Args:
fieldsets (list): The original ``fieldsets`` list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int)... | [
"def",
"get_fieldset_index",
"(",
"fieldsets",
",",
"index_or_name",
")",
":",
"if",
"isinstance",
"(",
"index_or_name",
",",
"six",
".",
"integer_types",
")",
":",
"return",
"index_or_name",
"for",
"key",
",",
"value",
"in",
"enumerate",
"(",
"fieldsets",
")"... | Return the index of a fieldset in the ``fieldsets`` list.
Args:
fieldsets (list): The original ``fieldsets`` list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the fieldset in the ``fieldsets`` list. | [
"Return",
"the",
"index",
"of",
"a",
"fieldset",
"in",
"the",
"fieldsets",
"list",
"."
] | train | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L93-L111 |
ppo/django-guitar | guitar/utils/admin.py | get_list_index | def get_list_index(lst, index_or_name):
"""
Return the index of an element in the list.
Args:
lst (list): The list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the element in the list.
"""
if... | python | def get_list_index(lst, index_or_name):
"""
Return the index of an element in the list.
Args:
lst (list): The list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the element in the list.
"""
if... | [
"def",
"get_list_index",
"(",
"lst",
",",
"index_or_name",
")",
":",
"if",
"isinstance",
"(",
"index_or_name",
",",
"six",
".",
"integer_types",
")",
":",
"return",
"index_or_name",
"return",
"lst",
".",
"index",
"(",
"index_or_name",
")"
] | Return the index of an element in the list.
Args:
lst (list): The list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the element in the list. | [
"Return",
"the",
"index",
"of",
"an",
"element",
"in",
"the",
"list",
"."
] | train | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L114-L128 |
ppo/django-guitar | guitar/utils/admin.py | insert_fields_in_fieldsets | def insert_fields_in_fieldsets(fieldsets, fieldset_index_or_name, new_fields, field_index_or_name=None, after=True):
"""
Return a copy of the ``fieldsets`` list with the new field(s) inserted.
Args:
fieldsets (list): The original ``fieldsets`` list.
fieldset_index_or_name (int or str): The ... | python | def insert_fields_in_fieldsets(fieldsets, fieldset_index_or_name, new_fields, field_index_or_name=None, after=True):
"""
Return a copy of the ``fieldsets`` list with the new field(s) inserted.
Args:
fieldsets (list): The original ``fieldsets`` list.
fieldset_index_or_name (int or str): The ... | [
"def",
"insert_fields_in_fieldsets",
"(",
"fieldsets",
",",
"fieldset_index_or_name",
",",
"new_fields",
",",
"field_index_or_name",
"=",
"None",
",",
"after",
"=",
"True",
")",
":",
"fieldset_index",
"=",
"get_fieldset_index",
"(",
"fieldsets",
",",
"fieldset_index_o... | Return a copy of the ``fieldsets`` list with the new field(s) inserted.
Args:
fieldsets (list): The original ``fieldsets`` list.
fieldset_index_or_name (int or str): The name of the reference fieldset, or directly its numeric index.
new_fields (str or list of str): The field(s) to insert in... | [
"Return",
"a",
"copy",
"of",
"the",
"fieldsets",
"list",
"with",
"the",
"new",
"field",
"(",
"s",
")",
"inserted",
"."
] | train | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L145-L170 |
ppo/django-guitar | guitar/utils/admin.py | list_insert | def list_insert(lst, new_elements, index_or_name=None, after=True):
"""
Return a copy of the list with the new element(s) inserted.
Args:
lst (list): The original list.
new_elements ("any" or list of "any"): The element(s) to insert in the list.
index_or_name (int or str): The value... | python | def list_insert(lst, new_elements, index_or_name=None, after=True):
"""
Return a copy of the list with the new element(s) inserted.
Args:
lst (list): The original list.
new_elements ("any" or list of "any"): The element(s) to insert in the list.
index_or_name (int or str): The value... | [
"def",
"list_insert",
"(",
"lst",
",",
"new_elements",
",",
"index_or_name",
"=",
"None",
",",
"after",
"=",
"True",
")",
":",
"if",
"index_or_name",
"is",
"None",
":",
"index",
"=",
"None",
"else",
":",
"try",
":",
"index",
"=",
"get_list_index",
"(",
... | Return a copy of the list with the new element(s) inserted.
Args:
lst (list): The original list.
new_elements ("any" or list of "any"): The element(s) to insert in the list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
... | [
"Return",
"a",
"copy",
"of",
"the",
"list",
"with",
"the",
"new",
"element",
"(",
"s",
")",
"inserted",
"."
] | train | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L173-L204 |
pip-services3-python/pip-services3-components-python | pip_services3_components/cache/CacheEntry.py | CacheEntry.set_value | def set_value(self, value, timeout):
"""
Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds.
"""
self.value = value
self.expiration = time.perf_counter() * 1000 + timeout | python | def set_value(self, value, timeout):
"""
Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds.
"""
self.value = value
self.expiration = time.perf_counter() * 1000 + timeout | [
"def",
"set_value",
"(",
"self",
",",
"value",
",",
"timeout",
")",
":",
"self",
".",
"value",
"=",
"value",
"self",
".",
"expiration",
"=",
"time",
".",
"perf_counter",
"(",
")",
"*",
"1000",
"+",
"timeout"
] | Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds. | [
"Sets",
"a",
"new",
"value",
"and",
"extends",
"its",
"expiration",
"."
] | train | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/cache/CacheEntry.py#L36-L45 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | _generate_password | def _generate_password():
"""Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password
"""
uuid_str = six.text_type(uuid.uuid4()).encode("UTF-8")
ret... | python | def _generate_password():
"""Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password
"""
uuid_str = six.text_type(uuid.uuid4()).encode("UTF-8")
ret... | [
"def",
"_generate_password",
"(",
")",
":",
"uuid_str",
"=",
"six",
".",
"text_type",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
".",
"encode",
"(",
"\"UTF-8\"",
")",
"return",
"hashlib",
".",
"sha1",
"(",
"uuid_str",
")",
".",
"hexdigest",
"(",
")"
] | Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password | [
"Create",
"a",
"random",
"password"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L51-L60 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | generate_overcloud_passwords | def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
"""Create the passwords needed for the overcloud
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords. If the
file already exists the existing... | python | def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
"""Create the passwords needed for the overcloud
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords. If the
file already exists the existing... | [
"def",
"generate_overcloud_passwords",
"(",
"output_file",
"=",
"\"tripleo-overcloud-passwords\"",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"output_file",
")",
":",
"with",
"open",
"(",
"output_file",
")",
"as",
"f",
":",
"return",
"dict",
"(",
... | Create the passwords needed for the overcloud
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords. If the
file already exists the existing passwords will be returned instead, | [
"Create",
"the",
"passwords",
"needed",
"for",
"the",
"overcloud"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L63-L97 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | check_hypervisor_stats | def check_hypervisor_stats(compute_client, nodes=1, memory=0, vcpu=0):
"""Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type... | python | def check_hypervisor_stats(compute_client, nodes=1, memory=0, vcpu=0):
"""Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type... | [
"def",
"check_hypervisor_stats",
"(",
"compute_client",
",",
"nodes",
"=",
"1",
",",
"memory",
"=",
"0",
",",
"vcpu",
"=",
"0",
")",
":",
"statistics",
"=",
"compute_client",
".",
"hypervisors",
".",
"statistics",
"(",
")",
".",
"to_dict",
"(",
")",
"if"... | Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type compute_client: novaclient.client.v2.Client
:param nodes: The number of... | [
"Check",
"the",
"Hypervisor",
"stats",
"meet",
"a",
"minimum",
"value"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L100-L126 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | wait_for_stack_ready | def wait_for_stack_ready(orchestration_client, stack_name):
"""Check the status of an orchestration stack
Get the status of an orchestration stack and check whether it is complete
or failed.
:param orchestration_client: Instance of Orchestration client
:type orchestration_client: heatclient.v1.cl... | python | def wait_for_stack_ready(orchestration_client, stack_name):
"""Check the status of an orchestration stack
Get the status of an orchestration stack and check whether it is complete
or failed.
:param orchestration_client: Instance of Orchestration client
:type orchestration_client: heatclient.v1.cl... | [
"def",
"wait_for_stack_ready",
"(",
"orchestration_client",
",",
"stack_name",
")",
":",
"SUCCESSFUL_MATCH_OUTPUT",
"=",
"\"(CREATE|UPDATE)_COMPLETE\"",
"FAIL_MATCH_OUTPUT",
"=",
"\"(CREATE|UPDATE)_FAILED\"",
"while",
"True",
":",
"stack",
"=",
"orchestration_client",
".",
... | Check the status of an orchestration stack
Get the status of an orchestration stack and check whether it is complete
or failed.
:param orchestration_client: Instance of Orchestration client
:type orchestration_client: heatclient.v1.client.Client
:param stack_name: Name or UUID of stack to retrie... | [
"Check",
"the",
"status",
"of",
"an",
"orchestration",
"stack"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L129-L159 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | wait_for_provision_state | def wait_for_provision_state(baremetal_client, node_uuid, provision_state,
loops=10, sleep=1):
"""Wait for a given Provisioning state in Ironic Discoverd
Updating the provisioning state is an async operation, we
need to wait for it to be completed.
:param baremetal_client:... | python | def wait_for_provision_state(baremetal_client, node_uuid, provision_state,
loops=10, sleep=1):
"""Wait for a given Provisioning state in Ironic Discoverd
Updating the provisioning state is an async operation, we
need to wait for it to be completed.
:param baremetal_client:... | [
"def",
"wait_for_provision_state",
"(",
"baremetal_client",
",",
"node_uuid",
",",
"provision_state",
",",
"loops",
"=",
"10",
",",
"sleep",
"=",
"1",
")",
":",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"loops",
")",
":",
"node",
"=",
"baremetal_client",
... | Wait for a given Provisioning state in Ironic Discoverd
Updating the provisioning state is an async operation, we
need to wait for it to be completed.
:param baremetal_client: Instance of Ironic client
:type baremetal_client: ironicclient.v1.client.Client
:param node_uuid: The Ironic node UUID
... | [
"Wait",
"for",
"a",
"given",
"Provisioning",
"state",
"in",
"Ironic",
"Discoverd"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L162-L199 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | wait_for_node_discovery | def wait_for_node_discovery(discoverd_client, auth_token, discoverd_url,
node_uuids, loops=220, sleep=10):
"""Check the status of Node discovery in Ironic discoverd
Gets the status and waits for them to complete.
:param discoverd_client: Ironic Discoverd client
:type disco... | python | def wait_for_node_discovery(discoverd_client, auth_token, discoverd_url,
node_uuids, loops=220, sleep=10):
"""Check the status of Node discovery in Ironic discoverd
Gets the status and waits for them to complete.
:param discoverd_client: Ironic Discoverd client
:type disco... | [
"def",
"wait_for_node_discovery",
"(",
"discoverd_client",
",",
"auth_token",
",",
"discoverd_url",
",",
"node_uuids",
",",
"loops",
"=",
"220",
",",
"sleep",
"=",
"10",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
"+",
"\".wait_for_node... | Check the status of Node discovery in Ironic discoverd
Gets the status and waits for them to complete.
:param discoverd_client: Ironic Discoverd client
:type discoverd_client: ironic_discoverd.client
:param auth_token: Authorisation token used by discoverd client
:type auth_token: string
:p... | [
"Check",
"the",
"status",
"of",
"Node",
"discovery",
"in",
"Ironic",
"discoverd"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L202-L251 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | create_environment_file | def create_environment_file(path="~/overcloud-env.json",
control_scale=1, compute_scale=1,
ceph_storage_scale=0, block_storage_scale=0,
swift_storage_scale=0):
"""Create a heat environment file
Create the heat environment file ... | python | def create_environment_file(path="~/overcloud-env.json",
control_scale=1, compute_scale=1,
ceph_storage_scale=0, block_storage_scale=0,
swift_storage_scale=0):
"""Create a heat environment file
Create the heat environment file ... | [
"def",
"create_environment_file",
"(",
"path",
"=",
"\"~/overcloud-env.json\"",
",",
"control_scale",
"=",
"1",
",",
"compute_scale",
"=",
"1",
",",
"ceph_storage_scale",
"=",
"0",
",",
"block_storage_scale",
"=",
"0",
",",
"swift_storage_scale",
"=",
"0",
")",
... | Create a heat environment file
Create the heat environment file with the scale parameters.
:param control_scale: Scale value for control roles.
:type control_scale: int
:param compute_scale: Scale value for compute roles.
:type compute_scale: int
:param ceph_storage_scale: Scale value for ce... | [
"Create",
"a",
"heat",
"environment",
"file"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L254-L289 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | set_nodes_state | def set_nodes_state(baremetal_client, nodes, transition, target_state,
skipped_states=()):
"""Make all nodes available in the baremetal service for a deployment
For each node, make it available unless it is already available or active.
Available nodes can be used for a deployment and an... | python | def set_nodes_state(baremetal_client, nodes, transition, target_state,
skipped_states=()):
"""Make all nodes available in the baremetal service for a deployment
For each node, make it available unless it is already available or active.
Available nodes can be used for a deployment and an... | [
"def",
"set_nodes_state",
"(",
"baremetal_client",
",",
"nodes",
",",
"transition",
",",
"target_state",
",",
"skipped_states",
"=",
"(",
")",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
"+",
"\".set_nodes_state\"",
")",
"for",
"node",
... | Make all nodes available in the baremetal service for a deployment
For each node, make it available unless it is already available or active.
Available nodes can be used for a deployment and an active node is already
in use.
:param baremetal_client: Instance of Ironic client
:type baremetal_clien... | [
"Make",
"all",
"nodes",
"available",
"in",
"the",
"baremetal",
"service",
"for",
"a",
"deployment"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L292-L338 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | get_hiera_key | def get_hiera_key(key_name):
"""Retrieve a key from the hiera store
:param password_name: Name of the key to retrieve
:type password_name: type
"""
command = ["hiera", key_name]
p = subprocess.Popen(command, stdout=subprocess.PIPE)
out, err = p.communicate()
return out | python | def get_hiera_key(key_name):
"""Retrieve a key from the hiera store
:param password_name: Name of the key to retrieve
:type password_name: type
"""
command = ["hiera", key_name]
p = subprocess.Popen(command, stdout=subprocess.PIPE)
out, err = p.communicate()
return out | [
"def",
"get_hiera_key",
"(",
"key_name",
")",
":",
"command",
"=",
"[",
"\"hiera\"",
",",
"key_name",
"]",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
",",
"err",
"=",
"p",
".",
"co... | Retrieve a key from the hiera store
:param password_name: Name of the key to retrieve
:type password_name: type | [
"Retrieve",
"a",
"key",
"from",
"the",
"hiera",
"store"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L341-L351 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | remove_known_hosts | def remove_known_hosts(overcloud_ip):
"""For a given IP address remove SSH keys from the known_hosts file"""
known_hosts = os.path.expanduser("~/.ssh/known_hosts")
if os.path.exists(known_hosts):
command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts]
subprocess.check_call(command) | python | def remove_known_hosts(overcloud_ip):
"""For a given IP address remove SSH keys from the known_hosts file"""
known_hosts = os.path.expanduser("~/.ssh/known_hosts")
if os.path.exists(known_hosts):
command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts]
subprocess.check_call(command) | [
"def",
"remove_known_hosts",
"(",
"overcloud_ip",
")",
":",
"known_hosts",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.ssh/known_hosts\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"known_hosts",
")",
":",
"command",
"=",
"[",
"'ssh-keygen'... | For a given IP address remove SSH keys from the known_hosts file | [
"For",
"a",
"given",
"IP",
"address",
"remove",
"SSH",
"keys",
"from",
"the",
"known_hosts",
"file"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L361-L368 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | file_checksum | def file_checksum(filepath):
"""Calculate md5 checksum on file
:param filepath: Full path to file (e.g. /home/stack/image.qcow2)
:type filepath: string
"""
checksum = hashlib.md5()
with open(filepath, 'rb') as f:
for fragment in iter(lambda: f.read(65536), ''):
checksum.up... | python | def file_checksum(filepath):
"""Calculate md5 checksum on file
:param filepath: Full path to file (e.g. /home/stack/image.qcow2)
:type filepath: string
"""
checksum = hashlib.md5()
with open(filepath, 'rb') as f:
for fragment in iter(lambda: f.read(65536), ''):
checksum.up... | [
"def",
"file_checksum",
"(",
"filepath",
")",
":",
"checksum",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"filepath",
",",
"'rb'",
")",
"as",
"f",
":",
"for",
"fragment",
"in",
"iter",
"(",
"lambda",
":",
"f",
".",
"read",
"(",
"655... | Calculate md5 checksum on file
:param filepath: Full path to file (e.g. /home/stack/image.qcow2)
:type filepath: string | [
"Calculate",
"md5",
"checksum",
"on",
"file"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L388-L399 |
rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | check_nodes_count | def check_nodes_count(baremetal_client, stack, parameters, defaults):
"""Check if there are enough available nodes for creating/scaling stack"""
count = 0
if stack:
for param in defaults:
try:
current = int(stack.parameters[param])
except KeyError:
... | python | def check_nodes_count(baremetal_client, stack, parameters, defaults):
"""Check if there are enough available nodes for creating/scaling stack"""
count = 0
if stack:
for param in defaults:
try:
current = int(stack.parameters[param])
except KeyError:
... | [
"def",
"check_nodes_count",
"(",
"baremetal_client",
",",
"stack",
",",
"parameters",
",",
"defaults",
")",
":",
"count",
"=",
"0",
"if",
"stack",
":",
"for",
"param",
"in",
"defaults",
":",
"try",
":",
"current",
"=",
"int",
"(",
"stack",
".",
"paramete... | Check if there are enough available nodes for creating/scaling stack | [
"Check",
"if",
"there",
"are",
"enough",
"available",
"nodes",
"for",
"creating",
"/",
"scaling",
"stack"
] | train | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L402-L424 |
lsst-sqre/BitlyOAuth2ProxySession | examples/example.py | main | def main():
"""Do the thing"""
username = os.environ["GITHUB_USERNAME"]
password = os.environ["GITHUB_PASSWORD"]
# Unless you have an LSST account you'd want to change these
baseurl = "https://logging.lsst.codes/oauth2/start"
authpage = "https://logging.lsst.codes/app/kibana"
session = bses.... | python | def main():
"""Do the thing"""
username = os.environ["GITHUB_USERNAME"]
password = os.environ["GITHUB_PASSWORD"]
# Unless you have an LSST account you'd want to change these
baseurl = "https://logging.lsst.codes/oauth2/start"
authpage = "https://logging.lsst.codes/app/kibana"
session = bses.... | [
"def",
"main",
"(",
")",
":",
"username",
"=",
"os",
".",
"environ",
"[",
"\"GITHUB_USERNAME\"",
"]",
"password",
"=",
"os",
".",
"environ",
"[",
"\"GITHUB_PASSWORD\"",
"]",
"# Unless you have an LSST account you'd want to change these",
"baseurl",
"=",
"\"https://log... | Do the thing | [
"Do",
"the",
"thing"
] | train | https://github.com/lsst-sqre/BitlyOAuth2ProxySession/blob/4d3839cfb9b897f46cffc41a5f6ff7c645a5f202/examples/example.py#L8-L21 |
limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker._parse_queues | def _parse_queues(queues):
"""
Parse the given parameter and return a list of queues.
The parameter must be a list/tuple of strings, or a string with queues
separated by a comma.
"""
if not queues:
raise ConfigurationException('The queue(s) to use are not defi... | python | def _parse_queues(queues):
"""
Parse the given parameter and return a list of queues.
The parameter must be a list/tuple of strings, or a string with queues
separated by a comma.
"""
if not queues:
raise ConfigurationException('The queue(s) to use are not defi... | [
"def",
"_parse_queues",
"(",
"queues",
")",
":",
"if",
"not",
"queues",
":",
"raise",
"ConfigurationException",
"(",
"'The queue(s) to use are not defined'",
")",
"if",
"isinstance",
"(",
"queues",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"queue_n... | Parse the given parameter and return a list of queues.
The parameter must be a list/tuple of strings, or a string with queues
separated by a comma. | [
"Parse",
"the",
"given",
"parameter",
"and",
"return",
"a",
"list",
"of",
"queues",
".",
"The",
"parameter",
"must",
"be",
"a",
"list",
"/",
"tuple",
"of",
"strings",
"or",
"a",
"string",
"with",
"queues",
"separated",
"by",
"a",
"comma",
"."
] | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L81-L101 |
limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker._assert_correct_model | def _assert_correct_model(model_to_check, model_reference, obj_name):
"""
Helper that asserts the model_to_check is the model_reference or one of
its subclasses. If not, raise an ImplementationError, using "obj_name"
to describe the name of the argument.
"""
if not issubc... | python | def _assert_correct_model(model_to_check, model_reference, obj_name):
"""
Helper that asserts the model_to_check is the model_reference or one of
its subclasses. If not, raise an ImplementationError, using "obj_name"
to describe the name of the argument.
"""
if not issubc... | [
"def",
"_assert_correct_model",
"(",
"model_to_check",
",",
"model_reference",
",",
"obj_name",
")",
":",
"if",
"not",
"issubclass",
"(",
"model_to_check",
",",
"model_reference",
")",
":",
"raise",
"ConfigurationException",
"(",
"'The %s model must be a subclass of %s'",... | Helper that asserts the model_to_check is the model_reference or one of
its subclasses. If not, raise an ImplementationError, using "obj_name"
to describe the name of the argument. | [
"Helper",
"that",
"asserts",
"the",
"model_to_check",
"is",
"the",
"model_reference",
"or",
"one",
"of",
"its",
"subclasses",
".",
"If",
"not",
"raise",
"an",
"ImplementationError",
"using",
"obj_name",
"to",
"describe",
"the",
"name",
"of",
"the",
"argument",
... | train | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L146-L154 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.