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 |
|---|---|---|---|---|---|---|---|---|---|---|
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.FindLocalHREF | def FindLocalHREF(self, href, elt, headers=1):
'''Find a local HREF in the data elements.
'''
if href[0] != '#':
raise EvaluateException(
'Absolute HREF ("%s") not implemented' % href,
self.Backtrace(elt))
frag = href[1:]
# Already foun... | python | def FindLocalHREF(self, href, elt, headers=1):
'''Find a local HREF in the data elements.
'''
if href[0] != '#':
raise EvaluateException(
'Absolute HREF ("%s") not implemented' % href,
self.Backtrace(elt))
frag = href[1:]
# Already foun... | [
"def",
"FindLocalHREF",
"(",
"self",
",",
"href",
",",
"elt",
",",
"headers",
"=",
"1",
")",
":",
"if",
"href",
"[",
"0",
"]",
"!=",
"'#'",
":",
"raise",
"EvaluateException",
"(",
"'Absolute HREF (\"%s\") not implemented'",
"%",
"href",
",",
"self",
".",
... | Find a local HREF in the data elements. | [
"Find",
"a",
"local",
"HREF",
"in",
"the",
"data",
"elements",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L241-L265 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.GetMyHeaderElements | def GetMyHeaderElements(self, actorlist=None):
'''Return a list of all elements intended for these actor(s).
'''
if actorlist is None:
actorlist = [None, SOAP.ACTOR_NEXT]
else:
actorlist = list(actorlist) + [None, SOAP.ACTOR_NEXT]
return [ E for E in self.... | python | def GetMyHeaderElements(self, actorlist=None):
'''Return a list of all elements intended for these actor(s).
'''
if actorlist is None:
actorlist = [None, SOAP.ACTOR_NEXT]
else:
actorlist = list(actorlist) + [None, SOAP.ACTOR_NEXT]
return [ E for E in self.... | [
"def",
"GetMyHeaderElements",
"(",
"self",
",",
"actorlist",
"=",
"None",
")",
":",
"if",
"actorlist",
"is",
"None",
":",
"actorlist",
"=",
"[",
"None",
",",
"SOAP",
".",
"ACTOR_NEXT",
"]",
"else",
":",
"actorlist",
"=",
"list",
"(",
"actorlist",
")",
... | Return a list of all elements intended for these actor(s). | [
"Return",
"a",
"list",
"of",
"all",
"elements",
"intended",
"for",
"these",
"actor",
"(",
"s",
")",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L279-L287 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.GetElementNSdict | def GetElementNSdict(self, elt):
'''Get a dictionary of all the namespace attributes for the indicated
element. The dictionaries are cached, and we recurse up the tree
as necessary.
'''
d = self.ns_cache.get(id(elt))
if not d:
if elt != self.dom: d = self.Get... | python | def GetElementNSdict(self, elt):
'''Get a dictionary of all the namespace attributes for the indicated
element. The dictionaries are cached, and we recurse up the tree
as necessary.
'''
d = self.ns_cache.get(id(elt))
if not d:
if elt != self.dom: d = self.Get... | [
"def",
"GetElementNSdict",
"(",
"self",
",",
"elt",
")",
":",
"d",
"=",
"self",
".",
"ns_cache",
".",
"get",
"(",
"id",
"(",
"elt",
")",
")",
"if",
"not",
"d",
":",
"if",
"elt",
"!=",
"self",
".",
"dom",
":",
"d",
"=",
"self",
".",
"GetElementN... | Get a dictionary of all the namespace attributes for the indicated
element. The dictionaries are cached, and we recurse up the tree
as necessary. | [
"Get",
"a",
"dictionary",
"of",
"all",
"the",
"namespace",
"attributes",
"for",
"the",
"indicated",
"element",
".",
"The",
"dictionaries",
"are",
"cached",
"and",
"we",
"recurse",
"up",
"the",
"tree",
"as",
"necessary",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L289-L304 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.IsAFault | def IsAFault(self):
'''Is this a fault message?
'''
e = self.body_root
if not e: return 0
return e.namespaceURI == SOAP.ENV and e.localName == 'Fault' | python | def IsAFault(self):
'''Is this a fault message?
'''
e = self.body_root
if not e: return 0
return e.namespaceURI == SOAP.ENV and e.localName == 'Fault' | [
"def",
"IsAFault",
"(",
"self",
")",
":",
"e",
"=",
"self",
".",
"body_root",
"if",
"not",
"e",
":",
"return",
"0",
"return",
"e",
".",
"namespaceURI",
"==",
"SOAP",
".",
"ENV",
"and",
"e",
".",
"localName",
"==",
"'Fault'"
] | Is this a fault message? | [
"Is",
"this",
"a",
"fault",
"message?"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L315-L320 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.Parse | def Parse(self, how):
'''Parse the message.
'''
if type(how) == types.ClassType: how = how.typecode
return how.parse(self.body_root, self) | python | def Parse(self, how):
'''Parse the message.
'''
if type(how) == types.ClassType: how = how.typecode
return how.parse(self.body_root, self) | [
"def",
"Parse",
"(",
"self",
",",
"how",
")",
":",
"if",
"type",
"(",
"how",
")",
"==",
"types",
".",
"ClassType",
":",
"how",
"=",
"how",
".",
"typecode",
"return",
"how",
".",
"parse",
"(",
"self",
".",
"body_root",
",",
"self",
")"
] | Parse the message. | [
"Parse",
"the",
"message",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L322-L326 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.WhatMustIUnderstand | def WhatMustIUnderstand(self):
'''Return a list of (uri,localname) tuples for all elements in the
header that have mustUnderstand set.
'''
return [ ( E.namespaceURI, E.localName )
for E in self.header_elements if _find_mu(E) == "1" ] | python | def WhatMustIUnderstand(self):
'''Return a list of (uri,localname) tuples for all elements in the
header that have mustUnderstand set.
'''
return [ ( E.namespaceURI, E.localName )
for E in self.header_elements if _find_mu(E) == "1" ] | [
"def",
"WhatMustIUnderstand",
"(",
"self",
")",
":",
"return",
"[",
"(",
"E",
".",
"namespaceURI",
",",
"E",
".",
"localName",
")",
"for",
"E",
"in",
"self",
".",
"header_elements",
"if",
"_find_mu",
"(",
"E",
")",
"==",
"\"1\"",
"]"
] | Return a list of (uri,localname) tuples for all elements in the
header that have mustUnderstand set. | [
"Return",
"a",
"list",
"of",
"(",
"uri",
"localname",
")",
"tuples",
"for",
"all",
"elements",
"in",
"the",
"header",
"that",
"have",
"mustUnderstand",
"set",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L328-L333 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.WhatActorsArePresent | def WhatActorsArePresent(self):
'''Return a list of URI's of all the actor attributes found in
the header. The special actor "next" is ignored.
'''
results = []
for E in self.header_elements:
a = _find_actor(E)
if a not in [ None, SOAP.ACTOR_NEXT ]: resul... | python | def WhatActorsArePresent(self):
'''Return a list of URI's of all the actor attributes found in
the header. The special actor "next" is ignored.
'''
results = []
for E in self.header_elements:
a = _find_actor(E)
if a not in [ None, SOAP.ACTOR_NEXT ]: resul... | [
"def",
"WhatActorsArePresent",
"(",
"self",
")",
":",
"results",
"=",
"[",
"]",
"for",
"E",
"in",
"self",
".",
"header_elements",
":",
"a",
"=",
"_find_actor",
"(",
"E",
")",
"if",
"a",
"not",
"in",
"[",
"None",
",",
"SOAP",
".",
"ACTOR_NEXT",
"]",
... | Return a list of URI's of all the actor attributes found in
the header. The special actor "next" is ignored. | [
"Return",
"a",
"list",
"of",
"URI",
"s",
"of",
"all",
"the",
"actor",
"attributes",
"found",
"in",
"the",
"header",
".",
"The",
"special",
"actor",
"next",
"is",
"ignored",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L335-L343 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/parse.py | ParsedSoap.ParseHeaderElements | def ParseHeaderElements(self, ofwhat):
'''Returns a dictionary of pyobjs.
ofhow -- list of typecodes w/matching nspname/pname to the header_elements.
'''
d = {}
lenofwhat = len(ofwhat)
c, crange = self.header_elements[:], range(len(self.header_elements))
for i,wha... | python | def ParseHeaderElements(self, ofwhat):
'''Returns a dictionary of pyobjs.
ofhow -- list of typecodes w/matching nspname/pname to the header_elements.
'''
d = {}
lenofwhat = len(ofwhat)
c, crange = self.header_elements[:], range(len(self.header_elements))
for i,wha... | [
"def",
"ParseHeaderElements",
"(",
"self",
",",
"ofwhat",
")",
":",
"d",
"=",
"{",
"}",
"lenofwhat",
"=",
"len",
"(",
"ofwhat",
")",
"c",
",",
"crange",
"=",
"self",
".",
"header_elements",
"[",
":",
"]",
",",
"range",
"(",
"len",
"(",
"self",
".",... | Returns a dictionary of pyobjs.
ofhow -- list of typecodes w/matching nspname/pname to the header_elements. | [
"Returns",
"a",
"dictionary",
"of",
"pyobjs",
".",
"ofhow",
"--",
"list",
"of",
"typecodes",
"w",
"/",
"matching",
"nspname",
"/",
"pname",
"to",
"the",
"header_elements",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/parse.py#L345-L375 |
magland/vdomr | vdomr/vdom.py | VDOM._repr_html_ | def _repr_html_(self):
"""
Return HTML representation of VDOM object.
HTML escaping is performed wherever necessary.
"""
# Use StringIO to avoid a large number of memory allocations with string concat
with io.StringIO() as out:
out.write('<{tag}'.format(tag=es... | python | def _repr_html_(self):
"""
Return HTML representation of VDOM object.
HTML escaping is performed wherever necessary.
"""
# Use StringIO to avoid a large number of memory allocations with string concat
with io.StringIO() as out:
out.write('<{tag}'.format(tag=es... | [
"def",
"_repr_html_",
"(",
"self",
")",
":",
"# Use StringIO to avoid a large number of memory allocations with string concat",
"with",
"io",
".",
"StringIO",
"(",
")",
"as",
"out",
":",
"out",
".",
"write",
"(",
"'<{tag}'",
".",
"format",
"(",
"tag",
"=",
"escape... | Return HTML representation of VDOM object.
HTML escaping is performed wherever necessary. | [
"Return",
"HTML",
"representation",
"of",
"VDOM",
"object",
".",
"HTML",
"escaping",
"is",
"performed",
"wherever",
"necessary",
"."
] | train | https://github.com/magland/vdomr/blob/89f62611689a596ca49d9e080f3a7e9cf58b71b6/vdomr/vdom.py#L31-L64 |
voidpp/python-tools | voidpp_tools/daemon.py | Daemon.daemonize | def daemonize(self):
"""
do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
"""
try:
pid = os.fork()
if pid > 0:
... | python | def daemonize(self):
"""
do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16
"""
try:
pid = os.fork()
if pid > 0:
... | [
"def",
"daemonize",
"(",
"self",
")",
":",
"try",
":",
"pid",
"=",
"os",
".",
"fork",
"(",
")",
"if",
"pid",
">",
"0",
":",
"# exit first parent",
"sys",
".",
"exit",
"(",
"0",
")",
"except",
"OSError",
"as",
"e",
":",
"self",
".",
"logger",
".",... | do the UNIX double-fork magic, see Stevens' "Advanced
Programming in the UNIX Environment" for details (ISBN 0201563177)
http://www.erlenstar.demon.co.uk/unix/faq_2.html#SEC16 | [
"do",
"the",
"UNIX",
"double",
"-",
"fork",
"magic",
"see",
"Stevens",
"Advanced",
"Programming",
"in",
"the",
"UNIX",
"Environment",
"for",
"details",
"(",
"ISBN",
"0201563177",
")",
"http",
":",
"//",
"www",
".",
"erlenstar",
".",
"demon",
".",
"co",
"... | train | https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/daemon.py#L25-L62 |
voidpp/python-tools | voidpp_tools/daemon.py | Daemon.start | def start(self):
"""
Start the daemon
"""
if self.is_running():
msg = "Daemon already running (pidfile:%s)" % self.pidfile
self.logger.error(msg)
return msg
initres = self.init()
if not initres[0]:
return initres[1]
... | python | def start(self):
"""
Start the daemon
"""
if self.is_running():
msg = "Daemon already running (pidfile:%s)" % self.pidfile
self.logger.error(msg)
return msg
initres = self.init()
if not initres[0]:
return initres[1]
... | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_running",
"(",
")",
":",
"msg",
"=",
"\"Daemon already running (pidfile:%s)\"",
"%",
"self",
".",
"pidfile",
"self",
".",
"logger",
".",
"error",
"(",
"msg",
")",
"return",
"msg",
"initres",
"... | Start the daemon | [
"Start",
"the",
"daemon"
] | train | https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/daemon.py#L99-L116 |
voidpp/python-tools | voidpp_tools/daemon.py | Daemon.stop | def stop(self):
"""
Stop the daemon
"""
# Get the pid from the pidfile
pid = self.get_pid()
if not pid:
message = "Pidfile %s does not exist. Daemon not running?" % self.pidfile
self.logger.error(message)
return message # not an error ... | python | def stop(self):
"""
Stop the daemon
"""
# Get the pid from the pidfile
pid = self.get_pid()
if not pid:
message = "Pidfile %s does not exist. Daemon not running?" % self.pidfile
self.logger.error(message)
return message # not an error ... | [
"def",
"stop",
"(",
"self",
")",
":",
"# Get the pid from the pidfile",
"pid",
"=",
"self",
".",
"get_pid",
"(",
")",
"if",
"not",
"pid",
":",
"message",
"=",
"\"Pidfile %s does not exist. Daemon not running?\"",
"%",
"self",
".",
"pidfile",
"self",
".",
"logger... | Stop the daemon | [
"Stop",
"the",
"daemon"
] | train | https://github.com/voidpp/python-tools/blob/0fc7460c827b02d8914411cedddadc23ccb3cc73/voidpp_tools/daemon.py#L118-L144 |
radjkarl/fancyTools | DUMP/interpolate2dFunctional.py | vignettingEq | def vignettingEq(xxx_todo_changeme, f=100, alpha=0, Xi=0, tau=0, cx=50, cy=50):
'''
Vignetting equation using the KARL-WEISS-MODEL
see http://research.microsoft.com/en-us/people/stevelin/vignetting.pdf
f - focal length
alpha - coefficient in the geometric vignetting factor
Xi - tilt fact... | python | def vignettingEq(xxx_todo_changeme, f=100, alpha=0, Xi=0, tau=0, cx=50, cy=50):
'''
Vignetting equation using the KARL-WEISS-MODEL
see http://research.microsoft.com/en-us/people/stevelin/vignetting.pdf
f - focal length
alpha - coefficient in the geometric vignetting factor
Xi - tilt fact... | [
"def",
"vignettingEq",
"(",
"xxx_todo_changeme",
",",
"f",
"=",
"100",
",",
"alpha",
"=",
"0",
",",
"Xi",
"=",
"0",
",",
"tau",
"=",
"0",
",",
"cx",
"=",
"50",
",",
"cy",
"=",
"50",
")",
":",
"(",
"x",
",",
"y",
")",
"=",
"xxx_todo_changeme",
... | Vignetting equation using the KARL-WEISS-MODEL
see http://research.microsoft.com/en-us/people/stevelin/vignetting.pdf
f - focal length
alpha - coefficient in the geometric vignetting factor
Xi - tilt factor of a planar scene
tau - rotation angle of a planar scene
cx - image center, x
... | [
"Vignetting",
"equation",
"using",
"the",
"KARL",
"-",
"WEISS",
"-",
"MODEL",
"see",
"http",
":",
"//",
"research",
".",
"microsoft",
".",
"com",
"/",
"en",
"-",
"us",
"/",
"people",
"/",
"stevelin",
"/",
"vignetting",
".",
"pdf",
"f",
"-",
"focal",
... | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/DUMP/interpolate2dFunctional.py#L16-L36 |
pybel/pybel-artifactory | src/pybel_artifactory/deploy.py | _deploy_helper | def _deploy_helper(filename, module_name, get_module, get_today_fn, hash_check=True, auth=None):
"""Deploys a file to the Artifactory BEL namespace cache
:param str filename: The physical path
:param str module_name: The name of the module to deploy to
:param tuple[str] auth: A pair of (str username, s... | python | def _deploy_helper(filename, module_name, get_module, get_today_fn, hash_check=True, auth=None):
"""Deploys a file to the Artifactory BEL namespace cache
:param str filename: The physical path
:param str module_name: The name of the module to deploy to
:param tuple[str] auth: A pair of (str username, s... | [
"def",
"_deploy_helper",
"(",
"filename",
",",
"module_name",
",",
"get_module",
",",
"get_today_fn",
",",
"hash_check",
"=",
"True",
",",
"auth",
"=",
"None",
")",
":",
"path",
"=",
"ArtifactoryPath",
"(",
"get_module",
"(",
"module_name",
")",
",",
"auth",... | Deploys a file to the Artifactory BEL namespace cache
:param str filename: The physical path
:param str module_name: The name of the module to deploy to
:param tuple[str] auth: A pair of (str username, str password) to give to the auth keyword of the constructor of
:class:`artif... | [
"Deploys",
"a",
"file",
"to",
"the",
"Artifactory",
"BEL",
"namespace",
"cache"
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/deploy.py#L37-L69 |
pybel/pybel-artifactory | src/pybel_artifactory/deploy.py | deploy_namespace | def deploy_namespace(filename, module_name, hash_check=True, auth=None):
"""Deploy a file to the Artifactory BEL namespace cache.
:param str filename: The physical path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
:pa... | python | def deploy_namespace(filename, module_name, hash_check=True, auth=None):
"""Deploy a file to the Artifactory BEL namespace cache.
:param str filename: The physical path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
:pa... | [
"def",
"deploy_namespace",
"(",
"filename",
",",
"module_name",
",",
"hash_check",
"=",
"True",
",",
"auth",
"=",
"None",
")",
":",
"return",
"_deploy_helper",
"(",
"filename",
",",
"module_name",
",",
"get_namespace_module_url",
",",
"get_namespace_today",
",",
... | Deploy a file to the Artifactory BEL namespace cache.
:param str filename: The physical path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
:param tuple[str] auth: A pair of (str username, str password) to give to the auth ... | [
"Deploy",
"a",
"file",
"to",
"the",
"Artifactory",
"BEL",
"namespace",
"cache",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/deploy.py#L72-L90 |
pybel/pybel-artifactory | src/pybel_artifactory/deploy.py | deploy_annotation | def deploy_annotation(filename, module_name, hash_check=True, auth=None):
"""Deploy a file to the Artifactory BEL annotation cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
... | python | def deploy_annotation(filename, module_name, hash_check=True, auth=None):
"""Deploy a file to the Artifactory BEL annotation cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
... | [
"def",
"deploy_annotation",
"(",
"filename",
",",
"module_name",
",",
"hash_check",
"=",
"True",
",",
"auth",
"=",
"None",
")",
":",
"return",
"_deploy_helper",
"(",
"filename",
",",
"module_name",
",",
"get_annotation_module_url",
",",
"get_annotation_today",
","... | Deploy a file to the Artifactory BEL annotation cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param bool hash_check: Ensure the hash is unique before deploying
:param tuple[str] auth: A pair of (str username, str password) to give to the... | [
"Deploy",
"a",
"file",
"to",
"the",
"Artifactory",
"BEL",
"annotation",
"cache",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/deploy.py#L93-L111 |
pybel/pybel-artifactory | src/pybel_artifactory/deploy.py | deploy_knowledge | def deploy_knowledge(filename, module_name, auth=None):
"""Deploy a file to the Artifactory BEL knowledge cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param tuple[str] auth: A pair of (str username, str password) to give to the auth key... | python | def deploy_knowledge(filename, module_name, auth=None):
"""Deploy a file to the Artifactory BEL knowledge cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param tuple[str] auth: A pair of (str username, str password) to give to the auth key... | [
"def",
"deploy_knowledge",
"(",
"filename",
",",
"module_name",
",",
"auth",
"=",
"None",
")",
":",
"return",
"_deploy_helper",
"(",
"filename",
",",
"module_name",
",",
"get_knowledge_module_url",
",",
"get_knowledge_today",
",",
"hash_check",
"=",
"False",
",",
... | Deploy a file to the Artifactory BEL knowledge cache.
:param str filename: The physical file path
:param str module_name: The name of the module to deploy to
:param tuple[str] auth: A pair of (str username, str password) to give to the auth keyword of the constructor of
:class:`... | [
"Deploy",
"a",
"file",
"to",
"the",
"Artifactory",
"BEL",
"knowledge",
"cache",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/deploy.py#L114-L131 |
pybel/pybel-artifactory | src/pybel_artifactory/deploy.py | deploy_directory | def deploy_directory(directory, auth=None):
"""Deploy all files in a given directory.
:param str directory: the path to a directory
:param tuple[str] auth: A pair of (str username, str password) to give to the auth keyword of the constructor of
:class:`artifactory.ArtifactoryPat... | python | def deploy_directory(directory, auth=None):
"""Deploy all files in a given directory.
:param str directory: the path to a directory
:param tuple[str] auth: A pair of (str username, str password) to give to the auth keyword of the constructor of
:class:`artifactory.ArtifactoryPat... | [
"def",
"deploy_directory",
"(",
"directory",
",",
"auth",
"=",
"None",
")",
":",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
"directory",
")",
":",
"full_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"directory",
",",
"file",
")",
"if",
"file"... | Deploy all files in a given directory.
:param str directory: the path to a directory
:param tuple[str] auth: A pair of (str username, str password) to give to the auth keyword of the constructor of
:class:`artifactory.ArtifactoryPath`. Defaults to the result of :func:`get_arty_auth`... | [
"Deploy",
"all",
"files",
"in",
"a",
"given",
"directory",
"."
] | train | https://github.com/pybel/pybel-artifactory/blob/720107780a59be2ef08885290dfa519b1da62871/src/pybel_artifactory/deploy.py#L134-L160 |
mbr/unleash | unleash/git.py | export_tree | def export_tree(lookup, tree, path):
"""Exports the given tree object to path.
:param lookup: Function to retrieve objects for SHA1 hashes.
:param tree: Tree to export.
:param path: Output path.
"""
FILE_PERM = S_IRWXU | S_IRWXG | S_IRWXO
for name, mode, hexsha in tree.iteritems():
... | python | def export_tree(lookup, tree, path):
"""Exports the given tree object to path.
:param lookup: Function to retrieve objects for SHA1 hashes.
:param tree: Tree to export.
:param path: Output path.
"""
FILE_PERM = S_IRWXU | S_IRWXG | S_IRWXO
for name, mode, hexsha in tree.iteritems():
... | [
"def",
"export_tree",
"(",
"lookup",
",",
"tree",
",",
"path",
")",
":",
"FILE_PERM",
"=",
"S_IRWXU",
"|",
"S_IRWXG",
"|",
"S_IRWXO",
"for",
"name",
",",
"mode",
",",
"hexsha",
"in",
"tree",
".",
"iteritems",
"(",
")",
":",
"dest",
"=",
"os",
".",
... | Exports the given tree object to path.
:param lookup: Function to retrieve objects for SHA1 hashes.
:param tree: Tree to export.
:param path: Output path. | [
"Exports",
"the",
"given",
"tree",
"object",
"to",
"path",
"."
] | train | https://github.com/mbr/unleash/blob/f36c6e6600868bc054f5b8d4cf1c03ea8eb8da4c/unleash/git.py#L17-L46 |
jspricke/python-abook | abook.py | abook2vcf | def abook2vcf():
"""Command line tool to convert from Abook to vCard"""
from argparse import ArgumentParser, FileType
from os.path import expanduser
from sys import stdout
parser = ArgumentParser(description='Converter from Abook to vCard syntax.')
parser.add_argument('infile', nargs='?', defau... | python | def abook2vcf():
"""Command line tool to convert from Abook to vCard"""
from argparse import ArgumentParser, FileType
from os.path import expanduser
from sys import stdout
parser = ArgumentParser(description='Converter from Abook to vCard syntax.')
parser.add_argument('infile', nargs='?', defau... | [
"def",
"abook2vcf",
"(",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
",",
"FileType",
"from",
"os",
".",
"path",
"import",
"expanduser",
"from",
"sys",
"import",
"stdout",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"'Converter from A... | Command line tool to convert from Abook to vCard | [
"Command",
"line",
"tool",
"to",
"convert",
"from",
"Abook",
"to",
"vCard"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L328-L341 |
jspricke/python-abook | abook.py | vcf2abook | def vcf2abook():
"""Command line tool to convert from vCard to Abook"""
from argparse import ArgumentParser, FileType
from sys import stdin
parser = ArgumentParser(description='Converter from vCard to Abook syntax.')
parser.add_argument('infile', nargs='?', type=FileType('r'), default=stdin,
... | python | def vcf2abook():
"""Command line tool to convert from vCard to Abook"""
from argparse import ArgumentParser, FileType
from sys import stdin
parser = ArgumentParser(description='Converter from vCard to Abook syntax.')
parser.add_argument('infile', nargs='?', type=FileType('r'), default=stdin,
... | [
"def",
"vcf2abook",
"(",
")",
":",
"from",
"argparse",
"import",
"ArgumentParser",
",",
"FileType",
"from",
"sys",
"import",
"stdin",
"parser",
"=",
"ArgumentParser",
"(",
"description",
"=",
"'Converter from vCard to Abook syntax.'",
")",
"parser",
".",
"add_argume... | Command line tool to convert from vCard to Abook | [
"Command",
"line",
"tool",
"to",
"convert",
"from",
"vCard",
"to",
"Abook"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L344-L356 |
jspricke/python-abook | abook.py | Abook._update | def _update(self):
""" Update internal state."""
with self._lock:
if getmtime(self._filename) > self._last_modified:
self._last_modified = getmtime(self._filename)
self._book = ConfigParser(default_section='format')
self._book.read(self._filena... | python | def _update(self):
""" Update internal state."""
with self._lock:
if getmtime(self._filename) > self._last_modified:
self._last_modified = getmtime(self._filename)
self._book = ConfigParser(default_section='format')
self._book.read(self._filena... | [
"def",
"_update",
"(",
"self",
")",
":",
"with",
"self",
".",
"_lock",
":",
"if",
"getmtime",
"(",
"self",
".",
"_filename",
")",
">",
"self",
".",
"_last_modified",
":",
"self",
".",
"_last_modified",
"=",
"getmtime",
"(",
"self",
".",
"_filename",
")... | Update internal state. | [
"Update",
"internal",
"state",
"."
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L42-L48 |
jspricke/python-abook | abook.py | Abook.append_vobject | def append_vobject(self, vcard, filename=None):
"""Appends an address to the Abook addressbook
vcard -- vCard to append
filename -- unused
return the new UID of the appended vcard
"""
book = ConfigParser(default_section='format')
with self._lock:
book.... | python | def append_vobject(self, vcard, filename=None):
"""Appends an address to the Abook addressbook
vcard -- vCard to append
filename -- unused
return the new UID of the appended vcard
"""
book = ConfigParser(default_section='format')
with self._lock:
book.... | [
"def",
"append_vobject",
"(",
"self",
",",
"vcard",
",",
"filename",
"=",
"None",
")",
":",
"book",
"=",
"ConfigParser",
"(",
"default_section",
"=",
"'format'",
")",
"with",
"self",
".",
"_lock",
":",
"book",
".",
"read",
"(",
"self",
".",
"_filename",
... | Appends an address to the Abook addressbook
vcard -- vCard to append
filename -- unused
return the new UID of the appended vcard | [
"Appends",
"an",
"address",
"to",
"the",
"Abook",
"addressbook",
"vcard",
"--",
"vCard",
"to",
"append",
"filename",
"--",
"unused",
"return",
"the",
"new",
"UID",
"of",
"the",
"appended",
"vcard"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L58-L72 |
jspricke/python-abook | abook.py | Abook.remove | def remove(self, uid, filename=None):
"""Removes an address to the Abook addressbook
uid -- UID of the entry to remove
"""
book = ConfigParser(default_section='format')
with self._lock:
book.read(self._filename)
del book[uid.split('@')[0]]
with... | python | def remove(self, uid, filename=None):
"""Removes an address to the Abook addressbook
uid -- UID of the entry to remove
"""
book = ConfigParser(default_section='format')
with self._lock:
book.read(self._filename)
del book[uid.split('@')[0]]
with... | [
"def",
"remove",
"(",
"self",
",",
"uid",
",",
"filename",
"=",
"None",
")",
":",
"book",
"=",
"ConfigParser",
"(",
"default_section",
"=",
"'format'",
")",
"with",
"self",
".",
"_lock",
":",
"book",
".",
"read",
"(",
"self",
".",
"_filename",
")",
"... | Removes an address to the Abook addressbook
uid -- UID of the entry to remove | [
"Removes",
"an",
"address",
"to",
"the",
"Abook",
"addressbook",
"uid",
"--",
"UID",
"of",
"the",
"entry",
"to",
"remove"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L74-L83 |
jspricke/python-abook | abook.py | Abook.replace_vobject | def replace_vobject(self, uid, vcard, filename=None):
"""Updates an address to the Abook addressbook
uid -- uid of the entry to replace
vcard -- vCard of the new content
filename -- unused
"""
entry = uid.split('@')[0]
book = ConfigParser(default_section='format'... | python | def replace_vobject(self, uid, vcard, filename=None):
"""Updates an address to the Abook addressbook
uid -- uid of the entry to replace
vcard -- vCard of the new content
filename -- unused
"""
entry = uid.split('@')[0]
book = ConfigParser(default_section='format'... | [
"def",
"replace_vobject",
"(",
"self",
",",
"uid",
",",
"vcard",
",",
"filename",
"=",
"None",
")",
":",
"entry",
"=",
"uid",
".",
"split",
"(",
"'@'",
")",
"[",
"0",
"]",
"book",
"=",
"ConfigParser",
"(",
"default_section",
"=",
"'format'",
")",
"wi... | Updates an address to the Abook addressbook
uid -- uid of the entry to replace
vcard -- vCard of the new content
filename -- unused | [
"Updates",
"an",
"address",
"to",
"the",
"Abook",
"addressbook",
"uid",
"--",
"uid",
"of",
"the",
"entry",
"to",
"replace",
"vcard",
"--",
"vCard",
"of",
"the",
"new",
"content",
"filename",
"--",
"unused"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L89-L104 |
jspricke/python-abook | abook.py | Abook._gen_addr | def _gen_addr(entry):
"""Generates a vCard Address object"""
return Address(street=entry.get('address', ''),
extended=entry.get('address2', ''),
city=entry.get('city', ''),
region=entry.get('state', ''),
code=ent... | python | def _gen_addr(entry):
"""Generates a vCard Address object"""
return Address(street=entry.get('address', ''),
extended=entry.get('address2', ''),
city=entry.get('city', ''),
region=entry.get('state', ''),
code=ent... | [
"def",
"_gen_addr",
"(",
"entry",
")",
":",
"return",
"Address",
"(",
"street",
"=",
"entry",
".",
"get",
"(",
"'address'",
",",
"''",
")",
",",
"extended",
"=",
"entry",
".",
"get",
"(",
"'address2'",
",",
"''",
")",
",",
"city",
"=",
"entry",
"."... | Generates a vCard Address object | [
"Generates",
"a",
"vCard",
"Address",
"object"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L125-L132 |
jspricke/python-abook | abook.py | Abook._add_photo | def _add_photo(self, card, name):
"""Tries to load a photo and add it to the vCard"""
try:
photo_file = join(dirname(self._filename), 'photo/%s.jpeg' % name)
jpeg = open(photo_file, 'rb').read()
photo = card.add('photo')
photo.type_param = 'jpeg'
... | python | def _add_photo(self, card, name):
"""Tries to load a photo and add it to the vCard"""
try:
photo_file = join(dirname(self._filename), 'photo/%s.jpeg' % name)
jpeg = open(photo_file, 'rb').read()
photo = card.add('photo')
photo.type_param = 'jpeg'
... | [
"def",
"_add_photo",
"(",
"self",
",",
"card",
",",
"name",
")",
":",
"try",
":",
"photo_file",
"=",
"join",
"(",
"dirname",
"(",
"self",
".",
"_filename",
")",
",",
"'photo/%s.jpeg'",
"%",
"name",
")",
"jpeg",
"=",
"open",
"(",
"photo_file",
",",
"'... | Tries to load a photo and add it to the vCard | [
"Tries",
"to",
"load",
"a",
"photo",
"and",
"add",
"it",
"to",
"the",
"vCard"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L134-L144 |
jspricke/python-abook | abook.py | Abook._to_vcard | def _to_vcard(self, entry):
"""Return a vCard of the Abook entry"""
card = vCard()
card.add('uid').value = Abook._gen_uid(entry)
card.add('fn').value = entry['name']
card.add('n').value = Abook._gen_name(entry['name'])
if 'email' in entry:
for email in entry... | python | def _to_vcard(self, entry):
"""Return a vCard of the Abook entry"""
card = vCard()
card.add('uid').value = Abook._gen_uid(entry)
card.add('fn').value = entry['name']
card.add('n').value = Abook._gen_name(entry['name'])
if 'email' in entry:
for email in entry... | [
"def",
"_to_vcard",
"(",
"self",
",",
"entry",
")",
":",
"card",
"=",
"vCard",
"(",
")",
"card",
".",
"add",
"(",
"'uid'",
")",
".",
"value",
"=",
"Abook",
".",
"_gen_uid",
"(",
"entry",
")",
"card",
".",
"add",
"(",
"'fn'",
")",
".",
"value",
... | Return a vCard of the Abook entry | [
"Return",
"a",
"vCard",
"of",
"the",
"Abook",
"entry"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L146-L192 |
jspricke/python-abook | abook.py | Abook.get_uids | def get_uids(self, filename=None):
"""Return a list of UIDs
filename -- unused, for API compatibility only
"""
self._update()
return [Abook._gen_uid(self._book[entry]) for entry in self._book.sections()] | python | def get_uids(self, filename=None):
"""Return a list of UIDs
filename -- unused, for API compatibility only
"""
self._update()
return [Abook._gen_uid(self._book[entry]) for entry in self._book.sections()] | [
"def",
"get_uids",
"(",
"self",
",",
"filename",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"return",
"[",
"Abook",
".",
"_gen_uid",
"(",
"self",
".",
"_book",
"[",
"entry",
"]",
")",
"for",
"entry",
"in",
"self",
".",
"_book",
".",
... | Return a list of UIDs
filename -- unused, for API compatibility only | [
"Return",
"a",
"list",
"of",
"UIDs",
"filename",
"--",
"unused",
"for",
"API",
"compatibility",
"only"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L194-L199 |
jspricke/python-abook | abook.py | Abook.to_vcards | def to_vcards(self):
"""Return a list of vCards"""
self._update()
return [self._to_vcard(self._book[entry]) for entry in self._book.sections()] | python | def to_vcards(self):
"""Return a list of vCards"""
self._update()
return [self._to_vcard(self._book[entry]) for entry in self._book.sections()] | [
"def",
"to_vcards",
"(",
"self",
")",
":",
"self",
".",
"_update",
"(",
")",
"return",
"[",
"self",
".",
"_to_vcard",
"(",
"self",
".",
"_book",
"[",
"entry",
"]",
")",
"for",
"entry",
"in",
"self",
".",
"_book",
".",
"sections",
"(",
")",
"]"
] | Return a list of vCards | [
"Return",
"a",
"list",
"of",
"vCards"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L214-L217 |
jspricke/python-abook | abook.py | Abook.to_vobjects | def to_vobjects(self, filename, uids=None):
"""Return vCards and etags of all Abook entries in uids
filename -- unused, for API compatibility only
uids -- the UIDs of the Abook entries (all if None)
"""
self._update()
if not uids:
uids = self.get_uids(filena... | python | def to_vobjects(self, filename, uids=None):
"""Return vCards and etags of all Abook entries in uids
filename -- unused, for API compatibility only
uids -- the UIDs of the Abook entries (all if None)
"""
self._update()
if not uids:
uids = self.get_uids(filena... | [
"def",
"to_vobjects",
"(",
"self",
",",
"filename",
",",
"uids",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"if",
"not",
"uids",
":",
"uids",
"=",
"self",
".",
"get_uids",
"(",
"filename",
")",
"items",
"=",
"[",
"]",
"for",
"uid",
... | Return vCards and etags of all Abook entries in uids
filename -- unused, for API compatibility only
uids -- the UIDs of the Abook entries (all if None) | [
"Return",
"vCards",
"and",
"etags",
"of",
"all",
"Abook",
"entries",
"in",
"uids",
"filename",
"--",
"unused",
"for",
"API",
"compatibility",
"only",
"uids",
"--",
"the",
"UIDs",
"of",
"the",
"Abook",
"entries",
"(",
"all",
"if",
"None",
")"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L226-L243 |
jspricke/python-abook | abook.py | Abook.to_vobject | def to_vobject(self, filename=None, uid=None):
"""Return the vCard corresponding to the uid
filename -- unused, for API compatibility only
uid -- the UID to get (required)
"""
self._update()
return self._to_vcard(self._book[uid.split('@')[0]]) | python | def to_vobject(self, filename=None, uid=None):
"""Return the vCard corresponding to the uid
filename -- unused, for API compatibility only
uid -- the UID to get (required)
"""
self._update()
return self._to_vcard(self._book[uid.split('@')[0]]) | [
"def",
"to_vobject",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"uid",
"=",
"None",
")",
":",
"self",
".",
"_update",
"(",
")",
"return",
"self",
".",
"_to_vcard",
"(",
"self",
".",
"_book",
"[",
"uid",
".",
"split",
"(",
"'@'",
")",
"[",
"0... | Return the vCard corresponding to the uid
filename -- unused, for API compatibility only
uid -- the UID to get (required) | [
"Return",
"the",
"vCard",
"corresponding",
"to",
"the",
"uid",
"filename",
"--",
"unused",
"for",
"API",
"compatibility",
"only",
"uid",
"--",
"the",
"UID",
"to",
"get",
"(",
"required",
")"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L245-L251 |
jspricke/python-abook | abook.py | Abook._conv_adr | def _conv_adr(adr, entry):
"""Converts to Abook address format"""
if adr.value.street:
entry['address'] = adr.value.street
if adr.value.extended:
entry['address2'] = adr.value.extended
if adr.value.city:
entry['city'] = adr.value.city
if adr.va... | python | def _conv_adr(adr, entry):
"""Converts to Abook address format"""
if adr.value.street:
entry['address'] = adr.value.street
if adr.value.extended:
entry['address2'] = adr.value.extended
if adr.value.city:
entry['city'] = adr.value.city
if adr.va... | [
"def",
"_conv_adr",
"(",
"adr",
",",
"entry",
")",
":",
"if",
"adr",
".",
"value",
".",
"street",
":",
"entry",
"[",
"'address'",
"]",
"=",
"adr",
".",
"value",
".",
"street",
"if",
"adr",
".",
"value",
".",
"extended",
":",
"entry",
"[",
"'address... | Converts to Abook address format | [
"Converts",
"to",
"Abook",
"address",
"format"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L254-L267 |
jspricke/python-abook | abook.py | Abook._conv_tel_list | def _conv_tel_list(tel_list, entry):
"""Converts to Abook phone types"""
for tel in tel_list:
if not hasattr(tel, 'TYPE_param'):
entry['other'] = tel.value
elif tel.TYPE_param.lower() == 'home':
entry['phone'] = tel.value
elif tel.TYPE_... | python | def _conv_tel_list(tel_list, entry):
"""Converts to Abook phone types"""
for tel in tel_list:
if not hasattr(tel, 'TYPE_param'):
entry['other'] = tel.value
elif tel.TYPE_param.lower() == 'home':
entry['phone'] = tel.value
elif tel.TYPE_... | [
"def",
"_conv_tel_list",
"(",
"tel_list",
",",
"entry",
")",
":",
"for",
"tel",
"in",
"tel_list",
":",
"if",
"not",
"hasattr",
"(",
"tel",
",",
"'TYPE_param'",
")",
":",
"entry",
"[",
"'other'",
"]",
"=",
"tel",
".",
"value",
"elif",
"tel",
".",
"TYP... | Converts to Abook phone types | [
"Converts",
"to",
"Abook",
"phone",
"types"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L270-L280 |
jspricke/python-abook | abook.py | Abook.to_abook | def to_abook(card, section, book, bookfile=None):
"""Converts a vCard to Abook"""
book[section] = {}
book[section]['name'] = card.fn.value
if hasattr(card, 'email'):
book[section]['email'] = ','.join([e.value for e in card.email_list])
if hasattr(card, 'adr'):
... | python | def to_abook(card, section, book, bookfile=None):
"""Converts a vCard to Abook"""
book[section] = {}
book[section]['name'] = card.fn.value
if hasattr(card, 'email'):
book[section]['email'] = ','.join([e.value for e in card.email_list])
if hasattr(card, 'adr'):
... | [
"def",
"to_abook",
"(",
"card",
",",
"section",
",",
"book",
",",
"bookfile",
"=",
"None",
")",
":",
"book",
"[",
"section",
"]",
"=",
"{",
"}",
"book",
"[",
"section",
"]",
"[",
"'name'",
"]",
"=",
"card",
".",
"fn",
".",
"value",
"if",
"hasattr... | Converts a vCard to Abook | [
"Converts",
"a",
"vCard",
"to",
"Abook"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L283-L311 |
jspricke/python-abook | abook.py | Abook.abook_file | def abook_file(vcard, bookfile):
"""Write a new Abook file with the given vcards"""
book = ConfigParser(default_section='format')
book['format'] = {}
book['format']['program'] = 'abook'
book['format']['version'] = '0.6.1'
for (i, card) in enumerate(readComponents(vcard.... | python | def abook_file(vcard, bookfile):
"""Write a new Abook file with the given vcards"""
book = ConfigParser(default_section='format')
book['format'] = {}
book['format']['program'] = 'abook'
book['format']['version'] = '0.6.1'
for (i, card) in enumerate(readComponents(vcard.... | [
"def",
"abook_file",
"(",
"vcard",
",",
"bookfile",
")",
":",
"book",
"=",
"ConfigParser",
"(",
"default_section",
"=",
"'format'",
")",
"book",
"[",
"'format'",
"]",
"=",
"{",
"}",
"book",
"[",
"'format'",
"]",
"[",
"'program'",
"]",
"=",
"'abook'",
"... | Write a new Abook file with the given vcards | [
"Write",
"a",
"new",
"Abook",
"file",
"with",
"the",
"given",
"vcards"
] | train | https://github.com/jspricke/python-abook/blob/cc58ad998303ce9a8b347a3317158c8f7cd0529f/abook.py#L314-L325 |
elapouya/addicted3 | addicted/__init__.py | Dict.prune | def prune(self, prune_zero=False, prune_empty_list=True):
"""
Removes all empty Dicts and falsy stuff inside the Dict.
E.g
>>> a = Dict()
>>> a.b.c.d
{}
>>> a.a = 2
>>> a
{'a': 2, 'b': {'c': {'d': {}}}}
>>> a.prune()
>>> a
{... | python | def prune(self, prune_zero=False, prune_empty_list=True):
"""
Removes all empty Dicts and falsy stuff inside the Dict.
E.g
>>> a = Dict()
>>> a.b.c.d
{}
>>> a.a = 2
>>> a
{'a': 2, 'b': {'c': {'d': {}}}}
>>> a.prune()
>>> a
{... | [
"def",
"prune",
"(",
"self",
",",
"prune_zero",
"=",
"False",
",",
"prune_empty_list",
"=",
"True",
")",
":",
"for",
"key",
",",
"val",
"in",
"list",
"(",
"self",
".",
"items",
"(",
")",
")",
":",
"if",
"(",
"(",
"not",
"val",
")",
"and",
"(",
... | Removes all empty Dicts and falsy stuff inside the Dict.
E.g
>>> a = Dict()
>>> a.b.c.d
{}
>>> a.a = 2
>>> a
{'a': 2, 'b': {'c': {'d': {}}}}
>>> a.prune()
>>> a
{'a': 2}
Set prune_zero=True to remove 0 values
E.g
>>>... | [
"Removes",
"all",
"empty",
"Dicts",
"and",
"falsy",
"stuff",
"inside",
"the",
"Dict",
".",
"E",
".",
"g",
">>>",
"a",
"=",
"Dict",
"()",
">>>",
"a",
".",
"b",
".",
"c",
".",
"d",
"{}",
">>>",
"a",
".",
"a",
"=",
"2",
">>>",
"a",
"{",
"a",
"... | train | https://github.com/elapouya/addicted3/blob/888d7d0ce3b53b7f1a2f33c1e7f5aa80369e76de/addicted/__init__.py#L155-L201 |
elapouya/addicted3 | addicted/__init__.py | Dict.update | def update(self, *args, **kwargs):
""" update() method will *recursively* update nested dict:
>>> d=Dict({'a':{'b':{'c':3,'d':4},'h':4}})
>>> d.update({'a':{'b':{'c':'888'}}})
>>> d
{'a': {'b': {'c': '888', 'd': 4}, 'h': 4}}
please use update_dict() ... | python | def update(self, *args, **kwargs):
""" update() method will *recursively* update nested dict:
>>> d=Dict({'a':{'b':{'c':3,'d':4},'h':4}})
>>> d.update({'a':{'b':{'c':'888'}}})
>>> d
{'a': {'b': {'c': '888', 'd': 4}, 'h': 4}}
please use update_dict() ... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"arg",
"in",
"args",
":",
"if",
"not",
"arg",
":",
"continue",
"elif",
"isinstance",
"(",
"arg",
",",
"dict",
")",
":",
"for",
"k",
",",
"v",
"in",
"arg",... | update() method will *recursively* update nested dict:
>>> d=Dict({'a':{'b':{'c':3,'d':4},'h':4}})
>>> d.update({'a':{'b':{'c':'888'}}})
>>> d
{'a': {'b': {'c': '888', 'd': 4}, 'h': 4}}
please use update_dict() if you do not want this behaviour | [
"update",
"()",
"method",
"will",
"*",
"recursively",
"*",
"update",
"nested",
"dict",
":"
] | train | https://github.com/elapouya/addicted3/blob/888d7d0ce3b53b7f1a2f33c1e7f5aa80369e76de/addicted/__init__.py#L262-L290 |
elapouya/addicted3 | addicted/__init__.py | Dict.update_dict | def update_dict(self,*args, **kwargs):
""" not recursive update() function """
super(Dict, self).update(*args, **kwargs) | python | def update_dict(self,*args, **kwargs):
""" not recursive update() function """
super(Dict, self).update(*args, **kwargs) | [
"def",
"update_dict",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"Dict",
",",
"self",
")",
".",
"update",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | not recursive update() function | [
"not",
"recursive",
"update",
"()",
"function"
] | train | https://github.com/elapouya/addicted3/blob/888d7d0ce3b53b7f1a2f33c1e7f5aa80369e76de/addicted/__init__.py#L292-L294 |
elapouya/addicted3 | addicted/__init__.py | AddDict.extract_keys | def extract_keys(self,key_list):
""" >>> d = {'a':1,'b':2,'c':3}
>>> print d.extract_keys('b,c,d')
>>> {'b':2,'c':3}
>>> print d.extract_keys(['b','c','d'])
>>> {'b':2,'c':3} """
if isinstance(key_list,basestring):
key_list = key_list.split(','... | python | def extract_keys(self,key_list):
""" >>> d = {'a':1,'b':2,'c':3}
>>> print d.extract_keys('b,c,d')
>>> {'b':2,'c':3}
>>> print d.extract_keys(['b','c','d'])
>>> {'b':2,'c':3} """
if isinstance(key_list,basestring):
key_list = key_list.split(','... | [
"def",
"extract_keys",
"(",
"self",
",",
"key_list",
")",
":",
"if",
"isinstance",
"(",
"key_list",
",",
"basestring",
")",
":",
"key_list",
"=",
"key_list",
".",
"split",
"(",
"','",
")",
"return",
"type",
"(",
"self",
")",
"(",
"[",
"(",
"k",
",",
... | >>> d = {'a':1,'b':2,'c':3}
>>> print d.extract_keys('b,c,d')
>>> {'b':2,'c':3}
>>> print d.extract_keys(['b','c','d'])
>>> {'b':2,'c':3} | [
">>>",
"d",
"=",
"{",
"a",
":",
"1",
"b",
":",
"2",
"c",
":",
"3",
"}",
">>>",
"print",
"d",
".",
"extract_keys",
"(",
"b",
"c",
"d",
")",
">>>",
"{",
"b",
":",
"2",
"c",
":",
"3",
"}",
">>>",
"print",
"d",
".",
"extract_keys",
"(",
"[",
... | train | https://github.com/elapouya/addicted3/blob/888d7d0ce3b53b7f1a2f33c1e7f5aa80369e76de/addicted/__init__.py#L408-L416 |
elapouya/addicted3 | addicted/__init__.py | AddDict.exclude_keys | def exclude_keys(self,key_list):
""" >>> d = {'a':1,'b':2,'c':3}
>>> print d.exclude_keys('b,c,d')
>>> {'a':1}
>>> d = {'a':1,'b':2,'c':3}
>>> print d.exclude_keys(['b','c','d'])
>>> {'a':1} """
if isinstance(key_list,basestring):
k... | python | def exclude_keys(self,key_list):
""" >>> d = {'a':1,'b':2,'c':3}
>>> print d.exclude_keys('b,c,d')
>>> {'a':1}
>>> d = {'a':1,'b':2,'c':3}
>>> print d.exclude_keys(['b','c','d'])
>>> {'a':1} """
if isinstance(key_list,basestring):
k... | [
"def",
"exclude_keys",
"(",
"self",
",",
"key_list",
")",
":",
"if",
"isinstance",
"(",
"key_list",
",",
"basestring",
")",
":",
"key_list",
"=",
"key_list",
".",
"split",
"(",
"','",
")",
"return",
"type",
"(",
"self",
")",
"(",
"[",
"(",
"k",
",",
... | >>> d = {'a':1,'b':2,'c':3}
>>> print d.exclude_keys('b,c,d')
>>> {'a':1}
>>> d = {'a':1,'b':2,'c':3}
>>> print d.exclude_keys(['b','c','d'])
>>> {'a':1} | [
">>>",
"d",
"=",
"{",
"a",
":",
"1",
"b",
":",
"2",
"c",
":",
"3",
"}",
">>>",
"print",
"d",
".",
"exclude_keys",
"(",
"b",
"c",
"d",
")",
">>>",
"{",
"a",
":",
"1",
"}",
">>>",
"d",
"=",
"{",
"a",
":",
"1",
"b",
":",
"2",
"c",
":",
... | train | https://github.com/elapouya/addicted3/blob/888d7d0ce3b53b7f1a2f33c1e7f5aa80369e76de/addicted/__init__.py#L418-L427 |
collectiveacuity/labPack | labpack/compilers/filters.py | positional_filter | def positional_filter(positional_filters, title=''):
'''
a method to construct a conditional filter function to test positional arguments
:param positional_filters: dictionary or list of dictionaries with query criteria
:param title: string with name of function to use instead
:return: callab... | python | def positional_filter(positional_filters, title=''):
'''
a method to construct a conditional filter function to test positional arguments
:param positional_filters: dictionary or list of dictionaries with query criteria
:param title: string with name of function to use instead
:return: callab... | [
"def",
"positional_filter",
"(",
"positional_filters",
",",
"title",
"=",
"''",
")",
":",
"# define help text ",
"if",
"not",
"title",
":",
"title",
"=",
"'positional_filter'",
"filter_arg",
"=",
"'%s(positional_filters=[...])'",
"%",
"title",
"# construct path_filte... | a method to construct a conditional filter function to test positional arguments
:param positional_filters: dictionary or list of dictionaries with query criteria
:param title: string with name of function to use instead
:return: callable for filter_function
NOTE: query criteria architecture
... | [
"a",
"method",
"to",
"construct",
"a",
"conditional",
"filter",
"function",
"to",
"test",
"positional",
"arguments"
] | train | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/compilers/filters.py#L6-L148 |
PSU-OIT-ARC/django-local-settings | local_settings/loader.py | Loader.load_and_check | def load_and_check(self, base_settings, prompt=None):
"""Load settings and check them.
Loads the settings from ``base_settings``, then checks them.
Returns:
(merged settings, True) on success
(None, False) on failure
"""
checker = Checker(self.file_name... | python | def load_and_check(self, base_settings, prompt=None):
"""Load settings and check them.
Loads the settings from ``base_settings``, then checks them.
Returns:
(merged settings, True) on success
(None, False) on failure
"""
checker = Checker(self.file_name... | [
"def",
"load_and_check",
"(",
"self",
",",
"base_settings",
",",
"prompt",
"=",
"None",
")",
":",
"checker",
"=",
"Checker",
"(",
"self",
".",
"file_name",
",",
"self",
".",
"section",
",",
"self",
".",
"registry",
",",
"self",
".",
"strategy_type",
",",... | Load settings and check them.
Loads the settings from ``base_settings``, then checks them.
Returns:
(merged settings, True) on success
(None, False) on failure | [
"Load",
"settings",
"and",
"check",
"them",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/loader.py#L20-L34 |
PSU-OIT-ARC/django-local-settings | local_settings/loader.py | Loader.load | def load(self, base_settings):
"""Merge local settings from file with ``base_settings``.
Returns a new settings dict containing the base settings and the
loaded settings. Includes:
- base settings
- settings from extended file(s), if any
- settings from file... | python | def load(self, base_settings):
"""Merge local settings from file with ``base_settings``.
Returns a new settings dict containing the base settings and the
loaded settings. Includes:
- base settings
- settings from extended file(s), if any
- settings from file... | [
"def",
"load",
"(",
"self",
",",
"base_settings",
")",
":",
"is_valid_key",
"=",
"lambda",
"k",
":",
"k",
".",
"isupper",
"(",
")",
"and",
"not",
"k",
".",
"startswith",
"(",
"'_'",
")",
"# Base settings, including `LocalSetting`s, loaded from the",
"# Django se... | Merge local settings from file with ``base_settings``.
Returns a new settings dict containing the base settings and the
loaded settings. Includes:
- base settings
- settings from extended file(s), if any
- settings from file | [
"Merge",
"local",
"settings",
"from",
"file",
"with",
"base_settings",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/loader.py#L36-L113 |
PSU-OIT-ARC/django-local-settings | local_settings/loader.py | Loader._inject | def _inject(self, value, settings):
"""Inject ``settings`` into ``value``.
Go through ``value`` looking for ``{{NAME}}`` groups and replace
each group with the value of the named item from ``settings``.
Args:
value (str): The value to inject settings into
settin... | python | def _inject(self, value, settings):
"""Inject ``settings`` into ``value``.
Go through ``value`` looking for ``{{NAME}}`` groups and replace
each group with the value of the named item from ``settings``.
Args:
value (str): The value to inject settings into
settin... | [
"def",
"_inject",
"(",
"self",
",",
"value",
",",
"settings",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"string_types",
")",
",",
"'Expected str; got {0.__class__}'",
".",
"format",
"(",
"value",
")",
"begin",
",",
"end",
"=",
"'{{'",
",",
"'}}'... | Inject ``settings`` into ``value``.
Go through ``value`` looking for ``{{NAME}}`` groups and replace
each group with the value of the named item from ``settings``.
Args:
value (str): The value to inject settings into
settings: An object that provides the dotted access i... | [
"Inject",
"settings",
"into",
"value",
"."
] | train | https://github.com/PSU-OIT-ARC/django-local-settings/blob/758810fbd9411c2046a187afcac6532155cac694/local_settings/loader.py#L208-L285 |
rosenbrockc/acorn | acorn/utility.py | _get_reporoot | def _get_reporoot():
"""Returns the absolute path to the repo root directory on the current
system.
"""
from os import path
import acorn
medpath = path.abspath(acorn.__file__)
return path.dirname(path.dirname(medpath)) | python | def _get_reporoot():
"""Returns the absolute path to the repo root directory on the current
system.
"""
from os import path
import acorn
medpath = path.abspath(acorn.__file__)
return path.dirname(path.dirname(medpath)) | [
"def",
"_get_reporoot",
"(",
")",
":",
"from",
"os",
"import",
"path",
"import",
"acorn",
"medpath",
"=",
"path",
".",
"abspath",
"(",
"acorn",
".",
"__file__",
")",
"return",
"path",
".",
"dirname",
"(",
"path",
".",
"dirname",
"(",
"medpath",
")",
")... | Returns the absolute path to the repo root directory on the current
system. | [
"Returns",
"the",
"absolute",
"path",
"to",
"the",
"repo",
"root",
"directory",
"on",
"the",
"current",
"system",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/utility.py#L3-L10 |
rosenbrockc/acorn | acorn/utility.py | abspath | def abspath(fpath):
"""Returns the absolute path to the specified file/folder *relative to the
repository root*.
Args:
fpath (str): path to a file or folder; doesn't need to exist.
"""
from os import path, getcwd, chdir
original = getcwd()
chdir(reporoot)
result = path.abspath(p... | python | def abspath(fpath):
"""Returns the absolute path to the specified file/folder *relative to the
repository root*.
Args:
fpath (str): path to a file or folder; doesn't need to exist.
"""
from os import path, getcwd, chdir
original = getcwd()
chdir(reporoot)
result = path.abspath(p... | [
"def",
"abspath",
"(",
"fpath",
")",
":",
"from",
"os",
"import",
"path",
",",
"getcwd",
",",
"chdir",
"original",
"=",
"getcwd",
"(",
")",
"chdir",
"(",
"reporoot",
")",
"result",
"=",
"path",
".",
"abspath",
"(",
"path",
".",
"expanduser",
"(",
"fp... | Returns the absolute path to the specified file/folder *relative to the
repository root*.
Args:
fpath (str): path to a file or folder; doesn't need to exist. | [
"Returns",
"the",
"absolute",
"path",
"to",
"the",
"specified",
"file",
"/",
"folder",
"*",
"relative",
"to",
"the",
"repository",
"root",
"*",
"."
] | train | https://github.com/rosenbrockc/acorn/blob/9a44d1a1ad8bfc2c54a6b56d9efe54433a797820/acorn/utility.py#L12-L24 |
babab/pycommand | pycommand/pycommand.py | run_and_exit | def run_and_exit(command_class):
'''A shortcut for reading from sys.argv and exiting the interpreter'''
cmd = command_class(sys.argv[1:])
if cmd.error:
print('error: {0}'.format(cmd.error))
sys.exit(1)
else:
sys.exit(cmd.run()) | python | def run_and_exit(command_class):
'''A shortcut for reading from sys.argv and exiting the interpreter'''
cmd = command_class(sys.argv[1:])
if cmd.error:
print('error: {0}'.format(cmd.error))
sys.exit(1)
else:
sys.exit(cmd.run()) | [
"def",
"run_and_exit",
"(",
"command_class",
")",
":",
"cmd",
"=",
"command_class",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
"if",
"cmd",
".",
"error",
":",
"print",
"(",
"'error: {0}'",
".",
"format",
"(",
"cmd",
".",
"error",
")",
")",
"... | A shortcut for reading from sys.argv and exiting the interpreter | [
"A",
"shortcut",
"for",
"reading",
"from",
"sys",
".",
"argv",
"and",
"exiting",
"the",
"interpreter"
] | train | https://github.com/babab/pycommand/blob/07237cd3a624e7b5688edca17ae38bf8b28b74d4/pycommand/pycommand.py#L216-L223 |
babab/pycommand | pycommand/pycommand.py | CommandBase.registerParentFlag | def registerParentFlag(self, optionName, value):
'''Register a flag of a parent command
:Parameters:
- `optionName`: String. Name of option
- `value`: Mixed. Value of parsed flag`
'''
self.parentFlags.update({optionName: value})
return self | python | def registerParentFlag(self, optionName, value):
'''Register a flag of a parent command
:Parameters:
- `optionName`: String. Name of option
- `value`: Mixed. Value of parsed flag`
'''
self.parentFlags.update({optionName: value})
return self | [
"def",
"registerParentFlag",
"(",
"self",
",",
"optionName",
",",
"value",
")",
":",
"self",
".",
"parentFlags",
".",
"update",
"(",
"{",
"optionName",
":",
"value",
"}",
")",
"return",
"self"
] | Register a flag of a parent command
:Parameters:
- `optionName`: String. Name of option
- `value`: Mixed. Value of parsed flag` | [
"Register",
"a",
"flag",
"of",
"a",
"parent",
"command"
] | train | https://github.com/babab/pycommand/blob/07237cd3a624e7b5688edca17ae38bf8b28b74d4/pycommand/pycommand.py#L205-L213 |
radjkarl/fancyTools | fancytools/math/radialAverage.py | radialAverage | def radialAverage(arr, center=None):
"""
radial average a 2darray around a center
if no center is given, take middle
"""
# taken from
# http://stackoverflow.com/questions/21242011/most-efficient-way-to-calculate-radial-profile
s0, s1 = arr.shape[:2]
if center is None:
center = s0... | python | def radialAverage(arr, center=None):
"""
radial average a 2darray around a center
if no center is given, take middle
"""
# taken from
# http://stackoverflow.com/questions/21242011/most-efficient-way-to-calculate-radial-profile
s0, s1 = arr.shape[:2]
if center is None:
center = s0... | [
"def",
"radialAverage",
"(",
"arr",
",",
"center",
"=",
"None",
")",
":",
"# taken from",
"# http://stackoverflow.com/questions/21242011/most-efficient-way-to-calculate-radial-profile",
"s0",
",",
"s1",
"=",
"arr",
".",
"shape",
"[",
":",
"2",
"]",
"if",
"center",
"... | radial average a 2darray around a center
if no center is given, take middle | [
"radial",
"average",
"a",
"2darray",
"around",
"a",
"center",
"if",
"no",
"center",
"is",
"given",
"take",
"middle"
] | train | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/math/radialAverage.py#L6-L22 |
tomi77/python-t77-date | t77_date/tz.py | _convert | def _convert(value, tzto, defaulttz):
"""Convert datetime.datetime object between timezones"""
if not isinstance(value, datetime):
raise ValueError('value must be a datetime.datetime object')
if value.tzinfo is None:
value = value.replace(tzinfo=defaulttz)
return value.astimezone(tzto) | python | def _convert(value, tzto, defaulttz):
"""Convert datetime.datetime object between timezones"""
if not isinstance(value, datetime):
raise ValueError('value must be a datetime.datetime object')
if value.tzinfo is None:
value = value.replace(tzinfo=defaulttz)
return value.astimezone(tzto) | [
"def",
"_convert",
"(",
"value",
",",
"tzto",
",",
"defaulttz",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"datetime",
")",
":",
"raise",
"ValueError",
"(",
"'value must be a datetime.datetime object'",
")",
"if",
"value",
".",
"tzinfo",
"is",
"... | Convert datetime.datetime object between timezones | [
"Convert",
"datetime",
".",
"datetime",
"object",
"between",
"timezones"
] | train | https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/tz.py#L9-L17 |
tomi77/python-t77-date | t77_date/tz.py | to_local | def to_local(value, defaulttz=None):
"""Convert datetime.datetime time to local time zone
If value doesn't have tzinfo, then defaulttz is set.
Default value of defaulttz is UTC.
"""
if defaulttz is None:
defaulttz = tzutc()
return _convert(value, tzlocal(), defaulttz) | python | def to_local(value, defaulttz=None):
"""Convert datetime.datetime time to local time zone
If value doesn't have tzinfo, then defaulttz is set.
Default value of defaulttz is UTC.
"""
if defaulttz is None:
defaulttz = tzutc()
return _convert(value, tzlocal(), defaulttz) | [
"def",
"to_local",
"(",
"value",
",",
"defaulttz",
"=",
"None",
")",
":",
"if",
"defaulttz",
"is",
"None",
":",
"defaulttz",
"=",
"tzutc",
"(",
")",
"return",
"_convert",
"(",
"value",
",",
"tzlocal",
"(",
")",
",",
"defaulttz",
")"
] | Convert datetime.datetime time to local time zone
If value doesn't have tzinfo, then defaulttz is set.
Default value of defaulttz is UTC. | [
"Convert",
"datetime",
".",
"datetime",
"time",
"to",
"local",
"time",
"zone"
] | train | https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/tz.py#L20-L28 |
tomi77/python-t77-date | t77_date/tz.py | to_utc | def to_utc(value, defaulttz=None):
"""Convert datetime.datetime time to UTC
If value doesn't have tzinfo, then defaulttz is set.
Default value of defaulttz is local time zone.
"""
if defaulttz is None:
defaulttz = tzlocal()
return _convert(value, tzutc(), defaulttz) | python | def to_utc(value, defaulttz=None):
"""Convert datetime.datetime time to UTC
If value doesn't have tzinfo, then defaulttz is set.
Default value of defaulttz is local time zone.
"""
if defaulttz is None:
defaulttz = tzlocal()
return _convert(value, tzutc(), defaulttz) | [
"def",
"to_utc",
"(",
"value",
",",
"defaulttz",
"=",
"None",
")",
":",
"if",
"defaulttz",
"is",
"None",
":",
"defaulttz",
"=",
"tzlocal",
"(",
")",
"return",
"_convert",
"(",
"value",
",",
"tzutc",
"(",
")",
",",
"defaulttz",
")"
] | Convert datetime.datetime time to UTC
If value doesn't have tzinfo, then defaulttz is set.
Default value of defaulttz is local time zone. | [
"Convert",
"datetime",
".",
"datetime",
"time",
"to",
"UTC"
] | train | https://github.com/tomi77/python-t77-date/blob/b4b12ce6a02884fb62460f6b9068e7fa28979fce/t77_date/tz.py#L31-L39 |
jasonfharris/sysexecute | sysexecute/common.py | filterKWArgsForFunc | def filterKWArgsForFunc(kwargs, f):
'''Yield a reduced set of kwargs of only the valid keyword arguments for the function / constructor f'''
return dict([(k, v) for k, v in kwargs.iteritems() if k in _getValidArgList(f)]) | python | def filterKWArgsForFunc(kwargs, f):
'''Yield a reduced set of kwargs of only the valid keyword arguments for the function / constructor f'''
return dict([(k, v) for k, v in kwargs.iteritems() if k in _getValidArgList(f)]) | [
"def",
"filterKWArgsForFunc",
"(",
"kwargs",
",",
"f",
")",
":",
"return",
"dict",
"(",
"[",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"iteritems",
"(",
")",
"if",
"k",
"in",
"_getValidArgList",
"(",
"f",
")",
"]",
")"
] | Yield a reduced set of kwargs of only the valid keyword arguments for the function / constructor f | [
"Yield",
"a",
"reduced",
"set",
"of",
"kwargs",
"of",
"only",
"the",
"valid",
"keyword",
"arguments",
"for",
"the",
"function",
"/",
"constructor",
"f"
] | train | https://github.com/jasonfharris/sysexecute/blob/5fb0639364fa91452da93f99220bf622351d0b7a/sysexecute/common.py#L16-L18 |
jasonfharris/sysexecute | sysexecute/common.py | prettyPrintDictionary | def prettyPrintDictionary(d):
'''Pretty print a dictionary as simple keys and values'''
maxKeyLength = 0
maxValueLength = 0
for key, value in d.iteritems():
maxKeyLength = max(maxKeyLength, len(key))
maxValueLength = max(maxValueLength, len(key))
for key in sorted(d.keys()):
... | python | def prettyPrintDictionary(d):
'''Pretty print a dictionary as simple keys and values'''
maxKeyLength = 0
maxValueLength = 0
for key, value in d.iteritems():
maxKeyLength = max(maxKeyLength, len(key))
maxValueLength = max(maxValueLength, len(key))
for key in sorted(d.keys()):
... | [
"def",
"prettyPrintDictionary",
"(",
"d",
")",
":",
"maxKeyLength",
"=",
"0",
"maxValueLength",
"=",
"0",
"for",
"key",
",",
"value",
"in",
"d",
".",
"iteritems",
"(",
")",
":",
"maxKeyLength",
"=",
"max",
"(",
"maxKeyLength",
",",
"len",
"(",
"key",
"... | Pretty print a dictionary as simple keys and values | [
"Pretty",
"print",
"a",
"dictionary",
"as",
"simple",
"keys",
"and",
"values"
] | train | https://github.com/jasonfharris/sysexecute/blob/5fb0639364fa91452da93f99220bf622351d0b7a/sysexecute/common.py#L49-L57 |
jasonfharris/sysexecute | sysexecute/common.py | flatten | def flatten(lst):
"""flatten([["a","btr"],"b", [],["c",["d",["e"], []]]]) will return ['a', 'btr', 'b', 'c', 'd', 'e']"""
def flatten_aux(item, accumulated):
if type(item) != list:
accumulated.append(item)
else:
for l in item:
flatten_aux(l, accumulated)
... | python | def flatten(lst):
"""flatten([["a","btr"],"b", [],["c",["d",["e"], []]]]) will return ['a', 'btr', 'b', 'c', 'd', 'e']"""
def flatten_aux(item, accumulated):
if type(item) != list:
accumulated.append(item)
else:
for l in item:
flatten_aux(l, accumulated)
... | [
"def",
"flatten",
"(",
"lst",
")",
":",
"def",
"flatten_aux",
"(",
"item",
",",
"accumulated",
")",
":",
"if",
"type",
"(",
"item",
")",
"!=",
"list",
":",
"accumulated",
".",
"append",
"(",
"item",
")",
"else",
":",
"for",
"l",
"in",
"item",
":",
... | flatten([["a","btr"],"b", [],["c",["d",["e"], []]]]) will return ['a', 'btr', 'b', 'c', 'd', 'e'] | [
"flatten",
"(",
"[[",
"a",
"btr",
"]",
"b",
"[]",
"[",
"c",
"[",
"d",
"[",
"e",
"]",
"[]",
"]]]",
")",
"will",
"return",
"[",
"a",
"btr",
"b",
"c",
"d",
"e",
"]"
] | train | https://github.com/jasonfharris/sysexecute/blob/5fb0639364fa91452da93f99220bf622351d0b7a/sysexecute/common.py#L73-L83 |
mugurbil/gnm | gnm/utils.py | update_params | def update_params(state, t):
"""
Update parameters
updates mean and precision to the step size
Inputs:
state :
mu :
mean
L :
cholesky factor of the precision matrix
t :
step size
Outputs:
mu :
... | python | def update_params(state, t):
"""
Update parameters
updates mean and precision to the step size
Inputs:
state :
mu :
mean
L :
cholesky factor of the precision matrix
t :
step size
Outputs:
mu :
... | [
"def",
"update_params",
"(",
"state",
",",
"t",
")",
":",
"mu",
"=",
"(",
"1.",
"-",
"t",
")",
"*",
"state",
"[",
"'x'",
"]",
"+",
"t",
"*",
"state",
"[",
"'mu'",
"]",
"L",
"=",
"state",
"[",
"'L'",
"]",
"/",
"np",
".",
"sqrt",
"(",
"2.",
... | Update parameters
updates mean and precision to the step size
Inputs:
state :
mu :
mean
L :
cholesky factor of the precision matrix
t :
step size
Outputs:
mu :
updated mean
L :
... | [
"Update",
"parameters",
"updates",
"mean",
"and",
"precision",
"to",
"the",
"step",
"size",
"Inputs",
":",
"state",
":",
"mu",
":",
"mean",
"L",
":",
"cholesky",
"factor",
"of",
"the",
"precision",
"matrix",
"t",
":",
"step",
"size",
"Outputs",
":",
"mu"... | train | https://github.com/mugurbil/gnm/blob/4f9711fb9d78cc02820c25234bc3ab9615014f11/gnm/utils.py#L22-L42 |
mugurbil/gnm | gnm/utils.py | log_K | def log_K(Z, X, t):
"""
Log K
Log of the proposal probability density function for gnm
Inputs :
Z :
proposed to
x :
proposed from
Outputs :
log of the probability density function
"""
m, L = update_params(X, t)
z = Z['x']
retur... | python | def log_K(Z, X, t):
"""
Log K
Log of the proposal probability density function for gnm
Inputs :
Z :
proposed to
x :
proposed from
Outputs :
log of the probability density function
"""
m, L = update_params(X, t)
z = Z['x']
retur... | [
"def",
"log_K",
"(",
"Z",
",",
"X",
",",
"t",
")",
":",
"m",
",",
"L",
"=",
"update_params",
"(",
"X",
",",
"t",
")",
"z",
"=",
"Z",
"[",
"'x'",
"]",
"return",
"np",
".",
"log",
"(",
"det",
"(",
"L",
")",
")",
"-",
"la",
".",
"norm",
"(... | Log K
Log of the proposal probability density function for gnm
Inputs :
Z :
proposed to
x :
proposed from
Outputs :
log of the probability density function | [
"Log",
"K",
"Log",
"of",
"the",
"proposal",
"probability",
"density",
"function",
"for",
"gnm",
"Inputs",
":",
"Z",
":",
"proposed",
"to",
"x",
":",
"proposed",
"from",
"Outputs",
":",
"log",
"of",
"the",
"probability",
"density",
"function"
] | train | https://github.com/mugurbil/gnm/blob/4f9711fb9d78cc02820c25234bc3ab9615014f11/gnm/utils.py#L44-L58 |
mugurbil/gnm | gnm/utils.py | multi_normal | def multi_normal(X, t):
"""
Multivariate normal sampler:
Generates normal samples with mean m, precision matrix LL'
Inputs:
x :
propose from
Outputs:
normal with mean m and precision LL'
"""
m, L = update_params(X, t)
z = np.random.standard_normal(np.sh... | python | def multi_normal(X, t):
"""
Multivariate normal sampler:
Generates normal samples with mean m, precision matrix LL'
Inputs:
x :
propose from
Outputs:
normal with mean m and precision LL'
"""
m, L = update_params(X, t)
z = np.random.standard_normal(np.sh... | [
"def",
"multi_normal",
"(",
"X",
",",
"t",
")",
":",
"m",
",",
"L",
"=",
"update_params",
"(",
"X",
",",
"t",
")",
"z",
"=",
"np",
".",
"random",
".",
"standard_normal",
"(",
"np",
".",
"shape",
"(",
"m",
")",
")",
"# generate i.i.d N(0,1)",
"retur... | Multivariate normal sampler:
Generates normal samples with mean m, precision matrix LL'
Inputs:
x :
propose from
Outputs:
normal with mean m and precision LL' | [
"Multivariate",
"normal",
"sampler",
":",
"Generates",
"normal",
"samples",
"with",
"mean",
"m",
"precision",
"matrix",
"LL",
"Inputs",
":",
"x",
":",
"propose",
"from",
"Outputs",
":",
"normal",
"with",
"mean",
"m",
"and",
"precision",
"LL"
] | train | https://github.com/mugurbil/gnm/blob/4f9711fb9d78cc02820c25234bc3ab9615014f11/gnm/utils.py#L60-L72 |
mugurbil/gnm | gnm/utils.py | det | def det(L):
"""
Determinant
Compute the determinant given a lower triangular matrix
Inputs:
L :
lower triangular matrix
Outputs:
det_L :
determinant of L
"""
size_L = L.shape
if np.size(L) == 1:
return np.array(L)
else:
... | python | def det(L):
"""
Determinant
Compute the determinant given a lower triangular matrix
Inputs:
L :
lower triangular matrix
Outputs:
det_L :
determinant of L
"""
size_L = L.shape
if np.size(L) == 1:
return np.array(L)
else:
... | [
"def",
"det",
"(",
"L",
")",
":",
"size_L",
"=",
"L",
".",
"shape",
"if",
"np",
".",
"size",
"(",
"L",
")",
"==",
"1",
":",
"return",
"np",
".",
"array",
"(",
"L",
")",
"else",
":",
"try",
":",
"assert",
"np",
".",
"all",
"(",
"np",
".",
... | Determinant
Compute the determinant given a lower triangular matrix
Inputs:
L :
lower triangular matrix
Outputs:
det_L :
determinant of L | [
"Determinant",
"Compute",
"the",
"determinant",
"given",
"a",
"lower",
"triangular",
"matrix",
"Inputs",
":",
"L",
":",
"lower",
"triangular",
"matrix",
"Outputs",
":",
"det_L",
":",
"determinant",
"of",
"L"
] | train | https://github.com/mugurbil/gnm/blob/4f9711fb9d78cc02820c25234bc3ab9615014f11/gnm/utils.py#L74-L102 |
mugurbil/gnm | gnm/utils.py | optimize | def optimize(t, f_0, d_f_0, f_t, d_f_t, t1=0.05, t2=0.5):
"""
Third order approximation to find the minimum of the function
f : function to be optimized over
Inputs :
t :
previous step size
f_0 : f(0),
function value at 0
d_f_0: f'(0),
t... | python | def optimize(t, f_0, d_f_0, f_t, d_f_t, t1=0.05, t2=0.5):
"""
Third order approximation to find the minimum of the function
f : function to be optimized over
Inputs :
t :
previous step size
f_0 : f(0),
function value at 0
d_f_0: f'(0),
t... | [
"def",
"optimize",
"(",
"t",
",",
"f_0",
",",
"d_f_0",
",",
"f_t",
",",
"d_f_t",
",",
"t1",
"=",
"0.05",
",",
"t2",
"=",
"0.5",
")",
":",
"if",
"t",
"<=",
"0",
":",
"print",
"(",
"\"Error: please enter non-negative t\"",
")",
"return",
"t",
"a",
"=... | Third order approximation to find the minimum of the function
f : function to be optimized over
Inputs :
t :
previous step size
f_0 : f(0),
function value at 0
d_f_0: f'(0),
the derivative of the function at 0
f_t : f(t),
fun... | [
"Third",
"order",
"approximation",
"to",
"find",
"the",
"minimum",
"of",
"the",
"function",
"f",
":",
"function",
"to",
"be",
"optimized",
"over",
"Inputs",
":",
"t",
":",
"previous",
"step",
"size",
"f_0",
":",
"f",
"(",
"0",
")",
"function",
"value",
... | train | https://github.com/mugurbil/gnm/blob/4f9711fb9d78cc02820c25234bc3ab9615014f11/gnm/utils.py#L104-L156 |
sassoo/goldman | goldman/middleware/http_specs/__init__.py | Middleware.process_request | def process_request(self, req, resp):
""" Process the request before routing it.
A summary of the rational for the different behavior
is shown below.
Expect Header
~~~~~~~~~~~~~
Our API does not currently support any implementation
of the Expect header. This mo... | python | def process_request(self, req, resp):
""" Process the request before routing it.
A summary of the rational for the different behavior
is shown below.
Expect Header
~~~~~~~~~~~~~
Our API does not currently support any implementation
of the Expect header. This mo... | [
"def",
"process_request",
"(",
"self",
",",
"req",
",",
"resp",
")",
":",
"max_length",
"=",
"goldman",
".",
"config",
".",
"MAX_URI_LENGTH",
"if",
"req",
".",
"expect",
":",
"abort",
"(",
"exceptions",
".",
"ExpectationUnmet",
")",
"elif",
"len",
"(",
"... | Process the request before routing it.
A summary of the rational for the different behavior
is shown below.
Expect Header
~~~~~~~~~~~~~
Our API does not currently support any implementation
of the Expect header. This mostly impacts clients that
use the `100-con... | [
"Process",
"the",
"request",
"before",
"routing",
"it",
"."
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/http_specs/__init__.py#L39-L99 |
sassoo/goldman | goldman/middleware/http_specs/__init__.py | Middleware.process_response | def process_response(self, req, resp, resource):
""" Post-processing of the response (after routing).
Some fundamental errors can't be intercepted any other
way in Falcon. These include 404 when the route isn't found
& 405 when the method is bunk. Falcon will try to send its
own... | python | def process_response(self, req, resp, resource):
""" Post-processing of the response (after routing).
Some fundamental errors can't be intercepted any other
way in Falcon. These include 404 when the route isn't found
& 405 when the method is bunk. Falcon will try to send its
own... | [
"def",
"process_response",
"(",
"self",
",",
"req",
",",
"resp",
",",
"resource",
")",
":",
"if",
"not",
"resource",
"and",
"resp",
".",
"status",
"==",
"falcon",
".",
"HTTP_404",
":",
"abort",
"(",
"exceptions",
".",
"RouteNotFound",
")",
"elif",
"resp"... | Post-processing of the response (after routing).
Some fundamental errors can't be intercepted any other
way in Falcon. These include 404 when the route isn't found
& 405 when the method is bunk. Falcon will try to send its
own errors.
In these cases, intercept them & replace th... | [
"Post",
"-",
"processing",
"of",
"the",
"response",
"(",
"after",
"routing",
")",
"."
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/http_specs/__init__.py#L101-L119 |
noirbizarre/minibench | minibench/benchmark.py | Benchmark.label | def label(self):
'''A human readable label'''
if self.__doc__ and self.__doc__.strip():
return self.__doc__.strip().splitlines()[0]
return humanize(self.__class__.__name__) | python | def label(self):
'''A human readable label'''
if self.__doc__ and self.__doc__.strip():
return self.__doc__.strip().splitlines()[0]
return humanize(self.__class__.__name__) | [
"def",
"label",
"(",
"self",
")",
":",
"if",
"self",
".",
"__doc__",
"and",
"self",
".",
"__doc__",
".",
"strip",
"(",
")",
":",
"return",
"self",
".",
"__doc__",
".",
"strip",
"(",
")",
".",
"splitlines",
"(",
")",
"[",
"0",
"]",
"return",
"huma... | A human readable label | [
"A",
"human",
"readable",
"label"
] | train | https://github.com/noirbizarre/minibench/blob/a1ac66dc075181c62bb3c0d3a26beb5c46d5f4ab/minibench/benchmark.py#L55-L59 |
noirbizarre/minibench | minibench/benchmark.py | Benchmark.label_for | def label_for(self, name):
'''Get a human readable label for a method given its name'''
method = getattr(self, name)
if method.__doc__ and method.__doc__.strip():
return method.__doc__.strip().splitlines()[0]
return humanize(name.replace(self._prefix, '')) | python | def label_for(self, name):
'''Get a human readable label for a method given its name'''
method = getattr(self, name)
if method.__doc__ and method.__doc__.strip():
return method.__doc__.strip().splitlines()[0]
return humanize(name.replace(self._prefix, '')) | [
"def",
"label_for",
"(",
"self",
",",
"name",
")",
":",
"method",
"=",
"getattr",
"(",
"self",
",",
"name",
")",
"if",
"method",
".",
"__doc__",
"and",
"method",
".",
"__doc__",
".",
"strip",
"(",
")",
":",
"return",
"method",
".",
"__doc__",
".",
... | Get a human readable label for a method given its name | [
"Get",
"a",
"human",
"readable",
"label",
"for",
"a",
"method",
"given",
"its",
"name"
] | train | https://github.com/noirbizarre/minibench/blob/a1ac66dc075181c62bb3c0d3a26beb5c46d5f4ab/minibench/benchmark.py#L61-L66 |
noirbizarre/minibench | minibench/benchmark.py | Benchmark.run | def run(self):
'''
Collect all tests to run and run them.
Each method will be run :attr:`Benchmark.times`.
'''
tests = self._collect()
if not tests:
return
self.times
self.before_class()
for test in tests:
func = getattr... | python | def run(self):
'''
Collect all tests to run and run them.
Each method will be run :attr:`Benchmark.times`.
'''
tests = self._collect()
if not tests:
return
self.times
self.before_class()
for test in tests:
func = getattr... | [
"def",
"run",
"(",
"self",
")",
":",
"tests",
"=",
"self",
".",
"_collect",
"(",
")",
"if",
"not",
"tests",
":",
"return",
"self",
".",
"times",
"self",
".",
"before_class",
"(",
")",
"for",
"test",
"in",
"tests",
":",
"func",
"=",
"getattr",
"(",
... | Collect all tests to run and run them.
Each method will be run :attr:`Benchmark.times`. | [
"Collect",
"all",
"tests",
"to",
"run",
"and",
"run",
"them",
"."
] | train | https://github.com/noirbizarre/minibench/blob/a1ac66dc075181c62bb3c0d3a26beb5c46d5f4ab/minibench/benchmark.py#L111-L145 |
GemHQ/round-py | round/__init__.py | Context.authorizer | def authorizer(self, schemes, resource, action, request_args):
"""Construct the Authorization header for a request.
Args:
schemes (list of str): Authentication schemes supported for the
requested action.
resource (str): Object upon which an action is being performed.
... | python | def authorizer(self, schemes, resource, action, request_args):
"""Construct the Authorization header for a request.
Args:
schemes (list of str): Authentication schemes supported for the
requested action.
resource (str): Object upon which an action is being performed.
... | [
"def",
"authorizer",
"(",
"self",
",",
"schemes",
",",
"resource",
",",
"action",
",",
"request_args",
")",
":",
"if",
"not",
"schemes",
":",
"return",
"u''",
",",
"u''",
"for",
"scheme",
"in",
"schemes",
":",
"if",
"scheme",
"in",
"self",
".",
"scheme... | Construct the Authorization header for a request.
Args:
schemes (list of str): Authentication schemes supported for the
requested action.
resource (str): Object upon which an action is being performed.
action (str): Action being performed.
request_args (list ... | [
"Construct",
"the",
"Authorization",
"header",
"for",
"a",
"request",
"."
] | train | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/__init__.py#L65-L89 |
GemHQ/round-py | round/__init__.py | Context.authorize | def authorize(self, scheme, **params):
"""Store credentials required to satisfy a given auth scheme.
Args:
scheme (str): The name of the Authentication scheme.
**params: parameters for the specified scheme.
Returns:
True if parameters are set successfully (note th... | python | def authorize(self, scheme, **params):
"""Store credentials required to satisfy a given auth scheme.
Args:
scheme (str): The name of the Authentication scheme.
**params: parameters for the specified scheme.
Returns:
True if parameters are set successfully (note th... | [
"def",
"authorize",
"(",
"self",
",",
"scheme",
",",
"*",
"*",
"params",
")",
":",
"if",
"scheme",
"not",
"in",
"self",
".",
"schemes",
":",
"return",
"False",
"for",
"field",
",",
"value",
"in",
"iteritems",
"(",
"params",
")",
":",
"setattr",
"(",
... | Store credentials required to satisfy a given auth scheme.
Args:
scheme (str): The name of the Authentication scheme.
**params: parameters for the specified scheme.
Returns:
True if parameters are set successfully (note that this doesn't mean
the credentials are... | [
"Store",
"credentials",
"required",
"to",
"satisfy",
"a",
"given",
"auth",
"scheme",
"."
] | train | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/__init__.py#L91-L111 |
GemHQ/round-py | round/__init__.py | Context.has_auth_params | def has_auth_params(self, scheme):
"""Check whether all information required for a given auth scheme have
been supplied.
Args:
scheme (str): Name of the authentication scheme to check. One of
Gem-Identify, Gem-Device, Gem-Application
Returns:
True if all... | python | def has_auth_params(self, scheme):
"""Check whether all information required for a given auth scheme have
been supplied.
Args:
scheme (str): Name of the authentication scheme to check. One of
Gem-Identify, Gem-Device, Gem-Application
Returns:
True if all... | [
"def",
"has_auth_params",
"(",
"self",
",",
"scheme",
")",
":",
"for",
"k",
",",
"v",
"in",
"iteritems",
"(",
"self",
".",
"schemes",
"[",
"scheme",
"]",
"[",
"u'params'",
"]",
")",
":",
"if",
"not",
"v",
":",
"return",
"False",
"return",
"True"
] | Check whether all information required for a given auth scheme have
been supplied.
Args:
scheme (str): Name of the authentication scheme to check. One of
Gem-Identify, Gem-Device, Gem-Application
Returns:
True if all required parameters for the specified scheme ... | [
"Check",
"whether",
"all",
"information",
"required",
"for",
"a",
"given",
"auth",
"scheme",
"have",
"been",
"supplied",
"."
] | train | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/__init__.py#L113-L127 |
GemHQ/round-py | round/__init__.py | Context.format_auth_params | def format_auth_params(params):
"""Generate the format expected by HTTP Headers from parameters.
Args:
params (dict): {key: value} to convert to key=value
Returns:
A formatted header string.
"""
parts = []
for (key, value) in params.items():
... | python | def format_auth_params(params):
"""Generate the format expected by HTTP Headers from parameters.
Args:
params (dict): {key: value} to convert to key=value
Returns:
A formatted header string.
"""
parts = []
for (key, value) in params.items():
... | [
"def",
"format_auth_params",
"(",
"params",
")",
":",
"parts",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"value",
")",
"in",
"params",
".",
"items",
"(",
")",
":",
"if",
"value",
":",
"parts",
".",
"append",
"(",
"'{}=\"{}\"'",
".",
"format",
"(",
"ke... | Generate the format expected by HTTP Headers from parameters.
Args:
params (dict): {key: value} to convert to key=value
Returns:
A formatted header string. | [
"Generate",
"the",
"format",
"expected",
"by",
"HTTP",
"Headers",
"from",
"parameters",
"."
] | train | https://github.com/GemHQ/round-py/blob/d0838f849cd260b1eb5df67ed3c6f2fe56c91c21/round/__init__.py#L130-L143 |
lambdalisue/django-roughpages | src/roughpages/backends/__init__.py | get_backend | def get_backend(backend_class=None):
"""
Get backend instance
If no `backend_class` is specified, the backend class is determined from
the value of `settings.ROUGHPAGES_BACKEND`.
`backend_class` can be a class object or dots separated python import path
Returns:
backend instance
""... | python | def get_backend(backend_class=None):
"""
Get backend instance
If no `backend_class` is specified, the backend class is determined from
the value of `settings.ROUGHPAGES_BACKEND`.
`backend_class` can be a class object or dots separated python import path
Returns:
backend instance
""... | [
"def",
"get_backend",
"(",
"backend_class",
"=",
"None",
")",
":",
"cache_name",
"=",
"'_backend_instance'",
"if",
"not",
"hasattr",
"(",
"get_backend",
",",
"cache_name",
")",
":",
"backend_class",
"=",
"backend_class",
"or",
"settings",
".",
"ROUGHPAGES_BACKEND"... | Get backend instance
If no `backend_class` is specified, the backend class is determined from
the value of `settings.ROUGHPAGES_BACKEND`.
`backend_class` can be a class object or dots separated python import path
Returns:
backend instance | [
"Get",
"backend",
"instance"
] | train | https://github.com/lambdalisue/django-roughpages/blob/f6a2724ece729c5deced2c2546d172561ef785ec/src/roughpages/backends/__init__.py#L9-L28 |
jayferg/faderport | faderport.py | find_faderport_input_name | def find_faderport_input_name(number=0):
"""
Find the MIDI input name for a connected FaderPort.
NOTE! Untested for more than one FaderPort attached.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
:return: Po... | python | def find_faderport_input_name(number=0):
"""
Find the MIDI input name for a connected FaderPort.
NOTE! Untested for more than one FaderPort attached.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
:return: Po... | [
"def",
"find_faderport_input_name",
"(",
"number",
"=",
"0",
")",
":",
"ins",
"=",
"[",
"i",
"for",
"i",
"in",
"mido",
".",
"get_input_names",
"(",
")",
"if",
"i",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'faderport'",
")",
"]",
"if",
"0",
... | Find the MIDI input name for a connected FaderPort.
NOTE! Untested for more than one FaderPort attached.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
:return: Port name or None | [
"Find",
"the",
"MIDI",
"input",
"name",
"for",
"a",
"connected",
"FaderPort",
"."
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L354-L367 |
jayferg/faderport | faderport.py | find_faderport_output_name | def find_faderport_output_name(number=0):
"""
Find the MIDI output name for a connected FaderPort.
NOTE! Untested for more than one FaderPort attached.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
:return: ... | python | def find_faderport_output_name(number=0):
"""
Find the MIDI output name for a connected FaderPort.
NOTE! Untested for more than one FaderPort attached.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
:return: ... | [
"def",
"find_faderport_output_name",
"(",
"number",
"=",
"0",
")",
":",
"outs",
"=",
"[",
"i",
"for",
"i",
"in",
"mido",
".",
"get_output_names",
"(",
")",
"if",
"i",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"'faderport'",
")",
"]",
"if",
"0",... | Find the MIDI output name for a connected FaderPort.
NOTE! Untested for more than one FaderPort attached.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
:return: Port name or None | [
"Find",
"the",
"MIDI",
"output",
"name",
"for",
"a",
"connected",
"FaderPort",
"."
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L370-L383 |
jayferg/faderport | faderport.py | FaderPort.open | def open(self, number=0):
"""
Open the FaderPort and register a callback so we can send and
receive MIDI messages.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
I only h... | python | def open(self, number=0):
"""
Open the FaderPort and register a callback so we can send and
receive MIDI messages.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
I only h... | [
"def",
"open",
"(",
"self",
",",
"number",
"=",
"0",
")",
":",
"self",
".",
"inport",
"=",
"mido",
".",
"open_input",
"(",
"find_faderport_input_name",
"(",
"number",
")",
")",
"self",
".",
"outport",
"=",
"mido",
".",
"open_output",
"(",
"find_faderport... | Open the FaderPort and register a callback so we can send and
receive MIDI messages.
:param number: 0 unless you've got more than one FaderPort attached.
In which case 0 is the first, 1 is the second etc
I only have access to a single device so I can't
... | [
"Open",
"the",
"FaderPort",
"and",
"register",
"a",
"callback",
"so",
"we",
"can",
"send",
"and",
"receive",
"MIDI",
"messages",
".",
":",
"param",
"number",
":",
"0",
"unless",
"you",
"ve",
"got",
"more",
"than",
"one",
"FaderPort",
"attached",
".",
"In... | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L142-L156 |
jayferg/faderport | faderport.py | FaderPort._message_callback | def _message_callback(self, msg):
"""Callback function to handle incoming MIDI messages."""
if msg.type == 'polytouch':
button = button_from_press(msg.note)
if button:
self.on_button(button, msg.value != 0)
elif msg.note == 127:
self.on... | python | def _message_callback(self, msg):
"""Callback function to handle incoming MIDI messages."""
if msg.type == 'polytouch':
button = button_from_press(msg.note)
if button:
self.on_button(button, msg.value != 0)
elif msg.note == 127:
self.on... | [
"def",
"_message_callback",
"(",
"self",
",",
"msg",
")",
":",
"if",
"msg",
".",
"type",
"==",
"'polytouch'",
":",
"button",
"=",
"button_from_press",
"(",
"msg",
".",
"note",
")",
"if",
"button",
":",
"self",
".",
"on_button",
"(",
"button",
",",
"msg... | Callback function to handle incoming MIDI messages. | [
"Callback",
"function",
"to",
"handle",
"incoming",
"MIDI",
"messages",
"."
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L177-L193 |
jayferg/faderport | faderport.py | FaderPort.fader | def fader(self, value: int):
"""Move the fader to a new position in the range 0 to 1023."""
self._fader = int(value) if 0 < value < 1024 else 0
self.outport.send(mido.Message('control_change', control=0,
value=self._fader >> 7))
self.outport.send(mi... | python | def fader(self, value: int):
"""Move the fader to a new position in the range 0 to 1023."""
self._fader = int(value) if 0 < value < 1024 else 0
self.outport.send(mido.Message('control_change', control=0,
value=self._fader >> 7))
self.outport.send(mi... | [
"def",
"fader",
"(",
"self",
",",
"value",
":",
"int",
")",
":",
"self",
".",
"_fader",
"=",
"int",
"(",
"value",
")",
"if",
"0",
"<",
"value",
"<",
"1024",
"else",
"0",
"self",
".",
"outport",
".",
"send",
"(",
"mido",
".",
"Message",
"(",
"'c... | Move the fader to a new position in the range 0 to 1023. | [
"Move",
"the",
"fader",
"to",
"a",
"new",
"position",
"in",
"the",
"range",
"0",
"to",
"1023",
"."
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L234-L240 |
jayferg/faderport | faderport.py | FaderPort.light_on | def light_on(self, button: Button):
"""Turn the light on for the given Button.
NOTE! If yuo turn the "Off" button light on, the fader won't
report value updates when it's moved."""
self.outport.send(mido.Message('polytouch', note=button.light, value=1)) | python | def light_on(self, button: Button):
"""Turn the light on for the given Button.
NOTE! If yuo turn the "Off" button light on, the fader won't
report value updates when it's moved."""
self.outport.send(mido.Message('polytouch', note=button.light, value=1)) | [
"def",
"light_on",
"(",
"self",
",",
"button",
":",
"Button",
")",
":",
"self",
".",
"outport",
".",
"send",
"(",
"mido",
".",
"Message",
"(",
"'polytouch'",
",",
"note",
"=",
"button",
".",
"light",
",",
"value",
"=",
"1",
")",
")"
] | Turn the light on for the given Button.
NOTE! If yuo turn the "Off" button light on, the fader won't
report value updates when it's moved. | [
"Turn",
"the",
"light",
"on",
"for",
"the",
"given",
"Button",
"."
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L242-L247 |
jayferg/faderport | faderport.py | FaderPort.snake | def snake(self, duration: float = 0.03):
"""
Turn the button lights on then off in a snakelike sequence.
NOTE! Does not remember prior state of lights and will finish
with all lights off.
:param duration: The duration to hold each individual button.
"""
for button... | python | def snake(self, duration: float = 0.03):
"""
Turn the button lights on then off in a snakelike sequence.
NOTE! Does not remember prior state of lights and will finish
with all lights off.
:param duration: The duration to hold each individual button.
"""
for button... | [
"def",
"snake",
"(",
"self",
",",
"duration",
":",
"float",
"=",
"0.03",
")",
":",
"for",
"button",
"in",
"BUTTONS",
":",
"self",
".",
"light_on",
"(",
"button",
")",
"time",
".",
"sleep",
"(",
"duration",
")",
"for",
"button",
"in",
"reversed",
"(",... | Turn the button lights on then off in a snakelike sequence.
NOTE! Does not remember prior state of lights and will finish
with all lights off.
:param duration: The duration to hold each individual button. | [
"Turn",
"the",
"button",
"lights",
"on",
"then",
"off",
"in",
"a",
"snakelike",
"sequence",
".",
"NOTE!",
"Does",
"not",
"remember",
"prior",
"state",
"of",
"lights",
"and",
"will",
"finish",
"with",
"all",
"lights",
"off",
".",
":",
"param",
"duration",
... | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L266-L279 |
jayferg/faderport | faderport.py | FaderPort.blink | def blink(self, interval: float = 0.2, n: int = 3):
"""
Blink all the lights on and off at once.
NOTE! Does not remember prior state of lights and will finish
with all lights off.
:param interval: The length in seconds of an ON/OFF cycle
:param n: How many times to cycle ... | python | def blink(self, interval: float = 0.2, n: int = 3):
"""
Blink all the lights on and off at once.
NOTE! Does not remember prior state of lights and will finish
with all lights off.
:param interval: The length in seconds of an ON/OFF cycle
:param n: How many times to cycle ... | [
"def",
"blink",
"(",
"self",
",",
"interval",
":",
"float",
"=",
"0.2",
",",
"n",
":",
"int",
"=",
"3",
")",
":",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"self",
".",
"all_on",
"(",
")",
"time",
".",
"sleep",
"(",
"interval",
"/",
"2",... | Blink all the lights on and off at once.
NOTE! Does not remember prior state of lights and will finish
with all lights off.
:param interval: The length in seconds of an ON/OFF cycle
:param n: How many times to cycle ON and OFF
:return: | [
"Blink",
"all",
"the",
"lights",
"on",
"and",
"off",
"at",
"once",
".",
"NOTE!",
"Does",
"not",
"remember",
"prior",
"state",
"of",
"lights",
"and",
"will",
"finish",
"with",
"all",
"lights",
"off",
".",
":",
"param",
"interval",
":",
"The",
"length",
... | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L281-L294 |
jayferg/faderport | faderport.py | FaderPort.char_on | def char_on(self, c):
"""
Use button lights (as matrix) to display a hex character.
:param c: String containing one of 0-9,A-F
"""
if c.upper() in CHARACTERS:
for i in CHARACTERS[c.upper()]:
self.light_on(BUTTONS[i]) | python | def char_on(self, c):
"""
Use button lights (as matrix) to display a hex character.
:param c: String containing one of 0-9,A-F
"""
if c.upper() in CHARACTERS:
for i in CHARACTERS[c.upper()]:
self.light_on(BUTTONS[i]) | [
"def",
"char_on",
"(",
"self",
",",
"c",
")",
":",
"if",
"c",
".",
"upper",
"(",
")",
"in",
"CHARACTERS",
":",
"for",
"i",
"in",
"CHARACTERS",
"[",
"c",
".",
"upper",
"(",
")",
"]",
":",
"self",
".",
"light_on",
"(",
"BUTTONS",
"[",
"i",
"]",
... | Use button lights (as matrix) to display a hex character.
:param c: String containing one of 0-9,A-F | [
"Use",
"button",
"lights",
"(",
"as",
"matrix",
")",
"to",
"display",
"a",
"hex",
"character",
".",
":",
"param",
"c",
":",
"String",
"containing",
"one",
"of",
"0",
"-",
"9",
"A",
"-",
"F"
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L296-L303 |
jayferg/faderport | faderport.py | FaderPort.countdown | def countdown(self, interval: float = 0.5):
"""
Display a numeric countdown from 5
:param interval: The interval in seconds for each number.
"""
for c in '54321':
self.char_on(c)
time.sleep(interval * 0.66667)
self.all_off()
time.sl... | python | def countdown(self, interval: float = 0.5):
"""
Display a numeric countdown from 5
:param interval: The interval in seconds for each number.
"""
for c in '54321':
self.char_on(c)
time.sleep(interval * 0.66667)
self.all_off()
time.sl... | [
"def",
"countdown",
"(",
"self",
",",
"interval",
":",
"float",
"=",
"0.5",
")",
":",
"for",
"c",
"in",
"'54321'",
":",
"self",
".",
"char_on",
"(",
"c",
")",
"time",
".",
"sleep",
"(",
"interval",
"*",
"0.66667",
")",
"self",
".",
"all_off",
"(",
... | Display a numeric countdown from 5
:param interval: The interval in seconds for each number. | [
"Display",
"a",
"numeric",
"countdown",
"from",
"5",
":",
"param",
"interval",
":",
"The",
"interval",
"in",
"seconds",
"for",
"each",
"number",
"."
] | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L305-L314 |
jayferg/faderport | faderport.py | FaderPort.chase | def chase(self, duration: float = 0.08, num_lights: int = 2, ticks: int = 20):
"""
Display an animated light chaser pattern
Chase will last ticks * duration seconds
:param duration: How long each chase step will last in seconds
:param num_lights: How many lights in the chase (1 t... | python | def chase(self, duration: float = 0.08, num_lights: int = 2, ticks: int = 20):
"""
Display an animated light chaser pattern
Chase will last ticks * duration seconds
:param duration: How long each chase step will last in seconds
:param num_lights: How many lights in the chase (1 t... | [
"def",
"chase",
"(",
"self",
",",
"duration",
":",
"float",
"=",
"0.08",
",",
"num_lights",
":",
"int",
"=",
"2",
",",
"ticks",
":",
"int",
"=",
"20",
")",
":",
"seq",
"=",
"[",
"button_from_name",
"(",
"'Chan Down'",
")",
",",
"button_from_name",
"(... | Display an animated light chaser pattern
Chase will last ticks * duration seconds
:param duration: How long each chase step will last in seconds
:param num_lights: How many lights in the chase (1 to 4)
:param ticks: How many chase steps. | [
"Display",
"an",
"animated",
"light",
"chaser",
"pattern",
"Chase",
"will",
"last",
"ticks",
"*",
"duration",
"seconds",
":",
"param",
"duration",
":",
"How",
"long",
"each",
"chase",
"step",
"will",
"last",
"in",
"seconds",
":",
"param",
"num_lights",
":",
... | train | https://github.com/jayferg/faderport/blob/53152797f3dedd0fa56d66068313f5484e469a68/faderport.py#L316-L351 |
kallimachos/chios | chios/remotecode/__init__.py | setup | def setup(app):
"""
Setup for Sphinx extension.
:param app: Sphinx application context.
"""
app.info('adding remote-code-block directive...', nonl=True)
app.add_directive('remote-code-block', RemoteCodeBlock)
app.info(' done')
return {
'version': __version__,
'parallel_r... | python | def setup(app):
"""
Setup for Sphinx extension.
:param app: Sphinx application context.
"""
app.info('adding remote-code-block directive...', nonl=True)
app.add_directive('remote-code-block', RemoteCodeBlock)
app.info(' done')
return {
'version': __version__,
'parallel_r... | [
"def",
"setup",
"(",
"app",
")",
":",
"app",
".",
"info",
"(",
"'adding remote-code-block directive...'",
",",
"nonl",
"=",
"True",
")",
"app",
".",
"add_directive",
"(",
"'remote-code-block'",
",",
"RemoteCodeBlock",
")",
"app",
".",
"info",
"(",
"' done'",
... | Setup for Sphinx extension.
:param app: Sphinx application context. | [
"Setup",
"for",
"Sphinx",
"extension",
"."
] | train | https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remotecode/__init__.py#L47-L60 |
kallimachos/chios | chios/remotecode/__init__.py | RemoteCodeBlock.run | def run(self):
"""Fetch remote code."""
link = self.content[0]
try:
r = requests.get(link)
r.raise_for_status()
self.content = [r.text]
return super(RemoteCodeBlock, self).run()
except Exception:
document = self.state.document
... | python | def run(self):
"""Fetch remote code."""
link = self.content[0]
try:
r = requests.get(link)
r.raise_for_status()
self.content = [r.text]
return super(RemoteCodeBlock, self).run()
except Exception:
document = self.state.document
... | [
"def",
"run",
"(",
"self",
")",
":",
"link",
"=",
"self",
".",
"content",
"[",
"0",
"]",
"try",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"link",
")",
"r",
".",
"raise_for_status",
"(",
")",
"self",
".",
"content",
"=",
"[",
"r",
".",
"text",... | Fetch remote code. | [
"Fetch",
"remote",
"code",
"."
] | train | https://github.com/kallimachos/chios/blob/e14044e4019d57089c625d4ad2f73ccb66b8b7b8/chios/remotecode/__init__.py#L33-L44 |
sassoo/goldman | goldman/serializers/comma_sep.py | Serializer.serialize | def serialize(self, data):
""" Determine & invoke the proper serializer method
If data is a list then the serialize_datas method will
be run otherwise serialize_data.
"""
super(Serializer, self).serialize(data)
self.resp.content_type += '; header=present'
impor... | python | def serialize(self, data):
""" Determine & invoke the proper serializer method
If data is a list then the serialize_datas method will
be run otherwise serialize_data.
"""
super(Serializer, self).serialize(data)
self.resp.content_type += '; header=present'
impor... | [
"def",
"serialize",
"(",
"self",
",",
"data",
")",
":",
"super",
"(",
"Serializer",
",",
"self",
")",
".",
"serialize",
"(",
"data",
")",
"self",
".",
"resp",
".",
"content_type",
"+=",
"'; header=present'",
"import",
"pprint",
"pprint",
".",
"PrettyPrinte... | Determine & invoke the proper serializer method
If data is a list then the serialize_datas method will
be run otherwise serialize_data. | [
"Determine",
"&",
"invoke",
"the",
"proper",
"serializer",
"method"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/comma_sep.py#L18-L29 |
sassoo/goldman | goldman/serializers/comma_sep.py | Serializer._serialize_data | def _serialize_data(self, data):
""" Turn the data into a single CSV record (row)
:spec: jsonapi.org/format/#document-resource-objects
:param data: dict
:return: dict
"""
data.update(data['include'])
data.update(data['to_many'])
data.update(data['to_one'... | python | def _serialize_data(self, data):
""" Turn the data into a single CSV record (row)
:spec: jsonapi.org/format/#document-resource-objects
:param data: dict
:return: dict
"""
data.update(data['include'])
data.update(data['to_many'])
data.update(data['to_one'... | [
"def",
"_serialize_data",
"(",
"self",
",",
"data",
")",
":",
"data",
".",
"update",
"(",
"data",
"[",
"'include'",
"]",
")",
"data",
".",
"update",
"(",
"data",
"[",
"'to_many'",
"]",
")",
"data",
".",
"update",
"(",
"data",
"[",
"'to_one'",
"]",
... | Turn the data into a single CSV record (row)
:spec: jsonapi.org/format/#document-resource-objects
:param data: dict
:return: dict | [
"Turn",
"the",
"data",
"into",
"a",
"single",
"CSV",
"record",
"(",
"row",
")"
] | train | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/serializers/comma_sep.py#L47-L65 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address.setUp | def setUp(self):
'''Look for WS-Address
'''
toplist = filter(lambda wsa: wsa.ADDRESS==self.wsAddressURI, WSA_LIST)
epr = 'EndpointReferenceType'
for WSA in toplist+WSA_LIST:
if (self.wsAddressURI is not None and self.wsAddressURI != WSA.ADDRESS) or \
_... | python | def setUp(self):
'''Look for WS-Address
'''
toplist = filter(lambda wsa: wsa.ADDRESS==self.wsAddressURI, WSA_LIST)
epr = 'EndpointReferenceType'
for WSA in toplist+WSA_LIST:
if (self.wsAddressURI is not None and self.wsAddressURI != WSA.ADDRESS) or \
_... | [
"def",
"setUp",
"(",
"self",
")",
":",
"toplist",
"=",
"filter",
"(",
"lambda",
"wsa",
":",
"wsa",
".",
"ADDRESS",
"==",
"self",
".",
"wsAddressURI",
",",
"WSA_LIST",
")",
"epr",
"=",
"'EndpointReferenceType'",
"for",
"WSA",
"in",
"toplist",
"+",
"WSA_LI... | Look for WS-Address | [
"Look",
"for",
"WS",
"-",
"Address"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L32-L47 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address._checkAction | def _checkAction(self, action, value):
'''WS-Address Action
action -- Action value expecting.
value -- Action value server returned.
'''
if action is None:
raise WSActionException, 'Response missing WSAddress Action'
if not value:
raise WSActionEx... | python | def _checkAction(self, action, value):
'''WS-Address Action
action -- Action value expecting.
value -- Action value server returned.
'''
if action is None:
raise WSActionException, 'Response missing WSAddress Action'
if not value:
raise WSActionEx... | [
"def",
"_checkAction",
"(",
"self",
",",
"action",
",",
"value",
")",
":",
"if",
"action",
"is",
"None",
":",
"raise",
"WSActionException",
",",
"'Response missing WSAddress Action'",
"if",
"not",
"value",
":",
"raise",
"WSActionException",
",",
"'missing WSAddres... | WS-Address Action
action -- Action value expecting.
value -- Action value server returned. | [
"WS",
"-",
"Address",
"Action",
"action",
"--",
"Action",
"value",
"expecting",
".",
"value",
"--",
"Action",
"value",
"server",
"returned",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L49-L59 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address._checkFrom | def _checkFrom(self, pyobj):
'''WS-Address From,
XXX currently not checking the hostname, not forwarding messages.
pyobj -- From server returned.
'''
if pyobj is None: return
value = pyobj._Address
if value != self._addressTo:
scheme,netloc,path,quer... | python | def _checkFrom(self, pyobj):
'''WS-Address From,
XXX currently not checking the hostname, not forwarding messages.
pyobj -- From server returned.
'''
if pyobj is None: return
value = pyobj._Address
if value != self._addressTo:
scheme,netloc,path,quer... | [
"def",
"_checkFrom",
"(",
"self",
",",
"pyobj",
")",
":",
"if",
"pyobj",
"is",
"None",
":",
"return",
"value",
"=",
"pyobj",
".",
"_Address",
"if",
"value",
"!=",
"self",
".",
"_addressTo",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"query",
","... | WS-Address From,
XXX currently not checking the hostname, not forwarding messages.
pyobj -- From server returned. | [
"WS",
"-",
"Address",
"From",
"XXX",
"currently",
"not",
"checking",
"the",
"hostname",
"not",
"forwarding",
"messages",
".",
"pyobj",
"--",
"From",
"server",
"returned",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L61-L79 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address._checkRelatesTo | def _checkRelatesTo(self, value):
'''WS-Address From
value -- From server returned.
'''
if value != self._messageID:
raise WSActionException, 'wrong WS-Address RelatesTo(%s), expecting %s'%(value,self._messageID) | python | def _checkRelatesTo(self, value):
'''WS-Address From
value -- From server returned.
'''
if value != self._messageID:
raise WSActionException, 'wrong WS-Address RelatesTo(%s), expecting %s'%(value,self._messageID) | [
"def",
"_checkRelatesTo",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"_messageID",
":",
"raise",
"WSActionException",
",",
"'wrong WS-Address RelatesTo(%s), expecting %s'",
"%",
"(",
"value",
",",
"self",
".",
"_messageID",
")"
] | WS-Address From
value -- From server returned. | [
"WS",
"-",
"Address",
"From",
"value",
"--",
"From",
"server",
"returned",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L81-L86 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address._checkReplyTo | def _checkReplyTo(self, value):
'''WS-Address From
value -- From server returned in wsa:To
'''
if value != self._replyTo:
raise WSActionException, 'wrong WS-Address ReplyTo(%s), expecting %s'%(value,self._replyTo) | python | def _checkReplyTo(self, value):
'''WS-Address From
value -- From server returned in wsa:To
'''
if value != self._replyTo:
raise WSActionException, 'wrong WS-Address ReplyTo(%s), expecting %s'%(value,self._replyTo) | [
"def",
"_checkReplyTo",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"!=",
"self",
".",
"_replyTo",
":",
"raise",
"WSActionException",
",",
"'wrong WS-Address ReplyTo(%s), expecting %s'",
"%",
"(",
"value",
",",
"self",
".",
"_replyTo",
")"
] | WS-Address From
value -- From server returned in wsa:To | [
"WS",
"-",
"Address",
"From",
"value",
"--",
"From",
"server",
"returned",
"in",
"wsa",
":",
"To"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L88-L93 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address._getWSAddressTypeCodes | def _getWSAddressTypeCodes(self, **kw):
'''kw -- namespaceURI keys with sequence of element names.
'''
typecodes = []
try:
for nsuri,elements in kw.items():
for el in elements:
typecode = GED(nsuri, el)
if typecode is No... | python | def _getWSAddressTypeCodes(self, **kw):
'''kw -- namespaceURI keys with sequence of element names.
'''
typecodes = []
try:
for nsuri,elements in kw.items():
for el in elements:
typecode = GED(nsuri, el)
if typecode is No... | [
"def",
"_getWSAddressTypeCodes",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"typecodes",
"=",
"[",
"]",
"try",
":",
"for",
"nsuri",
",",
"elements",
"in",
"kw",
".",
"items",
"(",
")",
":",
"for",
"el",
"in",
"elements",
":",
"typecode",
"=",
"GED... | kw -- namespaceURI keys with sequence of element names. | [
"kw",
"--",
"namespaceURI",
"keys",
"with",
"sequence",
"of",
"element",
"names",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L107-L124 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address.checkResponse | def checkResponse(self, ps, action):
'''
ps -- ParsedSoap
action -- ws-action for response
'''
namespaceURI = self.wsAddressURI
d = {namespaceURI:("MessageID","Action","To","From","RelatesTo")}
typecodes = self._getWSAddressTypeCodes(**d)
pyobjs = ps.Pars... | python | def checkResponse(self, ps, action):
'''
ps -- ParsedSoap
action -- ws-action for response
'''
namespaceURI = self.wsAddressURI
d = {namespaceURI:("MessageID","Action","To","From","RelatesTo")}
typecodes = self._getWSAddressTypeCodes(**d)
pyobjs = ps.Pars... | [
"def",
"checkResponse",
"(",
"self",
",",
"ps",
",",
"action",
")",
":",
"namespaceURI",
"=",
"self",
".",
"wsAddressURI",
"d",
"=",
"{",
"namespaceURI",
":",
"(",
"\"MessageID\"",
",",
"\"Action\"",
",",
"\"To\"",
",",
"\"From\"",
",",
"\"RelatesTo\"",
")... | ps -- ParsedSoap
action -- ws-action for response | [
"ps",
"--",
"ParsedSoap",
"action",
"--",
"ws",
"-",
"action",
"for",
"response"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L126-L146 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address.setRequest | def setRequest(self, endPointReference, action):
'''Call For Request
'''
self._action = action
self.header_pyobjs = None
pyobjs = []
namespaceURI = self.wsAddressURI
addressTo = self._addressTo
messageID = self._messageID = "uuid:%s" %time.time()
... | python | def setRequest(self, endPointReference, action):
'''Call For Request
'''
self._action = action
self.header_pyobjs = None
pyobjs = []
namespaceURI = self.wsAddressURI
addressTo = self._addressTo
messageID = self._messageID = "uuid:%s" %time.time()
... | [
"def",
"setRequest",
"(",
"self",
",",
"endPointReference",
",",
"action",
")",
":",
"self",
".",
"_action",
"=",
"action",
"self",
".",
"header_pyobjs",
"=",
"None",
"pyobjs",
"=",
"[",
"]",
"namespaceURI",
"=",
"self",
".",
"wsAddressURI",
"addressTo",
"... | Call For Request | [
"Call",
"For",
"Request"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L148-L194 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address.setResponseFromWSAddress | def setResponseFromWSAddress(self, address, localURL):
'''Server-side has to set these fields in response.
address -- Address instance, representing a WS-Address
'''
self.From = localURL
self.header_pyobjs = None
pyobjs = []
namespaceURI = self.wsAddressURI
... | python | def setResponseFromWSAddress(self, address, localURL):
'''Server-side has to set these fields in response.
address -- Address instance, representing a WS-Address
'''
self.From = localURL
self.header_pyobjs = None
pyobjs = []
namespaceURI = self.wsAddressURI
... | [
"def",
"setResponseFromWSAddress",
"(",
"self",
",",
"address",
",",
"localURL",
")",
":",
"self",
".",
"From",
"=",
"localURL",
"self",
".",
"header_pyobjs",
"=",
"None",
"pyobjs",
"=",
"[",
"]",
"namespaceURI",
"=",
"self",
".",
"wsAddressURI",
"for",
"n... | Server-side has to set these fields in response.
address -- Address instance, representing a WS-Address | [
"Server",
"-",
"side",
"has",
"to",
"set",
"these",
"fields",
"in",
"response",
".",
"address",
"--",
"Address",
"instance",
"representing",
"a",
"WS",
"-",
"Address"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L196-L218 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address.serialize | def serialize(self, sw, **kw):
'''
sw -- SoapWriter instance, add WS-Address header.
'''
for pyobj in self.header_pyobjs:
if hasattr(pyobj, 'typecode') is False:
raise RuntimeError, 'all header pyobjs must have a typecode attribute'
sw.serialize_h... | python | def serialize(self, sw, **kw):
'''
sw -- SoapWriter instance, add WS-Address header.
'''
for pyobj in self.header_pyobjs:
if hasattr(pyobj, 'typecode') is False:
raise RuntimeError, 'all header pyobjs must have a typecode attribute'
sw.serialize_h... | [
"def",
"serialize",
"(",
"self",
",",
"sw",
",",
"*",
"*",
"kw",
")",
":",
"for",
"pyobj",
"in",
"self",
".",
"header_pyobjs",
":",
"if",
"hasattr",
"(",
"pyobj",
",",
"'typecode'",
")",
"is",
"False",
":",
"raise",
"RuntimeError",
",",
"'all header py... | sw -- SoapWriter instance, add WS-Address header. | [
"sw",
"--",
"SoapWriter",
"instance",
"add",
"WS",
"-",
"Address",
"header",
"."
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L221-L229 |
rameshg87/pyremotevbox | pyremotevbox/ZSI/address.py | Address.parse | def parse(self, ps, **kw):
'''
ps -- ParsedSoap instance
'''
namespaceURI = self.wsAddressURI
elements = ("MessageID","Action","To","From","RelatesTo")
d = {namespaceURI:elements}
typecodes = self._getWSAddressTypeCodes(**d)
pyobjs = ps.ParseHeaderElements... | python | def parse(self, ps, **kw):
'''
ps -- ParsedSoap instance
'''
namespaceURI = self.wsAddressURI
elements = ("MessageID","Action","To","From","RelatesTo")
d = {namespaceURI:elements}
typecodes = self._getWSAddressTypeCodes(**d)
pyobjs = ps.ParseHeaderElements... | [
"def",
"parse",
"(",
"self",
",",
"ps",
",",
"*",
"*",
"kw",
")",
":",
"namespaceURI",
"=",
"self",
".",
"wsAddressURI",
"elements",
"=",
"(",
"\"MessageID\"",
",",
"\"Action\"",
",",
"\"To\"",
",",
"\"From\"",
",",
"\"RelatesTo\"",
")",
"d",
"=",
"{",... | ps -- ParsedSoap instance | [
"ps",
"--",
"ParsedSoap",
"instance"
] | train | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/address.py#L232-L245 |
MakerReduxCorp/PLOD | PLOD/__init__.py | PLOD.dropKey | def dropKey(self, key):
'''Drop an attribute/element/key-value pair from all the dictionaries.
If the dictionary key does not exist in a particular dictionary, then
that dictionary is left unchanged.
Side effect: if the key is a number and it matches a list (interpreted
as a di... | python | def dropKey(self, key):
'''Drop an attribute/element/key-value pair from all the dictionaries.
If the dictionary key does not exist in a particular dictionary, then
that dictionary is left unchanged.
Side effect: if the key is a number and it matches a list (interpreted
as a di... | [
"def",
"dropKey",
"(",
"self",
",",
"key",
")",
":",
"result",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
".",
"table",
":",
"result",
".",
"append",
"(",
"internal",
".",
"remove_member",
"(",
"row",
",",
"key",
")",
")",
"self",
".",
"table",
"... | Drop an attribute/element/key-value pair from all the dictionaries.
If the dictionary key does not exist in a particular dictionary, then
that dictionary is left unchanged.
Side effect: if the key is a number and it matches a list (interpreted
as a dictionary), it will cause the "keys"... | [
"Drop",
"an",
"attribute",
"/",
"element",
"/",
"key",
"-",
"value",
"pair",
"from",
"all",
"the",
"dictionaries",
"."
] | train | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/__init__.py#L104-L143 |
MakerReduxCorp/PLOD | PLOD/__init__.py | PLOD.addKey | def addKey(self, key, value):
'''Insert a attribute/element/key-value pair to all the dictionaries.
The same value is added to all of the dictionaries.
Of note: the current version of this routine cannot handle subtending
keys (dictionaries in dictionaries).
Example of use:
... | python | def addKey(self, key, value):
'''Insert a attribute/element/key-value pair to all the dictionaries.
The same value is added to all of the dictionaries.
Of note: the current version of this routine cannot handle subtending
keys (dictionaries in dictionaries).
Example of use:
... | [
"def",
"addKey",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"result",
"=",
"[",
"]",
"for",
"row",
"in",
"self",
".",
"table",
":",
"try",
":",
"row",
"[",
"key",
"]",
"=",
"value",
"except",
":",
"pass",
"result",
".",
"append",
"(",
"ro... | Insert a attribute/element/key-value pair to all the dictionaries.
The same value is added to all of the dictionaries.
Of note: the current version of this routine cannot handle subtending
keys (dictionaries in dictionaries).
Example of use:
>>> test = [
... {"name... | [
"Insert",
"a",
"attribute",
"/",
"element",
"/",
"key",
"-",
"value",
"pair",
"to",
"all",
"the",
"dictionaries",
"."
] | train | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/__init__.py#L145-L188 |
MakerReduxCorp/PLOD | PLOD/__init__.py | PLOD.upsert | def upsert(self, key, value, entry):
'''Update or Insert an entry into the list of dictionaries.
If a dictionary in the list is found where key matches the value, then
the FIRST matching list entry is replaced with entry
else
the entry is appended to the end of the list.
... | python | def upsert(self, key, value, entry):
'''Update or Insert an entry into the list of dictionaries.
If a dictionary in the list is found where key matches the value, then
the FIRST matching list entry is replaced with entry
else
the entry is appended to the end of the list.
... | [
"def",
"upsert",
"(",
"self",
",",
"key",
",",
"value",
",",
"entry",
")",
":",
"index",
"=",
"internal",
".",
"get_index",
"(",
"self",
".",
"table",
",",
"key",
",",
"self",
".",
"EQUAL",
",",
"value",
")",
"if",
"index",
"is",
"None",
":",
"se... | Update or Insert an entry into the list of dictionaries.
If a dictionary in the list is found where key matches the value, then
the FIRST matching list entry is replaced with entry
else
the entry is appended to the end of the list.
The new entry is not examined in any way... | [
"Update",
"or",
"Insert",
"an",
"entry",
"into",
"the",
"list",
"of",
"dictionaries",
"."
] | train | https://github.com/MakerReduxCorp/PLOD/blob/707502cd928e5be6bd5e46d7f6de7da0e188cf1e/PLOD/__init__.py#L195-L249 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.