repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
klahnakoski/pyLibrary | pyLibrary/env/emailer.py | Emailer.send_email | def send_email(self,
from_address=None,
to_address=None,
subject=None,
text_data=None,
html_data=None
):
"""Sends an email.
from_addr is an email address; to_addrs is a list of email adresses.
Addresses can be plain (e.g. "jsmith@e... | python | def send_email(self,
from_address=None,
to_address=None,
subject=None,
text_data=None,
html_data=None
):
"""Sends an email.
from_addr is an email address; to_addrs is a list of email adresses.
Addresses can be plain (e.g. "jsmith@e... | [
"def",
"send_email",
"(",
"self",
",",
"from_address",
"=",
"None",
",",
"to_address",
"=",
"None",
",",
"subject",
"=",
"None",
",",
"text_data",
"=",
"None",
",",
"html_data",
"=",
"None",
")",
":",
"settings",
"=",
"self",
".",
"settings",
"from_addre... | Sends an email.
from_addr is an email address; to_addrs is a list of email adresses.
Addresses can be plain (e.g. "jsmith@example.com") or with real names
(e.g. "John Smith <jsmith@example.com>").
text_data and html_data are both strings. You can specify one or both.
If you sp... | [
"Sends",
"an",
"email",
"."
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/emailer.py#L63-L111 |
klahnakoski/pyLibrary | jx_mysql/__init__.py | _esfilter2sqlwhere | def _esfilter2sqlwhere(db, esfilter):
"""
CONVERT ElassticSearch FILTER TO SQL FILTER
db - REQUIRED TO PROPERLY QUOTE VALUES AND COLUMN NAMES
"""
esfilter = wrap(esfilter)
if esfilter is True:
return SQL_TRUE
elif esfilter["and"]:
return sql_iso(SQL_AND.join([esfilter2sqlwhe... | python | def _esfilter2sqlwhere(db, esfilter):
"""
CONVERT ElassticSearch FILTER TO SQL FILTER
db - REQUIRED TO PROPERLY QUOTE VALUES AND COLUMN NAMES
"""
esfilter = wrap(esfilter)
if esfilter is True:
return SQL_TRUE
elif esfilter["and"]:
return sql_iso(SQL_AND.join([esfilter2sqlwhe... | [
"def",
"_esfilter2sqlwhere",
"(",
"db",
",",
"esfilter",
")",
":",
"esfilter",
"=",
"wrap",
"(",
"esfilter",
")",
"if",
"esfilter",
"is",
"True",
":",
"return",
"SQL_TRUE",
"elif",
"esfilter",
"[",
"\"and\"",
"]",
":",
"return",
"sql_iso",
"(",
"SQL_AND",
... | CONVERT ElassticSearch FILTER TO SQL FILTER
db - REQUIRED TO PROPERLY QUOTE VALUES AND COLUMN NAMES | [
"CONVERT",
"ElassticSearch",
"FILTER",
"TO",
"SQL",
"FILTER",
"db",
"-",
"REQUIRED",
"TO",
"PROPERLY",
"QUOTE",
"VALUES",
"AND",
"COLUMN",
"NAMES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_mysql/__init__.py#L335-L428 |
klahnakoski/pyLibrary | jx_mysql/__init__.py | MySQL.query | def query(self, query, stacked=False):
"""
TRANSLATE JSON QUERY EXPRESSION ON SINGLE TABLE TO SQL QUERY
"""
from jx_base.query import QueryOp
query = QueryOp.wrap(query)
sql, post = self._subquery(query, isolate=False, stacked=stacked)
query.data = post(sql)
... | python | def query(self, query, stacked=False):
"""
TRANSLATE JSON QUERY EXPRESSION ON SINGLE TABLE TO SQL QUERY
"""
from jx_base.query import QueryOp
query = QueryOp.wrap(query)
sql, post = self._subquery(query, isolate=False, stacked=stacked)
query.data = post(sql)
... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"stacked",
"=",
"False",
")",
":",
"from",
"jx_base",
".",
"query",
"import",
"QueryOp",
"query",
"=",
"QueryOp",
".",
"wrap",
"(",
"query",
")",
"sql",
",",
"post",
"=",
"self",
".",
"_subquery",
"(",
... | TRANSLATE JSON QUERY EXPRESSION ON SINGLE TABLE TO SQL QUERY | [
"TRANSLATE",
"JSON",
"QUERY",
"EXPRESSION",
"ON",
"SINGLE",
"TABLE",
"TO",
"SQL",
"QUERY"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_mysql/__init__.py#L59-L69 |
klahnakoski/pyLibrary | jx_mysql/__init__.py | MySQL._aggop | def _aggop(self, query):
"""
SINGLE ROW RETURNED WITH AGGREGATES
"""
if isinstance(query.select, list):
# RETURN SINGLE OBJECT WITH AGGREGATES
for s in query.select:
if s.aggregate not in aggregates:
Log.error("Expecting all col... | python | def _aggop(self, query):
"""
SINGLE ROW RETURNED WITH AGGREGATES
"""
if isinstance(query.select, list):
# RETURN SINGLE OBJECT WITH AGGREGATES
for s in query.select:
if s.aggregate not in aggregates:
Log.error("Expecting all col... | [
"def",
"_aggop",
"(",
"self",
",",
"query",
")",
":",
"if",
"isinstance",
"(",
"query",
".",
"select",
",",
"list",
")",
":",
"# RETURN SINGLE OBJECT WITH AGGREGATES",
"for",
"s",
"in",
"query",
".",
"select",
":",
"if",
"s",
".",
"aggregate",
"not",
"in... | SINGLE ROW RETURNED WITH AGGREGATES | [
"SINGLE",
"ROW",
"RETURNED",
"WITH",
"AGGREGATES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_mysql/__init__.py#L173-L224 |
klahnakoski/pyLibrary | jx_mysql/__init__.py | MySQL._setop | def _setop(self, query):
"""
NO AGGREGATION, SIMPLE LIST COMPREHENSION
"""
if isinstance(query.select, list):
# RETURN BORING RESULT SET
selects = FlatList()
for s in listwrap(query.select):
if isinstance(s.value, Mapping):
... | python | def _setop(self, query):
"""
NO AGGREGATION, SIMPLE LIST COMPREHENSION
"""
if isinstance(query.select, list):
# RETURN BORING RESULT SET
selects = FlatList()
for s in listwrap(query.select):
if isinstance(s.value, Mapping):
... | [
"def",
"_setop",
"(",
"self",
",",
"query",
")",
":",
"if",
"isinstance",
"(",
"query",
".",
"select",
",",
"list",
")",
":",
"# RETURN BORING RESULT SET",
"selects",
"=",
"FlatList",
"(",
")",
"for",
"s",
"in",
"listwrap",
"(",
"query",
".",
"select",
... | NO AGGREGATION, SIMPLE LIST COMPREHENSION | [
"NO",
"AGGREGATION",
"SIMPLE",
"LIST",
"COMPREHENSION"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_mysql/__init__.py#L226-L312 |
klahnakoski/pyLibrary | jx_mysql/__init__.py | MySQL._sort2sql | def _sort2sql(self, sort):
"""
RETURN ORDER BY CLAUSE
"""
if not sort:
return ""
return SQL_ORDERBY + sql_list([quote_column(o.field) + (" DESC" if o.sort == -1 else "") for o in sort]) | python | def _sort2sql(self, sort):
"""
RETURN ORDER BY CLAUSE
"""
if not sort:
return ""
return SQL_ORDERBY + sql_list([quote_column(o.field) + (" DESC" if o.sort == -1 else "") for o in sort]) | [
"def",
"_sort2sql",
"(",
"self",
",",
"sort",
")",
":",
"if",
"not",
"sort",
":",
"return",
"\"\"",
"return",
"SQL_ORDERBY",
"+",
"sql_list",
"(",
"[",
"quote_column",
"(",
"o",
".",
"field",
")",
"+",
"(",
"\" DESC\"",
"if",
"o",
".",
"sort",
"==",
... | RETURN ORDER BY CLAUSE | [
"RETURN",
"ORDER",
"BY",
"CLAUSE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_mysql/__init__.py#L314-L320 |
commonwealth-of-puerto-rico/libre | libre/apps/data_drivers/views.py | CustomAPIView.get_renderers | def get_renderers(self):
"""
Instantiates and returns the list of renderers that this view can use.
"""
try:
source = self.get_object()
except (ImproperlyConfigured, APIException):
self.renderer_classes = [RENDERER_MAPPING[i] for i in self.__class__.render... | python | def get_renderers(self):
"""
Instantiates and returns the list of renderers that this view can use.
"""
try:
source = self.get_object()
except (ImproperlyConfigured, APIException):
self.renderer_classes = [RENDERER_MAPPING[i] for i in self.__class__.render... | [
"def",
"get_renderers",
"(",
"self",
")",
":",
"try",
":",
"source",
"=",
"self",
".",
"get_object",
"(",
")",
"except",
"(",
"ImproperlyConfigured",
",",
"APIException",
")",
":",
"self",
".",
"renderer_classes",
"=",
"[",
"RENDERER_MAPPING",
"[",
"i",
"]... | Instantiates and returns the list of renderers that this view can use. | [
"Instantiates",
"and",
"returns",
"the",
"list",
"of",
"renderers",
"that",
"this",
"view",
"can",
"use",
"."
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/views.py#L39-L50 |
commonwealth-of-puerto-rico/libre | libre/apps/data_drivers/views.py | LIBREView.get_renderer_context | def get_renderer_context(self):
"""
Returns a dict that is passed through to Renderer.render(),
as the `renderer_context` keyword argument.
"""
# Note: Additionally 'response' will also be added to the context,
# by the Response object.
return {
... | python | def get_renderer_context(self):
"""
Returns a dict that is passed through to Renderer.render(),
as the `renderer_context` keyword argument.
"""
# Note: Additionally 'response' will also be added to the context,
# by the Response object.
return {
... | [
"def",
"get_renderer_context",
"(",
"self",
")",
":",
"# Note: Additionally 'response' will also be added to the context,",
"# by the Response object.",
"return",
"{",
"'view'",
":",
"self",
",",
"'args'",
":",
"getattr",
"(",
"self",
",",
"'args'",
",",
"(",
")",... | Returns a dict that is passed through to Renderer.render(),
as the `renderer_context` keyword argument. | [
"Returns",
"a",
"dict",
"that",
"is",
"passed",
"through",
"to",
"Renderer",
".",
"render",
"()",
"as",
"the",
"renderer_context",
"keyword",
"argument",
"."
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/views.py#L92-L105 |
grampajoe/pymosh | pymosh/avi.py | AVIFile.rebuild | def rebuild(self):
"""Rebuild RIFF tree and index from streams."""
movi = self.riff.find('LIST', 'movi')
movi.chunks = self.combine_streams()
self.rebuild_index() | python | def rebuild(self):
"""Rebuild RIFF tree and index from streams."""
movi = self.riff.find('LIST', 'movi')
movi.chunks = self.combine_streams()
self.rebuild_index() | [
"def",
"rebuild",
"(",
"self",
")",
":",
"movi",
"=",
"self",
".",
"riff",
".",
"find",
"(",
"'LIST'",
",",
"'movi'",
")",
"movi",
".",
"chunks",
"=",
"self",
".",
"combine_streams",
"(",
")",
"self",
".",
"rebuild_index",
"(",
")"
] | Rebuild RIFF tree and index from streams. | [
"Rebuild",
"RIFF",
"tree",
"and",
"index",
"from",
"streams",
"."
] | train | https://github.com/grampajoe/pymosh/blob/2a17a0271fda939528edc31572940d3b676f8a47/pymosh/avi.py#L83-L87 |
appuri/python-etcd-lock | etcdlock/lock.py | Lock.acquire | def acquire(self, **kwargs):
"""
Aquire the lock. Returns True if the lock was acquired; False otherwise.
timeout (int): Timeout to wait for the lock to change if it is already acquired.
Defaults to what was provided during initialization, which will block and retry until acquired. ... | python | def acquire(self, **kwargs):
"""
Aquire the lock. Returns True if the lock was acquired; False otherwise.
timeout (int): Timeout to wait for the lock to change if it is already acquired.
Defaults to what was provided during initialization, which will block and retry until acquired. ... | [
"def",
"acquire",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"token",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"attempted",
"=",
"False",
"while",
"self",
".",
"token",
"is",
"None",
":",
"try",
":",
"self",
".",
"client",
".",
... | Aquire the lock. Returns True if the lock was acquired; False otherwise.
timeout (int): Timeout to wait for the lock to change if it is already acquired.
Defaults to what was provided during initialization, which will block and retry until acquired. | [
"Aquire",
"the",
"lock",
".",
"Returns",
"True",
"if",
"the",
"lock",
"was",
"acquired",
";",
"False",
"otherwise",
"."
] | train | https://github.com/appuri/python-etcd-lock/blob/123fde50dd1be8edef9299999fd2671f26f84764/etcdlock/lock.py#L51-L99 |
appuri/python-etcd-lock | etcdlock/lock.py | Lock.renew | def renew(self):
"""
Renew the lock if acquired.
"""
if self.token is not None:
try:
self.client.test_and_set(self.key, self.token, self.token, ttl=self.ttl)
return True
except ValueError, e:
self.token = None
... | python | def renew(self):
"""
Renew the lock if acquired.
"""
if self.token is not None:
try:
self.client.test_and_set(self.key, self.token, self.token, ttl=self.ttl)
return True
except ValueError, e:
self.token = None
... | [
"def",
"renew",
"(",
"self",
")",
":",
"if",
"self",
".",
"token",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"client",
".",
"test_and_set",
"(",
"self",
".",
"key",
",",
"self",
".",
"token",
",",
"self",
".",
"token",
",",
"ttl",
"=",
... | Renew the lock if acquired. | [
"Renew",
"the",
"lock",
"if",
"acquired",
"."
] | train | https://github.com/appuri/python-etcd-lock/blob/123fde50dd1be8edef9299999fd2671f26f84764/etcdlock/lock.py#L101-L111 |
appuri/python-etcd-lock | etcdlock/lock.py | Lock.release | def release(self):
"""
Release the lock if acquired.
"""
# TODO: thread safety (currently the lock may be acquired for one more TTL length)
if self.token is not None:
try:
self.client.test_and_set(self.key, 0, self.token)
except (ValueError... | python | def release(self):
"""
Release the lock if acquired.
"""
# TODO: thread safety (currently the lock may be acquired for one more TTL length)
if self.token is not None:
try:
self.client.test_and_set(self.key, 0, self.token)
except (ValueError... | [
"def",
"release",
"(",
"self",
")",
":",
"# TODO: thread safety (currently the lock may be acquired for one more TTL length)",
"if",
"self",
".",
"token",
"is",
"not",
"None",
":",
"try",
":",
"self",
".",
"client",
".",
"test_and_set",
"(",
"self",
".",
"key",
",... | Release the lock if acquired. | [
"Release",
"the",
"lock",
"if",
"acquired",
"."
] | train | https://github.com/appuri/python-etcd-lock/blob/123fde50dd1be8edef9299999fd2671f26f84764/etcdlock/lock.py#L119-L130 |
ff0000/scarlet | scarlet/assets/fields.py | AssetsFileField.deconstruct | def deconstruct(self):
"""
Denormalize is always false migrations
"""
name, path, args, kwargs = super(AssetsFileField, self).deconstruct()
kwargs['denormalize'] = False
return name, path, args, kwargs | python | def deconstruct(self):
"""
Denormalize is always false migrations
"""
name, path, args, kwargs = super(AssetsFileField, self).deconstruct()
kwargs['denormalize'] = False
return name, path, args, kwargs | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"name",
",",
"path",
",",
"args",
",",
"kwargs",
"=",
"super",
"(",
"AssetsFileField",
",",
"self",
")",
".",
"deconstruct",
"(",
")",
"kwargs",
"[",
"'denormalize'",
"]",
"=",
"False",
"return",
"name",
","... | Denormalize is always false migrations | [
"Denormalize",
"is",
"always",
"false",
"migrations"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/fields.py#L149-L155 |
ff0000/scarlet | scarlet/cms/actions.py | ActionView.get_context_data | def get_context_data(self, **kwargs):
"""
Hook for adding arguments to the context.
"""
context = {'obj': self.object }
if 'queryset' in kwargs:
context['conf_msg'] = self.get_confirmation_message(kwargs['queryset'])
context.update(kwargs)
return cont... | python | def get_context_data(self, **kwargs):
"""
Hook for adding arguments to the context.
"""
context = {'obj': self.object }
if 'queryset' in kwargs:
context['conf_msg'] = self.get_confirmation_message(kwargs['queryset'])
context.update(kwargs)
return cont... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"{",
"'obj'",
":",
"self",
".",
"object",
"}",
"if",
"'queryset'",
"in",
"kwargs",
":",
"context",
"[",
"'conf_msg'",
"]",
"=",
"self",
".",
"get_confirmation_mess... | Hook for adding arguments to the context. | [
"Hook",
"for",
"adding",
"arguments",
"to",
"the",
"context",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L107-L116 |
ff0000/scarlet | scarlet/cms/actions.py | ActionView.get_object | def get_object(self):
"""
If a single object has been requested, will set
`self.object` and return the object.
"""
queryset = None
slug = self.kwargs.get(self.slug_url_kwarg, None)
if slug is not None:
queryset = self.get_queryset()
slug_f... | python | def get_object(self):
"""
If a single object has been requested, will set
`self.object` and return the object.
"""
queryset = None
slug = self.kwargs.get(self.slug_url_kwarg, None)
if slug is not None:
queryset = self.get_queryset()
slug_f... | [
"def",
"get_object",
"(",
"self",
")",
":",
"queryset",
"=",
"None",
"slug",
"=",
"self",
".",
"kwargs",
".",
"get",
"(",
"self",
".",
"slug_url_kwarg",
",",
"None",
")",
"if",
"slug",
"is",
"not",
"None",
":",
"queryset",
"=",
"self",
".",
"get_quer... | If a single object has been requested, will set
`self.object` and return the object. | [
"If",
"a",
"single",
"object",
"has",
"been",
"requested",
"will",
"set",
"self",
".",
"object",
"and",
"return",
"the",
"object",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L118-L134 |
ff0000/scarlet | scarlet/cms/actions.py | ActionView.get_done_url | def get_done_url(self):
"""
Returns the url to redirect to after a successful update.
The get_view_url will be called on the current bundle using
`self.redirect_to_view` as the view name.
"""
data = dict(self.kwargs)
data.pop(self.slug_url_kwarg, None)
url... | python | def get_done_url(self):
"""
Returns the url to redirect to after a successful update.
The get_view_url will be called on the current bundle using
`self.redirect_to_view` as the view name.
"""
data = dict(self.kwargs)
data.pop(self.slug_url_kwarg, None)
url... | [
"def",
"get_done_url",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
"self",
".",
"kwargs",
")",
"data",
".",
"pop",
"(",
"self",
".",
"slug_url_kwarg",
",",
"None",
")",
"url",
"=",
"self",
".",
"bundle",
".",
"get_view_url",
"(",
"self",
".",
... | Returns the url to redirect to after a successful update.
The get_view_url will be called on the current bundle using
`self.redirect_to_view` as the view name. | [
"Returns",
"the",
"url",
"to",
"redirect",
"to",
"after",
"a",
"successful",
"update",
".",
"The",
"get_view_url",
"will",
"be",
"called",
"on",
"the",
"current",
"bundle",
"using",
"self",
".",
"redirect_to_view",
"as",
"the",
"view",
"name",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L146-L156 |
ff0000/scarlet | scarlet/cms/actions.py | ActionView.get_selected | def get_selected(self, request):
"""
Returns a queryset of the selected objects as specified by \
a GET or POST request.
"""
obj = self.get_object()
queryset = None
# if single-object URL not used, check for selected objects
if not obj:
if requ... | python | def get_selected(self, request):
"""
Returns a queryset of the selected objects as specified by \
a GET or POST request.
"""
obj = self.get_object()
queryset = None
# if single-object URL not used, check for selected objects
if not obj:
if requ... | [
"def",
"get_selected",
"(",
"self",
",",
"request",
")",
":",
"obj",
"=",
"self",
".",
"get_object",
"(",
")",
"queryset",
"=",
"None",
"# if single-object URL not used, check for selected objects",
"if",
"not",
"obj",
":",
"if",
"request",
".",
"GET",
".",
"g... | Returns a queryset of the selected objects as specified by \
a GET or POST request. | [
"Returns",
"a",
"queryset",
"of",
"the",
"selected",
"objects",
"as",
"specified",
"by",
"\\",
"a",
"GET",
"or",
"POST",
"request",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L158-L175 |
ff0000/scarlet | scarlet/cms/actions.py | ActionView.get | def get(self, request, *args, **kwargs):
"""
Method for handling GET requests.
Calls the `render` method with the following
items in context:
* **queryset** - Objects to perform action on
"""
queryset = self.get_selected(request)
return self.render(reque... | python | def get(self, request, *args, **kwargs):
"""
Method for handling GET requests.
Calls the `render` method with the following
items in context:
* **queryset** - Objects to perform action on
"""
queryset = self.get_selected(request)
return self.render(reque... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"self",
".",
"get_selected",
"(",
"request",
")",
"return",
"self",
".",
"render",
"(",
"request",
",",
"queryset",
"=",
"queryset",
")"
... | Method for handling GET requests.
Calls the `render` method with the following
items in context:
* **queryset** - Objects to perform action on | [
"Method",
"for",
"handling",
"GET",
"requests",
".",
"Calls",
"the",
"render",
"method",
"with",
"the",
"following",
"items",
"in",
"context",
":"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L177-L187 |
ff0000/scarlet | scarlet/cms/actions.py | ActionView.post | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests.
Checks for a modify confirmation and performs
the action by calling `process_action`.
"""
queryset = self.get_selected(request)
if request.POST.get('modify'):
response =... | python | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests.
Checks for a modify confirmation and performs
the action by calling `process_action`.
"""
queryset = self.get_selected(request)
if request.POST.get('modify'):
response =... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"queryset",
"=",
"self",
".",
"get_selected",
"(",
"request",
")",
"if",
"request",
".",
"POST",
".",
"get",
"(",
"'modify'",
")",
":",
"response",
"="... | Method for handling POST requests.
Checks for a modify confirmation and performs
the action by calling `process_action`. | [
"Method",
"for",
"handling",
"POST",
"requests",
".",
"Checks",
"for",
"a",
"modify",
"confirmation",
"and",
"performs",
"the",
"action",
"by",
"calling",
"process_action",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L190-L207 |
ff0000/scarlet | scarlet/cms/actions.py | DeleteActionView.process_action | def process_action(self, request, queryset):
"""
Deletes the object(s). Successful deletes are logged.
Returns a 'render redirect' to the result of the
`get_done_url` method.
If a ProtectedError is raised, the `render` method
is called with message explaining the error a... | python | def process_action(self, request, queryset):
"""
Deletes the object(s). Successful deletes are logged.
Returns a 'render redirect' to the result of the
`get_done_url` method.
If a ProtectedError is raised, the `render` method
is called with message explaining the error a... | [
"def",
"process_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"count",
"=",
"0",
"try",
":",
"with",
"transaction",
".",
"commit_on_success",
"(",
")",
":",
"for",
"obj",
"in",
"queryset",
":",
"self",
".",
"log_action",
"(",
"obj",
... | Deletes the object(s). Successful deletes are logged.
Returns a 'render redirect' to the result of the
`get_done_url` method.
If a ProtectedError is raised, the `render` method
is called with message explaining the error added
to the context as `protected`. | [
"Deletes",
"the",
"object",
"(",
"s",
")",
".",
"Successful",
"deletes",
"are",
"logged",
".",
"Returns",
"a",
"render",
"redirect",
"to",
"the",
"result",
"of",
"the",
"get_done_url",
"method",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L233-L261 |
ff0000/scarlet | scarlet/cms/actions.py | PublishActionView.get_object | def get_object(self):
"""
Get the object for publishing
Raises a http404 error if the object is not found.
"""
obj = super(PublishActionView, self).get_object()
if obj:
if not hasattr(obj, 'publish'):
raise http.Http404
return obj | python | def get_object(self):
"""
Get the object for publishing
Raises a http404 error if the object is not found.
"""
obj = super(PublishActionView, self).get_object()
if obj:
if not hasattr(obj, 'publish'):
raise http.Http404
return obj | [
"def",
"get_object",
"(",
"self",
")",
":",
"obj",
"=",
"super",
"(",
"PublishActionView",
",",
"self",
")",
".",
"get_object",
"(",
")",
"if",
"obj",
":",
"if",
"not",
"hasattr",
"(",
"obj",
",",
"'publish'",
")",
":",
"raise",
"http",
".",
"Http404... | Get the object for publishing
Raises a http404 error if the object is not found. | [
"Get",
"the",
"object",
"for",
"publishing",
"Raises",
"a",
"http404",
"error",
"if",
"the",
"object",
"is",
"not",
"found",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L278-L289 |
ff0000/scarlet | scarlet/cms/actions.py | PublishActionView.process_action | def process_action(self, request, queryset):
"""
Publishes the selected objects by passing the value of \
'when' to the object's publish method. The object's \
`purge_archives` method is also called to limit the number \
of old items that we keep around. The action is logged as \... | python | def process_action(self, request, queryset):
"""
Publishes the selected objects by passing the value of \
'when' to the object's publish method. The object's \
`purge_archives` method is also called to limit the number \
of old items that we keep around. The action is logged as \... | [
"def",
"process_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"form",
"=",
"self",
".",
"form",
"(",
"request",
".",
"POST",
")",
"if",
"form",
".",
"is_valid",
"(",
")",
":",
"when",
"=",
"form",
".",
"cleaned_data",
".",
"get",
... | Publishes the selected objects by passing the value of \
'when' to the object's publish method. The object's \
`purge_archives` method is also called to limit the number \
of old items that we keep around. The action is logged as \
either 'published' or 'scheduled' depending on the value... | [
"Publishes",
"the",
"selected",
"objects",
"by",
"passing",
"the",
"value",
"of",
"\\",
"when",
"to",
"the",
"object",
"s",
"publish",
"method",
".",
"The",
"object",
"s",
"\\",
"purge_archives",
"method",
"is",
"also",
"called",
"to",
"limit",
"the",
"num... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L315-L348 |
ff0000/scarlet | scarlet/cms/actions.py | UnPublishActionView.process_action | def process_action(self, request, queryset):
"""
Unpublishes the selected objects by calling the object's \
unpublish method. The action is logged and the user is \
notified with a message.
Returns a 'render redirect' to the result of the \
`get_done_url` method.
... | python | def process_action(self, request, queryset):
"""
Unpublishes the selected objects by calling the object's \
unpublish method. The action is logged and the user is \
notified with a message.
Returns a 'render redirect' to the result of the \
`get_done_url` method.
... | [
"def",
"process_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"count",
"=",
"0",
"for",
"obj",
"in",
"queryset",
":",
"count",
"+=",
"1",
"obj",
".",
"unpublish",
"(",
")",
"object_url",
"=",
"self",
".",
"get_object_url",
"(",
"obj"... | Unpublishes the selected objects by calling the object's \
unpublish method. The action is logged and the user is \
notified with a message.
Returns a 'render redirect' to the result of the \
`get_done_url` method. | [
"Unpublishes",
"the",
"selected",
"objects",
"by",
"calling",
"the",
"object",
"s",
"\\",
"unpublish",
"method",
".",
"The",
"action",
"is",
"logged",
"and",
"the",
"user",
"is",
"\\",
"notified",
"with",
"a",
"message",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L373-L392 |
ff0000/scarlet | scarlet/cms/actions.py | PublishView.get_object | def get_object(self):
"""
Get the object for publishing
Raises a http404 error if the object is not found.
"""
obj = super(PublishView, self).get_object()
if not obj or not hasattr(obj, 'publish'):
raise http.Http404
return obj | python | def get_object(self):
"""
Get the object for publishing
Raises a http404 error if the object is not found.
"""
obj = super(PublishView, self).get_object()
if not obj or not hasattr(obj, 'publish'):
raise http.Http404
return obj | [
"def",
"get_object",
"(",
"self",
")",
":",
"obj",
"=",
"super",
"(",
"PublishView",
",",
"self",
")",
".",
"get_object",
"(",
")",
"if",
"not",
"obj",
"or",
"not",
"hasattr",
"(",
"obj",
",",
"'publish'",
")",
":",
"raise",
"http",
".",
"Http404",
... | Get the object for publishing
Raises a http404 error if the object is not found. | [
"Get",
"the",
"object",
"for",
"publishing",
"Raises",
"a",
"http404",
"error",
"if",
"the",
"object",
"is",
"not",
"found",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L409-L419 |
ff0000/scarlet | scarlet/cms/actions.py | PublishView.get_object_url | def get_object_url(self):
"""
Returns the url to link to the object
The get_view_url will be called on the current bundle using
'edit` as the view name.
"""
return self.bundle.get_view_url('edit',
self.request.user, {}, self.kwargs) | python | def get_object_url(self):
"""
Returns the url to link to the object
The get_view_url will be called on the current bundle using
'edit` as the view name.
"""
return self.bundle.get_view_url('edit',
self.request.user, {}, self.kwargs) | [
"def",
"get_object_url",
"(",
"self",
")",
":",
"return",
"self",
".",
"bundle",
".",
"get_view_url",
"(",
"'edit'",
",",
"self",
".",
"request",
".",
"user",
",",
"{",
"}",
",",
"self",
".",
"kwargs",
")"
] | Returns the url to link to the object
The get_view_url will be called on the current bundle using
'edit` as the view name. | [
"Returns",
"the",
"url",
"to",
"link",
"to",
"the",
"object",
"The",
"get_view_url",
"will",
"be",
"called",
"on",
"the",
"current",
"bundle",
"using",
"edit",
"as",
"the",
"view",
"name",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L421-L428 |
ff0000/scarlet | scarlet/cms/actions.py | PublishView.get_done_url | def get_done_url(self):
"""
Returns the url to redirect to after a successful update.
The get_view_url will be called on the current bundle using
`self.redirect_to_view` as the view name.
"""
url = self.bundle.get_view_url(self.redirect_to_view,
... | python | def get_done_url(self):
"""
Returns the url to redirect to after a successful update.
The get_view_url will be called on the current bundle using
`self.redirect_to_view` as the view name.
"""
url = self.bundle.get_view_url(self.redirect_to_view,
... | [
"def",
"get_done_url",
"(",
"self",
")",
":",
"url",
"=",
"self",
".",
"bundle",
".",
"get_view_url",
"(",
"self",
".",
"redirect_to_view",
",",
"self",
".",
"request",
".",
"user",
",",
"{",
"}",
",",
"self",
".",
"kwargs",
")",
"return",
"self",
".... | Returns the url to redirect to after a successful update.
The get_view_url will be called on the current bundle using
`self.redirect_to_view` as the view name. | [
"Returns",
"the",
"url",
"to",
"redirect",
"to",
"after",
"a",
"successful",
"update",
".",
"The",
"get_view_url",
"will",
"be",
"called",
"on",
"the",
"current",
"bundle",
"using",
"self",
".",
"redirect_to_view",
"as",
"the",
"view",
"name",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L430-L438 |
ff0000/scarlet | scarlet/cms/actions.py | PublishView.post | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests. Publishes
the object passing the value of 'when' to the object's
publish method. The object's `purge_archives` method
is also called to limit the number of old items
that we keep around. The ... | python | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests. Publishes
the object passing the value of 'when' to the object's
publish method. The object's `purge_archives` method
is also called to limit the number of old items
that we keep around. The ... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"form",
"=",
"self",
".",
"form",
"(",
")",
"url",
"=",
"self",
".",
"get_done_url",... | Method for handling POST requests. Publishes
the object passing the value of 'when' to the object's
publish method. The object's `purge_archives` method
is also called to limit the number of old items
that we keep around. The action is logged as either
'published' or 'scheduled' ... | [
"Method",
"for",
"handling",
"POST",
"requests",
".",
"Publishes",
"the",
"object",
"passing",
"the",
"value",
"of",
"when",
"to",
"the",
"object",
"s",
"publish",
"method",
".",
"The",
"object",
"s",
"purge_archives",
"method",
"is",
"also",
"called",
"to",... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L454-L492 |
ff0000/scarlet | scarlet/cms/actions.py | UnPublishView.get | def get(self, request, *args, **kwargs):
"""
Method for handling GET requests. Passes the
following arguments to the context:
* **obj** - The object to publish
* **done_url** - The result of the `get_done_url` method
"""
self.object = self.get_object()
r... | python | def get(self, request, *args, **kwargs):
"""
Method for handling GET requests. Passes the
following arguments to the context:
* **obj** - The object to publish
* **done_url** - The result of the `get_done_url` method
"""
self.object = self.get_object()
r... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"return",
"self",
".",
"render",
"(",
"request",
",",
"obj",
"=",
"self",
".",
"objec... | Method for handling GET requests. Passes the
following arguments to the context:
* **obj** - The object to publish
* **done_url** - The result of the `get_done_url` method | [
"Method",
"for",
"handling",
"GET",
"requests",
".",
"Passes",
"the",
"following",
"arguments",
"to",
"the",
"context",
":"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L505-L516 |
ff0000/scarlet | scarlet/cms/actions.py | UnPublishView.post | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests. Unpublishes the
the object by calling the object's unpublish method.
The action is logged, the user is notified with a
message. Returns a 'render redirect' to the result of
the `get_done_url`... | python | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests. Unpublishes the
the object by calling the object's unpublish method.
The action is logged, the user is notified with a
message. Returns a 'render redirect' to the result of
the `get_done_url`... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"url",
"=",
"self",
".",
"get_done_url",
"(",
")",
"if",
"request",
".",
"POST",
"."... | Method for handling POST requests. Unpublishes the
the object by calling the object's unpublish method.
The action is logged, the user is notified with a
message. Returns a 'render redirect' to the result of
the `get_done_url` method. | [
"Method",
"for",
"handling",
"POST",
"requests",
".",
"Unpublishes",
"the",
"the",
"object",
"by",
"calling",
"the",
"object",
"s",
"unpublish",
"method",
".",
"The",
"action",
"is",
"logged",
"the",
"user",
"is",
"notified",
"with",
"a",
"message",
".",
"... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L518-L539 |
ff0000/scarlet | scarlet/cms/actions.py | DeleteView.get_object | def get_object(self):
"""
Get the object for previewing.
Raises a http404 error if the object is not found.
"""
obj = super(DeleteView, self).get_object()
if not obj:
raise http.Http404
return obj | python | def get_object(self):
"""
Get the object for previewing.
Raises a http404 error if the object is not found.
"""
obj = super(DeleteView, self).get_object()
if not obj:
raise http.Http404
return obj | [
"def",
"get_object",
"(",
"self",
")",
":",
"obj",
"=",
"super",
"(",
"DeleteView",
",",
"self",
")",
".",
"get_object",
"(",
")",
"if",
"not",
"obj",
":",
"raise",
"http",
".",
"Http404",
"return",
"obj"
] | Get the object for previewing.
Raises a http404 error if the object is not found. | [
"Get",
"the",
"object",
"for",
"previewing",
".",
"Raises",
"a",
"http404",
"error",
"if",
"the",
"object",
"is",
"not",
"found",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L573-L583 |
ff0000/scarlet | scarlet/cms/actions.py | DeleteView.post | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests.
Deletes the object. Successful deletes are logged.
Returns a 'render redirect' to the result of the
`get_done_url` method.
If a ProtectedError is raised, the `render` method
is calle... | python | def post(self, request, *args, **kwargs):
"""
Method for handling POST requests.
Deletes the object. Successful deletes are logged.
Returns a 'render redirect' to the result of the
`get_done_url` method.
If a ProtectedError is raised, the `render` method
is calle... | [
"def",
"post",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"object",
"=",
"self",
".",
"get_object",
"(",
")",
"msg",
"=",
"None",
"if",
"request",
".",
"POST",
".",
"get",
"(",
"'delete'",
")",
... | Method for handling POST requests.
Deletes the object. Successful deletes are logged.
Returns a 'render redirect' to the result of the
`get_done_url` method.
If a ProtectedError is raised, the `render` method
is called with message explaining the error added
to the conte... | [
"Method",
"for",
"handling",
"POST",
"requests",
".",
"Deletes",
"the",
"object",
".",
"Successful",
"deletes",
"are",
"logged",
".",
"Returns",
"a",
"render",
"redirect",
"to",
"the",
"result",
"of",
"the",
"get_done_url",
"method",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/actions.py#L597-L630 |
klahnakoski/pyLibrary | mo_math/vendor/aespython/key_expander.py | KeyExpander.expand | def expand(self, key_array):
"""
Expand the encryption key per AES key schedule specifications
http://en.wikipedia.org/wiki/Rijndael_key_schedule# Key_schedule_description
"""
if len(key_array) != self._n:
raise RuntimeError('expand(): key size ' + str(len(k... | python | def expand(self, key_array):
"""
Expand the encryption key per AES key schedule specifications
http://en.wikipedia.org/wiki/Rijndael_key_schedule# Key_schedule_description
"""
if len(key_array) != self._n:
raise RuntimeError('expand(): key size ' + str(len(k... | [
"def",
"expand",
"(",
"self",
",",
"key_array",
")",
":",
"if",
"len",
"(",
"key_array",
")",
"!=",
"self",
".",
"_n",
":",
"raise",
"RuntimeError",
"(",
"'expand(): key size '",
"+",
"str",
"(",
"len",
"(",
"key_array",
")",
")",
"+",
"' is invalid'",
... | Expand the encryption key per AES key schedule specifications
http://en.wikipedia.org/wiki/Rijndael_key_schedule# Key_schedule_description | [
"Expand",
"the",
"encryption",
"key",
"per",
"AES",
"key",
"schedule",
"specifications"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/vendor/aespython/key_expander.py#L54-L118 |
edaniszewski/bison | bison/utils.py | build_dot_value | def build_dot_value(key, value):
"""Build new dictionaries based off of the dot notation key.
For example, if a key were 'x.y.z' and the value was 'foo',
we would expect a return value of: ('x', {'y': {'z': 'foo'}})
Args:
key (str): The key to build a dictionary off of.
value: The valu... | python | def build_dot_value(key, value):
"""Build new dictionaries based off of the dot notation key.
For example, if a key were 'x.y.z' and the value was 'foo',
we would expect a return value of: ('x', {'y': {'z': 'foo'}})
Args:
key (str): The key to build a dictionary off of.
value: The valu... | [
"def",
"build_dot_value",
"(",
"key",
",",
"value",
")",
":",
"# if there is no nesting in the key (as specified by the",
"# presence of dot notation), then the key/value pair here",
"# are the final key value pair.",
"if",
"key",
".",
"count",
"(",
"'.'",
")",
"==",
"0",
":"... | Build new dictionaries based off of the dot notation key.
For example, if a key were 'x.y.z' and the value was 'foo',
we would expect a return value of: ('x', {'y': {'z': 'foo'}})
Args:
key (str): The key to build a dictionary off of.
value: The value associated with the dot notation key.
... | [
"Build",
"new",
"dictionaries",
"based",
"off",
"of",
"the",
"dot",
"notation",
"key",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/utils.py#L12-L42 |
edaniszewski/bison | bison/utils.py | _merge | def _merge(d, u):
"""Merge two dictionaries (or DotDicts) together.
Args:
d: The dictionary/DotDict to merge into.
u: The source of the data to merge.
"""
for k, v in u.items():
# if we have a mapping, recursively merge the values
if isinstance(v, collections.Mapping... | python | def _merge(d, u):
"""Merge two dictionaries (or DotDicts) together.
Args:
d: The dictionary/DotDict to merge into.
u: The source of the data to merge.
"""
for k, v in u.items():
# if we have a mapping, recursively merge the values
if isinstance(v, collections.Mapping... | [
"def",
"_merge",
"(",
"d",
",",
"u",
")",
":",
"for",
"k",
",",
"v",
"in",
"u",
".",
"items",
"(",
")",
":",
"# if we have a mapping, recursively merge the values",
"if",
"isinstance",
"(",
"v",
",",
"collections",
".",
"Mapping",
")",
":",
"d",
"[",
"... | Merge two dictionaries (or DotDicts) together.
Args:
d: The dictionary/DotDict to merge into.
u: The source of the data to merge. | [
"Merge",
"two",
"dictionaries",
"(",
"or",
"DotDicts",
")",
"together",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/utils.py#L210-L237 |
edaniszewski/bison | bison/utils.py | DotDict.get | def get(self, key, default=None):
"""Get a value from the `DotDict`.
The `key` parameter can either be a regular string key,
e.g. "foo", or it can be a string key with dot notation,
e.g. "foo.bar.baz", to signify a nested lookup.
The default value is returned if any level of th... | python | def get(self, key, default=None):
"""Get a value from the `DotDict`.
The `key` parameter can either be a regular string key,
e.g. "foo", or it can be a string key with dot notation,
e.g. "foo.bar.baz", to signify a nested lookup.
The default value is returned if any level of th... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"# if there are no dots in the key, its a normal get",
"if",
"key",
".",
"count",
"(",
"'.'",
")",
"==",
"0",
":",
"return",
"super",
"(",
"DotDict",
",",
"self",
")",
".",
"ge... | Get a value from the `DotDict`.
The `key` parameter can either be a regular string key,
e.g. "foo", or it can be a string key with dot notation,
e.g. "foo.bar.baz", to signify a nested lookup.
The default value is returned if any level of the key's
components are not found.
... | [
"Get",
"a",
"value",
"from",
"the",
"DotDict",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/utils.py#L98-L135 |
edaniszewski/bison | bison/utils.py | DotDict.delete | def delete(self, key):
"""Remove a value from the `DotDict`.
The `key` parameter can either be a regular string key,
e.g. "foo", or it can be a string key with dot notation,
e.g. "foo.bar.baz", to signify a nested element.
If the key does not exist in the `DotDict`, it will con... | python | def delete(self, key):
"""Remove a value from the `DotDict`.
The `key` parameter can either be a regular string key,
e.g. "foo", or it can be a string key with dot notation,
e.g. "foo.bar.baz", to signify a nested element.
If the key does not exist in the `DotDict`, it will con... | [
"def",
"delete",
"(",
"self",
",",
"key",
")",
":",
"dct",
"=",
"self",
"keys",
"=",
"key",
".",
"split",
"(",
"'.'",
")",
"last_key",
"=",
"keys",
"[",
"-",
"1",
"]",
"for",
"k",
"in",
"keys",
":",
"# if the key is the last one, e.g. 'z' in 'x.y.z', try... | Remove a value from the `DotDict`.
The `key` parameter can either be a regular string key,
e.g. "foo", or it can be a string key with dot notation,
e.g. "foo.bar.baz", to signify a nested element.
If the key does not exist in the `DotDict`, it will continue
silently.
A... | [
"Remove",
"a",
"value",
"from",
"the",
"DotDict",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/utils.py#L137-L171 |
delfick/nose-of-yeti | noseOfYeti/plugins/pylinter.py | make_extractor | def make_extractor(non_default):
"""
Return us a function to extract options
Anything not in non_default is wrapped in a "Default" object
"""
def extract_options(template, options):
for option, val in normalise_options(template):
name = option.replace('-', '_')
... | python | def make_extractor(non_default):
"""
Return us a function to extract options
Anything not in non_default is wrapped in a "Default" object
"""
def extract_options(template, options):
for option, val in normalise_options(template):
name = option.replace('-', '_')
... | [
"def",
"make_extractor",
"(",
"non_default",
")",
":",
"def",
"extract_options",
"(",
"template",
",",
"options",
")",
":",
"for",
"option",
",",
"val",
"in",
"normalise_options",
"(",
"template",
")",
":",
"name",
"=",
"option",
".",
"replace",
"(",
"'-'"... | Return us a function to extract options
Anything not in non_default is wrapped in a "Default" object | [
"Return",
"us",
"a",
"function",
"to",
"extract",
"options",
"Anything",
"not",
"in",
"non_default",
"is",
"wrapped",
"in",
"a",
"Default",
"object"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/plugins/pylinter.py#L27-L41 |
delfick/nose-of-yeti | noseOfYeti/plugins/pylinter.py | SpecRegister.set_option | def set_option(self, name, val, action=Empty, opts=Empty):
"""Determine which options were specified outside of the defaults"""
if action is Empty and opts is Empty:
self.specified.append(name)
super(SpecRegister, self).set_option(name, val)
else:
super(SpecRe... | python | def set_option(self, name, val, action=Empty, opts=Empty):
"""Determine which options were specified outside of the defaults"""
if action is Empty and opts is Empty:
self.specified.append(name)
super(SpecRegister, self).set_option(name, val)
else:
super(SpecRe... | [
"def",
"set_option",
"(",
"self",
",",
"name",
",",
"val",
",",
"action",
"=",
"Empty",
",",
"opts",
"=",
"Empty",
")",
":",
"if",
"action",
"is",
"Empty",
"and",
"opts",
"is",
"Empty",
":",
"self",
".",
"specified",
".",
"append",
"(",
"name",
")"... | Determine which options were specified outside of the defaults | [
"Determine",
"which",
"options",
"were",
"specified",
"outside",
"of",
"the",
"defaults"
] | train | https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/plugins/pylinter.py#L57-L63 |
klahnakoski/pyLibrary | jx_base/container.py | Container.new_instance | def new_instance(type, frum, schema=None):
"""
Factory!
"""
if not type2container:
_delayed_imports()
if isinstance(frum, Container):
return frum
elif isinstance(frum, _Cube):
return frum
elif isinstance(frum, _Query):
... | python | def new_instance(type, frum, schema=None):
"""
Factory!
"""
if not type2container:
_delayed_imports()
if isinstance(frum, Container):
return frum
elif isinstance(frum, _Cube):
return frum
elif isinstance(frum, _Query):
... | [
"def",
"new_instance",
"(",
"type",
",",
"frum",
",",
"schema",
"=",
"None",
")",
":",
"if",
"not",
"type2container",
":",
"_delayed_imports",
"(",
")",
"if",
"isinstance",
"(",
"frum",
",",
"Container",
")",
":",
"return",
"frum",
"elif",
"isinstance",
... | Factory! | [
"Factory!"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_base/container.py#L54-L94 |
Galarzaa90/tibia.py | tibiapy/house.py | House.from_content | def from_content(cls, content):
"""Parses a Tibia.com response into a House object.
Parameters
----------
content: :class:`str`
HTML content of the page.
Returns
-------
:class:`House`
The house contained in the page, or None if the house... | python | def from_content(cls, content):
"""Parses a Tibia.com response into a House object.
Parameters
----------
content: :class:`str`
HTML content of the page.
Returns
-------
:class:`House`
The house contained in the page, or None if the house... | [
"def",
"from_content",
"(",
"cls",
",",
"content",
")",
":",
"parsed_content",
"=",
"parse_tibiacom_content",
"(",
"content",
")",
"image_column",
",",
"desc_column",
",",
"",
"*",
"_",
"=",
"parsed_content",
".",
"find_all",
"(",
"'td'",
")",
"if",
"\"Error... | Parses a Tibia.com response into a House object.
Parameters
----------
content: :class:`str`
HTML content of the page.
Returns
-------
:class:`House`
The house contained in the page, or None if the house doesn't exist.
Raises
---... | [
"Parses",
"a",
"Tibia",
".",
"com",
"response",
"into",
"a",
"House",
"object",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L120-L171 |
Galarzaa90/tibia.py | tibiapy/house.py | House.from_tibiadata | def from_tibiadata(cls, content):
"""
Parses a TibiaData response into a House object.
Parameters
----------
content: :class:`str`
The JSON content of the TibiaData response.
Returns
-------
:class:`House`
The house contained in t... | python | def from_tibiadata(cls, content):
"""
Parses a TibiaData response into a House object.
Parameters
----------
content: :class:`str`
The JSON content of the TibiaData response.
Returns
-------
:class:`House`
The house contained in t... | [
"def",
"from_tibiadata",
"(",
"cls",
",",
"content",
")",
":",
"json_content",
"=",
"parse_json",
"(",
"content",
")",
"try",
":",
"house_json",
"=",
"json_content",
"[",
"\"house\"",
"]",
"if",
"not",
"house_json",
"[",
"\"name\"",
"]",
":",
"return",
"No... | Parses a TibiaData response into a House object.
Parameters
----------
content: :class:`str`
The JSON content of the TibiaData response.
Returns
-------
:class:`House`
The house contained in the response, if found.
Raises
------
... | [
"Parses",
"a",
"TibiaData",
"response",
"into",
"a",
"House",
"object",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L174-L212 |
Galarzaa90/tibia.py | tibiapy/house.py | House._parse_status | def _parse_status(self, status):
"""Parses the house's state description and applies the corresponding values
Parameters
----------
status: :class:`str`
Plain text string containing the current renting state of the house.
"""
m = rented_regex.search(status)
... | python | def _parse_status(self, status):
"""Parses the house's state description and applies the corresponding values
Parameters
----------
status: :class:`str`
Plain text string containing the current renting state of the house.
"""
m = rented_regex.search(status)
... | [
"def",
"_parse_status",
"(",
"self",
",",
"status",
")",
":",
"m",
"=",
"rented_regex",
".",
"search",
"(",
"status",
")",
"if",
"m",
":",
"self",
".",
"status",
"=",
"HouseStatus",
".",
"RENTED",
"self",
".",
"owner",
"=",
"m",
".",
"group",
"(",
... | Parses the house's state description and applies the corresponding values
Parameters
----------
status: :class:`str`
Plain text string containing the current renting state of the house. | [
"Parses",
"the",
"house",
"s",
"state",
"description",
"and",
"applies",
"the",
"corresponding",
"values"
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L215-L247 |
Galarzaa90/tibia.py | tibiapy/house.py | ListedHouse.list_from_content | def list_from_content(cls, content):
"""Parses the content of a house list from Tibia.com into a list of houses
Parameters
----------
content: :class:`str`
The raw HTML response from the house list.
Returns
-------
:class:`list` of :class:`ListedHous... | python | def list_from_content(cls, content):
"""Parses the content of a house list from Tibia.com into a list of houses
Parameters
----------
content: :class:`str`
The raw HTML response from the house list.
Returns
-------
:class:`list` of :class:`ListedHous... | [
"def",
"list_from_content",
"(",
"cls",
",",
"content",
")",
":",
"try",
":",
"parsed_content",
"=",
"parse_tibiacom_content",
"(",
"content",
")",
"table",
"=",
"parsed_content",
".",
"find",
"(",
"\"table\"",
")",
"header",
",",
"",
"*",
"rows",
"=",
"ta... | Parses the content of a house list from Tibia.com into a list of houses
Parameters
----------
content: :class:`str`
The raw HTML response from the house list.
Returns
-------
:class:`list` of :class:`ListedHouse`
Raises
------
Invali... | [
"Parses",
"the",
"content",
"of",
"a",
"house",
"list",
"from",
"Tibia",
".",
"com",
"into",
"a",
"list",
"of",
"houses"
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L359-L405 |
Galarzaa90/tibia.py | tibiapy/house.py | ListedHouse.list_from_tibiadata | def list_from_tibiadata(cls, content):
"""Parses the content of a house list from TibiaData.com into a list of houses
Parameters
----------
content: :class:`str`
The raw JSON response from TibiaData
Returns
-------
:class:`list` of :class:`ListedHous... | python | def list_from_tibiadata(cls, content):
"""Parses the content of a house list from TibiaData.com into a list of houses
Parameters
----------
content: :class:`str`
The raw JSON response from TibiaData
Returns
-------
:class:`list` of :class:`ListedHous... | [
"def",
"list_from_tibiadata",
"(",
"cls",
",",
"content",
")",
":",
"json_data",
"=",
"parse_json",
"(",
"content",
")",
"try",
":",
"house_data",
"=",
"json_data",
"[",
"\"houses\"",
"]",
"houses",
"=",
"[",
"]",
"house_type",
"=",
"HouseType",
".",
"HOUS... | Parses the content of a house list from TibiaData.com into a list of houses
Parameters
----------
content: :class:`str`
The raw JSON response from TibiaData
Returns
-------
:class:`list` of :class:`ListedHouse`
Raises
------
InvalidC... | [
"Parses",
"the",
"content",
"of",
"a",
"house",
"list",
"from",
"TibiaData",
".",
"com",
"into",
"a",
"list",
"of",
"houses"
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L408-L438 |
Galarzaa90/tibia.py | tibiapy/house.py | ListedHouse.get_list_url | def get_list_url(cls, world, town, house_type: HouseType = HouseType.HOUSE):
"""
Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters
----------
world: :class:`str`
The name of the world.
town: :class:`str`
The nam... | python | def get_list_url(cls, world, town, house_type: HouseType = HouseType.HOUSE):
"""
Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters
----------
world: :class:`str`
The name of the world.
town: :class:`str`
The nam... | [
"def",
"get_list_url",
"(",
"cls",
",",
"world",
",",
"town",
",",
"house_type",
":",
"HouseType",
"=",
"HouseType",
".",
"HOUSE",
")",
":",
"house_type",
"=",
"\"%ss\"",
"%",
"house_type",
".",
"value",
"return",
"HOUSE_LIST_URL",
"%",
"(",
"urllib",
".",... | Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters
----------
world: :class:`str`
The name of the world.
town: :class:`str`
The name of the town.
house_type: :class:`HouseType`
Whether to search for houses or... | [
"Gets",
"the",
"URL",
"to",
"the",
"house",
"list",
"on",
"Tibia",
".",
"com",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L441-L460 |
Galarzaa90/tibia.py | tibiapy/house.py | ListedHouse.get_list_url_tibiadata | def get_list_url_tibiadata(cls, world, town, house_type: HouseType = HouseType.HOUSE):
"""
Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters
----------
world: :class:`str`
The name of the world.
town: :class:`str`
... | python | def get_list_url_tibiadata(cls, world, town, house_type: HouseType = HouseType.HOUSE):
"""
Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters
----------
world: :class:`str`
The name of the world.
town: :class:`str`
... | [
"def",
"get_list_url_tibiadata",
"(",
"cls",
",",
"world",
",",
"town",
",",
"house_type",
":",
"HouseType",
"=",
"HouseType",
".",
"HOUSE",
")",
":",
"house_type",
"=",
"\"%ss\"",
"%",
"house_type",
".",
"value",
"return",
"HOUSE_LIST_URL_TIBIADATA",
"%",
"("... | Gets the URL to the house list on Tibia.com with the specified parameters.
Parameters
----------
world: :class:`str`
The name of the world.
town: :class:`str`
The name of the town.
house_type: :class:`HouseType`
Whether to search for houses or... | [
"Gets",
"the",
"URL",
"to",
"the",
"house",
"list",
"on",
"Tibia",
".",
"com",
"with",
"the",
"specified",
"parameters",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L463-L482 |
Galarzaa90/tibia.py | tibiapy/house.py | ListedHouse._parse_status | def _parse_status(self, status):
"""
Parses the status string found in the table and applies the corresponding values.
Parameters
----------
status: :class:`str`
The string containing the status.
"""
if "rented" in status:
self.status = Ho... | python | def _parse_status(self, status):
"""
Parses the status string found in the table and applies the corresponding values.
Parameters
----------
status: :class:`str`
The string containing the status.
"""
if "rented" in status:
self.status = Ho... | [
"def",
"_parse_status",
"(",
"self",
",",
"status",
")",
":",
"if",
"\"rented\"",
"in",
"status",
":",
"self",
".",
"status",
"=",
"HouseStatus",
".",
"RENTED",
"else",
":",
"m",
"=",
"list_auction_regex",
".",
"search",
"(",
"status",
")",
"if",
"m",
... | Parses the status string found in the table and applies the corresponding values.
Parameters
----------
status: :class:`str`
The string containing the status. | [
"Parses",
"the",
"status",
"string",
"found",
"in",
"the",
"table",
"and",
"applies",
"the",
"corresponding",
"values",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/house.py#L486-L505 |
edaniszewski/bison | bison/bison.py | Bison.config | def config(self):
"""Get the complete configuration where the default, config,
environment, and override values are merged together.
Returns:
(DotDict): A dictionary of configuration values that
allows lookups using dot notation.
"""
if self._full_con... | python | def config(self):
"""Get the complete configuration where the default, config,
environment, and override values are merged together.
Returns:
(DotDict): A dictionary of configuration values that
allows lookups using dot notation.
"""
if self._full_con... | [
"def",
"config",
"(",
"self",
")",
":",
"if",
"self",
".",
"_full_config",
"is",
"None",
":",
"self",
".",
"_full_config",
"=",
"DotDict",
"(",
")",
"self",
".",
"_full_config",
".",
"merge",
"(",
"self",
".",
"_default",
")",
"self",
".",
"_full_confi... | Get the complete configuration where the default, config,
environment, and override values are merged together.
Returns:
(DotDict): A dictionary of configuration values that
allows lookups using dot notation. | [
"Get",
"the",
"complete",
"configuration",
"where",
"the",
"default",
"config",
"environment",
"and",
"override",
"values",
"are",
"merged",
"together",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L79-L93 |
edaniszewski/bison | bison/bison.py | Bison.set | def set(self, key, value):
"""Set a value in the `Bison` configuration.
Args:
key (str): The configuration key to set a new value for.
value: The value to set.
"""
# the configuration changes, so we invalidate the cached config
self._full_config = None
... | python | def set(self, key, value):
"""Set a value in the `Bison` configuration.
Args:
key (str): The configuration key to set a new value for.
value: The value to set.
"""
# the configuration changes, so we invalidate the cached config
self._full_config = None
... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# the configuration changes, so we invalidate the cached config",
"self",
".",
"_full_config",
"=",
"None",
"self",
".",
"_override",
"[",
"key",
"]",
"=",
"value"
] | Set a value in the `Bison` configuration.
Args:
key (str): The configuration key to set a new value for.
value: The value to set. | [
"Set",
"a",
"value",
"in",
"the",
"Bison",
"configuration",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L108-L117 |
edaniszewski/bison | bison/bison.py | Bison.parse | def parse(self, requires_cfg=True):
"""Parse the configuration sources into `Bison`.
Args:
requires_cfg (bool): Specify whether or not parsing should fail
if a config file is not found. (default: True)
"""
self._parse_default()
self._parse_config(requ... | python | def parse(self, requires_cfg=True):
"""Parse the configuration sources into `Bison`.
Args:
requires_cfg (bool): Specify whether or not parsing should fail
if a config file is not found. (default: True)
"""
self._parse_default()
self._parse_config(requ... | [
"def",
"parse",
"(",
"self",
",",
"requires_cfg",
"=",
"True",
")",
":",
"self",
".",
"_parse_default",
"(",
")",
"self",
".",
"_parse_config",
"(",
"requires_cfg",
")",
"self",
".",
"_parse_env",
"(",
")"
] | Parse the configuration sources into `Bison`.
Args:
requires_cfg (bool): Specify whether or not parsing should fail
if a config file is not found. (default: True) | [
"Parse",
"the",
"configuration",
"sources",
"into",
"Bison",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L138-L147 |
edaniszewski/bison | bison/bison.py | Bison._find_config | def _find_config(self):
"""Searches through the configured `config_paths` for the `config_name`
file.
If there are no `config_paths` defined, this will raise an error, so the
caller should take care to check the value of `config_paths` first.
Returns:
str: The fully... | python | def _find_config(self):
"""Searches through the configured `config_paths` for the `config_name`
file.
If there are no `config_paths` defined, this will raise an error, so the
caller should take care to check the value of `config_paths` first.
Returns:
str: The fully... | [
"def",
"_find_config",
"(",
"self",
")",
":",
"for",
"search_path",
"in",
"self",
".",
"config_paths",
":",
"for",
"ext",
"in",
"self",
".",
"_fmt_to_ext",
".",
"get",
"(",
"self",
".",
"config_format",
")",
":",
"path",
"=",
"os",
".",
"path",
".",
... | Searches through the configured `config_paths` for the `config_name`
file.
If there are no `config_paths` defined, this will raise an error, so the
caller should take care to check the value of `config_paths` first.
Returns:
str: The fully qualified path to the configuratio... | [
"Searches",
"through",
"the",
"configured",
"config_paths",
"for",
"the",
"config_name",
"file",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L149-L170 |
edaniszewski/bison | bison/bison.py | Bison._parse_config | def _parse_config(self, requires_cfg=True):
"""Parse the configuration file, if one is configured, and add it to
the `Bison` state.
Args:
requires_cfg (bool): Specify whether or not parsing should fail
if a config file is not found. (default: True)
"""
... | python | def _parse_config(self, requires_cfg=True):
"""Parse the configuration file, if one is configured, and add it to
the `Bison` state.
Args:
requires_cfg (bool): Specify whether or not parsing should fail
if a config file is not found. (default: True)
"""
... | [
"def",
"_parse_config",
"(",
"self",
",",
"requires_cfg",
"=",
"True",
")",
":",
"if",
"len",
"(",
"self",
".",
"config_paths",
")",
">",
"0",
":",
"try",
":",
"self",
".",
"_find_config",
"(",
")",
"except",
"BisonError",
":",
"if",
"not",
"requires_c... | Parse the configuration file, if one is configured, and add it to
the `Bison` state.
Args:
requires_cfg (bool): Specify whether or not parsing should fail
if a config file is not found. (default: True) | [
"Parse",
"the",
"configuration",
"file",
"if",
"one",
"is",
"configured",
"and",
"add",
"it",
"to",
"the",
"Bison",
"state",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L172-L197 |
edaniszewski/bison | bison/bison.py | Bison._parse_env | def _parse_env(self):
"""Parse the environment variables for any configuration if an `env_prefix`
is set.
"""
env_cfg = DotDict()
# if the env prefix doesn't end with '_', we'll append it here
if self.env_prefix and not self.env_prefix.endswith('_'):
self.env... | python | def _parse_env(self):
"""Parse the environment variables for any configuration if an `env_prefix`
is set.
"""
env_cfg = DotDict()
# if the env prefix doesn't end with '_', we'll append it here
if self.env_prefix and not self.env_prefix.endswith('_'):
self.env... | [
"def",
"_parse_env",
"(",
"self",
")",
":",
"env_cfg",
"=",
"DotDict",
"(",
")",
"# if the env prefix doesn't end with '_', we'll append it here",
"if",
"self",
".",
"env_prefix",
"and",
"not",
"self",
".",
"env_prefix",
".",
"endswith",
"(",
"'_'",
")",
":",
"s... | Parse the environment variables for any configuration if an `env_prefix`
is set. | [
"Parse",
"the",
"environment",
"variables",
"for",
"any",
"configuration",
"if",
"an",
"env_prefix",
"is",
"set",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L199-L220 |
edaniszewski/bison | bison/bison.py | Bison._parse_default | def _parse_default(self):
"""Parse the `Schema` for the `Bison` instance to create the set of
default values.
If no defaults are specified in the `Schema`, the default dictionary
will not contain anything.
"""
# the configuration changes, so we invalidate the cached conf... | python | def _parse_default(self):
"""Parse the `Schema` for the `Bison` instance to create the set of
default values.
If no defaults are specified in the `Schema`, the default dictionary
will not contain anything.
"""
# the configuration changes, so we invalidate the cached conf... | [
"def",
"_parse_default",
"(",
"self",
")",
":",
"# the configuration changes, so we invalidate the cached config",
"self",
".",
"_full_config",
"=",
"None",
"if",
"self",
".",
"scheme",
":",
"self",
".",
"_default",
".",
"update",
"(",
"self",
".",
"scheme",
".",
... | Parse the `Schema` for the `Bison` instance to create the set of
default values.
If no defaults are specified in the `Schema`, the default dictionary
will not contain anything. | [
"Parse",
"the",
"Schema",
"for",
"the",
"Bison",
"instance",
"to",
"create",
"the",
"set",
"of",
"default",
"values",
"."
] | train | https://github.com/edaniszewski/bison/blob/0b889196bb314a0803c4089fe102eacacabb118b/bison/bison.py#L222-L233 |
klahnakoski/pyLibrary | mo_collections/relation.py | Relation_usingList.get_domain | def get_domain(self, value):
"""
RETURN domain FOR GIVEN CODOMAIN
:param value:
:return:
"""
return [k for k, v in self.all if v == value] | python | def get_domain(self, value):
"""
RETURN domain FOR GIVEN CODOMAIN
:param value:
:return:
"""
return [k for k, v in self.all if v == value] | [
"def",
"get_domain",
"(",
"self",
",",
"value",
")",
":",
"return",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"self",
".",
"all",
"if",
"v",
"==",
"value",
"]"
] | RETURN domain FOR GIVEN CODOMAIN
:param value:
:return: | [
"RETURN",
"domain",
"FOR",
"GIVEN",
"CODOMAIN",
":",
"param",
"value",
":",
":",
"return",
":"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/relation.py#L53-L59 |
klahnakoski/pyLibrary | mo_collections/relation.py | Relation_usingList.get_codomain | def get_codomain(self, key):
"""
RETURN AN ARRAY OF OBJECTS THAT key MAPS TO
"""
return [v for k, v in self.all if k == key] | python | def get_codomain(self, key):
"""
RETURN AN ARRAY OF OBJECTS THAT key MAPS TO
"""
return [v for k, v in self.all if k == key] | [
"def",
"get_codomain",
"(",
"self",
",",
"key",
")",
":",
"return",
"[",
"v",
"for",
"k",
",",
"v",
"in",
"self",
".",
"all",
"if",
"k",
"==",
"key",
"]"
] | RETURN AN ARRAY OF OBJECTS THAT key MAPS TO | [
"RETURN",
"AN",
"ARRAY",
"OF",
"OBJECTS",
"THAT",
"key",
"MAPS",
"TO"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_collections/relation.py#L61-L65 |
klahnakoski/pyLibrary | jx_python/containers/list_usingPythonList.py | ListContainer.update | def update(self, command):
"""
EXPECTING command == {"set":term, "clear":term, "where":where}
THE set CLAUSE IS A DICT MAPPING NAMES TO VALUES
THE where CLAUSE IS A JSON EXPRESSION FILTER
"""
command = wrap(command)
command_clear = listwrap(command["clear"])
... | python | def update(self, command):
"""
EXPECTING command == {"set":term, "clear":term, "where":where}
THE set CLAUSE IS A DICT MAPPING NAMES TO VALUES
THE where CLAUSE IS A JSON EXPRESSION FILTER
"""
command = wrap(command)
command_clear = listwrap(command["clear"])
... | [
"def",
"update",
"(",
"self",
",",
"command",
")",
":",
"command",
"=",
"wrap",
"(",
"command",
")",
"command_clear",
"=",
"listwrap",
"(",
"command",
"[",
"\"clear\"",
"]",
")",
"command_set",
"=",
"command",
".",
"set",
".",
"items",
"(",
")",
"comma... | EXPECTING command == {"set":term, "clear":term, "where":where}
THE set CLAUSE IS A DICT MAPPING NAMES TO VALUES
THE where CLAUSE IS A JSON EXPRESSION FILTER | [
"EXPECTING",
"command",
"==",
"{",
"set",
":",
"term",
"clear",
":",
"term",
"where",
":",
"where",
"}",
"THE",
"set",
"CLAUSE",
"IS",
"A",
"DICT",
"MAPPING",
"NAMES",
"TO",
"VALUES",
"THE",
"where",
"CLAUSE",
"IS",
"A",
"JSON",
"EXPRESSION",
"FILTER"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/containers/list_usingPythonList.py#L121-L137 |
klahnakoski/pyLibrary | jx_python/containers/list_usingPythonList.py | ListContainer.get | def get(self, select):
"""
:param select: the variable to extract from list
:return: a simple list of the extraction
"""
if is_list(select):
return [(d[s] for s in select) for d in self.data]
else:
return [d[select] for d in self.data] | python | def get(self, select):
"""
:param select: the variable to extract from list
:return: a simple list of the extraction
"""
if is_list(select):
return [(d[s] for s in select) for d in self.data]
else:
return [d[select] for d in self.data] | [
"def",
"get",
"(",
"self",
",",
"select",
")",
":",
"if",
"is_list",
"(",
"select",
")",
":",
"return",
"[",
"(",
"d",
"[",
"s",
"]",
"for",
"s",
"in",
"select",
")",
"for",
"d",
"in",
"self",
".",
"data",
"]",
"else",
":",
"return",
"[",
"d"... | :param select: the variable to extract from list
:return: a simple list of the extraction | [
":",
"param",
"select",
":",
"the",
"variable",
"to",
"extract",
"from",
"list",
":",
"return",
":",
"a",
"simple",
"list",
"of",
"the",
"extraction"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/containers/list_usingPythonList.py#L155-L163 |
anomaly/vishnu | vishnu/session.py | Session.timeout | def timeout(self, value):
"""Sets a custom timeout value for this session"""
if value == TIMEOUT_SESSION:
self._config.timeout = None
self._backend_client.expires = None
else:
self._config.timeout = value
self._calculate_expires() | python | def timeout(self, value):
"""Sets a custom timeout value for this session"""
if value == TIMEOUT_SESSION:
self._config.timeout = None
self._backend_client.expires = None
else:
self._config.timeout = value
self._calculate_expires() | [
"def",
"timeout",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"TIMEOUT_SESSION",
":",
"self",
".",
"_config",
".",
"timeout",
"=",
"None",
"self",
".",
"_backend_client",
".",
"expires",
"=",
"None",
"else",
":",
"self",
".",
"_config",
"... | Sets a custom timeout value for this session | [
"Sets",
"a",
"custom",
"timeout",
"value",
"for",
"this",
"session"
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L235-L243 |
anomaly/vishnu | vishnu/session.py | Session._calculate_expires | def _calculate_expires(self):
"""Calculates the session expiry using the timeout"""
self._backend_client.expires = None
now = datetime.utcnow()
self._backend_client.expires = now + timedelta(seconds=self._config.timeout) | python | def _calculate_expires(self):
"""Calculates the session expiry using the timeout"""
self._backend_client.expires = None
now = datetime.utcnow()
self._backend_client.expires = now + timedelta(seconds=self._config.timeout) | [
"def",
"_calculate_expires",
"(",
"self",
")",
":",
"self",
".",
"_backend_client",
".",
"expires",
"=",
"None",
"now",
"=",
"datetime",
".",
"utcnow",
"(",
")",
"self",
".",
"_backend_client",
".",
"expires",
"=",
"now",
"+",
"timedelta",
"(",
"seconds",
... | Calculates the session expiry using the timeout | [
"Calculates",
"the",
"session",
"expiry",
"using",
"the",
"timeout"
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L245-L250 |
anomaly/vishnu | vishnu/session.py | Session._load_cookie | def _load_cookie(self):
"""Loads HTTP Cookie from environ"""
cookie = SimpleCookie(self._environ.get('HTTP_COOKIE'))
vishnu_keys = [key for key in cookie.keys() if key == self._config.cookie_name]
# no session was started yet
if not vishnu_keys:
return
mors... | python | def _load_cookie(self):
"""Loads HTTP Cookie from environ"""
cookie = SimpleCookie(self._environ.get('HTTP_COOKIE'))
vishnu_keys = [key for key in cookie.keys() if key == self._config.cookie_name]
# no session was started yet
if not vishnu_keys:
return
mors... | [
"def",
"_load_cookie",
"(",
"self",
")",
":",
"cookie",
"=",
"SimpleCookie",
"(",
"self",
".",
"_environ",
".",
"get",
"(",
"'HTTP_COOKIE'",
")",
")",
"vishnu_keys",
"=",
"[",
"key",
"for",
"key",
"in",
"cookie",
".",
"keys",
"(",
")",
"if",
"key",
"... | Loads HTTP Cookie from environ | [
"Loads",
"HTTP",
"Cookie",
"from",
"environ"
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L252-L273 |
anomaly/vishnu | vishnu/session.py | Session.header | def header(self):
"""Generates HTTP header for this cookie."""
if self._send_cookie:
morsel = Morsel()
cookie_value = Session.encode_sid(self._config.secret, self._sid)
if self._config.encrypt_key:
cipher = AESCipher(self._config.encrypt_key)
... | python | def header(self):
"""Generates HTTP header for this cookie."""
if self._send_cookie:
morsel = Morsel()
cookie_value = Session.encode_sid(self._config.secret, self._sid)
if self._config.encrypt_key:
cipher = AESCipher(self._config.encrypt_key)
... | [
"def",
"header",
"(",
"self",
")",
":",
"if",
"self",
".",
"_send_cookie",
":",
"morsel",
"=",
"Morsel",
"(",
")",
"cookie_value",
"=",
"Session",
".",
"encode_sid",
"(",
"self",
".",
"_config",
".",
"secret",
",",
"self",
".",
"_sid",
")",
"if",
"se... | Generates HTTP header for this cookie. | [
"Generates",
"HTTP",
"header",
"for",
"this",
"cookie",
"."
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L275-L313 |
anomaly/vishnu | vishnu/session.py | Session.encode_sid | def encode_sid(cls, secret, sid):
"""Computes the HMAC for the given session id."""
secret_bytes = secret.encode("utf-8")
sid_bytes = sid.encode("utf-8")
sig = hmac.new(secret_bytes, sid_bytes, hashlib.sha512).hexdigest()
return "%s%s" % (sig, sid) | python | def encode_sid(cls, secret, sid):
"""Computes the HMAC for the given session id."""
secret_bytes = secret.encode("utf-8")
sid_bytes = sid.encode("utf-8")
sig = hmac.new(secret_bytes, sid_bytes, hashlib.sha512).hexdigest()
return "%s%s" % (sig, sid) | [
"def",
"encode_sid",
"(",
"cls",
",",
"secret",
",",
"sid",
")",
":",
"secret_bytes",
"=",
"secret",
".",
"encode",
"(",
"\"utf-8\"",
")",
"sid_bytes",
"=",
"sid",
".",
"encode",
"(",
"\"utf-8\"",
")",
"sig",
"=",
"hmac",
".",
"new",
"(",
"secret_bytes... | Computes the HMAC for the given session id. | [
"Computes",
"the",
"HMAC",
"for",
"the",
"given",
"session",
"id",
"."
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L316-L323 |
anomaly/vishnu | vishnu/session.py | Session.is_signature_equal | def is_signature_equal(cls, sig_a, sig_b):
"""Compares two signatures using a constant time algorithm to avoid timing attacks."""
if len(sig_a) != len(sig_b):
return False
invalid_chars = 0
for char_a, char_b in zip(sig_a, sig_b):
if char_a != char_b:
... | python | def is_signature_equal(cls, sig_a, sig_b):
"""Compares two signatures using a constant time algorithm to avoid timing attacks."""
if len(sig_a) != len(sig_b):
return False
invalid_chars = 0
for char_a, char_b in zip(sig_a, sig_b):
if char_a != char_b:
... | [
"def",
"is_signature_equal",
"(",
"cls",
",",
"sig_a",
",",
"sig_b",
")",
":",
"if",
"len",
"(",
"sig_a",
")",
"!=",
"len",
"(",
"sig_b",
")",
":",
"return",
"False",
"invalid_chars",
"=",
"0",
"for",
"char_a",
",",
"char_b",
"in",
"zip",
"(",
"sig_a... | Compares two signatures using a constant time algorithm to avoid timing attacks. | [
"Compares",
"two",
"signatures",
"using",
"a",
"constant",
"time",
"algorithm",
"to",
"avoid",
"timing",
"attacks",
"."
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L326-L335 |
anomaly/vishnu | vishnu/session.py | Session.decode_sid | def decode_sid(cls, secret, cookie_value):
"""Decodes a cookie value and returns the sid if value or None if invalid."""
if len(cookie_value) > SIG_LENGTH + SID_LENGTH:
logging.warn("cookie value is incorrect length")
return None
cookie_sig = cookie_value[:SIG_LENGTH]
... | python | def decode_sid(cls, secret, cookie_value):
"""Decodes a cookie value and returns the sid if value or None if invalid."""
if len(cookie_value) > SIG_LENGTH + SID_LENGTH:
logging.warn("cookie value is incorrect length")
return None
cookie_sig = cookie_value[:SIG_LENGTH]
... | [
"def",
"decode_sid",
"(",
"cls",
",",
"secret",
",",
"cookie_value",
")",
":",
"if",
"len",
"(",
"cookie_value",
")",
">",
"SIG_LENGTH",
"+",
"SID_LENGTH",
":",
"logging",
".",
"warn",
"(",
"\"cookie value is incorrect length\"",
")",
"return",
"None",
"cookie... | Decodes a cookie value and returns the sid if value or None if invalid. | [
"Decodes",
"a",
"cookie",
"value",
"and",
"returns",
"the",
"sid",
"if",
"value",
"or",
"None",
"if",
"invalid",
"."
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L338-L355 |
anomaly/vishnu | vishnu/session.py | Session.terminate | def terminate(self):
"""Terminates an active session"""
self._backend_client.clear()
self._needs_save = False
self._started = False
self._expire_cookie = True
self._send_cookie = True | python | def terminate(self):
"""Terminates an active session"""
self._backend_client.clear()
self._needs_save = False
self._started = False
self._expire_cookie = True
self._send_cookie = True | [
"def",
"terminate",
"(",
"self",
")",
":",
"self",
".",
"_backend_client",
".",
"clear",
"(",
")",
"self",
".",
"_needs_save",
"=",
"False",
"self",
".",
"_started",
"=",
"False",
"self",
".",
"_expire_cookie",
"=",
"True",
"self",
".",
"_send_cookie",
"... | Terminates an active session | [
"Terminates",
"an",
"active",
"session"
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L368-L374 |
anomaly/vishnu | vishnu/session.py | Session.get | def get(self, key):
"""Retrieve a value from the session dictionary"""
self._started = self._backend_client.load()
self._needs_save = True
return self._backend_client.get(key) | python | def get(self, key):
"""Retrieve a value from the session dictionary"""
self._started = self._backend_client.load()
self._needs_save = True
return self._backend_client.get(key) | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_started",
"=",
"self",
".",
"_backend_client",
".",
"load",
"(",
")",
"self",
".",
"_needs_save",
"=",
"True",
"return",
"self",
".",
"_backend_client",
".",
"get",
"(",
"key",
")"
] | Retrieve a value from the session dictionary | [
"Retrieve",
"a",
"value",
"from",
"the",
"session",
"dictionary"
] | train | https://github.com/anomaly/vishnu/blob/5b3a6a69beedc8554cc506ddfab273760d61dc65/vishnu/session.py#L376-L381 |
klahnakoski/pyLibrary | pyLibrary/env/flask_wrappers.py | cors_wrapper | def cors_wrapper(func):
"""
Decorator for CORS
:param func: Flask method that handles requests and returns a response
:return: Same, but with permissive CORS headers set
"""
def _setdefault(obj, key, value):
if value == None:
return
obj.setdefault(key, value)
de... | python | def cors_wrapper(func):
"""
Decorator for CORS
:param func: Flask method that handles requests and returns a response
:return: Same, but with permissive CORS headers set
"""
def _setdefault(obj, key, value):
if value == None:
return
obj.setdefault(key, value)
de... | [
"def",
"cors_wrapper",
"(",
"func",
")",
":",
"def",
"_setdefault",
"(",
"obj",
",",
"key",
",",
"value",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"obj",
".",
"setdefault",
"(",
"key",
",",
"value",
")",
"def",
"output",
"(",
"*",
"arg... | Decorator for CORS
:param func: Flask method that handles requests and returns a response
:return: Same, but with permissive CORS headers set | [
"Decorator",
"for",
"CORS",
":",
"param",
"func",
":",
"Flask",
"method",
"that",
"handles",
"requests",
"and",
"returns",
"a",
"response",
":",
"return",
":",
"Same",
"but",
"with",
"permissive",
"CORS",
"headers",
"set"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/flask_wrappers.py#L42-L65 |
klahnakoski/pyLibrary | pyLibrary/env/flask_wrappers.py | dockerflow | def dockerflow(flask_app, backend_check):
"""
ADD ROUTING TO HANDLE DOCKERFLOW APP REQUIREMENTS
(see https://github.com/mozilla-services/Dockerflow#containerized-app-requirements)
:param flask_app: THE (Flask) APP
:param backend_check: METHOD THAT WILL CHECK THE BACKEND IS WORKING AND RAISE AN EXCEP... | python | def dockerflow(flask_app, backend_check):
"""
ADD ROUTING TO HANDLE DOCKERFLOW APP REQUIREMENTS
(see https://github.com/mozilla-services/Dockerflow#containerized-app-requirements)
:param flask_app: THE (Flask) APP
:param backend_check: METHOD THAT WILL CHECK THE BACKEND IS WORKING AND RAISE AN EXCEP... | [
"def",
"dockerflow",
"(",
"flask_app",
",",
"backend_check",
")",
":",
"global",
"VERSION_JSON",
"try",
":",
"VERSION_JSON",
"=",
"File",
"(",
"\"version.json\"",
")",
".",
"read_bytes",
"(",
")",
"@",
"cors_wrapper",
"def",
"version",
"(",
")",
":",
"return... | ADD ROUTING TO HANDLE DOCKERFLOW APP REQUIREMENTS
(see https://github.com/mozilla-services/Dockerflow#containerized-app-requirements)
:param flask_app: THE (Flask) APP
:param backend_check: METHOD THAT WILL CHECK THE BACKEND IS WORKING AND RAISE AN EXCEPTION IF NOT
:return: | [
"ADD",
"ROUTING",
"TO",
"HANDLE",
"DOCKERFLOW",
"APP",
"REQUIREMENTS",
"(",
"see",
"https",
":",
"//",
"github",
".",
"com",
"/",
"mozilla",
"-",
"services",
"/",
"Dockerflow#containerized",
"-",
"app",
"-",
"requirements",
")",
":",
"param",
"flask_app",
":... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/flask_wrappers.py#L68-L114 |
inveniosoftware/invenio-collections | invenio_collections/percolator.py | new_collection_percolator | def new_collection_percolator(target):
"""Create new percolator associated with the new collection.
:param target: Collection where the percolator will be atached.
"""
query = IQ(target.dbquery)
for name in current_search.mappings.keys():
if target.name and target.dbquery:
curre... | python | def new_collection_percolator(target):
"""Create new percolator associated with the new collection.
:param target: Collection where the percolator will be atached.
"""
query = IQ(target.dbquery)
for name in current_search.mappings.keys():
if target.name and target.dbquery:
curre... | [
"def",
"new_collection_percolator",
"(",
"target",
")",
":",
"query",
"=",
"IQ",
"(",
"target",
".",
"dbquery",
")",
"for",
"name",
"in",
"current_search",
".",
"mappings",
".",
"keys",
"(",
")",
":",
"if",
"target",
".",
"name",
"and",
"target",
".",
... | Create new percolator associated with the new collection.
:param target: Collection where the percolator will be atached. | [
"Create",
"new",
"percolator",
"associated",
"with",
"the",
"new",
"collection",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/percolator.py#L27-L40 |
inveniosoftware/invenio-collections | invenio_collections/percolator.py | delete_collection_percolator | def delete_collection_percolator(target):
"""Delete percolator associated with the new collection.
:param target: Collection where the percolator was attached.
"""
for name in current_search.mappings.keys():
if target.name and target.dbquery:
current_search.client.delete(
... | python | def delete_collection_percolator(target):
"""Delete percolator associated with the new collection.
:param target: Collection where the percolator was attached.
"""
for name in current_search.mappings.keys():
if target.name and target.dbquery:
current_search.client.delete(
... | [
"def",
"delete_collection_percolator",
"(",
"target",
")",
":",
"for",
"name",
"in",
"current_search",
".",
"mappings",
".",
"keys",
"(",
")",
":",
"if",
"target",
".",
"name",
"and",
"target",
".",
"dbquery",
":",
"current_search",
".",
"client",
".",
"de... | Delete percolator associated with the new collection.
:param target: Collection where the percolator was attached. | [
"Delete",
"percolator",
"associated",
"with",
"the",
"new",
"collection",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/percolator.py#L43-L55 |
inveniosoftware/invenio-collections | invenio_collections/percolator.py | collection_updated_percolator | def collection_updated_percolator(mapper, connection, target):
"""Create percolator when collection is created.
:param mapper: Not used. It keeps the function signature.
:param connection: Not used. It keeps the function signature.
:param target: Collection where the percolator should be updated.
"... | python | def collection_updated_percolator(mapper, connection, target):
"""Create percolator when collection is created.
:param mapper: Not used. It keeps the function signature.
:param connection: Not used. It keeps the function signature.
:param target: Collection where the percolator should be updated.
"... | [
"def",
"collection_updated_percolator",
"(",
"mapper",
",",
"connection",
",",
"target",
")",
":",
"delete_collection_percolator",
"(",
"target",
")",
"if",
"target",
".",
"dbquery",
"is",
"not",
"None",
":",
"new_collection_percolator",
"(",
"target",
")"
] | Create percolator when collection is created.
:param mapper: Not used. It keeps the function signature.
:param connection: Not used. It keeps the function signature.
:param target: Collection where the percolator should be updated. | [
"Create",
"percolator",
"when",
"collection",
"is",
"created",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/percolator.py#L69-L78 |
inveniosoftware/invenio-collections | invenio_collections/percolator.py | _find_matching_collections_externally | def _find_matching_collections_externally(collections, record):
"""Find matching collections with percolator engine.
:param collections: set of collections where search
:param record: record to match
"""
index, doc_type = RecordIndexer().record_to_index(record)
body = {"doc": record.dumps()}
... | python | def _find_matching_collections_externally(collections, record):
"""Find matching collections with percolator engine.
:param collections: set of collections where search
:param record: record to match
"""
index, doc_type = RecordIndexer().record_to_index(record)
body = {"doc": record.dumps()}
... | [
"def",
"_find_matching_collections_externally",
"(",
"collections",
",",
"record",
")",
":",
"index",
",",
"doc_type",
"=",
"RecordIndexer",
"(",
")",
".",
"record_to_index",
"(",
"record",
")",
"body",
"=",
"{",
"\"doc\"",
":",
"record",
".",
"dumps",
"(",
... | Find matching collections with percolator engine.
:param collections: set of collections where search
:param record: record to match | [
"Find",
"matching",
"collections",
"with",
"percolator",
"engine",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/percolator.py#L92-L114 |
klahnakoski/pyLibrary | mo_dots/datas.py | leaves | def leaves(value, prefix=None):
"""
LIKE items() BUT RECURSIVE, AND ONLY FOR THE LEAVES (non dict) VALUES
SEE wrap_leaves FOR THE INVERSE
:param value: THE Mapping TO TRAVERSE
:param prefix: OPTIONAL PREFIX GIVEN TO EACH KEY
:return: Data, WHICH EACH KEY BEING A PATH INTO value TREE
"""
... | python | def leaves(value, prefix=None):
"""
LIKE items() BUT RECURSIVE, AND ONLY FOR THE LEAVES (non dict) VALUES
SEE wrap_leaves FOR THE INVERSE
:param value: THE Mapping TO TRAVERSE
:param prefix: OPTIONAL PREFIX GIVEN TO EACH KEY
:return: Data, WHICH EACH KEY BEING A PATH INTO value TREE
"""
... | [
"def",
"leaves",
"(",
"value",
",",
"prefix",
"=",
"None",
")",
":",
"prefix",
"=",
"coalesce",
"(",
"prefix",
",",
"\"\"",
")",
"output",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"value",
".",
"items",
"(",
")",
":",
"try",
":",
"if",
"_get"... | LIKE items() BUT RECURSIVE, AND ONLY FOR THE LEAVES (non dict) VALUES
SEE wrap_leaves FOR THE INVERSE
:param value: THE Mapping TO TRAVERSE
:param prefix: OPTIONAL PREFIX GIVEN TO EACH KEY
:return: Data, WHICH EACH KEY BEING A PATH INTO value TREE | [
"LIKE",
"items",
"()",
"BUT",
"RECURSIVE",
"AND",
"ONLY",
"FOR",
"THE",
"LEAVES",
"(",
"non",
"dict",
")",
"VALUES",
"SEE",
"wrap_leaves",
"FOR",
"THE",
"INVERSE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/datas.py#L307-L326 |
klahnakoski/pyLibrary | mo_dots/datas.py | _str | def _str(value, depth):
"""
FOR DEBUGGING POSSIBLY RECURSIVE STRUCTURES
"""
output = []
if depth >0 and _get(value, CLASS) in data_types:
for k, v in value.items():
output.append(str(k) + "=" + _str(v, depth - 1))
return "{" + ",\n".join(output) + "}"
elif depth >0 an... | python | def _str(value, depth):
"""
FOR DEBUGGING POSSIBLY RECURSIVE STRUCTURES
"""
output = []
if depth >0 and _get(value, CLASS) in data_types:
for k, v in value.items():
output.append(str(k) + "=" + _str(v, depth - 1))
return "{" + ",\n".join(output) + "}"
elif depth >0 an... | [
"def",
"_str",
"(",
"value",
",",
"depth",
")",
":",
"output",
"=",
"[",
"]",
"if",
"depth",
">",
"0",
"and",
"_get",
"(",
"value",
",",
"CLASS",
")",
"in",
"data_types",
":",
"for",
"k",
",",
"v",
"in",
"value",
".",
"items",
"(",
")",
":",
... | FOR DEBUGGING POSSIBLY RECURSIVE STRUCTURES | [
"FOR",
"DEBUGGING",
"POSSIBLY",
"RECURSIVE",
"STRUCTURES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/datas.py#L533-L547 |
klahnakoski/pyLibrary | mo_dots/datas.py | _DictUsingSelf.leaves | def leaves(self, prefix=None):
"""
LIKE items() BUT RECURSIVE, AND ONLY FOR THE LEAVES (non dict) VALUES
"""
prefix = coalesce(prefix, "")
output = []
for k, v in self.items():
if _get(v, CLASS) in data_types:
output.extend(wrap(v).leaves(prefi... | python | def leaves(self, prefix=None):
"""
LIKE items() BUT RECURSIVE, AND ONLY FOR THE LEAVES (non dict) VALUES
"""
prefix = coalesce(prefix, "")
output = []
for k, v in self.items():
if _get(v, CLASS) in data_types:
output.extend(wrap(v).leaves(prefi... | [
"def",
"leaves",
"(",
"self",
",",
"prefix",
"=",
"None",
")",
":",
"prefix",
"=",
"coalesce",
"(",
"prefix",
",",
"\"\"",
")",
"output",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"_get",
"(",
"v",
... | LIKE items() BUT RECURSIVE, AND ONLY FOR THE LEAVES (non dict) VALUES | [
"LIKE",
"items",
"()",
"BUT",
"RECURSIVE",
"AND",
"ONLY",
"FOR",
"THE",
"LEAVES",
"(",
"non",
"dict",
")",
"VALUES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_dots/datas.py#L450-L461 |
ambitioninc/django-entity-event | entity_event/context_serializer.py | DefaultContextSerializer.serialize_value | def serialize_value(self, value):
"""
Given a value, ensure that it is serialized properly
:param value:
:return:
"""
# Create a list of serialize methods to run the value through
serialize_methods = [
self.serialize_model,
self.serialize_j... | python | def serialize_value(self, value):
"""
Given a value, ensure that it is serialized properly
:param value:
:return:
"""
# Create a list of serialize methods to run the value through
serialize_methods = [
self.serialize_model,
self.serialize_j... | [
"def",
"serialize_value",
"(",
"self",
",",
"value",
")",
":",
"# Create a list of serialize methods to run the value through",
"serialize_methods",
"=",
"[",
"self",
".",
"serialize_model",
",",
"self",
".",
"serialize_json_string",
",",
"self",
".",
"serialize_list",
... | Given a value, ensure that it is serialized properly
:param value:
:return: | [
"Given",
"a",
"value",
"ensure",
"that",
"it",
"is",
"serialized",
"properly",
":",
"param",
"value",
":",
":",
"return",
":"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_serializer.py#L29-L48 |
ambitioninc/django-entity-event | entity_event/context_serializer.py | DefaultContextSerializer.serialize_model | def serialize_model(self, value):
"""
Serializes a model and all of its prefetched foreign keys
:param value:
:return:
"""
# Check if the context value is a model
if not isinstance(value, models.Model):
return value
# Serialize the model
... | python | def serialize_model(self, value):
"""
Serializes a model and all of its prefetched foreign keys
:param value:
:return:
"""
# Check if the context value is a model
if not isinstance(value, models.Model):
return value
# Serialize the model
... | [
"def",
"serialize_model",
"(",
"self",
",",
"value",
")",
":",
"# Check if the context value is a model",
"if",
"not",
"isinstance",
"(",
"value",
",",
"models",
".",
"Model",
")",
":",
"return",
"value",
"# Serialize the model",
"serialized_model",
"=",
"model_to_d... | Serializes a model and all of its prefetched foreign keys
:param value:
:return: | [
"Serializes",
"a",
"model",
"and",
"all",
"of",
"its",
"prefetched",
"foreign",
"keys",
":",
"param",
"value",
":",
":",
"return",
":"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_serializer.py#L50-L79 |
ambitioninc/django-entity-event | entity_event/context_serializer.py | DefaultContextSerializer.serialize_json_string | def serialize_json_string(self, value):
"""
Tries to load an encoded json string back into an object
:param json_string:
:return:
"""
# Check if the value might be a json string
if not isinstance(value, six.string_types):
return value
# Make ... | python | def serialize_json_string(self, value):
"""
Tries to load an encoded json string back into an object
:param json_string:
:return:
"""
# Check if the value might be a json string
if not isinstance(value, six.string_types):
return value
# Make ... | [
"def",
"serialize_json_string",
"(",
"self",
",",
"value",
")",
":",
"# Check if the value might be a json string",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"return",
"value",
"# Make sure it starts with a brace",
"if",
"not"... | Tries to load an encoded json string back into an object
:param json_string:
:return: | [
"Tries",
"to",
"load",
"an",
"encoded",
"json",
"string",
"back",
"into",
"an",
"object",
":",
"param",
"json_string",
":",
":",
"return",
":"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_serializer.py#L81-L100 |
ambitioninc/django-entity-event | entity_event/context_serializer.py | DefaultContextSerializer.serialize_list | def serialize_list(self, value):
"""
Ensure that all values of a list or tuple are serialized
:return:
"""
# Check if this is a list or a tuple
if not isinstance(value, (list, tuple)):
return value
# Loop over all the values and serialize the values
... | python | def serialize_list(self, value):
"""
Ensure that all values of a list or tuple are serialized
:return:
"""
# Check if this is a list or a tuple
if not isinstance(value, (list, tuple)):
return value
# Loop over all the values and serialize the values
... | [
"def",
"serialize_list",
"(",
"self",
",",
"value",
")",
":",
"# Check if this is a list or a tuple",
"if",
"not",
"isinstance",
"(",
"value",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"value",
"# Loop over all the values and serialize the values",
"r... | Ensure that all values of a list or tuple are serialized
:return: | [
"Ensure",
"that",
"all",
"values",
"of",
"a",
"list",
"or",
"tuple",
"are",
"serialized",
":",
"return",
":"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_serializer.py#L102-L116 |
ambitioninc/django-entity-event | entity_event/context_serializer.py | DefaultContextSerializer.serialize_dict | def serialize_dict(self, value):
"""
Ensure that all values of a dictionary are properly serialized
:param value:
:return:
"""
# Check if this is a dict
if not isinstance(value, dict):
return value
# Loop over all the values and serialize the... | python | def serialize_dict(self, value):
"""
Ensure that all values of a dictionary are properly serialized
:param value:
:return:
"""
# Check if this is a dict
if not isinstance(value, dict):
return value
# Loop over all the values and serialize the... | [
"def",
"serialize_dict",
"(",
"self",
",",
"value",
")",
":",
"# Check if this is a dict",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"return",
"value",
"# Loop over all the values and serialize them",
"return",
"{",
"dict_key",
":",
"self",
"... | Ensure that all values of a dictionary are properly serialized
:param value:
:return: | [
"Ensure",
"that",
"all",
"values",
"of",
"a",
"dictionary",
"are",
"properly",
"serialized",
":",
"param",
"value",
":",
":",
"return",
":"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_serializer.py#L118-L133 |
inveniosoftware/invenio-collections | invenio_collections/ext.py | _AppState.cache | def cache(self):
"""Return a cache instance."""
cache = self._cache or self.app.config.get('COLLECTIONS_CACHE')
return import_string(cache) if isinstance(cache, six.string_types) \
else cache | python | def cache(self):
"""Return a cache instance."""
cache = self._cache or self.app.config.get('COLLECTIONS_CACHE')
return import_string(cache) if isinstance(cache, six.string_types) \
else cache | [
"def",
"cache",
"(",
"self",
")",
":",
"cache",
"=",
"self",
".",
"_cache",
"or",
"self",
".",
"app",
".",
"config",
".",
"get",
"(",
"'COLLECTIONS_CACHE'",
")",
"return",
"import_string",
"(",
"cache",
")",
"if",
"isinstance",
"(",
"cache",
",",
"six"... | Return a cache instance. | [
"Return",
"a",
"cache",
"instance",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L48-L52 |
inveniosoftware/invenio-collections | invenio_collections/ext.py | _AppState.collections | def collections(self):
"""Get list of collections."""
# if cache server is configured, load collection from there
if self.cache:
return self.cache.get(
self.app.config['COLLECTIONS_CACHE_KEY']) | python | def collections(self):
"""Get list of collections."""
# if cache server is configured, load collection from there
if self.cache:
return self.cache.get(
self.app.config['COLLECTIONS_CACHE_KEY']) | [
"def",
"collections",
"(",
"self",
")",
":",
"# if cache server is configured, load collection from there",
"if",
"self",
".",
"cache",
":",
"return",
"self",
".",
"cache",
".",
"get",
"(",
"self",
".",
"app",
".",
"config",
"[",
"'COLLECTIONS_CACHE_KEY'",
"]",
... | Get list of collections. | [
"Get",
"list",
"of",
"collections",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L55-L60 |
inveniosoftware/invenio-collections | invenio_collections/ext.py | _AppState.collections | def collections(self, values):
"""Set list of collections."""
# if cache server is configured, save collection list
if self.cache:
self.cache.set(
self.app.config['COLLECTIONS_CACHE_KEY'], values) | python | def collections(self, values):
"""Set list of collections."""
# if cache server is configured, save collection list
if self.cache:
self.cache.set(
self.app.config['COLLECTIONS_CACHE_KEY'], values) | [
"def",
"collections",
"(",
"self",
",",
"values",
")",
":",
"# if cache server is configured, save collection list",
"if",
"self",
".",
"cache",
":",
"self",
".",
"cache",
".",
"set",
"(",
"self",
".",
"app",
".",
"config",
"[",
"'COLLECTIONS_CACHE_KEY'",
"]",
... | Set list of collections. | [
"Set",
"list",
"of",
"collections",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L63-L68 |
inveniosoftware/invenio-collections | invenio_collections/ext.py | _AppState.register_signals | def register_signals(self):
"""Register signals."""
from .models import Collection
from .receivers import CollectionUpdater
if self.app.config['COLLECTIONS_USE_PERCOLATOR']:
from .percolator import collection_inserted_percolator, \
collection_removed_percolat... | python | def register_signals(self):
"""Register signals."""
from .models import Collection
from .receivers import CollectionUpdater
if self.app.config['COLLECTIONS_USE_PERCOLATOR']:
from .percolator import collection_inserted_percolator, \
collection_removed_percolat... | [
"def",
"register_signals",
"(",
"self",
")",
":",
"from",
".",
"models",
"import",
"Collection",
"from",
".",
"receivers",
"import",
"CollectionUpdater",
"if",
"self",
".",
"app",
".",
"config",
"[",
"'COLLECTIONS_USE_PERCOLATOR'",
"]",
":",
"from",
".",
"perc... | Register signals. | [
"Register",
"signals",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L70-L91 |
inveniosoftware/invenio-collections | invenio_collections/ext.py | _AppState.unregister_signals | def unregister_signals(self):
"""Unregister signals."""
from .models import Collection
from .percolator import collection_inserted_percolator, \
collection_removed_percolator, collection_updated_percolator
# Unregister Record signals
if hasattr(self, 'update_function'... | python | def unregister_signals(self):
"""Unregister signals."""
from .models import Collection
from .percolator import collection_inserted_percolator, \
collection_removed_percolator, collection_updated_percolator
# Unregister Record signals
if hasattr(self, 'update_function'... | [
"def",
"unregister_signals",
"(",
"self",
")",
":",
"from",
".",
"models",
"import",
"Collection",
"from",
".",
"percolator",
"import",
"collection_inserted_percolator",
",",
"collection_removed_percolator",
",",
"collection_updated_percolator",
"# Unregister Record signals",... | Unregister signals. | [
"Unregister",
"signals",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L93-L107 |
inveniosoftware/invenio-collections | invenio_collections/ext.py | InvenioCollections.init_app | def init_app(self, app, **kwargs):
"""Flask application initialization."""
self.init_config(app)
state = _AppState(app=app, cache=kwargs.get('cache'))
app.extensions['invenio-collections'] = state
return state | python | def init_app(self, app, **kwargs):
"""Flask application initialization."""
self.init_config(app)
state = _AppState(app=app, cache=kwargs.get('cache'))
app.extensions['invenio-collections'] = state
return state | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"init_config",
"(",
"app",
")",
"state",
"=",
"_AppState",
"(",
"app",
"=",
"app",
",",
"cache",
"=",
"kwargs",
".",
"get",
"(",
"'cache'",
")",
")",
"app... | Flask application initialization. | [
"Flask",
"application",
"initialization",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L123-L128 |
allo-/django-bingo | bingo/views.py | _post_vote | def _post_vote(user_bingo_board, field, vote):
"""
change vote on a field
@param user_bingo_board: the user's bingo board or None
@param field: the BingoField to vote on
@param vote: the vote property from the HTTP POST
@raises: VoteException: if user_bingo_board is None or
... | python | def _post_vote(user_bingo_board, field, vote):
"""
change vote on a field
@param user_bingo_board: the user's bingo board or None
@param field: the BingoField to vote on
@param vote: the vote property from the HTTP POST
@raises: VoteException: if user_bingo_board is None or
... | [
"def",
"_post_vote",
"(",
"user_bingo_board",
",",
"field",
",",
"vote",
")",
":",
"if",
"field",
".",
"board",
"!=",
"user_bingo_board",
":",
"raise",
"VoteException",
"(",
"\"the voted field does not belong to the user's BingoBoard\"",
")",
"if",
"vote",
"==",
"\"... | change vote on a field
@param user_bingo_board: the user's bingo board or None
@param field: the BingoField to vote on
@param vote: the vote property from the HTTP POST
@raises: VoteException: if user_bingo_board is None or
the field does not belong to the user's bingo board.
... | [
"change",
"vote",
"on",
"a",
"field"
] | train | https://github.com/allo-/django-bingo/blob/16adcabbb91f227cb007f62b19f904ab1b751419/bingo/views.py#L309-L358 |
tetframework/Tonnikala | tonnikala/runtime/debug.py | translate_exception | def translate_exception(exc_info, initial_skip=0):
"""If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames.
"""
tb = exc_info[2]
frames = []
# skip some internal frames if wanted
for x in range(initial_skip):
if t... | python | def translate_exception(exc_info, initial_skip=0):
"""If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames.
"""
tb = exc_info[2]
frames = []
# skip some internal frames if wanted
for x in range(initial_skip):
if t... | [
"def",
"translate_exception",
"(",
"exc_info",
",",
"initial_skip",
"=",
"0",
")",
":",
"tb",
"=",
"exc_info",
"[",
"2",
"]",
"frames",
"=",
"[",
"]",
"# skip some internal frames if wanted",
"for",
"x",
"in",
"range",
"(",
"initial_skip",
")",
":",
"if",
... | If passed an exc_info it will automatically rewrite the exceptions
all the way down to the correct line numbers and frames. | [
"If",
"passed",
"an",
"exc_info",
"it",
"will",
"automatically",
"rewrite",
"the",
"exceptions",
"all",
"the",
"way",
"down",
"to",
"the",
"correct",
"line",
"numbers",
"and",
"frames",
"."
] | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/runtime/debug.py#L162-L201 |
tetframework/Tonnikala | tonnikala/runtime/debug.py | fake_exc_info | def fake_exc_info(exc_info, filename, lineno):
"""Helper for `translate_exception`."""
exc_type, exc_value, tb = exc_info
# figure the real context out
if tb is not None:
# if there is a local called __tonnikala_exception__, we get
# rid of it to not break the debug functionality.
... | python | def fake_exc_info(exc_info, filename, lineno):
"""Helper for `translate_exception`."""
exc_type, exc_value, tb = exc_info
# figure the real context out
if tb is not None:
# if there is a local called __tonnikala_exception__, we get
# rid of it to not break the debug functionality.
... | [
"def",
"fake_exc_info",
"(",
"exc_info",
",",
"filename",
",",
"lineno",
")",
":",
"exc_type",
",",
"exc_value",
",",
"tb",
"=",
"exc_info",
"# figure the real context out",
"if",
"tb",
"is",
"not",
"None",
":",
"# if there is a local called __tonnikala_exception__, w... | Helper for `translate_exception`. | [
"Helper",
"for",
"translate_exception",
"."
] | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/runtime/debug.py#L204-L278 |
commonwealth-of-puerto-rico/libre | libre/apps/data_drivers/utils.py | split_qs | def split_qs(string, delimiter='&'):
"""Split a string by the specified unquoted, not enclosed delimiter"""
open_list = '[<{('
close_list = ']>})'
quote_chars = '"\''
level = index = last_index = 0
quoted = False
result = []
for index, letter in enumerate(string):
if letter in... | python | def split_qs(string, delimiter='&'):
"""Split a string by the specified unquoted, not enclosed delimiter"""
open_list = '[<{('
close_list = ']>})'
quote_chars = '"\''
level = index = last_index = 0
quoted = False
result = []
for index, letter in enumerate(string):
if letter in... | [
"def",
"split_qs",
"(",
"string",
",",
"delimiter",
"=",
"'&'",
")",
":",
"open_list",
"=",
"'[<{('",
"close_list",
"=",
"']>})'",
"quote_chars",
"=",
"'\"\\''",
"level",
"=",
"index",
"=",
"last_index",
"=",
"0",
"quoted",
"=",
"False",
"result",
"=",
"... | Split a string by the specified unquoted, not enclosed delimiter | [
"Split",
"a",
"string",
"by",
"the",
"specified",
"unquoted",
"not",
"enclosed",
"delimiter"
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/utils.py#L174-L209 |
commonwealth-of-puerto-rico/libre | libre/apps/data_drivers/utils.py | parse_qs | def parse_qs(string):
"""Intelligently parse the query string"""
result = {}
for item in split_qs(string):
# Split the query string by unquotes ampersants ('&')
try:
# Split the item by unquotes equal signs
key, value = split_qs(item, delimiter='=')
except Va... | python | def parse_qs(string):
"""Intelligently parse the query string"""
result = {}
for item in split_qs(string):
# Split the query string by unquotes ampersants ('&')
try:
# Split the item by unquotes equal signs
key, value = split_qs(item, delimiter='=')
except Va... | [
"def",
"parse_qs",
"(",
"string",
")",
":",
"result",
"=",
"{",
"}",
"for",
"item",
"in",
"split_qs",
"(",
"string",
")",
":",
"# Split the query string by unquotes ampersants ('&')",
"try",
":",
"# Split the item by unquotes equal signs",
"key",
",",
"value",
"=",
... | Intelligently parse the query string | [
"Intelligently",
"parse",
"the",
"query",
"string"
] | train | https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/data_drivers/utils.py#L212-L227 |
klahnakoski/pyLibrary | mo_math/__init__.py | round | def round(value, decimal=7, digits=None):
"""
ROUND TO GIVEN NUMBER OF DIGITS, OR GIVEN NUMBER OF DECIMAL PLACES
decimal - NUMBER OF DIGITS AFTER DECIMAL POINT (NEGATIVE IS VALID)
digits - NUMBER OF SIGNIFICANT DIGITS (LESS THAN 1 IS INVALID)
"""
if value == None:
return None
else:
... | python | def round(value, decimal=7, digits=None):
"""
ROUND TO GIVEN NUMBER OF DIGITS, OR GIVEN NUMBER OF DECIMAL PLACES
decimal - NUMBER OF DIGITS AFTER DECIMAL POINT (NEGATIVE IS VALID)
digits - NUMBER OF SIGNIFICANT DIGITS (LESS THAN 1 IS INVALID)
"""
if value == None:
return None
else:
... | [
"def",
"round",
"(",
"value",
",",
"decimal",
"=",
"7",
",",
"digits",
"=",
"None",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"else",
":",
"value",
"=",
"float",
"(",
"value",
")",
"if",
"digits",
"!=",
"None",
":",
"if",
"dig... | ROUND TO GIVEN NUMBER OF DIGITS, OR GIVEN NUMBER OF DECIMAL PLACES
decimal - NUMBER OF DIGITS AFTER DECIMAL POINT (NEGATIVE IS VALID)
digits - NUMBER OF SIGNIFICANT DIGITS (LESS THAN 1 IS INVALID) | [
"ROUND",
"TO",
"GIVEN",
"NUMBER",
"OF",
"DIGITS",
"OR",
"GIVEN",
"NUMBER",
"OF",
"DECIMAL",
"PLACES",
"decimal",
"-",
"NUMBER",
"OF",
"DIGITS",
"AFTER",
"DECIMAL",
"POINT",
"(",
"NEGATIVE",
"IS",
"VALID",
")",
"digits",
"-",
"NUMBER",
"OF",
"SIGNIFICANT",
... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/__init__.py#L136-L170 |
klahnakoski/pyLibrary | mo_math/__init__.py | floor | def floor(value, mod=1):
"""
x == floor(x, a) + mod(x, a) FOR ALL a, x
RETURN None WHEN GIVEN INVALID ARGUMENTS
"""
if value == None:
return None
elif mod <= 0:
return None
elif mod == 1:
return int(math_floor(value))
elif is_integer(mod):
return int(math... | python | def floor(value, mod=1):
"""
x == floor(x, a) + mod(x, a) FOR ALL a, x
RETURN None WHEN GIVEN INVALID ARGUMENTS
"""
if value == None:
return None
elif mod <= 0:
return None
elif mod == 1:
return int(math_floor(value))
elif is_integer(mod):
return int(math... | [
"def",
"floor",
"(",
"value",
",",
"mod",
"=",
"1",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"elif",
"mod",
"<=",
"0",
":",
"return",
"None",
"elif",
"mod",
"==",
"1",
":",
"return",
"int",
"(",
"math_floor",
"(",
"value",
")... | x == floor(x, a) + mod(x, a) FOR ALL a, x
RETURN None WHEN GIVEN INVALID ARGUMENTS | [
"x",
"==",
"floor",
"(",
"x",
"a",
")",
"+",
"mod",
"(",
"x",
"a",
")",
"FOR",
"ALL",
"a",
"x",
"RETURN",
"None",
"WHEN",
"GIVEN",
"INVALID",
"ARGUMENTS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/__init__.py#L173-L187 |
klahnakoski/pyLibrary | mo_math/__init__.py | mod | def mod(value, mod=1):
"""
RETURN NON-NEGATIVE MODULO
RETURN None WHEN GIVEN INVALID ARGUMENTS
"""
if value == None:
return None
elif mod <= 0:
return None
elif value < 0:
return (value % mod + mod) % mod
else:
return value % mod | python | def mod(value, mod=1):
"""
RETURN NON-NEGATIVE MODULO
RETURN None WHEN GIVEN INVALID ARGUMENTS
"""
if value == None:
return None
elif mod <= 0:
return None
elif value < 0:
return (value % mod + mod) % mod
else:
return value % mod | [
"def",
"mod",
"(",
"value",
",",
"mod",
"=",
"1",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"elif",
"mod",
"<=",
"0",
":",
"return",
"None",
"elif",
"value",
"<",
"0",
":",
"return",
"(",
"value",
"%",
"mod",
"+",
"mod",
")"... | RETURN NON-NEGATIVE MODULO
RETURN None WHEN GIVEN INVALID ARGUMENTS | [
"RETURN",
"NON",
"-",
"NEGATIVE",
"MODULO",
"RETURN",
"None",
"WHEN",
"GIVEN",
"INVALID",
"ARGUMENTS"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/__init__.py#L190-L202 |
klahnakoski/pyLibrary | mo_math/__init__.py | ceiling | def ceiling(value, mod=1):
"""
RETURN SMALLEST INTEGER GREATER THAN value
"""
if value == None:
return None
mod = int(mod)
v = int(math_floor(value + mod))
return v - (v % mod) | python | def ceiling(value, mod=1):
"""
RETURN SMALLEST INTEGER GREATER THAN value
"""
if value == None:
return None
mod = int(mod)
v = int(math_floor(value + mod))
return v - (v % mod) | [
"def",
"ceiling",
"(",
"value",
",",
"mod",
"=",
"1",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"mod",
"=",
"int",
"(",
"mod",
")",
"v",
"=",
"int",
"(",
"math_floor",
"(",
"value",
"+",
"mod",
")",
")",
"return",
"v",
"-",
... | RETURN SMALLEST INTEGER GREATER THAN value | [
"RETURN",
"SMALLEST",
"INTEGER",
"GREATER",
"THAN",
"value"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/__init__.py#L225-L234 |
klahnakoski/pyLibrary | mo_math/__init__.py | MAX | def MAX(values, *others):
"""
DECISIVE MAX
:param values:
:param others:
:return:
"""
if others:
from mo_logs import Log
Log.warning("Calling wrong")
return MAX([values] + list(others))
output = Null
for v in values:
if v == None:
continu... | python | def MAX(values, *others):
"""
DECISIVE MAX
:param values:
:param others:
:return:
"""
if others:
from mo_logs import Log
Log.warning("Calling wrong")
return MAX([values] + list(others))
output = Null
for v in values:
if v == None:
continu... | [
"def",
"MAX",
"(",
"values",
",",
"*",
"others",
")",
":",
"if",
"others",
":",
"from",
"mo_logs",
"import",
"Log",
"Log",
".",
"warning",
"(",
"\"Calling wrong\"",
")",
"return",
"MAX",
"(",
"[",
"values",
"]",
"+",
"list",
"(",
"others",
")",
")",
... | DECISIVE MAX
:param values:
:param others:
:return: | [
"DECISIVE",
"MAX",
":",
"param",
"values",
":",
":",
"param",
"others",
":",
":",
"return",
":"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_math/__init__.py#L277-L298 |
rh-marketingops/dwm | dwm/cleaning.py | DataLookup | def DataLookup(fieldVal, db, lookupType, fieldName, histObj={}):
"""
Return new field value based on single-value lookup against MongoDB
:param string fieldVal: input value to lookup
:param MongoClient db: MongoClient instance connected to MongoDB
:param string lookupType: Type of lookup to perform... | python | def DataLookup(fieldVal, db, lookupType, fieldName, histObj={}):
"""
Return new field value based on single-value lookup against MongoDB
:param string fieldVal: input value to lookup
:param MongoClient db: MongoClient instance connected to MongoDB
:param string lookupType: Type of lookup to perform... | [
"def",
"DataLookup",
"(",
"fieldVal",
",",
"db",
",",
"lookupType",
",",
"fieldName",
",",
"histObj",
"=",
"{",
"}",
")",
":",
"if",
"lookupType",
"==",
"'genericLookup'",
":",
"lookup_dict",
"=",
"{",
"\"find\"",
":",
"_DataClean_",
"(",
"fieldVal",
")",
... | Return new field value based on single-value lookup against MongoDB
:param string fieldVal: input value to lookup
:param MongoClient db: MongoClient instance connected to MongoDB
:param string lookupType: Type of lookup to perform/MongoDB collection name.
One of 'genericLookup', 'fieldSpecificLo... | [
"Return",
"new",
"field",
"value",
"based",
"on",
"single",
"-",
"value",
"lookup",
"against",
"MongoDB"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/cleaning.py#L16-L51 |
rh-marketingops/dwm | dwm/cleaning.py | IncludesLookup | def IncludesLookup(fieldVal, lookupType, db, fieldName, deriveFieldName='',
deriveInput={}, histObj={}, overwrite=False,
blankIfNoMatch=False):
"""
Return new field value based on whether or not original value includes AND
excludes all words in a comma-delimited list qu... | python | def IncludesLookup(fieldVal, lookupType, db, fieldName, deriveFieldName='',
deriveInput={}, histObj={}, overwrite=False,
blankIfNoMatch=False):
"""
Return new field value based on whether or not original value includes AND
excludes all words in a comma-delimited list qu... | [
"def",
"IncludesLookup",
"(",
"fieldVal",
",",
"lookupType",
",",
"db",
",",
"fieldName",
",",
"deriveFieldName",
"=",
"''",
",",
"deriveInput",
"=",
"{",
"}",
",",
"histObj",
"=",
"{",
"}",
",",
"overwrite",
"=",
"False",
",",
"blankIfNoMatch",
"=",
"Fa... | Return new field value based on whether or not original value includes AND
excludes all words in a comma-delimited list queried from MongoDB
:param string fieldVal: input value to lookup
:param string lookupType: Type of lookup to perform/MongoDB collection name.
One of 'normIncludes', 'deriveIn... | [
"Return",
"new",
"field",
"value",
"based",
"on",
"whether",
"or",
"not",
"original",
"value",
"includes",
"AND",
"excludes",
"all",
"words",
"in",
"a",
"comma",
"-",
"delimited",
"list",
"queried",
"from",
"MongoDB"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/cleaning.py#L54-L157 |
rh-marketingops/dwm | dwm/cleaning.py | RegexLookup | def RegexLookup(fieldVal, db, fieldName, lookupType, histObj={}):
"""
Return a new field value based on match against regex queried from MongoDB
:param string fieldVal: input value to lookup
:param MongoClient db: MongoClient instance connected to MongoDB
:param string lookupType: Type of lookup to... | python | def RegexLookup(fieldVal, db, fieldName, lookupType, histObj={}):
"""
Return a new field value based on match against regex queried from MongoDB
:param string fieldVal: input value to lookup
:param MongoClient db: MongoClient instance connected to MongoDB
:param string lookupType: Type of lookup to... | [
"def",
"RegexLookup",
"(",
"fieldVal",
",",
"db",
",",
"fieldName",
",",
"lookupType",
",",
"histObj",
"=",
"{",
"}",
")",
":",
"if",
"lookupType",
"==",
"'genericRegex'",
":",
"lookup_dict",
"=",
"{",
"}",
"elif",
"lookupType",
"in",
"[",
"'fieldSpecificR... | Return a new field value based on match against regex queried from MongoDB
:param string fieldVal: input value to lookup
:param MongoClient db: MongoClient instance connected to MongoDB
:param string lookupType: Type of lookup to perform/MongoDB collection name.
One of 'genericRegex', 'fieldSpe... | [
"Return",
"a",
"new",
"field",
"value",
"based",
"on",
"match",
"against",
"regex",
"queried",
"from",
"MongoDB"
] | train | https://github.com/rh-marketingops/dwm/blob/66c7d18db857afbe5d574478ceaaad6159ae7469/dwm/cleaning.py#L160-L218 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.