id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
243,800 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | _Binding.ReceiveFault | def ReceiveFault(self, **kw):
'''Parse incoming message as a fault. Raise TypeError if no
fault found.
'''
self.ReceiveSOAP(**kw)
if not self.ps.IsAFault():
raise TypeError("Expected SOAP Fault not found")
return FaultFromFaultMessage(self.ps) | python | def ReceiveFault(self, **kw):
'''Parse incoming message as a fault. Raise TypeError if no
fault found.
'''
self.ReceiveSOAP(**kw)
if not self.ps.IsAFault():
raise TypeError("Expected SOAP Fault not found")
return FaultFromFaultMessage(self.ps) | [
"def",
"ReceiveFault",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"self",
".",
"ReceiveSOAP",
"(",
"*",
"*",
"kw",
")",
"if",
"not",
"self",
".",
"ps",
".",
"IsAFault",
"(",
")",
":",
"raise",
"TypeError",
"(",
"\"Expected SOAP Fault not found\"",
")"... | Parse incoming message as a fault. Raise TypeError if no
fault found. | [
"Parse",
"incoming",
"message",
"as",
"a",
"fault",
".",
"Raise",
"TypeError",
"if",
"no",
"fault",
"found",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L435-L442 |
243,801 | rameshg87/pyremotevbox | pyremotevbox/ZSI/client.py | Binding.__parse_child | def __parse_child(self, node):
'''for rpc-style map each message part to a class in typesmodule
'''
try:
tc = self.gettypecode(self.typesmodule, node)
except:
self.logger.debug('didnt find typecode for "%s" in typesmodule: %s',
node.localName, sel... | python | def __parse_child(self, node):
'''for rpc-style map each message part to a class in typesmodule
'''
try:
tc = self.gettypecode(self.typesmodule, node)
except:
self.logger.debug('didnt find typecode for "%s" in typesmodule: %s',
node.localName, sel... | [
"def",
"__parse_child",
"(",
"self",
",",
"node",
")",
":",
"try",
":",
"tc",
"=",
"self",
".",
"gettypecode",
"(",
"self",
".",
"typesmodule",
",",
"node",
")",
"except",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"'didnt find typecode for \"%s\" in t... | for rpc-style map each message part to a class in typesmodule | [
"for",
"rpc",
"-",
"style",
"map",
"each",
"message",
"part",
"to",
"a",
"class",
"in",
"typesmodule"
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/client.py#L503-L521 |
243,802 | sassoo/goldman | goldman/middleware/basicauth/__init__.py | Middleware._get_creds | def _get_creds(self, req):
""" Get the username & password from the Authorization header
If the header is actually malformed where Basic Auth was
indicated by the request then an InvalidAuthSyntax exception
is raised. Otherwise an AuthRequired exception since it's
unclear in thi... | python | def _get_creds(self, req):
""" Get the username & password from the Authorization header
If the header is actually malformed where Basic Auth was
indicated by the request then an InvalidAuthSyntax exception
is raised. Otherwise an AuthRequired exception since it's
unclear in thi... | [
"def",
"_get_creds",
"(",
"self",
",",
"req",
")",
":",
"self",
".",
"_validate_auth_scheme",
"(",
"req",
")",
"try",
":",
"creds",
"=",
"naked",
"(",
"req",
".",
"auth",
".",
"split",
"(",
"' '",
")",
"[",
"1",
"]",
")",
"creds",
"=",
"b64decode",... | Get the username & password from the Authorization header
If the header is actually malformed where Basic Auth was
indicated by the request then an InvalidAuthSyntax exception
is raised. Otherwise an AuthRequired exception since it's
unclear in this scenario if the requestor was even aw... | [
"Get",
"the",
"username",
"&",
"password",
"from",
"the",
"Authorization",
"header"
] | b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2 | https://github.com/sassoo/goldman/blob/b72540c9ad06b5c68aadb1b4fa8cb0b716260bf2/goldman/middleware/basicauth/__init__.py#L81-L129 |
243,803 | nanvel/c2p2 | c2p2/models.py | Site._update_page | def _update_page(self, uri, path):
"""Update page content."""
if uri in self._pages:
self._pages[uri].update()
else:
self._pages[uri] = Page(uri=uri, path=path) | python | def _update_page(self, uri, path):
"""Update page content."""
if uri in self._pages:
self._pages[uri].update()
else:
self._pages[uri] = Page(uri=uri, path=path) | [
"def",
"_update_page",
"(",
"self",
",",
"uri",
",",
"path",
")",
":",
"if",
"uri",
"in",
"self",
".",
"_pages",
":",
"self",
".",
"_pages",
"[",
"uri",
"]",
".",
"update",
"(",
")",
"else",
":",
"self",
".",
"_pages",
"[",
"uri",
"]",
"=",
"Pa... | Update page content. | [
"Update",
"page",
"content",
"."
] | 3900a9bb54d35e1332b92d6560f3cb1e77943209 | https://github.com/nanvel/c2p2/blob/3900a9bb54d35e1332b92d6560f3cb1e77943209/c2p2/models.py#L189-L194 |
243,804 | nanvel/c2p2 | c2p2/models.py | Site._update_labels | def _update_labels(self):
"""Updates list of available labels."""
labels = set()
for page in self.get_pages():
for label in page.labels:
labels.add(label)
to_delete = self._labels - labels
for label in labels:
self._labels.add(label)
... | python | def _update_labels(self):
"""Updates list of available labels."""
labels = set()
for page in self.get_pages():
for label in page.labels:
labels.add(label)
to_delete = self._labels - labels
for label in labels:
self._labels.add(label)
... | [
"def",
"_update_labels",
"(",
"self",
")",
":",
"labels",
"=",
"set",
"(",
")",
"for",
"page",
"in",
"self",
".",
"get_pages",
"(",
")",
":",
"for",
"label",
"in",
"page",
".",
"labels",
":",
"labels",
".",
"add",
"(",
"label",
")",
"to_delete",
"=... | Updates list of available labels. | [
"Updates",
"list",
"of",
"available",
"labels",
"."
] | 3900a9bb54d35e1332b92d6560f3cb1e77943209 | https://github.com/nanvel/c2p2/blob/3900a9bb54d35e1332b92d6560f3cb1e77943209/c2p2/models.py#L201-L211 |
243,805 | nanvel/c2p2 | c2p2/models.py | Site.get_pages | def get_pages(self, label=None):
"""Returns list of pages with specified label."""
return (
page for page in sorted(
self._pages.values(), key=lambda i: i.created, reverse=True
) if ((not label or label in page.labels) and page.visible)
) | python | def get_pages(self, label=None):
"""Returns list of pages with specified label."""
return (
page for page in sorted(
self._pages.values(), key=lambda i: i.created, reverse=True
) if ((not label or label in page.labels) and page.visible)
) | [
"def",
"get_pages",
"(",
"self",
",",
"label",
"=",
"None",
")",
":",
"return",
"(",
"page",
"for",
"page",
"in",
"sorted",
"(",
"self",
".",
"_pages",
".",
"values",
"(",
")",
",",
"key",
"=",
"lambda",
"i",
":",
"i",
".",
"created",
",",
"rever... | Returns list of pages with specified label. | [
"Returns",
"list",
"of",
"pages",
"with",
"specified",
"label",
"."
] | 3900a9bb54d35e1332b92d6560f3cb1e77943209 | https://github.com/nanvel/c2p2/blob/3900a9bb54d35e1332b92d6560f3cb1e77943209/c2p2/models.py#L216-L222 |
243,806 | collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient._requests | def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):
''' a helper method for relaying requests from client to api '''
title = '%s._requests' % self.__class__.__name__
# import dependencies
from time import time
import requests
# valid... | python | def _requests(self, url, method='GET', headers=None, params=None, data=None, errors=None):
''' a helper method for relaying requests from client to api '''
title = '%s._requests' % self.__class__.__name__
# import dependencies
from time import time
import requests
# valid... | [
"def",
"_requests",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'GET'",
",",
"headers",
"=",
"None",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"errors",
"=",
"None",
")",
":",
"title",
"=",
"'%s._requests'",
"%",
"self",
".",
"__... | a helper method for relaying requests from client to api | [
"a",
"helper",
"method",
"for",
"relaying",
"requests",
"from",
"client",
"to",
"api"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L230-L297 |
243,807 | collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient._get_products | def _get_products(self):
''' a method to retrieve account product details at initialization '''
# request product list
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
# construct list of produc... | python | def _get_products(self):
''' a method to retrieve account product details at initialization '''
# request product list
products_request = self.account_products()
if products_request['error']:
raise Exception(products_request['error'])
# construct list of produc... | [
"def",
"_get_products",
"(",
"self",
")",
":",
"# request product list",
"products_request",
"=",
"self",
".",
"account_products",
"(",
")",
"if",
"products_request",
"[",
"'error'",
"]",
":",
"raise",
"Exception",
"(",
"products_request",
"[",
"'error'",
"]",
"... | a method to retrieve account product details at initialization | [
"a",
"method",
"to",
"retrieve",
"account",
"product",
"details",
"at",
"initialization"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L299-L323 |
243,808 | collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient.access_token | def access_token(self):
''' a method to acquire an oauth access token '''
title = '%s.access_token' % self.__class__.__name__
# import dependencies
from time import time
import requests
# construct request kwargs
request_kwargs = {
'url': self.token_en... | python | def access_token(self):
''' a method to acquire an oauth access token '''
title = '%s.access_token' % self.__class__.__name__
# import dependencies
from time import time
import requests
# construct request kwargs
request_kwargs = {
'url': self.token_en... | [
"def",
"access_token",
"(",
"self",
")",
":",
"title",
"=",
"'%s.access_token'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# import dependencies",
"from",
"time",
"import",
"time",
"import",
"requests",
"# construct request kwargs",
"request_kwargs",
"=",
"{"... | a method to acquire an oauth access token | [
"a",
"method",
"to",
"acquire",
"an",
"oauth",
"access",
"token"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L325-L364 |
243,809 | collectiveacuity/labPack | labpack/banking/capitalone.py | depositsClient.account_products | def account_products(self):
''' a method to retrieve a list of the account products
returns:
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"jso... | python | def account_products(self):
''' a method to retrieve a list of the account products
returns:
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"jso... | [
"def",
"account_products",
"(",
"self",
")",
":",
"title",
"=",
"'%s.account_products'",
"%",
"self",
".",
"__class__",
".",
"__name__",
"# construct url",
"url",
"=",
"self",
".",
"deposits_endpoint",
"+",
"'account-products'",
"# send request",
"details",
"=",
"... | a method to retrieve a list of the account products
returns:
{
"error": "",
"code": 200,
"method": "GET",
"url": "https://...",
"headers": { },
"json": {
"entries": [
... | [
"a",
"method",
"to",
"retrieve",
"a",
"list",
"of",
"the",
"account",
"products"
] | 52949ece35e72e3cc308f54d9ffa6bfbd96805b8 | https://github.com/collectiveacuity/labPack/blob/52949ece35e72e3cc308f54d9ffa6bfbd96805b8/labpack/banking/capitalone.py#L366-L396 |
243,810 | uw-it-aca/uw-restclients-mailman | uw_mailman/instructor_term_list.py | get_instructor_term_list_name | def get_instructor_term_list_name(instructor_netid, year, quarter):
"""
Return the list address of UW instructor email list for
the given year and quarter
"""
return "{uwnetid}_{quarter}{year}".format(
uwnetid=instructor_netid,
quarter=quarter.lower()[:2],
year=str(year)[-2:]... | python | def get_instructor_term_list_name(instructor_netid, year, quarter):
"""
Return the list address of UW instructor email list for
the given year and quarter
"""
return "{uwnetid}_{quarter}{year}".format(
uwnetid=instructor_netid,
quarter=quarter.lower()[:2],
year=str(year)[-2:]... | [
"def",
"get_instructor_term_list_name",
"(",
"instructor_netid",
",",
"year",
",",
"quarter",
")",
":",
"return",
"\"{uwnetid}_{quarter}{year}\"",
".",
"format",
"(",
"uwnetid",
"=",
"instructor_netid",
",",
"quarter",
"=",
"quarter",
".",
"lower",
"(",
")",
"[",
... | Return the list address of UW instructor email list for
the given year and quarter | [
"Return",
"the",
"list",
"address",
"of",
"UW",
"instructor",
"email",
"list",
"for",
"the",
"given",
"year",
"and",
"quarter"
] | ef077f2cc945871422fcd66391e82264e2384b2c | https://github.com/uw-it-aca/uw-restclients-mailman/blob/ef077f2cc945871422fcd66391e82264e2384b2c/uw_mailman/instructor_term_list.py#L8-L16 |
243,811 | wooyek/django-pascal-templates | src/pascal_templates/views.py | TemplatePathMixin.get_template_path | def get_template_path(self, meta=None, **kwargs):
"""
Formats template_name_path_pattern with kwargs given.
"""
if 'template_name_suffix' not in kwargs or kwargs.get('template_name_suffix') is None:
kwargs['template_name_suffix'] = self.get_template_name_suffix()
... | python | def get_template_path(self, meta=None, **kwargs):
"""
Formats template_name_path_pattern with kwargs given.
"""
if 'template_name_suffix' not in kwargs or kwargs.get('template_name_suffix') is None:
kwargs['template_name_suffix'] = self.get_template_name_suffix()
... | [
"def",
"get_template_path",
"(",
"self",
",",
"meta",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'template_name_suffix'",
"not",
"in",
"kwargs",
"or",
"kwargs",
".",
"get",
"(",
"'template_name_suffix'",
")",
"is",
"None",
":",
"kwargs",
"[",
... | Formats template_name_path_pattern with kwargs given. | [
"Formats",
"template_name_path_pattern",
"with",
"kwargs",
"given",
"."
] | 4c2216de7f7e53c7db6c2ab1f75f0b9065ce580e | https://github.com/wooyek/django-pascal-templates/blob/4c2216de7f7e53c7db6c2ab1f75f0b9065ce580e/src/pascal_templates/views.py#L14-L20 |
243,812 | sliem/barrett | barrett/util.py | threenum | def threenum(h5file, var, post_col='mult'):
""" Calculates the three number summary for a variable.
The three number summary is the minimum, maximum and the mean
of the data. Traditionally one would summerise data with the
five number summary: max, min, 1st, 2nd (median), 3rd quartile.
But quantile... | python | def threenum(h5file, var, post_col='mult'):
""" Calculates the three number summary for a variable.
The three number summary is the minimum, maximum and the mean
of the data. Traditionally one would summerise data with the
five number summary: max, min, 1st, 2nd (median), 3rd quartile.
But quantile... | [
"def",
"threenum",
"(",
"h5file",
",",
"var",
",",
"post_col",
"=",
"'mult'",
")",
":",
"f",
"=",
"h5py",
".",
"File",
"(",
"h5file",
",",
"'r'",
")",
"d",
"=",
"f",
"[",
"var",
"]",
"w",
"=",
"f",
"[",
"post_col",
"]",
"s",
"=",
"d",
".",
... | Calculates the three number summary for a variable.
The three number summary is the minimum, maximum and the mean
of the data. Traditionally one would summerise data with the
five number summary: max, min, 1st, 2nd (median), 3rd quartile.
But quantiles are hard to calculate without sorting the data
... | [
"Calculates",
"the",
"three",
"number",
"summary",
"for",
"a",
"variable",
"."
] | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/barrett/util.py#L6-L45 |
243,813 | sliem/barrett | barrett/util.py | filechunk | def filechunk(f, chunksize):
"""Iterator that allow for piecemeal processing of a file."""
while True:
chunk = tuple(itertools.islice(f, chunksize))
if not chunk:
return
yield np.loadtxt(iter(chunk), dtype=np.float64) | python | def filechunk(f, chunksize):
"""Iterator that allow for piecemeal processing of a file."""
while True:
chunk = tuple(itertools.islice(f, chunksize))
if not chunk:
return
yield np.loadtxt(iter(chunk), dtype=np.float64) | [
"def",
"filechunk",
"(",
"f",
",",
"chunksize",
")",
":",
"while",
"True",
":",
"chunk",
"=",
"tuple",
"(",
"itertools",
".",
"islice",
"(",
"f",
",",
"chunksize",
")",
")",
"if",
"not",
"chunk",
":",
"return",
"yield",
"np",
".",
"loadtxt",
"(",
"... | Iterator that allow for piecemeal processing of a file. | [
"Iterator",
"that",
"allow",
"for",
"piecemeal",
"processing",
"of",
"a",
"file",
"."
] | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/barrett/util.py#L48-L54 |
243,814 | sliem/barrett | barrett/util.py | convert_chain | def convert_chain(
txtfiles,
headers,
h5file,
chunksize):
"""Converts chain in plain text format into HDF5 format.
Keyword arguments:
txtfiles -- list of paths to the plain text chains.
headers -- name of each column.
h5file -- where to put the resulting HDF5 file.
... | python | def convert_chain(
txtfiles,
headers,
h5file,
chunksize):
"""Converts chain in plain text format into HDF5 format.
Keyword arguments:
txtfiles -- list of paths to the plain text chains.
headers -- name of each column.
h5file -- where to put the resulting HDF5 file.
... | [
"def",
"convert_chain",
"(",
"txtfiles",
",",
"headers",
",",
"h5file",
",",
"chunksize",
")",
":",
"h5",
"=",
"h5py",
".",
"File",
"(",
"h5file",
",",
"'w'",
")",
"for",
"h",
"in",
"headers",
":",
"h5",
".",
"create_dataset",
"(",
"h",
",",
"shape",... | Converts chain in plain text format into HDF5 format.
Keyword arguments:
txtfiles -- list of paths to the plain text chains.
headers -- name of each column.
h5file -- where to put the resulting HDF5 file.
chunksize -- how large the HDF5 chunk, i.e. number of rows.
Chunking - How to pick a chun... | [
"Converts",
"chain",
"in",
"plain",
"text",
"format",
"into",
"HDF5",
"format",
"."
] | d48e96591577d1fcecd50c21a9be71573218cde7 | https://github.com/sliem/barrett/blob/d48e96591577d1fcecd50c21a9be71573218cde7/barrett/util.py#L57-L102 |
243,815 | radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getAvailableClassesInModule | def getAvailableClassesInModule(prooveModule):
"""
return a list of all classes in the given module
that dont begin with '_'
"""
l = tuple(x[1] for x in inspect.getmembers(prooveModule, inspect.isclass))
l = [x for x in l if x.__name__[0] != "_"]
return l | python | def getAvailableClassesInModule(prooveModule):
"""
return a list of all classes in the given module
that dont begin with '_'
"""
l = tuple(x[1] for x in inspect.getmembers(prooveModule, inspect.isclass))
l = [x for x in l if x.__name__[0] != "_"]
return l | [
"def",
"getAvailableClassesInModule",
"(",
"prooveModule",
")",
":",
"l",
"=",
"tuple",
"(",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"inspect",
".",
"getmembers",
"(",
"prooveModule",
",",
"inspect",
".",
"isclass",
")",
")",
"l",
"=",
"[",
"x",
"for",
... | return a list of all classes in the given module
that dont begin with '_' | [
"return",
"a",
"list",
"of",
"all",
"classes",
"in",
"the",
"given",
"module",
"that",
"dont",
"begin",
"with",
"_"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L11-L18 |
243,816 | radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getAvailableClassesInPackage | def getAvailableClassesInPackage(package):
"""
return a list of all classes in the given package
whose modules dont begin with '_'
"""
l = list(x[1] for x in inspect.getmembers(package, inspect.isclass))
modules = list(x[1] for x in inspect.getmembers(package, inspect.ismodule))
for m in mo... | python | def getAvailableClassesInPackage(package):
"""
return a list of all classes in the given package
whose modules dont begin with '_'
"""
l = list(x[1] for x in inspect.getmembers(package, inspect.isclass))
modules = list(x[1] for x in inspect.getmembers(package, inspect.ismodule))
for m in mo... | [
"def",
"getAvailableClassesInPackage",
"(",
"package",
")",
":",
"l",
"=",
"list",
"(",
"x",
"[",
"1",
"]",
"for",
"x",
"in",
"inspect",
".",
"getmembers",
"(",
"package",
",",
"inspect",
".",
"isclass",
")",
")",
"modules",
"=",
"list",
"(",
"x",
"[... | return a list of all classes in the given package
whose modules dont begin with '_' | [
"return",
"a",
"list",
"of",
"all",
"classes",
"in",
"the",
"given",
"package",
"whose",
"modules",
"dont",
"begin",
"with",
"_"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L21-L39 |
243,817 | radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getClassInPackageFromName | def getClassInPackageFromName(className, pkg):
"""
get a class from name within a package
"""
# TODO: more efficiency!
n = getAvClassNamesInPackage(pkg)
i = n.index(className)
c = getAvailableClassesInPackage(pkg)
return c[i] | python | def getClassInPackageFromName(className, pkg):
"""
get a class from name within a package
"""
# TODO: more efficiency!
n = getAvClassNamesInPackage(pkg)
i = n.index(className)
c = getAvailableClassesInPackage(pkg)
return c[i] | [
"def",
"getClassInPackageFromName",
"(",
"className",
",",
"pkg",
")",
":",
"# TODO: more efficiency!",
"n",
"=",
"getAvClassNamesInPackage",
"(",
"pkg",
")",
"i",
"=",
"n",
".",
"index",
"(",
"className",
")",
"c",
"=",
"getAvailableClassesInPackage",
"(",
"pkg... | get a class from name within a package | [
"get",
"a",
"class",
"from",
"name",
"within",
"a",
"package"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L54-L62 |
243,818 | radjkarl/fancyTools | fancytools/pystructure/getMembers.py | getClassInModuleFromName | def getClassInModuleFromName(className, module):
"""
get a class from name within a module
"""
n = getAvClassNamesInModule(module)
i = n.index(className)
c = getAvailableClassesInModule(module)
return c[i] | python | def getClassInModuleFromName(className, module):
"""
get a class from name within a module
"""
n = getAvClassNamesInModule(module)
i = n.index(className)
c = getAvailableClassesInModule(module)
return c[i] | [
"def",
"getClassInModuleFromName",
"(",
"className",
",",
"module",
")",
":",
"n",
"=",
"getAvClassNamesInModule",
"(",
"module",
")",
"i",
"=",
"n",
".",
"index",
"(",
"className",
")",
"c",
"=",
"getAvailableClassesInModule",
"(",
"module",
")",
"return",
... | get a class from name within a module | [
"get",
"a",
"class",
"from",
"name",
"within",
"a",
"module"
] | 4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b | https://github.com/radjkarl/fancyTools/blob/4c4d961003dc4ed6e46429a0c24f7e2bb52caa8b/fancytools/pystructure/getMembers.py#L65-L72 |
243,819 | rikrd/inspire | inspirespeech/htk_model_utils.py | create_prototype | def create_prototype(sample_dimension,
parameter_kind_base='user',
parameter_kind_options=[],
state_stay_probabilities=[0.6, 0.6, 0.7]):
"""Create a prototype HTK model file using a feature file.
"""
parameter_kind = create_parameter_kind(base=p... | python | def create_prototype(sample_dimension,
parameter_kind_base='user',
parameter_kind_options=[],
state_stay_probabilities=[0.6, 0.6, 0.7]):
"""Create a prototype HTK model file using a feature file.
"""
parameter_kind = create_parameter_kind(base=p... | [
"def",
"create_prototype",
"(",
"sample_dimension",
",",
"parameter_kind_base",
"=",
"'user'",
",",
"parameter_kind_options",
"=",
"[",
"]",
",",
"state_stay_probabilities",
"=",
"[",
"0.6",
",",
"0.6",
",",
"0.7",
"]",
")",
":",
"parameter_kind",
"=",
"create_p... | Create a prototype HTK model file using a feature file. | [
"Create",
"a",
"prototype",
"HTK",
"model",
"file",
"using",
"a",
"feature",
"file",
"."
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk_model_utils.py#L140-L168 |
243,820 | rikrd/inspire | inspirespeech/htk_model_utils.py | map_hmms | def map_hmms(input_model, mapping):
"""Create a new HTK HMM model given a model and a mapping dictionary.
:param input_model: The model to transform of type dict
:param mapping: A dictionary from string -> list(string)
:return: The transformed model of type dict
"""
output_model = copy.copy(in... | python | def map_hmms(input_model, mapping):
"""Create a new HTK HMM model given a model and a mapping dictionary.
:param input_model: The model to transform of type dict
:param mapping: A dictionary from string -> list(string)
:return: The transformed model of type dict
"""
output_model = copy.copy(in... | [
"def",
"map_hmms",
"(",
"input_model",
",",
"mapping",
")",
":",
"output_model",
"=",
"copy",
".",
"copy",
"(",
"input_model",
")",
"o_hmms",
"=",
"[",
"]",
"for",
"i_hmm",
"in",
"input_model",
"[",
"'hmms'",
"]",
":",
"i_hmm_name",
"=",
"i_hmm",
"[",
... | Create a new HTK HMM model given a model and a mapping dictionary.
:param input_model: The model to transform of type dict
:param mapping: A dictionary from string -> list(string)
:return: The transformed model of type dict | [
"Create",
"a",
"new",
"HTK",
"HMM",
"model",
"given",
"a",
"model",
"and",
"a",
"mapping",
"dictionary",
"."
] | e281c0266a9a9633f34ab70f9c3ad58036c19b59 | https://github.com/rikrd/inspire/blob/e281c0266a9a9633f34ab70f9c3ad58036c19b59/inspirespeech/htk_model_utils.py#L185-L208 |
243,821 | fusionbox/django-decoratormixins | decoratormixins/__init__.py | DecoratorMixin | def DecoratorMixin(decorator):
"""
Converts a decorator written for a function view into a mixin for a
class-based view.
::
LoginRequiredMixin = DecoratorMixin(login_required)
class MyView(LoginRequiredMixin):
pass
class SomeView(DecoratorMixin(some_decorator),
... | python | def DecoratorMixin(decorator):
"""
Converts a decorator written for a function view into a mixin for a
class-based view.
::
LoginRequiredMixin = DecoratorMixin(login_required)
class MyView(LoginRequiredMixin):
pass
class SomeView(DecoratorMixin(some_decorator),
... | [
"def",
"DecoratorMixin",
"(",
"decorator",
")",
":",
"class",
"Mixin",
"(",
"object",
")",
":",
"__doc__",
"=",
"decorator",
".",
"__doc__",
"@",
"classmethod",
"def",
"as_view",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"view",
... | Converts a decorator written for a function view into a mixin for a
class-based view.
::
LoginRequiredMixin = DecoratorMixin(login_required)
class MyView(LoginRequiredMixin):
pass
class SomeView(DecoratorMixin(some_decorator),
DecoratorMixin(somethi... | [
"Converts",
"a",
"decorator",
"written",
"for",
"a",
"function",
"view",
"into",
"a",
"mixin",
"for",
"a",
"class",
"-",
"based",
"view",
"."
] | d1c9b193532d9904e288bb6471f2e7abc4a5b707 | https://github.com/fusionbox/django-decoratormixins/blob/d1c9b193532d9904e288bb6471f2e7abc4a5b707/decoratormixins/__init__.py#L3-L30 |
243,822 | mbodenhamer/syn | syn/base_utils/tree.py | seq_list_nested | def seq_list_nested(b, d, x=0, top_level=True):
'''
Create a nested list of iteratively increasing values.
b: branching factor
d: max depth
x: starting value (default = 0)
'''
x += 1
if d == 0:
ret = [x]
else:
val = x
ret = []
for i in range(b):
... | python | def seq_list_nested(b, d, x=0, top_level=True):
'''
Create a nested list of iteratively increasing values.
b: branching factor
d: max depth
x: starting value (default = 0)
'''
x += 1
if d == 0:
ret = [x]
else:
val = x
ret = []
for i in range(b):
... | [
"def",
"seq_list_nested",
"(",
"b",
",",
"d",
",",
"x",
"=",
"0",
",",
"top_level",
"=",
"True",
")",
":",
"x",
"+=",
"1",
"if",
"d",
"==",
"0",
":",
"ret",
"=",
"[",
"x",
"]",
"else",
":",
"val",
"=",
"x",
"ret",
"=",
"[",
"]",
"for",
"i... | Create a nested list of iteratively increasing values.
b: branching factor
d: max depth
x: starting value (default = 0) | [
"Create",
"a",
"nested",
"list",
"of",
"iteratively",
"increasing",
"values",
"."
] | aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258 | https://github.com/mbodenhamer/syn/blob/aeaa3ad8a49bac8f50cf89b6f1fe97ad43d1d258/syn/base_utils/tree.py#L4-L27 |
243,823 | rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | Opaque | def Opaque(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as a string.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']: return source.read()
data = StringIO.StringIO()
mimetools.decode(source, data, enc)
... | python | def Opaque(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as a string.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']: return source.read()
data = StringIO.StringIO()
mimetools.decode(source, data, enc)
... | [
"def",
"Opaque",
"(",
"uri",
",",
"tc",
",",
"ps",
",",
"*",
"*",
"keywords",
")",
":",
"source",
"=",
"urllib",
".",
"urlopen",
"(",
"uri",
",",
"*",
"*",
"keywords",
")",
"enc",
"=",
"source",
".",
"info",
"(",
")",
".",
"getencoding",
"(",
"... | Resolve a URI and return its content as a string. | [
"Resolve",
"a",
"URI",
"and",
"return",
"its",
"content",
"as",
"a",
"string",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L12-L21 |
243,824 | rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | XML | def XML(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as an XML DOM.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']:
data = source
else:
data = StringIO.StringIO()
mimetools.decode(so... | python | def XML(uri, tc, ps, **keywords):
'''Resolve a URI and return its content as an XML DOM.
'''
source = urllib.urlopen(uri, **keywords)
enc = source.info().getencoding()
if enc in ['7bit', '8bit', 'binary']:
data = source
else:
data = StringIO.StringIO()
mimetools.decode(so... | [
"def",
"XML",
"(",
"uri",
",",
"tc",
",",
"ps",
",",
"*",
"*",
"keywords",
")",
":",
"source",
"=",
"urllib",
".",
"urlopen",
"(",
"uri",
",",
"*",
"*",
"keywords",
")",
"enc",
"=",
"source",
".",
"info",
"(",
")",
".",
"getencoding",
"(",
")",... | Resolve a URI and return its content as an XML DOM. | [
"Resolve",
"a",
"URI",
"and",
"return",
"its",
"content",
"as",
"an",
"XML",
"DOM",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L24-L36 |
243,825 | rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | MIMEResolver.GetSOAPPart | def GetSOAPPart(self):
'''Get the SOAP body part.
'''
head, part = self.parts[0]
return StringIO.StringIO(part.getvalue()) | python | def GetSOAPPart(self):
'''Get the SOAP body part.
'''
head, part = self.parts[0]
return StringIO.StringIO(part.getvalue()) | [
"def",
"GetSOAPPart",
"(",
"self",
")",
":",
"head",
",",
"part",
"=",
"self",
".",
"parts",
"[",
"0",
"]",
"return",
"StringIO",
".",
"StringIO",
"(",
"part",
".",
"getvalue",
"(",
")",
")"
] | Get the SOAP body part. | [
"Get",
"the",
"SOAP",
"body",
"part",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L105-L109 |
243,826 | rameshg87/pyremotevbox | pyremotevbox/ZSI/resolvers.py | MIMEResolver.get | def get(self, uri):
'''Get the content for the bodypart identified by the uri.
'''
if uri.startswith('cid:'):
# Content-ID, so raise exception if not found.
head, part = self.id_dict[uri[4:]]
return StringIO.StringIO(part.getvalue())
if self.loc_dict.h... | python | def get(self, uri):
'''Get the content for the bodypart identified by the uri.
'''
if uri.startswith('cid:'):
# Content-ID, so raise exception if not found.
head, part = self.id_dict[uri[4:]]
return StringIO.StringIO(part.getvalue())
if self.loc_dict.h... | [
"def",
"get",
"(",
"self",
",",
"uri",
")",
":",
"if",
"uri",
".",
"startswith",
"(",
"'cid:'",
")",
":",
"# Content-ID, so raise exception if not found.",
"head",
",",
"part",
"=",
"self",
".",
"id_dict",
"[",
"uri",
"[",
"4",
":",
"]",
"]",
"return",
... | Get the content for the bodypart identified by the uri. | [
"Get",
"the",
"content",
"for",
"the",
"bodypart",
"identified",
"by",
"the",
"uri",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/resolvers.py#L111-L121 |
243,827 | ravenac95/lxc4u | lxc4u/meta.py | LXCMeta.load_from_file | def load_from_file(cls, file_path):
"""Load the meta data given a file_path or empty meta data"""
data = None
if os.path.exists(file_path):
metadata_file = open(file_path)
data = json.loads(metadata_file.read())
return cls(initial=data) | python | def load_from_file(cls, file_path):
"""Load the meta data given a file_path or empty meta data"""
data = None
if os.path.exists(file_path):
metadata_file = open(file_path)
data = json.loads(metadata_file.read())
return cls(initial=data) | [
"def",
"load_from_file",
"(",
"cls",
",",
"file_path",
")",
":",
"data",
"=",
"None",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"file_path",
")",
":",
"metadata_file",
"=",
"open",
"(",
"file_path",
")",
"data",
"=",
"json",
".",
"loads",
"(",
"me... | Load the meta data given a file_path or empty meta data | [
"Load",
"the",
"meta",
"data",
"given",
"a",
"file_path",
"or",
"empty",
"meta",
"data"
] | 4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32 | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/meta.py#L10-L16 |
243,828 | ravenac95/lxc4u | lxc4u/meta.py | LXCMeta.bind_and_save | def bind_and_save(self, lxc):
"""Binds metadata to an LXC and saves it"""
bound_meta = self.bind(lxc)
bound_meta.save()
return bound_meta | python | def bind_and_save(self, lxc):
"""Binds metadata to an LXC and saves it"""
bound_meta = self.bind(lxc)
bound_meta.save()
return bound_meta | [
"def",
"bind_and_save",
"(",
"self",
",",
"lxc",
")",
":",
"bound_meta",
"=",
"self",
".",
"bind",
"(",
"lxc",
")",
"bound_meta",
".",
"save",
"(",
")",
"return",
"bound_meta"
] | Binds metadata to an LXC and saves it | [
"Binds",
"metadata",
"to",
"an",
"LXC",
"and",
"saves",
"it"
] | 4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32 | https://github.com/ravenac95/lxc4u/blob/4b5a9c8e25af97e5637db2f4c0c67d319ab0ed32/lxc4u/meta.py#L41-L45 |
243,829 | jeroyang/txttk | txttk/report.py | Report.update | def update(self, report):
"""
Add the items from the given report.
"""
self.tp.extend(pack_boxes(report.tp, self.title))
self.fp.extend(pack_boxes(report.fp, self.title))
self.fn.extend(pack_boxes(report.fn, self.title)) | python | def update(self, report):
"""
Add the items from the given report.
"""
self.tp.extend(pack_boxes(report.tp, self.title))
self.fp.extend(pack_boxes(report.fp, self.title))
self.fn.extend(pack_boxes(report.fn, self.title)) | [
"def",
"update",
"(",
"self",
",",
"report",
")",
":",
"self",
".",
"tp",
".",
"extend",
"(",
"pack_boxes",
"(",
"report",
".",
"tp",
",",
"self",
".",
"title",
")",
")",
"self",
".",
"fp",
".",
"extend",
"(",
"pack_boxes",
"(",
"report",
".",
"f... | Add the items from the given report. | [
"Add",
"the",
"items",
"from",
"the",
"given",
"report",
"."
] | 8e6daf9cbb7dfbc4900870fb365add17929bd4ab | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/report.py#L117-L123 |
243,830 | jeroyang/txttk | txttk/report.py | Report.from_scale | def from_scale(cls, gold_number, precision, recall, title):
"""
deprecated, for backward compactbility
try to use from_score
"""
tp_count = get_numerator(recall, gold_number)
positive_count = get_denominator(precision, tp_count)
fp_count = positive_count - tp_coun... | python | def from_scale(cls, gold_number, precision, recall, title):
"""
deprecated, for backward compactbility
try to use from_score
"""
tp_count = get_numerator(recall, gold_number)
positive_count = get_denominator(precision, tp_count)
fp_count = positive_count - tp_coun... | [
"def",
"from_scale",
"(",
"cls",
",",
"gold_number",
",",
"precision",
",",
"recall",
",",
"title",
")",
":",
"tp_count",
"=",
"get_numerator",
"(",
"recall",
",",
"gold_number",
")",
"positive_count",
"=",
"get_denominator",
"(",
"precision",
",",
"tp_count",... | deprecated, for backward compactbility
try to use from_score | [
"deprecated",
"for",
"backward",
"compactbility",
"try",
"to",
"use",
"from_score"
] | 8e6daf9cbb7dfbc4900870fb365add17929bd4ab | https://github.com/jeroyang/txttk/blob/8e6daf9cbb7dfbc4900870fb365add17929bd4ab/txttk/report.py#L150-L163 |
243,831 | dossier/dossier.models | dossier/models/linker/worker.py | worker | def worker(work_unit):
'''Expects a WorkUnit from coordinated, obtains a config, and runs
traverse_extract_fetch
'''
if 'config' not in work_unit.spec:
raise coordinate.exceptions.ProgrammerError(
'could not run extraction without global config')
web_conf = Config()
unitcon... | python | def worker(work_unit):
'''Expects a WorkUnit from coordinated, obtains a config, and runs
traverse_extract_fetch
'''
if 'config' not in work_unit.spec:
raise coordinate.exceptions.ProgrammerError(
'could not run extraction without global config')
web_conf = Config()
unitcon... | [
"def",
"worker",
"(",
"work_unit",
")",
":",
"if",
"'config'",
"not",
"in",
"work_unit",
".",
"spec",
":",
"raise",
"coordinate",
".",
"exceptions",
".",
"ProgrammerError",
"(",
"'could not run extraction without global config'",
")",
"web_conf",
"=",
"Config",
"(... | Expects a WorkUnit from coordinated, obtains a config, and runs
traverse_extract_fetch | [
"Expects",
"a",
"WorkUnit",
"from",
"coordinated",
"obtains",
"a",
"config",
"and",
"runs",
"traverse_extract_fetch"
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L38-L52 |
243,832 | dossier/dossier.models | dossier/models/linker/worker.py | name_filter | def name_filter(keywords, names):
'''
Returns the first keyword from the list, unless
that keyword is one of the names in names, in which case
it continues to the next keyword.
Since keywords consists of tuples, it just returns the first
element of the tuple, the keyword. It also adds double
... | python | def name_filter(keywords, names):
'''
Returns the first keyword from the list, unless
that keyword is one of the names in names, in which case
it continues to the next keyword.
Since keywords consists of tuples, it just returns the first
element of the tuple, the keyword. It also adds double
... | [
"def",
"name_filter",
"(",
"keywords",
",",
"names",
")",
":",
"name_set",
"=",
"set",
"(",
"name",
".",
"lower",
"(",
")",
"for",
"name",
"in",
"names",
")",
"for",
"key_tuple",
"in",
"keywords",
":",
"if",
"not",
"key_tuple",
"[",
"0",
"]",
"in",
... | Returns the first keyword from the list, unless
that keyword is one of the names in names, in which case
it continues to the next keyword.
Since keywords consists of tuples, it just returns the first
element of the tuple, the keyword. It also adds double
quotes around the keywords, as is appropriat... | [
"Returns",
"the",
"first",
"keyword",
"from",
"the",
"list",
"unless",
"that",
"keyword",
"is",
"one",
"of",
"the",
"names",
"in",
"names",
"in",
"which",
"case",
"it",
"continues",
"to",
"the",
"next",
"keyword",
"."
] | c9e282f690eab72963926329efe1600709e48b13 | https://github.com/dossier/dossier.models/blob/c9e282f690eab72963926329efe1600709e48b13/dossier/models/linker/worker.py#L300-L321 |
243,833 | rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _resolve_prefix | def _resolve_prefix(celt, prefix):
'''resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
Parameters:
celt -- element node
prefix -- xmlns:prefix, or empty str or None
'''
namespace = None
while _is_element(celt):
if prefix:
... | python | def _resolve_prefix(celt, prefix):
'''resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
Parameters:
celt -- element node
prefix -- xmlns:prefix, or empty str or None
'''
namespace = None
while _is_element(celt):
if prefix:
... | [
"def",
"_resolve_prefix",
"(",
"celt",
",",
"prefix",
")",
":",
"namespace",
"=",
"None",
"while",
"_is_element",
"(",
"celt",
")",
":",
"if",
"prefix",
":",
"namespaceURI",
"=",
"_find_xmlns_prefix",
"(",
"celt",
",",
"prefix",
")",
"else",
":",
"namespac... | resolve prefix to a namespaceURI. If None or
empty str, return default namespace or None.
Parameters:
celt -- element node
prefix -- xmlns:prefix, or empty str or None | [
"resolve",
"prefix",
"to",
"a",
"namespaceURI",
".",
"If",
"None",
"or",
"empty",
"str",
"return",
"default",
"namespace",
"or",
"None",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L235-L254 |
243,834 | rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _valid_encoding | def _valid_encoding(elt):
'''Does this node have a valid encoding?
'''
enc = _find_encstyle(elt)
if not enc or enc == _SOAP.ENC: return 1
for e in enc.split():
if e.startswith(_SOAP.ENC):
# XXX Is this correct? Once we find a Sec5 compatible
# XXX encoding, should we... | python | def _valid_encoding(elt):
'''Does this node have a valid encoding?
'''
enc = _find_encstyle(elt)
if not enc or enc == _SOAP.ENC: return 1
for e in enc.split():
if e.startswith(_SOAP.ENC):
# XXX Is this correct? Once we find a Sec5 compatible
# XXX encoding, should we... | [
"def",
"_valid_encoding",
"(",
"elt",
")",
":",
"enc",
"=",
"_find_encstyle",
"(",
"elt",
")",
"if",
"not",
"enc",
"or",
"enc",
"==",
"_SOAP",
".",
"ENC",
":",
"return",
"1",
"for",
"e",
"in",
"enc",
".",
"split",
"(",
")",
":",
"if",
"e",
".",
... | Does this node have a valid encoding? | [
"Does",
"this",
"node",
"have",
"a",
"valid",
"encoding?"
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L256-L268 |
243,835 | rameshg87/pyremotevbox | pyremotevbox/ZSI/__init__.py | _backtrace | def _backtrace(elt, dom):
'''Return a "backtrace" from the given element to the DOM root,
in XPath syntax.
'''
s = ''
while elt != dom:
name, parent = elt.nodeName, elt.parentNode
if parent is None: break
matches = [ c for c in _child_elements(parent)
... | python | def _backtrace(elt, dom):
'''Return a "backtrace" from the given element to the DOM root,
in XPath syntax.
'''
s = ''
while elt != dom:
name, parent = elt.nodeName, elt.parentNode
if parent is None: break
matches = [ c for c in _child_elements(parent)
... | [
"def",
"_backtrace",
"(",
"elt",
",",
"dom",
")",
":",
"s",
"=",
"''",
"while",
"elt",
"!=",
"dom",
":",
"name",
",",
"parent",
"=",
"elt",
".",
"nodeName",
",",
"elt",
".",
"parentNode",
"if",
"parent",
"is",
"None",
":",
"break",
"matches",
"=",
... | Return a "backtrace" from the given element to the DOM root,
in XPath syntax. | [
"Return",
"a",
"backtrace",
"from",
"the",
"given",
"element",
"to",
"the",
"DOM",
"root",
"in",
"XPath",
"syntax",
"."
] | 123dffff27da57c8faa3ac1dd4c68b1cf4558b1a | https://github.com/rameshg87/pyremotevbox/blob/123dffff27da57c8faa3ac1dd4c68b1cf4558b1a/pyremotevbox/ZSI/__init__.py#L270-L286 |
243,836 | sarenji/pyrc | pyrc/bots.py | Bot.connect | def connect(self):
'''
Connects to the IRC server with the options defined in `config`
'''
self._connect()
try:
self._listen()
except (KeyboardInterrupt, SystemExit):
pass
finally:
self.close() | python | def connect(self):
'''
Connects to the IRC server with the options defined in `config`
'''
self._connect()
try:
self._listen()
except (KeyboardInterrupt, SystemExit):
pass
finally:
self.close() | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_connect",
"(",
")",
"try",
":",
"self",
".",
"_listen",
"(",
")",
"except",
"(",
"KeyboardInterrupt",
",",
"SystemExit",
")",
":",
"pass",
"finally",
":",
"self",
".",
"close",
"(",
")"
] | Connects to the IRC server with the options defined in `config` | [
"Connects",
"to",
"the",
"IRC",
"server",
"with",
"the",
"options",
"defined",
"in",
"config"
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L43-L54 |
243,837 | sarenji/pyrc | pyrc/bots.py | Bot._listen | def _listen(self):
"""
Constantly listens to the input from the server. Since the messages come
in pieces, we wait until we receive 1 or more full lines to start parsing.
A new line is defined as ending in \r\n in the RFC, but some servers
separate by \n. This script takes care ... | python | def _listen(self):
"""
Constantly listens to the input from the server. Since the messages come
in pieces, we wait until we receive 1 or more full lines to start parsing.
A new line is defined as ending in \r\n in the RFC, but some servers
separate by \n. This script takes care ... | [
"def",
"_listen",
"(",
"self",
")",
":",
"while",
"True",
":",
"self",
".",
"_inbuffer",
"=",
"self",
".",
"_inbuffer",
"+",
"self",
".",
"socket",
".",
"recv",
"(",
"1024",
")",
"# Some IRC servers disregard the RFC and split lines by \\n rather than \\r\\n.",
"t... | Constantly listens to the input from the server. Since the messages come
in pieces, we wait until we receive 1 or more full lines to start parsing.
A new line is defined as ending in \r\n in the RFC, but some servers
separate by \n. This script takes care of both. | [
"Constantly",
"listens",
"to",
"the",
"input",
"from",
"the",
"server",
".",
"Since",
"the",
"messages",
"come",
"in",
"pieces",
"we",
"wait",
"until",
"we",
"receive",
"1",
"or",
"more",
"full",
"lines",
"to",
"start",
"parsing",
"."
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L62-L81 |
243,838 | sarenji/pyrc | pyrc/bots.py | Bot._run_listeners | def _run_listeners(self, line):
"""
Each listener's associated regular expression is matched against raw IRC
input. If there is a match, the listener's associated function is called
with all the regular expression's matched subgroups.
"""
for regex, callbacks in self.list... | python | def _run_listeners(self, line):
"""
Each listener's associated regular expression is matched against raw IRC
input. If there is a match, the listener's associated function is called
with all the regular expression's matched subgroups.
"""
for regex, callbacks in self.list... | [
"def",
"_run_listeners",
"(",
"self",
",",
"line",
")",
":",
"for",
"regex",
",",
"callbacks",
"in",
"self",
".",
"listeners",
".",
"iteritems",
"(",
")",
":",
"match",
"=",
"regex",
".",
"match",
"(",
"line",
")",
"if",
"not",
"match",
":",
"continu... | Each listener's associated regular expression is matched against raw IRC
input. If there is a match, the listener's associated function is called
with all the regular expression's matched subgroups. | [
"Each",
"listener",
"s",
"associated",
"regular",
"expression",
"is",
"matched",
"against",
"raw",
"IRC",
"input",
".",
"If",
"there",
"is",
"a",
"match",
"the",
"listener",
"s",
"associated",
"function",
"is",
"called",
"with",
"all",
"the",
"regular",
"exp... | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L83-L96 |
243,839 | sarenji/pyrc | pyrc/bots.py | Bot._strip_prefix | def _strip_prefix(self, message):
"""
Checks if the bot was called by a user.
Returns the suffix if so.
Prefixes include the bot's nick as well as a set symbol.
"""
if not hasattr(self, "name_regex"):
"""
regex example:
^(((BotA|BotB)... | python | def _strip_prefix(self, message):
"""
Checks if the bot was called by a user.
Returns the suffix if so.
Prefixes include the bot's nick as well as a set symbol.
"""
if not hasattr(self, "name_regex"):
"""
regex example:
^(((BotA|BotB)... | [
"def",
"_strip_prefix",
"(",
"self",
",",
"message",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"name_regex\"",
")",
":",
"\"\"\"\n regex example:\n ^(((BotA|BotB)[,:]?\\s+)|%)(.+)$\n \n names = [BotA, BotB]\n prefix... | Checks if the bot was called by a user.
Returns the suffix if so.
Prefixes include the bot's nick as well as a set symbol. | [
"Checks",
"if",
"the",
"bot",
"was",
"called",
"by",
"a",
"user",
".",
"Returns",
"the",
"suffix",
"if",
"so",
"."
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L144-L171 |
243,840 | sarenji/pyrc | pyrc/bots.py | Bot._connect | def _connect(self):
"Connects a socket to the server using options defined in `config`."
self.socket = socket.socket()
self.socket.connect((self.config['host'], self.config['port']))
self.cmd("NICK %s" % self.config['nick'])
self.cmd("USER %s %s bla :%s" %
(self.c... | python | def _connect(self):
"Connects a socket to the server using options defined in `config`."
self.socket = socket.socket()
self.socket.connect((self.config['host'], self.config['port']))
self.cmd("NICK %s" % self.config['nick'])
self.cmd("USER %s %s bla :%s" %
(self.c... | [
"def",
"_connect",
"(",
"self",
")",
":",
"self",
".",
"socket",
"=",
"socket",
".",
"socket",
"(",
")",
"self",
".",
"socket",
".",
"connect",
"(",
"(",
"self",
".",
"config",
"[",
"'host'",
"]",
",",
"self",
".",
"config",
"[",
"'port'",
"]",
"... | Connects a socket to the server using options defined in `config`. | [
"Connects",
"a",
"socket",
"to",
"the",
"server",
"using",
"options",
"defined",
"in",
"config",
"."
] | 5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68 | https://github.com/sarenji/pyrc/blob/5e8377ddcda6e0ef4ba7d66cf400e243b1fb8f68/pyrc/bots.py#L173-L179 |
243,841 | sampottinger/pycotracer | pycotracer/report_interpreters.py | interpret_contribution_entry | def interpret_contribution_entry(entry):
"""Interpret data fields within a CO-TRACER contributions report.
Interpret the contribution amount, contribution date, filed date, amended,
and amendment fields of the provided entry. All dates (contribution and
filed) are interpreted together and, if any fails... | python | def interpret_contribution_entry(entry):
"""Interpret data fields within a CO-TRACER contributions report.
Interpret the contribution amount, contribution date, filed date, amended,
and amendment fields of the provided entry. All dates (contribution and
filed) are interpreted together and, if any fails... | [
"def",
"interpret_contribution_entry",
"(",
"entry",
")",
":",
"try",
":",
"new_contribution_amount",
"=",
"float",
"(",
"entry",
"[",
"'ContributionAmount'",
"]",
")",
"entry",
"[",
"'AmountsInterpreted'",
"]",
"=",
"True",
"entry",
"[",
"'ContributionAmount'",
"... | Interpret data fields within a CO-TRACER contributions report.
Interpret the contribution amount, contribution date, filed date, amended,
and amendment fields of the provided entry. All dates (contribution and
filed) are interpreted together and, if any fails, all will retain their
original value. Like... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"contributions",
"report",
"."
] | c66c3230949b7bee8c9fec5fc00ab392865a0c8b | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L54-L119 |
243,842 | sampottinger/pycotracer | pycotracer/report_interpreters.py | interpret_expenditure_entry | def interpret_expenditure_entry(entry):
"""Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all w... | python | def interpret_expenditure_entry(entry):
"""Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all w... | [
"def",
"interpret_expenditure_entry",
"(",
"entry",
")",
":",
"try",
":",
"expenditure_amount",
"=",
"float",
"(",
"entry",
"[",
"'ExpenditureAmount'",
"]",
")",
"entry",
"[",
"'AmountsInterpreted'",
"]",
"=",
"True",
"entry",
"[",
"'ExpenditureAmount'",
"]",
"=... | Interpret data fields within a CO-TRACER expediture report.
Interpret the expenditure amount, expenditure date, filed date, amended,
and amendment fields of the provided entry. All dates (expenditure and
filed) are interpreted together and, if any fails, all will retain their
original value. Likewise, ... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"expediture",
"report",
"."
] | c66c3230949b7bee8c9fec5fc00ab392865a0c8b | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L156-L209 |
243,843 | sampottinger/pycotracer | pycotracer/report_interpreters.py | interpret_loan_entry | def interpret_loan_entry(entry):
"""Interpret data fields within a CO-TRACER loan report.
Interpret the payment amount, loan amount, interest rate, interest payment,
loan balance, payment date, filed date, loan date, amended, and amendment
fields of the provided entry. All dates (payment, filed, and lo... | python | def interpret_loan_entry(entry):
"""Interpret data fields within a CO-TRACER loan report.
Interpret the payment amount, loan amount, interest rate, interest payment,
loan balance, payment date, filed date, loan date, amended, and amendment
fields of the provided entry. All dates (payment, filed, and lo... | [
"def",
"interpret_loan_entry",
"(",
"entry",
")",
":",
"try",
":",
"payment_amount",
"=",
"float",
"(",
"entry",
"[",
"'PaymentAmount'",
"]",
")",
"loan_amount",
"=",
"float",
"(",
"entry",
"[",
"'LoanAmount'",
"]",
")",
"interest_rate",
"=",
"float",
"(",
... | Interpret data fields within a CO-TRACER loan report.
Interpret the payment amount, loan amount, interest rate, interest payment,
loan balance, payment date, filed date, loan date, amended, and amendment
fields of the provided entry. All dates (payment, filed, and loan) are
interpreted together and, if... | [
"Interpret",
"data",
"fields",
"within",
"a",
"CO",
"-",
"TRACER",
"loan",
"report",
"."
] | c66c3230949b7bee8c9fec5fc00ab392865a0c8b | https://github.com/sampottinger/pycotracer/blob/c66c3230949b7bee8c9fec5fc00ab392865a0c8b/pycotracer/report_interpreters.py#L246-L315 |
243,844 | RonenNess/Fileter | fileter/iterators/add_header.py | AddHeader.process_file | def process_file(self, path, dryrun):
"""
Add header to all files.
"""
if dryrun:
return path
# get file's current header
with open(path, "r") as infile:
head = infile.read(len(self.__header))
# normalize line breaks
if self.__nor... | python | def process_file(self, path, dryrun):
"""
Add header to all files.
"""
if dryrun:
return path
# get file's current header
with open(path, "r") as infile:
head = infile.read(len(self.__header))
# normalize line breaks
if self.__nor... | [
"def",
"process_file",
"(",
"self",
",",
"path",
",",
"dryrun",
")",
":",
"if",
"dryrun",
":",
"return",
"path",
"# get file's current header",
"with",
"open",
"(",
"path",
",",
"\"r\"",
")",
"as",
"infile",
":",
"head",
"=",
"infile",
".",
"read",
"(",
... | Add header to all files. | [
"Add",
"header",
"to",
"all",
"files",
"."
] | 5372221b4049d5d46a9926573b91af17681c81f3 | https://github.com/RonenNess/Fileter/blob/5372221b4049d5d46a9926573b91af17681c81f3/fileter/iterators/add_header.py#L40-L63 |
243,845 | ppo/django-guitar | guitar/utils/admin.py | csv_list | def csv_list(models, attr, link=False, separator=", "):
"""Return a comma-separated list of models, optionaly with a link."""
values = []
for model in models:
value = getattr(model, attr)
if link and hasattr(model, "get_admin_url") and callable(model.get_admin_url):
value = get_a... | python | def csv_list(models, attr, link=False, separator=", "):
"""Return a comma-separated list of models, optionaly with a link."""
values = []
for model in models:
value = getattr(model, attr)
if link and hasattr(model, "get_admin_url") and callable(model.get_admin_url):
value = get_a... | [
"def",
"csv_list",
"(",
"models",
",",
"attr",
",",
"link",
"=",
"False",
",",
"separator",
"=",
"\", \"",
")",
":",
"values",
"=",
"[",
"]",
"for",
"model",
"in",
"models",
":",
"value",
"=",
"getattr",
"(",
"model",
",",
"attr",
")",
"if",
"link"... | Return a comma-separated list of models, optionaly with a link. | [
"Return",
"a",
"comma",
"-",
"separated",
"list",
"of",
"models",
"optionaly",
"with",
"a",
"link",
"."
] | 857282219c0c4ff5907c3ad04ef012281d245348 | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L15-L23 |
243,846 | ppo/django-guitar | guitar/utils/admin.py | get_admin_url | def get_admin_url(obj, page=None):
"""Return the URL to admin pages for this object."""
if obj is None:
return None
if page is None:
page = "change"
if page not in ADMIN_ALL_PAGES:
raise ValueError("Invalid page name '{}'. Available pages are: {}.".format(page, ADMIN_ALL_PAGES))... | python | def get_admin_url(obj, page=None):
"""Return the URL to admin pages for this object."""
if obj is None:
return None
if page is None:
page = "change"
if page not in ADMIN_ALL_PAGES:
raise ValueError("Invalid page name '{}'. Available pages are: {}.".format(page, ADMIN_ALL_PAGES))... | [
"def",
"get_admin_url",
"(",
"obj",
",",
"page",
"=",
"None",
")",
":",
"if",
"obj",
"is",
"None",
":",
"return",
"None",
"if",
"page",
"is",
"None",
":",
"page",
"=",
"\"change\"",
"if",
"page",
"not",
"in",
"ADMIN_ALL_PAGES",
":",
"raise",
"ValueErro... | Return the URL to admin pages for this object. | [
"Return",
"the",
"URL",
"to",
"admin",
"pages",
"for",
"this",
"object",
"."
] | 857282219c0c4ff5907c3ad04ef012281d245348 | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L26-L54 |
243,847 | ppo/django-guitar | guitar/utils/admin.py | get_fieldset_index | def get_fieldset_index(fieldsets, index_or_name):
"""
Return the index of a fieldset in the ``fieldsets`` list.
Args:
fieldsets (list): The original ``fieldsets`` list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int)... | python | def get_fieldset_index(fieldsets, index_or_name):
"""
Return the index of a fieldset in the ``fieldsets`` list.
Args:
fieldsets (list): The original ``fieldsets`` list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int)... | [
"def",
"get_fieldset_index",
"(",
"fieldsets",
",",
"index_or_name",
")",
":",
"if",
"isinstance",
"(",
"index_or_name",
",",
"six",
".",
"integer_types",
")",
":",
"return",
"index_or_name",
"for",
"key",
",",
"value",
"in",
"enumerate",
"(",
"fieldsets",
")"... | Return the index of a fieldset in the ``fieldsets`` list.
Args:
fieldsets (list): The original ``fieldsets`` list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the fieldset in the ``fieldsets`` list. | [
"Return",
"the",
"index",
"of",
"a",
"fieldset",
"in",
"the",
"fieldsets",
"list",
"."
] | 857282219c0c4ff5907c3ad04ef012281d245348 | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L93-L111 |
243,848 | ppo/django-guitar | guitar/utils/admin.py | get_list_index | def get_list_index(lst, index_or_name):
"""
Return the index of an element in the list.
Args:
lst (list): The list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the element in the list.
"""
if... | python | def get_list_index(lst, index_or_name):
"""
Return the index of an element in the list.
Args:
lst (list): The list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the element in the list.
"""
if... | [
"def",
"get_list_index",
"(",
"lst",
",",
"index_or_name",
")",
":",
"if",
"isinstance",
"(",
"index_or_name",
",",
"six",
".",
"integer_types",
")",
":",
"return",
"index_or_name",
"return",
"lst",
".",
"index",
"(",
"index_or_name",
")"
] | Return the index of an element in the list.
Args:
lst (list): The list.
index_or_name (int or str): The value of the reference element, or directly its numeric index.
Returns:
(int) The index of the element in the list. | [
"Return",
"the",
"index",
"of",
"an",
"element",
"in",
"the",
"list",
"."
] | 857282219c0c4ff5907c3ad04ef012281d245348 | https://github.com/ppo/django-guitar/blob/857282219c0c4ff5907c3ad04ef012281d245348/guitar/utils/admin.py#L114-L128 |
243,849 | pip-services3-python/pip-services3-components-python | pip_services3_components/cache/CacheEntry.py | CacheEntry.set_value | def set_value(self, value, timeout):
"""
Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds.
"""
self.value = value
self.expiration = time.perf_counter() * 1000 + timeout | python | def set_value(self, value, timeout):
"""
Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds.
"""
self.value = value
self.expiration = time.perf_counter() * 1000 + timeout | [
"def",
"set_value",
"(",
"self",
",",
"value",
",",
"timeout",
")",
":",
"self",
".",
"value",
"=",
"value",
"self",
".",
"expiration",
"=",
"time",
".",
"perf_counter",
"(",
")",
"*",
"1000",
"+",
"timeout"
] | Sets a new value and extends its expiration.
:param value: a new cached value.
:param timeout: a expiration timeout in milliseconds. | [
"Sets",
"a",
"new",
"value",
"and",
"extends",
"its",
"expiration",
"."
] | 1de9c1bb544cf1891111e9a5f5d67653f62c9b52 | https://github.com/pip-services3-python/pip-services3-components-python/blob/1de9c1bb544cf1891111e9a5f5d67653f62c9b52/pip_services3_components/cache/CacheEntry.py#L36-L45 |
243,850 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | _generate_password | def _generate_password():
"""Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password
"""
uuid_str = six.text_type(uuid.uuid4()).encode("UTF-8")
ret... | python | def _generate_password():
"""Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password
"""
uuid_str = six.text_type(uuid.uuid4()).encode("UTF-8")
ret... | [
"def",
"_generate_password",
"(",
")",
":",
"uuid_str",
"=",
"six",
".",
"text_type",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
".",
"encode",
"(",
"\"UTF-8\"",
")",
"return",
"hashlib",
".",
"sha1",
"(",
"uuid_str",
")",
".",
"hexdigest",
"(",
")"
] | Create a random password
The password is made by taking a uuid and passing it though sha1sum.
We may change this in future to gain more entropy.
This is based on the tripleo command os-make-password | [
"Create",
"a",
"random",
"password"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L51-L60 |
243,851 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | generate_overcloud_passwords | def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
"""Create the passwords needed for the overcloud
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords. If the
file already exists the existing... | python | def generate_overcloud_passwords(output_file="tripleo-overcloud-passwords"):
"""Create the passwords needed for the overcloud
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords. If the
file already exists the existing... | [
"def",
"generate_overcloud_passwords",
"(",
"output_file",
"=",
"\"tripleo-overcloud-passwords\"",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"output_file",
")",
":",
"with",
"open",
"(",
"output_file",
")",
"as",
"f",
":",
"return",
"dict",
"(",
... | Create the passwords needed for the overcloud
This will create the set of passwords required by the overcloud, store
them in the output file path and return a dictionary of passwords. If the
file already exists the existing passwords will be returned instead, | [
"Create",
"the",
"passwords",
"needed",
"for",
"the",
"overcloud"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L63-L97 |
243,852 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | check_hypervisor_stats | def check_hypervisor_stats(compute_client, nodes=1, memory=0, vcpu=0):
"""Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type... | python | def check_hypervisor_stats(compute_client, nodes=1, memory=0, vcpu=0):
"""Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type... | [
"def",
"check_hypervisor_stats",
"(",
"compute_client",
",",
"nodes",
"=",
"1",
",",
"memory",
"=",
"0",
",",
"vcpu",
"=",
"0",
")",
":",
"statistics",
"=",
"compute_client",
".",
"hypervisors",
".",
"statistics",
"(",
")",
".",
"to_dict",
"(",
")",
"if"... | Check the Hypervisor stats meet a minimum value
Check the hypervisor stats match the required counts. This is an
implementation of a command in TripleO with the same name.
:param compute_client: Instance of Nova client
:type compute_client: novaclient.client.v2.Client
:param nodes: The number of... | [
"Check",
"the",
"Hypervisor",
"stats",
"meet",
"a",
"minimum",
"value"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L100-L126 |
243,853 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | wait_for_stack_ready | def wait_for_stack_ready(orchestration_client, stack_name):
"""Check the status of an orchestration stack
Get the status of an orchestration stack and check whether it is complete
or failed.
:param orchestration_client: Instance of Orchestration client
:type orchestration_client: heatclient.v1.cl... | python | def wait_for_stack_ready(orchestration_client, stack_name):
"""Check the status of an orchestration stack
Get the status of an orchestration stack and check whether it is complete
or failed.
:param orchestration_client: Instance of Orchestration client
:type orchestration_client: heatclient.v1.cl... | [
"def",
"wait_for_stack_ready",
"(",
"orchestration_client",
",",
"stack_name",
")",
":",
"SUCCESSFUL_MATCH_OUTPUT",
"=",
"\"(CREATE|UPDATE)_COMPLETE\"",
"FAIL_MATCH_OUTPUT",
"=",
"\"(CREATE|UPDATE)_FAILED\"",
"while",
"True",
":",
"stack",
"=",
"orchestration_client",
".",
... | Check the status of an orchestration stack
Get the status of an orchestration stack and check whether it is complete
or failed.
:param orchestration_client: Instance of Orchestration client
:type orchestration_client: heatclient.v1.client.Client
:param stack_name: Name or UUID of stack to retrie... | [
"Check",
"the",
"status",
"of",
"an",
"orchestration",
"stack"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L129-L159 |
243,854 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | wait_for_provision_state | def wait_for_provision_state(baremetal_client, node_uuid, provision_state,
loops=10, sleep=1):
"""Wait for a given Provisioning state in Ironic Discoverd
Updating the provisioning state is an async operation, we
need to wait for it to be completed.
:param baremetal_client:... | python | def wait_for_provision_state(baremetal_client, node_uuid, provision_state,
loops=10, sleep=1):
"""Wait for a given Provisioning state in Ironic Discoverd
Updating the provisioning state is an async operation, we
need to wait for it to be completed.
:param baremetal_client:... | [
"def",
"wait_for_provision_state",
"(",
"baremetal_client",
",",
"node_uuid",
",",
"provision_state",
",",
"loops",
"=",
"10",
",",
"sleep",
"=",
"1",
")",
":",
"for",
"_",
"in",
"range",
"(",
"0",
",",
"loops",
")",
":",
"node",
"=",
"baremetal_client",
... | Wait for a given Provisioning state in Ironic Discoverd
Updating the provisioning state is an async operation, we
need to wait for it to be completed.
:param baremetal_client: Instance of Ironic client
:type baremetal_client: ironicclient.v1.client.Client
:param node_uuid: The Ironic node UUID
... | [
"Wait",
"for",
"a",
"given",
"Provisioning",
"state",
"in",
"Ironic",
"Discoverd"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L162-L199 |
243,855 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | wait_for_node_discovery | def wait_for_node_discovery(discoverd_client, auth_token, discoverd_url,
node_uuids, loops=220, sleep=10):
"""Check the status of Node discovery in Ironic discoverd
Gets the status and waits for them to complete.
:param discoverd_client: Ironic Discoverd client
:type disco... | python | def wait_for_node_discovery(discoverd_client, auth_token, discoverd_url,
node_uuids, loops=220, sleep=10):
"""Check the status of Node discovery in Ironic discoverd
Gets the status and waits for them to complete.
:param discoverd_client: Ironic Discoverd client
:type disco... | [
"def",
"wait_for_node_discovery",
"(",
"discoverd_client",
",",
"auth_token",
",",
"discoverd_url",
",",
"node_uuids",
",",
"loops",
"=",
"220",
",",
"sleep",
"=",
"10",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
"+",
"\".wait_for_node... | Check the status of Node discovery in Ironic discoverd
Gets the status and waits for them to complete.
:param discoverd_client: Ironic Discoverd client
:type discoverd_client: ironic_discoverd.client
:param auth_token: Authorisation token used by discoverd client
:type auth_token: string
:p... | [
"Check",
"the",
"status",
"of",
"Node",
"discovery",
"in",
"Ironic",
"discoverd"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L202-L251 |
243,856 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | create_environment_file | def create_environment_file(path="~/overcloud-env.json",
control_scale=1, compute_scale=1,
ceph_storage_scale=0, block_storage_scale=0,
swift_storage_scale=0):
"""Create a heat environment file
Create the heat environment file ... | python | def create_environment_file(path="~/overcloud-env.json",
control_scale=1, compute_scale=1,
ceph_storage_scale=0, block_storage_scale=0,
swift_storage_scale=0):
"""Create a heat environment file
Create the heat environment file ... | [
"def",
"create_environment_file",
"(",
"path",
"=",
"\"~/overcloud-env.json\"",
",",
"control_scale",
"=",
"1",
",",
"compute_scale",
"=",
"1",
",",
"ceph_storage_scale",
"=",
"0",
",",
"block_storage_scale",
"=",
"0",
",",
"swift_storage_scale",
"=",
"0",
")",
... | Create a heat environment file
Create the heat environment file with the scale parameters.
:param control_scale: Scale value for control roles.
:type control_scale: int
:param compute_scale: Scale value for compute roles.
:type compute_scale: int
:param ceph_storage_scale: Scale value for ce... | [
"Create",
"a",
"heat",
"environment",
"file"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L254-L289 |
243,857 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | set_nodes_state | def set_nodes_state(baremetal_client, nodes, transition, target_state,
skipped_states=()):
"""Make all nodes available in the baremetal service for a deployment
For each node, make it available unless it is already available or active.
Available nodes can be used for a deployment and an... | python | def set_nodes_state(baremetal_client, nodes, transition, target_state,
skipped_states=()):
"""Make all nodes available in the baremetal service for a deployment
For each node, make it available unless it is already available or active.
Available nodes can be used for a deployment and an... | [
"def",
"set_nodes_state",
"(",
"baremetal_client",
",",
"nodes",
",",
"transition",
",",
"target_state",
",",
"skipped_states",
"=",
"(",
")",
")",
":",
"log",
"=",
"logging",
".",
"getLogger",
"(",
"__name__",
"+",
"\".set_nodes_state\"",
")",
"for",
"node",
... | Make all nodes available in the baremetal service for a deployment
For each node, make it available unless it is already available or active.
Available nodes can be used for a deployment and an active node is already
in use.
:param baremetal_client: Instance of Ironic client
:type baremetal_clien... | [
"Make",
"all",
"nodes",
"available",
"in",
"the",
"baremetal",
"service",
"for",
"a",
"deployment"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L292-L338 |
243,858 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | get_hiera_key | def get_hiera_key(key_name):
"""Retrieve a key from the hiera store
:param password_name: Name of the key to retrieve
:type password_name: type
"""
command = ["hiera", key_name]
p = subprocess.Popen(command, stdout=subprocess.PIPE)
out, err = p.communicate()
return out | python | def get_hiera_key(key_name):
"""Retrieve a key from the hiera store
:param password_name: Name of the key to retrieve
:type password_name: type
"""
command = ["hiera", key_name]
p = subprocess.Popen(command, stdout=subprocess.PIPE)
out, err = p.communicate()
return out | [
"def",
"get_hiera_key",
"(",
"key_name",
")",
":",
"command",
"=",
"[",
"\"hiera\"",
",",
"key_name",
"]",
"p",
"=",
"subprocess",
".",
"Popen",
"(",
"command",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
")",
"out",
",",
"err",
"=",
"p",
".",
"co... | Retrieve a key from the hiera store
:param password_name: Name of the key to retrieve
:type password_name: type | [
"Retrieve",
"a",
"key",
"from",
"the",
"hiera",
"store"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L341-L351 |
243,859 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | remove_known_hosts | def remove_known_hosts(overcloud_ip):
"""For a given IP address remove SSH keys from the known_hosts file"""
known_hosts = os.path.expanduser("~/.ssh/known_hosts")
if os.path.exists(known_hosts):
command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts]
subprocess.check_call(command) | python | def remove_known_hosts(overcloud_ip):
"""For a given IP address remove SSH keys from the known_hosts file"""
known_hosts = os.path.expanduser("~/.ssh/known_hosts")
if os.path.exists(known_hosts):
command = ['ssh-keygen', '-R', overcloud_ip, '-f', known_hosts]
subprocess.check_call(command) | [
"def",
"remove_known_hosts",
"(",
"overcloud_ip",
")",
":",
"known_hosts",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"\"~/.ssh/known_hosts\"",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"known_hosts",
")",
":",
"command",
"=",
"[",
"'ssh-keygen'... | For a given IP address remove SSH keys from the known_hosts file | [
"For",
"a",
"given",
"IP",
"address",
"remove",
"SSH",
"keys",
"from",
"the",
"known_hosts",
"file"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L361-L368 |
243,860 | rdo-management/python-rdomanager-oscplugin | rdomanager_oscplugin/utils.py | file_checksum | def file_checksum(filepath):
"""Calculate md5 checksum on file
:param filepath: Full path to file (e.g. /home/stack/image.qcow2)
:type filepath: string
"""
checksum = hashlib.md5()
with open(filepath, 'rb') as f:
for fragment in iter(lambda: f.read(65536), ''):
checksum.up... | python | def file_checksum(filepath):
"""Calculate md5 checksum on file
:param filepath: Full path to file (e.g. /home/stack/image.qcow2)
:type filepath: string
"""
checksum = hashlib.md5()
with open(filepath, 'rb') as f:
for fragment in iter(lambda: f.read(65536), ''):
checksum.up... | [
"def",
"file_checksum",
"(",
"filepath",
")",
":",
"checksum",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"filepath",
",",
"'rb'",
")",
"as",
"f",
":",
"for",
"fragment",
"in",
"iter",
"(",
"lambda",
":",
"f",
".",
"read",
"(",
"655... | Calculate md5 checksum on file
:param filepath: Full path to file (e.g. /home/stack/image.qcow2)
:type filepath: string | [
"Calculate",
"md5",
"checksum",
"on",
"file"
] | 165a166fb2e5a2598380779b35812b8b8478c4fb | https://github.com/rdo-management/python-rdomanager-oscplugin/blob/165a166fb2e5a2598380779b35812b8b8478c4fb/rdomanager_oscplugin/utils.py#L388-L399 |
243,861 | lsst-sqre/BitlyOAuth2ProxySession | examples/example.py | main | def main():
"""Do the thing"""
username = os.environ["GITHUB_USERNAME"]
password = os.environ["GITHUB_PASSWORD"]
# Unless you have an LSST account you'd want to change these
baseurl = "https://logging.lsst.codes/oauth2/start"
authpage = "https://logging.lsst.codes/app/kibana"
session = bses.... | python | def main():
"""Do the thing"""
username = os.environ["GITHUB_USERNAME"]
password = os.environ["GITHUB_PASSWORD"]
# Unless you have an LSST account you'd want to change these
baseurl = "https://logging.lsst.codes/oauth2/start"
authpage = "https://logging.lsst.codes/app/kibana"
session = bses.... | [
"def",
"main",
"(",
")",
":",
"username",
"=",
"os",
".",
"environ",
"[",
"\"GITHUB_USERNAME\"",
"]",
"password",
"=",
"os",
".",
"environ",
"[",
"\"GITHUB_PASSWORD\"",
"]",
"# Unless you have an LSST account you'd want to change these",
"baseurl",
"=",
"\"https://log... | Do the thing | [
"Do",
"the",
"thing"
] | 4d3839cfb9b897f46cffc41a5f6ff7c645a5f202 | https://github.com/lsst-sqre/BitlyOAuth2ProxySession/blob/4d3839cfb9b897f46cffc41a5f6ff7c645a5f202/examples/example.py#L8-L21 |
243,862 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker._assert_correct_model | def _assert_correct_model(model_to_check, model_reference, obj_name):
"""
Helper that asserts the model_to_check is the model_reference or one of
its subclasses. If not, raise an ImplementationError, using "obj_name"
to describe the name of the argument.
"""
if not issubc... | python | def _assert_correct_model(model_to_check, model_reference, obj_name):
"""
Helper that asserts the model_to_check is the model_reference or one of
its subclasses. If not, raise an ImplementationError, using "obj_name"
to describe the name of the argument.
"""
if not issubc... | [
"def",
"_assert_correct_model",
"(",
"model_to_check",
",",
"model_reference",
",",
"obj_name",
")",
":",
"if",
"not",
"issubclass",
"(",
"model_to_check",
",",
"model_reference",
")",
":",
"raise",
"ConfigurationException",
"(",
"'The %s model must be a subclass of %s'",... | Helper that asserts the model_to_check is the model_reference or one of
its subclasses. If not, raise an ImplementationError, using "obj_name"
to describe the name of the argument. | [
"Helper",
"that",
"asserts",
"the",
"model_to_check",
"is",
"the",
"model_reference",
"or",
"one",
"of",
"its",
"subclasses",
".",
"If",
"not",
"raise",
"an",
"ImplementationError",
"using",
"obj_name",
"to",
"describe",
"the",
"name",
"of",
"the",
"argument",
... | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L146-L154 |
243,863 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.handle_end_signal | def handle_end_signal(self):
"""
Catch some system signals to handle them internaly
"""
try:
signal.signal(signal.SIGTERM, self.catch_end_signal)
signal.signal(signal.SIGINT, self.catch_end_signal)
except ValueError:
self.log('Signals cannot be... | python | def handle_end_signal(self):
"""
Catch some system signals to handle them internaly
"""
try:
signal.signal(signal.SIGTERM, self.catch_end_signal)
signal.signal(signal.SIGINT, self.catch_end_signal)
except ValueError:
self.log('Signals cannot be... | [
"def",
"handle_end_signal",
"(",
"self",
")",
":",
"try",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"self",
".",
"catch_end_signal",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"self",
".",
"catch_end_signal",
... | Catch some system signals to handle them internaly | [
"Catch",
"some",
"system",
"signals",
"to",
"handle",
"them",
"internaly"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L156-L164 |
243,864 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.stop_handling_end_signal | def stop_handling_end_signal(self):
"""
Stop handling the SIGINT and SIGTERM signals
"""
try:
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.SIG_DFL)
except ValueError:
self.log('Signals cannot be caught in a ... | python | def stop_handling_end_signal(self):
"""
Stop handling the SIGINT and SIGTERM signals
"""
try:
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.SIG_DFL)
except ValueError:
self.log('Signals cannot be caught in a ... | [
"def",
"stop_handling_end_signal",
"(",
"self",
")",
":",
"try",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"signal",
".",
"SIG_DFL",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal",
".",
"SIG_DFL",
")",
... | Stop handling the SIGINT and SIGTERM signals | [
"Stop",
"handling",
"the",
"SIGINT",
"and",
"SIGTERM",
"signals"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L166-L174 |
243,865 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.set_logger | def set_logger(self):
"""
Prepare the logger, using self.logger_name and self.logger_level
"""
self.logger = logging.getLogger(self.logger_name)
self.logger.setLevel(self.logger_level) | python | def set_logger(self):
"""
Prepare the logger, using self.logger_name and self.logger_level
"""
self.logger = logging.getLogger(self.logger_name)
self.logger.setLevel(self.logger_level) | [
"def",
"set_logger",
"(",
"self",
")",
":",
"self",
".",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"self",
".",
"logger_name",
")",
"self",
".",
"logger",
".",
"setLevel",
"(",
"self",
".",
"logger_level",
")"
] | Prepare the logger, using self.logger_name and self.logger_level | [
"Prepare",
"the",
"logger",
"using",
"self",
".",
"logger_name",
"and",
"self",
".",
"logger_level"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L176-L181 |
243,866 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.id | def id(self):
"""
Return an identifier for the worker to use in logging
"""
if not hasattr(self, '_id'):
self._id = str(threading.current_thread().ident + id(self))[-6:]
return self._id | python | def id(self):
"""
Return an identifier for the worker to use in logging
"""
if not hasattr(self, '_id'):
self._id = str(threading.current_thread().ident + id(self))[-6:]
return self._id | [
"def",
"id",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_id'",
")",
":",
"self",
".",
"_id",
"=",
"str",
"(",
"threading",
".",
"current_thread",
"(",
")",
".",
"ident",
"+",
"id",
"(",
"self",
")",
")",
"[",
"-",
"6",
... | Return an identifier for the worker to use in logging | [
"Return",
"an",
"identifier",
"for",
"the",
"worker",
"to",
"use",
"in",
"logging"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L184-L190 |
243,867 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.must_stop | def must_stop(self):
"""
Return True if the worker must stop when the current loop is over.
"""
return bool(self.terminate_gracefuly and self.end_signal_caught
or self.num_loops >= self.max_loops or self.end_forced
or self.wanted_end_date and datetime.ut... | python | def must_stop(self):
"""
Return True if the worker must stop when the current loop is over.
"""
return bool(self.terminate_gracefuly and self.end_signal_caught
or self.num_loops >= self.max_loops or self.end_forced
or self.wanted_end_date and datetime.ut... | [
"def",
"must_stop",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"terminate_gracefuly",
"and",
"self",
".",
"end_signal_caught",
"or",
"self",
".",
"num_loops",
">=",
"self",
".",
"max_loops",
"or",
"self",
".",
"end_forced",
"or",
"self",
".... | Return True if the worker must stop when the current loop is over. | [
"Return",
"True",
"if",
"the",
"worker",
"must",
"stop",
"when",
"the",
"current",
"loop",
"is",
"over",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L205-L211 |
243,868 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.set_status | def set_status(self, status):
"""
Save the new status and call all defined callbacks
"""
self.status = status
for callback in self._update_status_callbacks:
callback(self) | python | def set_status(self, status):
"""
Save the new status and call all defined callbacks
"""
self.status = status
for callback in self._update_status_callbacks:
callback(self) | [
"def",
"set_status",
"(",
"self",
",",
"status",
")",
":",
"self",
".",
"status",
"=",
"status",
"for",
"callback",
"in",
"self",
".",
"_update_status_callbacks",
":",
"callback",
"(",
"self",
")"
] | Save the new status and call all defined callbacks | [
"Save",
"the",
"new",
"status",
"and",
"call",
"all",
"defined",
"callbacks"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L213-L219 |
243,869 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.wait_for_job | def wait_for_job(self):
"""
Use a redis blocking list call to wait for a job, and return it.
"""
blpop_result = self.connection.blpop(self.keys, self.timeout)
if blpop_result is None:
return None
queue_redis_key, job_ident = blpop_result
self.set_statu... | python | def wait_for_job(self):
"""
Use a redis blocking list call to wait for a job, and return it.
"""
blpop_result = self.connection.blpop(self.keys, self.timeout)
if blpop_result is None:
return None
queue_redis_key, job_ident = blpop_result
self.set_statu... | [
"def",
"wait_for_job",
"(",
"self",
")",
":",
"blpop_result",
"=",
"self",
".",
"connection",
".",
"blpop",
"(",
"self",
".",
"keys",
",",
"self",
".",
"timeout",
")",
"if",
"blpop_result",
"is",
"None",
":",
"return",
"None",
"queue_redis_key",
",",
"jo... | Use a redis blocking list call to wait for a job, and return it. | [
"Use",
"a",
"redis",
"blocking",
"list",
"call",
"to",
"wait",
"for",
"a",
"job",
"and",
"return",
"it",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L227-L236 |
243,870 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.get_queue | def get_queue(self, queue_redis_key):
"""
Return a queue based on the key used in redis to store the list
"""
try:
queue_pk = int(queue_redis_key.split(':')[-2])
except:
raise DoesNotExist('Unable to get the queue from the key %s' % queue_redis_key)
... | python | def get_queue(self, queue_redis_key):
"""
Return a queue based on the key used in redis to store the list
"""
try:
queue_pk = int(queue_redis_key.split(':')[-2])
except:
raise DoesNotExist('Unable to get the queue from the key %s' % queue_redis_key)
... | [
"def",
"get_queue",
"(",
"self",
",",
"queue_redis_key",
")",
":",
"try",
":",
"queue_pk",
"=",
"int",
"(",
"queue_redis_key",
".",
"split",
"(",
"':'",
")",
"[",
"-",
"2",
"]",
")",
"except",
":",
"raise",
"DoesNotExist",
"(",
"'Unable to get the queue fr... | Return a queue based on the key used in redis to store the list | [
"Return",
"a",
"queue",
"based",
"on",
"the",
"key",
"used",
"in",
"redis",
"to",
"store",
"the",
"list"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L244-L252 |
243,871 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.update_keys | def update_keys(self):
"""
Update the redis keys to listen for new jobs priorities.
"""
self.keys = self.queue_model.get_waiting_keys(self.queues)
if not self.keys:
self.log('No queues yet', level='warning')
self.last_update_keys = datetime.utcnow() | python | def update_keys(self):
"""
Update the redis keys to listen for new jobs priorities.
"""
self.keys = self.queue_model.get_waiting_keys(self.queues)
if not self.keys:
self.log('No queues yet', level='warning')
self.last_update_keys = datetime.utcnow() | [
"def",
"update_keys",
"(",
"self",
")",
":",
"self",
".",
"keys",
"=",
"self",
".",
"queue_model",
".",
"get_waiting_keys",
"(",
"self",
".",
"queues",
")",
"if",
"not",
"self",
".",
"keys",
":",
"self",
".",
"log",
"(",
"'No queues yet'",
",",
"level"... | Update the redis keys to listen for new jobs priorities. | [
"Update",
"the",
"redis",
"keys",
"to",
"listen",
"for",
"new",
"jobs",
"priorities",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L285-L293 |
243,872 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.run | def run(self):
"""
The main method of the worker. Will ask redis for list items via
blocking calls, get jobs from them, try to execute these jobs, and end
when needed.
"""
# if status is not None, we already had a run !
if self.status:
self.set_status(... | python | def run(self):
"""
The main method of the worker. Will ask redis for list items via
blocking calls, get jobs from them, try to execute these jobs, and end
when needed.
"""
# if status is not None, we already had a run !
if self.status:
self.set_status(... | [
"def",
"run",
"(",
"self",
")",
":",
"# if status is not None, we already had a run !",
"if",
"self",
".",
"status",
":",
"self",
".",
"set_status",
"(",
"'aborted'",
")",
"raise",
"LimpydJobsException",
"(",
"'This worker run is already terminated'",
")",
"self",
"."... | The main method of the worker. Will ask redis for list items via
blocking calls, get jobs from them, try to execute these jobs, and end
when needed. | [
"The",
"main",
"method",
"of",
"the",
"worker",
".",
"Will",
"ask",
"redis",
"for",
"list",
"items",
"via",
"blocking",
"calls",
"get",
"jobs",
"from",
"them",
"try",
"to",
"execute",
"these",
"jobs",
"and",
"end",
"when",
"needed",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L313-L351 |
243,873 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.elapsed | def elapsed(self):
"""
Return a timedelta representation of the time passed sine the worker
was running.
"""
if not self.start_date:
return None
return (self.end_date or datetime.utcnow()) - self.start_date | python | def elapsed(self):
"""
Return a timedelta representation of the time passed sine the worker
was running.
"""
if not self.start_date:
return None
return (self.end_date or datetime.utcnow()) - self.start_date | [
"def",
"elapsed",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"start_date",
":",
"return",
"None",
"return",
"(",
"self",
".",
"end_date",
"or",
"datetime",
".",
"utcnow",
"(",
")",
")",
"-",
"self",
".",
"start_date"
] | Return a timedelta representation of the time passed sine the worker
was running. | [
"Return",
"a",
"timedelta",
"representation",
"of",
"the",
"time",
"passed",
"sine",
"the",
"worker",
"was",
"running",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L354-L361 |
243,874 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.requeue_delayed_jobs | def requeue_delayed_jobs(self):
"""
Requeue each delayed job that are now ready to be executed
"""
failures = []
for queue in self.queue_model.get_all_by_priority(self.queues):
failures.extend(queue.requeue_delayed_jobs())
self.last_requeue_delayed = datetime... | python | def requeue_delayed_jobs(self):
"""
Requeue each delayed job that are now ready to be executed
"""
failures = []
for queue in self.queue_model.get_all_by_priority(self.queues):
failures.extend(queue.requeue_delayed_jobs())
self.last_requeue_delayed = datetime... | [
"def",
"requeue_delayed_jobs",
"(",
"self",
")",
":",
"failures",
"=",
"[",
"]",
"for",
"queue",
"in",
"self",
".",
"queue_model",
".",
"get_all_by_priority",
"(",
"self",
".",
"queues",
")",
":",
"failures",
".",
"extend",
"(",
"queue",
".",
"requeue_dela... | Requeue each delayed job that are now ready to be executed | [
"Requeue",
"each",
"delayed",
"job",
"that",
"are",
"now",
"ready",
"to",
"be",
"executed"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L363-L374 |
243,875 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker._main_loop | def _main_loop(self):
"""
Run jobs until must_stop returns True
"""
fetch_priorities_delay = timedelta(seconds=self.fetch_priorities_delay)
fetch_delayed_delay = timedelta(seconds=self.fetch_delayed_delay)
while not self.must_stop():
self.set_status('waiting'... | python | def _main_loop(self):
"""
Run jobs until must_stop returns True
"""
fetch_priorities_delay = timedelta(seconds=self.fetch_priorities_delay)
fetch_delayed_delay = timedelta(seconds=self.fetch_delayed_delay)
while not self.must_stop():
self.set_status('waiting'... | [
"def",
"_main_loop",
"(",
"self",
")",
":",
"fetch_priorities_delay",
"=",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"fetch_priorities_delay",
")",
"fetch_delayed_delay",
"=",
"timedelta",
"(",
"seconds",
"=",
"self",
".",
"fetch_delayed_delay",
")",
"while",... | Run jobs until must_stop returns True | [
"Run",
"jobs",
"until",
"must_stop",
"returns",
"True"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L376-L443 |
243,876 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_error | def job_error(self, job, queue, exception, trace=None):
"""
Called when an exception was raised during the execute call for a job.
"""
to_be_requeued = not job.must_be_cancelled_on_error and self.requeue_times and self.requeue_times >= int(job.tries.hget() or 0)
if not to_be_req... | python | def job_error(self, job, queue, exception, trace=None):
"""
Called when an exception was raised during the execute call for a job.
"""
to_be_requeued = not job.must_be_cancelled_on_error and self.requeue_times and self.requeue_times >= int(job.tries.hget() or 0)
if not to_be_req... | [
"def",
"job_error",
"(",
"self",
",",
"job",
",",
"queue",
",",
"exception",
",",
"trace",
"=",
"None",
")",
":",
"to_be_requeued",
"=",
"not",
"job",
".",
"must_be_cancelled_on_error",
"and",
"self",
".",
"requeue_times",
"and",
"self",
".",
"requeue_times"... | Called when an exception was raised during the execute call for a job. | [
"Called",
"when",
"an",
"exception",
"was",
"raised",
"during",
"the",
"execute",
"call",
"for",
"a",
"job",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L458-L490 |
243,877 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.requeue_job | def requeue_job(self, job, queue, priority, delayed_for=None):
"""
Requeue a job in a queue with the given priority, possibly delayed
"""
job.requeue(queue_name=queue._cached_name,
priority=priority,
delayed_for=delayed_for,
que... | python | def requeue_job(self, job, queue, priority, delayed_for=None):
"""
Requeue a job in a queue with the given priority, possibly delayed
"""
job.requeue(queue_name=queue._cached_name,
priority=priority,
delayed_for=delayed_for,
que... | [
"def",
"requeue_job",
"(",
"self",
",",
"job",
",",
"queue",
",",
"priority",
",",
"delayed_for",
"=",
"None",
")",
":",
"job",
".",
"requeue",
"(",
"queue_name",
"=",
"queue",
".",
"_cached_name",
",",
"priority",
"=",
"priority",
",",
"delayed_for",
"=... | Requeue a job in a queue with the given priority, possibly delayed | [
"Requeue",
"a",
"job",
"in",
"a",
"queue",
"with",
"the",
"given",
"priority",
"possibly",
"delayed"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L492-L504 |
243,878 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_error_message | def job_error_message(self, job, queue, to_be_requeued, exception, trace=None):
"""
Return the message to log when a job raised an error
"""
return '[%s|%s|%s] error: %s [%s]' % (queue._cached_name,
job.pk.get(),
job._cached_ident... | python | def job_error_message(self, job, queue, to_be_requeued, exception, trace=None):
"""
Return the message to log when a job raised an error
"""
return '[%s|%s|%s] error: %s [%s]' % (queue._cached_name,
job.pk.get(),
job._cached_ident... | [
"def",
"job_error_message",
"(",
"self",
",",
"job",
",",
"queue",
",",
"to_be_requeued",
",",
"exception",
",",
"trace",
"=",
"None",
")",
":",
"return",
"'[%s|%s|%s] error: %s [%s]'",
"%",
"(",
"queue",
".",
"_cached_name",
",",
"job",
".",
"pk",
".",
"g... | Return the message to log when a job raised an error | [
"Return",
"the",
"message",
"to",
"log",
"when",
"a",
"job",
"raised",
"an",
"error"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L506-L514 |
243,879 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_requeue_message | def job_requeue_message(self, job, queue):
"""
Return the message to log when a job is requeued
"""
priority, delayed_until = job.hmget('priority', 'delayed_until')
msg = '[%s|%s|%s] requeued with priority %s'
args = [queue._cached_name, job.pk.get(), job._cached_identif... | python | def job_requeue_message(self, job, queue):
"""
Return the message to log when a job is requeued
"""
priority, delayed_until = job.hmget('priority', 'delayed_until')
msg = '[%s|%s|%s] requeued with priority %s'
args = [queue._cached_name, job.pk.get(), job._cached_identif... | [
"def",
"job_requeue_message",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"priority",
",",
"delayed_until",
"=",
"job",
".",
"hmget",
"(",
"'priority'",
",",
"'delayed_until'",
")",
"msg",
"=",
"'[%s|%s|%s] requeued with priority %s'",
"args",
"=",
"[",
"... | Return the message to log when a job is requeued | [
"Return",
"the",
"message",
"to",
"log",
"when",
"a",
"job",
"is",
"requeued"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L516-L529 |
243,880 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_success | def job_success(self, job, queue, job_result):
"""
Called just after an execute call was successful.
job_result is the value returned by the callback, if any.
"""
job.queued.delete()
job.hmset(end=str(datetime.utcnow()), status=STATUSES.SUCCESS)
queue.success.rpus... | python | def job_success(self, job, queue, job_result):
"""
Called just after an execute call was successful.
job_result is the value returned by the callback, if any.
"""
job.queued.delete()
job.hmset(end=str(datetime.utcnow()), status=STATUSES.SUCCESS)
queue.success.rpus... | [
"def",
"job_success",
"(",
"self",
",",
"job",
",",
"queue",
",",
"job_result",
")",
":",
"job",
".",
"queued",
".",
"delete",
"(",
")",
"job",
".",
"hmset",
"(",
"end",
"=",
"str",
"(",
"datetime",
".",
"utcnow",
"(",
")",
")",
",",
"status",
"=... | Called just after an execute call was successful.
job_result is the value returned by the callback, if any. | [
"Called",
"just",
"after",
"an",
"execute",
"call",
"was",
"successful",
".",
"job_result",
"is",
"the",
"value",
"returned",
"by",
"the",
"callback",
"if",
"any",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L531-L541 |
243,881 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_success_message | def job_success_message(self, job, queue, job_result):
"""
Return the message to log when a job is successful
"""
return '[%s|%s|%s] success, in %s' % (queue._cached_name, job.pk.get(),
job._cached_identifier, job.duration) | python | def job_success_message(self, job, queue, job_result):
"""
Return the message to log when a job is successful
"""
return '[%s|%s|%s] success, in %s' % (queue._cached_name, job.pk.get(),
job._cached_identifier, job.duration) | [
"def",
"job_success_message",
"(",
"self",
",",
"job",
",",
"queue",
",",
"job_result",
")",
":",
"return",
"'[%s|%s|%s] success, in %s'",
"%",
"(",
"queue",
".",
"_cached_name",
",",
"job",
".",
"pk",
".",
"get",
"(",
")",
",",
"job",
".",
"_cached_identi... | Return the message to log when a job is successful | [
"Return",
"the",
"message",
"to",
"log",
"when",
"a",
"job",
"is",
"successful"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L543-L548 |
243,882 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_started | def job_started(self, job, queue):
"""
Called just before the execution of the job
"""
job.hmset(start=str(datetime.utcnow()), status=STATUSES.RUNNING)
job.tries.hincrby(1)
self.log(self.job_started_message(job, queue))
if hasattr(job, 'on_started'):
j... | python | def job_started(self, job, queue):
"""
Called just before the execution of the job
"""
job.hmset(start=str(datetime.utcnow()), status=STATUSES.RUNNING)
job.tries.hincrby(1)
self.log(self.job_started_message(job, queue))
if hasattr(job, 'on_started'):
j... | [
"def",
"job_started",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"job",
".",
"hmset",
"(",
"start",
"=",
"str",
"(",
"datetime",
".",
"utcnow",
"(",
")",
")",
",",
"status",
"=",
"STATUSES",
".",
"RUNNING",
")",
"job",
".",
"tries",
".",
"h... | Called just before the execution of the job | [
"Called",
"just",
"before",
"the",
"execution",
"of",
"the",
"job"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L550-L558 |
243,883 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_started_message | def job_started_message(self, job, queue):
"""
Return the message to log just befre the execution of the job
"""
return '[%s|%s|%s] starting' % (queue._cached_name, job.pk.get(),
job._cached_identifier) | python | def job_started_message(self, job, queue):
"""
Return the message to log just befre the execution of the job
"""
return '[%s|%s|%s] starting' % (queue._cached_name, job.pk.get(),
job._cached_identifier) | [
"def",
"job_started_message",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"return",
"'[%s|%s|%s] starting'",
"%",
"(",
"queue",
".",
"_cached_name",
",",
"job",
".",
"pk",
".",
"get",
"(",
")",
",",
"job",
".",
"_cached_identifier",
")"
] | Return the message to log just befre the execution of the job | [
"Return",
"the",
"message",
"to",
"log",
"just",
"befre",
"the",
"execution",
"of",
"the",
"job"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L560-L565 |
243,884 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_skipped | def job_skipped(self, job, queue):
"""
Called if a job, before trying to run it, has not the "waiting" status,
or, after run, if its status was set to "canceled"
"""
job.queued.delete()
self.log(self.job_skipped_message(job, queue), level='warning')
if hasattr(job... | python | def job_skipped(self, job, queue):
"""
Called if a job, before trying to run it, has not the "waiting" status,
or, after run, if its status was set to "canceled"
"""
job.queued.delete()
self.log(self.job_skipped_message(job, queue), level='warning')
if hasattr(job... | [
"def",
"job_skipped",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"job",
".",
"queued",
".",
"delete",
"(",
")",
"self",
".",
"log",
"(",
"self",
".",
"job_skipped_message",
"(",
"job",
",",
"queue",
")",
",",
"level",
"=",
"'warning'",
")",
"... | Called if a job, before trying to run it, has not the "waiting" status,
or, after run, if its status was set to "canceled" | [
"Called",
"if",
"a",
"job",
"before",
"trying",
"to",
"run",
"it",
"has",
"not",
"the",
"waiting",
"status",
"or",
"after",
"run",
"if",
"its",
"status",
"was",
"set",
"to",
"canceled"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L567-L575 |
243,885 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_skipped_message | def job_skipped_message(self, job, queue):
"""
Return the message to log when a job was skipped
"""
return '[%s|%s|%s] job skipped (current status: %s)' % (
queue._cached_name,
job.pk.get(),
job._cached_identifier,
STATUSES.... | python | def job_skipped_message(self, job, queue):
"""
Return the message to log when a job was skipped
"""
return '[%s|%s|%s] job skipped (current status: %s)' % (
queue._cached_name,
job.pk.get(),
job._cached_identifier,
STATUSES.... | [
"def",
"job_skipped_message",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"return",
"'[%s|%s|%s] job skipped (current status: %s)'",
"%",
"(",
"queue",
".",
"_cached_name",
",",
"job",
".",
"pk",
".",
"get",
"(",
")",
",",
"job",
".",
"_cached_identifier"... | Return the message to log when a job was skipped | [
"Return",
"the",
"message",
"to",
"log",
"when",
"a",
"job",
"was",
"skipped"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L577-L585 |
243,886 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_delayed | def job_delayed(self, job, queue):
"""
Called if a job, before trying to run it, has the "delayed" status, or,
after run, if its status was set to "delayed"
If delayed_until was not set, or is invalid, set it to 60sec in the future
"""
delayed_until = job.delayed_until.hg... | python | def job_delayed(self, job, queue):
"""
Called if a job, before trying to run it, has the "delayed" status, or,
after run, if its status was set to "delayed"
If delayed_until was not set, or is invalid, set it to 60sec in the future
"""
delayed_until = job.delayed_until.hg... | [
"def",
"job_delayed",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"delayed_until",
"=",
"job",
".",
"delayed_until",
".",
"hget",
"(",
")",
"if",
"delayed_until",
":",
"try",
":",
"delayed_until",
"=",
"compute_delayed_until",
"(",
"delayed_until",
"=",... | Called if a job, before trying to run it, has the "delayed" status, or,
after run, if its status was set to "delayed"
If delayed_until was not set, or is invalid, set it to 60sec in the future | [
"Called",
"if",
"a",
"job",
"before",
"trying",
"to",
"run",
"it",
"has",
"the",
"delayed",
"status",
"or",
"after",
"run",
"if",
"its",
"status",
"was",
"set",
"to",
"delayed",
"If",
"delayed_until",
"was",
"not",
"set",
"or",
"is",
"invalid",
"set",
... | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L587-L613 |
243,887 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | Worker.job_delayed_message | def job_delayed_message(self, job, queue):
"""
Return the message to log when a job was delayed just before or during
its execution
"""
return '[%s|%s|%s] job delayed until %s' % (
queue._cached_name,
job.pk.get(),
job._cached_ident... | python | def job_delayed_message(self, job, queue):
"""
Return the message to log when a job was delayed just before or during
its execution
"""
return '[%s|%s|%s] job delayed until %s' % (
queue._cached_name,
job.pk.get(),
job._cached_ident... | [
"def",
"job_delayed_message",
"(",
"self",
",",
"job",
",",
"queue",
")",
":",
"return",
"'[%s|%s|%s] job delayed until %s'",
"%",
"(",
"queue",
".",
"_cached_name",
",",
"job",
".",
"pk",
".",
"get",
"(",
")",
",",
"job",
".",
"_cached_identifier",
",",
"... | Return the message to log when a job was delayed just before or during
its execution | [
"Return",
"the",
"message",
"to",
"log",
"when",
"a",
"job",
"was",
"delayed",
"just",
"before",
"or",
"during",
"its",
"execution"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L615-L624 |
243,888 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | WorkerConfig.create_parser | def create_parser(self):
"""
Create and return the ``OptionParser`` which will be used to
parse the arguments to the worker.
"""
return OptionParser(prog=self.prog_name,
usage=self.usage(),
version='%%prog %s' % self.get_ve... | python | def create_parser(self):
"""
Create and return the ``OptionParser`` which will be used to
parse the arguments to the worker.
"""
return OptionParser(prog=self.prog_name,
usage=self.usage(),
version='%%prog %s' % self.get_ve... | [
"def",
"create_parser",
"(",
"self",
")",
":",
"return",
"OptionParser",
"(",
"prog",
"=",
"self",
".",
"prog_name",
",",
"usage",
"=",
"self",
".",
"usage",
"(",
")",
",",
"version",
"=",
"'%%prog %s'",
"%",
"self",
".",
"get_version",
"(",
")",
",",
... | Create and return the ``OptionParser`` which will be used to
parse the arguments to the worker. | [
"Create",
"and",
"return",
"the",
"OptionParser",
"which",
"will",
"be",
"used",
"to",
"parse",
"the",
"arguments",
"to",
"the",
"worker",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L740-L749 |
243,889 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | WorkerConfig.manage_options | def manage_options(self):
"""
Create a parser given the command-line arguments, creates a parser
Return True if the programme must exit.
"""
self.parser = self.create_parser()
self.options, self.args = self.parser.parse_args(self.argv)
self.do_imports()
... | python | def manage_options(self):
"""
Create a parser given the command-line arguments, creates a parser
Return True if the programme must exit.
"""
self.parser = self.create_parser()
self.options, self.args = self.parser.parse_args(self.argv)
self.do_imports()
... | [
"def",
"manage_options",
"(",
"self",
")",
":",
"self",
".",
"parser",
"=",
"self",
".",
"create_parser",
"(",
")",
"self",
".",
"options",
",",
"self",
".",
"args",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
"self",
".",
"argv",
")",
"self"... | Create a parser given the command-line arguments, creates a parser
Return True if the programme must exit. | [
"Create",
"a",
"parser",
"given",
"the",
"command",
"-",
"line",
"arguments",
"creates",
"a",
"parser",
"Return",
"True",
"if",
"the",
"programme",
"must",
"exit",
"."
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L751-L800 |
243,890 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | WorkerConfig.do_imports | def do_imports(self):
"""
Import all importable options
"""
self.do_import('worker_class', Worker)
self.do_import('queue_model', self.options.worker_class.queue_model)
self.do_import('error_model', self.options.worker_class.error_model)
self.do_import('callback', ... | python | def do_imports(self):
"""
Import all importable options
"""
self.do_import('worker_class', Worker)
self.do_import('queue_model', self.options.worker_class.queue_model)
self.do_import('error_model', self.options.worker_class.error_model)
self.do_import('callback', ... | [
"def",
"do_imports",
"(",
"self",
")",
":",
"self",
".",
"do_import",
"(",
"'worker_class'",
",",
"Worker",
")",
"self",
".",
"do_import",
"(",
"'queue_model'",
",",
"self",
".",
"options",
".",
"worker_class",
".",
"queue_model",
")",
"self",
".",
"do_imp... | Import all importable options | [
"Import",
"all",
"importable",
"options"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L816-L823 |
243,891 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | WorkerConfig.print_options | def print_options(self):
"""
Print all options as parsed by the script
"""
options = []
print("The script is running with the following options:")
options.append(("dry_run", self.options.dry_run))
options.append(("worker_config", self.__class__))
datab... | python | def print_options(self):
"""
Print all options as parsed by the script
"""
options = []
print("The script is running with the following options:")
options.append(("dry_run", self.options.dry_run))
options.append(("worker_config", self.__class__))
datab... | [
"def",
"print_options",
"(",
"self",
")",
":",
"options",
"=",
"[",
"]",
"print",
"(",
"\"The script is running with the following options:\"",
")",
"options",
".",
"append",
"(",
"(",
"\"dry_run\"",
",",
"self",
".",
"options",
".",
"dry_run",
")",
")",
"opti... | Print all options as parsed by the script | [
"Print",
"all",
"options",
"as",
"parsed",
"by",
"the",
"script"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L825-L857 |
243,892 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | WorkerConfig.execute | def execute(self):
"""
Main method to call to run the worker
"""
self.prepare_models()
self.prepare_worker()
if self.options.print_options:
self.print_options()
self.run() | python | def execute(self):
"""
Main method to call to run the worker
"""
self.prepare_models()
self.prepare_worker()
if self.options.print_options:
self.print_options()
self.run() | [
"def",
"execute",
"(",
"self",
")",
":",
"self",
".",
"prepare_models",
"(",
")",
"self",
".",
"prepare_worker",
"(",
")",
"if",
"self",
".",
"options",
".",
"print_options",
":",
"self",
".",
"print_options",
"(",
")",
"self",
".",
"run",
"(",
")"
] | Main method to call to run the worker | [
"Main",
"method",
"to",
"call",
"to",
"run",
"the",
"worker"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L859-L867 |
243,893 | limpyd/redis-limpyd-jobs | limpyd_jobs/workers.py | WorkerConfig.prepare_models | def prepare_models(self):
"""
If a database config ws given as argument, apply it to our models
"""
if self.database_config:
for model in (self.options.queue_model, self.options.error_model):
model.database.reset(**self.database_config) | python | def prepare_models(self):
"""
If a database config ws given as argument, apply it to our models
"""
if self.database_config:
for model in (self.options.queue_model, self.options.error_model):
model.database.reset(**self.database_config) | [
"def",
"prepare_models",
"(",
"self",
")",
":",
"if",
"self",
".",
"database_config",
":",
"for",
"model",
"in",
"(",
"self",
".",
"options",
".",
"queue_model",
",",
"self",
".",
"options",
".",
"error_model",
")",
":",
"model",
".",
"database",
".",
... | If a database config ws given as argument, apply it to our models | [
"If",
"a",
"database",
"config",
"ws",
"given",
"as",
"argument",
"apply",
"it",
"to",
"our",
"models"
] | 264c71029bad4377d6132bf8bb9c55c44f3b03a2 | https://github.com/limpyd/redis-limpyd-jobs/blob/264c71029bad4377d6132bf8bb9c55c44f3b03a2/limpyd_jobs/workers.py#L869-L875 |
243,894 | Robpol86/docoptcfg | docoptcfg.py | settable_options | def settable_options(doc, argv, ignore, options_first):
"""Determine which options we can set, which ones are boolean, and which ones are repeatable.
All set items are option long names.
:param str doc: Docstring from docoptcfg().
:param iter argv: CLI arguments from docoptcfg().
:param iter ignor... | python | def settable_options(doc, argv, ignore, options_first):
"""Determine which options we can set, which ones are boolean, and which ones are repeatable.
All set items are option long names.
:param str doc: Docstring from docoptcfg().
:param iter argv: CLI arguments from docoptcfg().
:param iter ignor... | [
"def",
"settable_options",
"(",
"doc",
",",
"argv",
",",
"ignore",
",",
"options_first",
")",
":",
"settable",
",",
"booleans",
",",
"repeatable",
",",
"short_map",
"=",
"set",
"(",
")",
",",
"set",
"(",
")",
",",
"set",
"(",
")",
",",
"dict",
"(",
... | Determine which options we can set, which ones are boolean, and which ones are repeatable.
All set items are option long names.
:param str doc: Docstring from docoptcfg().
:param iter argv: CLI arguments from docoptcfg().
:param iter ignore: Options to ignore from docoptcfg().
:param bool options_... | [
"Determine",
"which",
"options",
"we",
"can",
"set",
"which",
"ones",
"are",
"boolean",
"and",
"which",
"ones",
"are",
"repeatable",
"."
] | 3746dc263549f7f3ef5a86e739d588546b084bde | https://github.com/Robpol86/docoptcfg/blob/3746dc263549f7f3ef5a86e739d588546b084bde/docoptcfg.py#L39-L79 |
243,895 | Robpol86/docoptcfg | docoptcfg.py | values_from_env | def values_from_env(env_prefix, settable, booleans, repeatable):
"""Get all values from environment variables.
:param str env_prefix: Argument from docoptcfg().
:param iter settable: Option long names available to set by config file.
:param iter booleans: Option long names of boolean/flag types.
:p... | python | def values_from_env(env_prefix, settable, booleans, repeatable):
"""Get all values from environment variables.
:param str env_prefix: Argument from docoptcfg().
:param iter settable: Option long names available to set by config file.
:param iter booleans: Option long names of boolean/flag types.
:p... | [
"def",
"values_from_env",
"(",
"env_prefix",
",",
"settable",
",",
"booleans",
",",
"repeatable",
")",
":",
"defaults_env",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"settable",
":",
"try",
":",
"defaults_env",
"[",
"key",
"]",
"=",
"get_env",
"(",
"key... | Get all values from environment variables.
:param str env_prefix: Argument from docoptcfg().
:param iter settable: Option long names available to set by config file.
:param iter booleans: Option long names of boolean/flag types.
:param iter repeatable: Option long names of repeatable options.
:ret... | [
"Get",
"all",
"values",
"from",
"environment",
"variables",
"."
] | 3746dc263549f7f3ef5a86e739d588546b084bde | https://github.com/Robpol86/docoptcfg/blob/3746dc263549f7f3ef5a86e739d588546b084bde/docoptcfg.py#L126-L143 |
243,896 | Robpol86/docoptcfg | docoptcfg.py | get_opt | def get_opt(key, config, section, booleans, repeatable):
"""Get one value from config file.
:raise DocoptcfgFileError: If an option is the wrong type.
:param str key: Option long name (e.g. --config).
:param ConfigParser config: ConfigParser instance with config file data already loaded.
:param st... | python | def get_opt(key, config, section, booleans, repeatable):
"""Get one value from config file.
:raise DocoptcfgFileError: If an option is the wrong type.
:param str key: Option long name (e.g. --config).
:param ConfigParser config: ConfigParser instance with config file data already loaded.
:param st... | [
"def",
"get_opt",
"(",
"key",
",",
"config",
",",
"section",
",",
"booleans",
",",
"repeatable",
")",
":",
"# Handle repeatable non-boolean options (e.g. --file=file1.txt --file=file2.txt).",
"if",
"key",
"in",
"repeatable",
"and",
"key",
"not",
"in",
"booleans",
":",... | Get one value from config file.
:raise DocoptcfgFileError: If an option is the wrong type.
:param str key: Option long name (e.g. --config).
:param ConfigParser config: ConfigParser instance with config file data already loaded.
:param str section: Section in config file to focus on.
:param iter b... | [
"Get",
"one",
"value",
"from",
"config",
"file",
"."
] | 3746dc263549f7f3ef5a86e739d588546b084bde | https://github.com/Robpol86/docoptcfg/blob/3746dc263549f7f3ef5a86e739d588546b084bde/docoptcfg.py#L146-L178 |
243,897 | Robpol86/docoptcfg | docoptcfg.py | values_from_file | def values_from_file(docopt_dict, config_option, settable, booleans, repeatable):
"""Parse config file and read settable values.
Can be overridden by both command line arguments and environment variables.
:raise DocoptcfgError: If `config_option` isn't found in docstring.
:raise DocoptcfgFileError: On... | python | def values_from_file(docopt_dict, config_option, settable, booleans, repeatable):
"""Parse config file and read settable values.
Can be overridden by both command line arguments and environment variables.
:raise DocoptcfgError: If `config_option` isn't found in docstring.
:raise DocoptcfgFileError: On... | [
"def",
"values_from_file",
"(",
"docopt_dict",
",",
"config_option",
",",
"settable",
",",
"booleans",
",",
"repeatable",
")",
":",
"section",
"=",
"docopt",
".",
"DocoptExit",
".",
"usage",
".",
"split",
"(",
")",
"[",
"1",
"]",
"settable",
"=",
"set",
... | Parse config file and read settable values.
Can be overridden by both command line arguments and environment variables.
:raise DocoptcfgError: If `config_option` isn't found in docstring.
:raise DocoptcfgFileError: On any error while trying to read and parse config file.
:param dict docopt_dict: Dict... | [
"Parse",
"config",
"file",
"and",
"read",
"settable",
"values",
"."
] | 3746dc263549f7f3ef5a86e739d588546b084bde | https://github.com/Robpol86/docoptcfg/blob/3746dc263549f7f3ef5a86e739d588546b084bde/docoptcfg.py#L181-L231 |
243,898 | TC01/calcpkg | calcrepo/repo.py | CalcRepository.setRepoData | def setRepoData(self, searchString, category="", extension="", math=False, game=False, searchFiles=False):
"""Call this function with all the settings to use for future operations on a repository, must be called FIRST"""
self.searchString = searchString
self.category = category
self.math = math
self.game = ga... | python | def setRepoData(self, searchString, category="", extension="", math=False, game=False, searchFiles=False):
"""Call this function with all the settings to use for future operations on a repository, must be called FIRST"""
self.searchString = searchString
self.category = category
self.math = math
self.game = ga... | [
"def",
"setRepoData",
"(",
"self",
",",
"searchString",
",",
"category",
"=",
"\"\"",
",",
"extension",
"=",
"\"\"",
",",
"math",
"=",
"False",
",",
"game",
"=",
"False",
",",
"searchFiles",
"=",
"False",
")",
":",
"self",
".",
"searchString",
"=",
"se... | Call this function with all the settings to use for future operations on a repository, must be called FIRST | [
"Call",
"this",
"function",
"with",
"all",
"the",
"settings",
"to",
"use",
"for",
"future",
"operations",
"on",
"a",
"repository",
"must",
"be",
"called",
"FIRST"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/repo.py#L37-L44 |
243,899 | TC01/calcpkg | calcrepo/repo.py | CalcRepository.setOutputObject | def setOutputObject(self, newOutput=output.CalcpkgOutput(True, True)):
"""Set an object where all output from calcpkg will be redirected to for this repository"""
self.output = newOutput | python | def setOutputObject(self, newOutput=output.CalcpkgOutput(True, True)):
"""Set an object where all output from calcpkg will be redirected to for this repository"""
self.output = newOutput | [
"def",
"setOutputObject",
"(",
"self",
",",
"newOutput",
"=",
"output",
".",
"CalcpkgOutput",
"(",
"True",
",",
"True",
")",
")",
":",
"self",
".",
"output",
"=",
"newOutput"
] | Set an object where all output from calcpkg will be redirected to for this repository | [
"Set",
"an",
"object",
"where",
"all",
"output",
"from",
"calcpkg",
"will",
"be",
"redirected",
"to",
"for",
"this",
"repository"
] | 5168f606264620a090b42a64354331d208b00d5f | https://github.com/TC01/calcpkg/blob/5168f606264620a090b42a64354331d208b00d5f/calcrepo/repo.py#L46-L48 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.