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 |
|---|---|---|---|---|---|---|---|---|---|---|
maoaiz/django-admin-conf-vars | django_admin_conf_vars/global_vars.py | VariablesManager.load_attributes | def load_attributes(self):
'''Read the variables from the VARS_MODULE_PATH'''
try:
vars_path = settings.VARS_MODULE_PATH
except Exception:
# logger.warning("*" * 55)
logger.warning(
" [WARNING] Using default VARS_MODULE_PATH = '{}'".format(
... | python | def load_attributes(self):
'''Read the variables from the VARS_MODULE_PATH'''
try:
vars_path = settings.VARS_MODULE_PATH
except Exception:
# logger.warning("*" * 55)
logger.warning(
" [WARNING] Using default VARS_MODULE_PATH = '{}'".format(
... | [
"def",
"load_attributes",
"(",
"self",
")",
":",
"try",
":",
"vars_path",
"=",
"settings",
".",
"VARS_MODULE_PATH",
"except",
"Exception",
":",
"# logger.warning(\"*\" * 55)",
"logger",
".",
"warning",
"(",
"\" [WARNING] Using default VARS_MODULE_PATH = '{}'\"",
".",
"f... | Read the variables from the VARS_MODULE_PATH | [
"Read",
"the",
"variables",
"from",
"the",
"VARS_MODULE_PATH"
] | train | https://github.com/maoaiz/django-admin-conf-vars/blob/f18ddb62647719e3612ea87ee866fb27b901ac27/django_admin_conf_vars/global_vars.py#L64-L82 |
klahnakoski/pyLibrary | jx_python/expression_compiler.py | compile_expression | def compile_expression(source):
"""
THIS FUNCTION IS ON ITS OWN FOR MINIMAL GLOBAL NAMESPACE
:param source: PYTHON SOURCE CODE
:return: PYTHON FUNCTION
"""
# FORCE MODULES TO BE IN NAMESPACE
_ = coalesce
_ = listwrap
_ = Date
_ = convert
_ = Log
_ = Data
_ = EMPTY... | python | def compile_expression(source):
"""
THIS FUNCTION IS ON ITS OWN FOR MINIMAL GLOBAL NAMESPACE
:param source: PYTHON SOURCE CODE
:return: PYTHON FUNCTION
"""
# FORCE MODULES TO BE IN NAMESPACE
_ = coalesce
_ = listwrap
_ = Date
_ = convert
_ = Log
_ = Data
_ = EMPTY... | [
"def",
"compile_expression",
"(",
"source",
")",
":",
"# FORCE MODULES TO BE IN NAMESPACE",
"_",
"=",
"coalesce",
"_",
"=",
"listwrap",
"_",
"=",
"Date",
"_",
"=",
"convert",
"_",
"=",
"Log",
"_",
"=",
"Data",
"_",
"=",
"EMPTY_DICT",
"_",
"=",
"re",
"_",... | THIS FUNCTION IS ON ITS OWN FOR MINIMAL GLOBAL NAMESPACE
:param source: PYTHON SOURCE CODE
:return: PYTHON FUNCTION | [
"THIS",
"FUNCTION",
"IS",
"ON",
"ITS",
"OWN",
"FOR",
"MINIMAL",
"GLOBAL",
"NAMESPACE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/expression_compiler.py#L26-L62 |
oblalex/django-candv-choices | candv_x/django/choices/db.py | ChoicesField.clean | def clean(self, value, model_instance):
"""
Convert the value's type and run validation. Validation errors
from to_python and validate are propagated. The correct value is
returned if no error is raised.
"""
#: return constant's name instead of constant itself
val... | python | def clean(self, value, model_instance):
"""
Convert the value's type and run validation. Validation errors
from to_python and validate are propagated. The correct value is
returned if no error is raised.
"""
#: return constant's name instead of constant itself
val... | [
"def",
"clean",
"(",
"self",
",",
"value",
",",
"model_instance",
")",
":",
"#: return constant's name instead of constant itself",
"value",
"=",
"self",
".",
"to_python",
"(",
"value",
")",
".",
"name",
"self",
".",
"validate",
"(",
"value",
",",
"model_instanc... | Convert the value's type and run validation. Validation errors
from to_python and validate are propagated. The correct value is
returned if no error is raised. | [
"Convert",
"the",
"value",
"s",
"type",
"and",
"run",
"validation",
".",
"Validation",
"errors",
"from",
"to_python",
"and",
"validate",
"are",
"propagated",
".",
"The",
"correct",
"value",
"is",
"returned",
"if",
"no",
"error",
"is",
"raised",
"."
] | train | https://github.com/oblalex/django-candv-choices/blob/a299cefceebc2fb23e223dfcc63700dff572b6a0/candv_x/django/choices/db.py#L75-L85 |
oblalex/django-candv-choices | candv_x/django/choices/db.py | ChoicesField._get_choices | def _get_choices(self):
"""
Redefine standard method.
"""
if not self._choices:
self._choices = tuple(
(x.name, getattr(x, 'verbose_name', x.name) or x.name)
for x in self.choices_class.constants()
)
return self._choices | python | def _get_choices(self):
"""
Redefine standard method.
"""
if not self._choices:
self._choices = tuple(
(x.name, getattr(x, 'verbose_name', x.name) or x.name)
for x in self.choices_class.constants()
)
return self._choices | [
"def",
"_get_choices",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_choices",
":",
"self",
".",
"_choices",
"=",
"tuple",
"(",
"(",
"x",
".",
"name",
",",
"getattr",
"(",
"x",
",",
"'verbose_name'",
",",
"x",
".",
"name",
")",
"or",
"x",
".... | Redefine standard method. | [
"Redefine",
"standard",
"method",
"."
] | train | https://github.com/oblalex/django-candv-choices/blob/a299cefceebc2fb23e223dfcc63700dff572b6a0/candv_x/django/choices/db.py#L87-L96 |
oblalex/django-candv-choices | candv_x/django/choices/db.py | ChoicesField._get_flatchoices | def _get_flatchoices(self):
"""
Redefine standard method.
Return constants themselves instead of their names for right rendering
in admin's 'change_list' view, if field is present in 'list_display'
attribute of model's admin.
"""
return [
(self.to_pyt... | python | def _get_flatchoices(self):
"""
Redefine standard method.
Return constants themselves instead of their names for right rendering
in admin's 'change_list' view, if field is present in 'list_display'
attribute of model's admin.
"""
return [
(self.to_pyt... | [
"def",
"_get_flatchoices",
"(",
"self",
")",
":",
"return",
"[",
"(",
"self",
".",
"to_python",
"(",
"choice",
")",
",",
"value",
")",
"for",
"choice",
",",
"value",
"in",
"self",
".",
"_choices",
"]"
] | Redefine standard method.
Return constants themselves instead of their names for right rendering
in admin's 'change_list' view, if field is present in 'list_display'
attribute of model's admin. | [
"Redefine",
"standard",
"method",
"."
] | train | https://github.com/oblalex/django-candv-choices/blob/a299cefceebc2fb23e223dfcc63700dff572b6a0/candv_x/django/choices/db.py#L99-L109 |
oblalex/django-candv-choices | candv_x/django/choices/db.py | ChoicesField.formfield | def formfield(self, form_class=None, choices_form_class=None, **kwargs):
"""
Returns a django.forms.Field instance for this database Field.
"""
defaults = {
'required': not self.blank,
'label': capfirst(self.verbose_name),
'help_text': self.help_text,
... | python | def formfield(self, form_class=None, choices_form_class=None, **kwargs):
"""
Returns a django.forms.Field instance for this database Field.
"""
defaults = {
'required': not self.blank,
'label': capfirst(self.verbose_name),
'help_text': self.help_text,
... | [
"def",
"formfield",
"(",
"self",
",",
"form_class",
"=",
"None",
",",
"choices_form_class",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'required'",
":",
"not",
"self",
".",
"blank",
",",
"'label'",
":",
"capfirst",
"(",
"sel... | Returns a django.forms.Field instance for this database Field. | [
"Returns",
"a",
"django",
".",
"forms",
".",
"Field",
"instance",
"for",
"this",
"database",
"Field",
"."
] | train | https://github.com/oblalex/django-candv-choices/blob/a299cefceebc2fb23e223dfcc63700dff572b6a0/candv_x/django/choices/db.py#L112-L159 |
ff0000/scarlet | scarlet/cms/bundles.py | URLAlias.get_bundle | def get_bundle(self, current_bundle, url_kwargs, context_kwargs):
"""
Returns the bundle to get the alias view from.
If 'self.bundle_attr' is set, that bundle that it points to
will be returned, otherwise the current_bundle will be
returned.
"""
if self.bundle_att... | python | def get_bundle(self, current_bundle, url_kwargs, context_kwargs):
"""
Returns the bundle to get the alias view from.
If 'self.bundle_attr' is set, that bundle that it points to
will be returned, otherwise the current_bundle will be
returned.
"""
if self.bundle_att... | [
"def",
"get_bundle",
"(",
"self",
",",
"current_bundle",
",",
"url_kwargs",
",",
"context_kwargs",
")",
":",
"if",
"self",
".",
"bundle_attr",
":",
"if",
"self",
".",
"bundle_attr",
"==",
"PARENT",
":",
"return",
"current_bundle",
".",
"parent",
"view",
",",... | Returns the bundle to get the alias view from.
If 'self.bundle_attr' is set, that bundle that it points to
will be returned, otherwise the current_bundle will be
returned. | [
"Returns",
"the",
"bundle",
"to",
"get",
"the",
"alias",
"view",
"from",
".",
"If",
"self",
".",
"bundle_attr",
"is",
"set",
"that",
"bundle",
"that",
"it",
"points",
"to",
"will",
"be",
"returned",
"otherwise",
"the",
"current_bundle",
"will",
"be",
"retu... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L86-L100 |
ff0000/scarlet | scarlet/cms/bundles.py | URLAlias.get_view_name | def get_view_name(self, requested):
"""
Returns the name of the view to lookup.
If `requested` is equal to 'self.bundle_attr' then
'main' will be returned. Otherwise if `self.alias_to`
is set the it's value will be returned. Otherwise
the `requested` itself will be return... | python | def get_view_name(self, requested):
"""
Returns the name of the view to lookup.
If `requested` is equal to 'self.bundle_attr' then
'main' will be returned. Otherwise if `self.alias_to`
is set the it's value will be returned. Otherwise
the `requested` itself will be return... | [
"def",
"get_view_name",
"(",
"self",
",",
"requested",
")",
":",
"value",
"=",
"self",
".",
"alias_to",
"and",
"self",
".",
"alias_to",
"or",
"requested",
"if",
"value",
"==",
"self",
".",
"bundle_attr",
":",
"return",
"'main'",
"return",
"value"
] | Returns the name of the view to lookup.
If `requested` is equal to 'self.bundle_attr' then
'main' will be returned. Otherwise if `self.alias_to`
is set the it's value will be returned. Otherwise
the `requested` itself will be returned. | [
"Returns",
"the",
"name",
"of",
"the",
"view",
"to",
"lookup",
".",
"If",
"requested",
"is",
"equal",
"to",
"self",
".",
"bundle_attr",
"then",
"main",
"will",
"be",
"returned",
".",
"Otherwise",
"if",
"self",
".",
"alias_to",
"is",
"set",
"the",
"it",
... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L102-L114 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_object_header_view | def get_object_header_view(self, request, url_kwargs, parent_only=False,
render_type='object_header'):
"""
An object header is the title block of a CMS page. Actions
to linked to in the header are based on this views
bundle.
This returns a view in... | python | def get_object_header_view(self, request, url_kwargs, parent_only=False,
render_type='object_header'):
"""
An object header is the title block of a CMS page. Actions
to linked to in the header are based on this views
bundle.
This returns a view in... | [
"def",
"get_object_header_view",
"(",
"self",
",",
"request",
",",
"url_kwargs",
",",
"parent_only",
"=",
"False",
",",
"render_type",
"=",
"'object_header'",
")",
":",
"if",
"parent_only",
"and",
"self",
".",
"object_view",
"!=",
"self",
".",
"parent_attr",
"... | An object header is the title block of a CMS page. Actions
to linked to in the header are based on this views
bundle.
This returns a view instance and view name of the view that
should be rendered as an object header the view used is specified
in `self.object_view`. If not match... | [
"An",
"object",
"header",
"is",
"the",
"title",
"block",
"of",
"a",
"CMS",
"page",
".",
"Actions",
"to",
"linked",
"to",
"in",
"the",
"header",
"are",
"based",
"on",
"this",
"views",
"bundle",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L305-L340 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_string_from_view | def get_string_from_view(self, request, view_name, url_kwargs,
render_type='string'):
"""
Returns a string that is a rendering of the view given a
request, view_name, and the original url_kwargs. Makes the
following changes the view before... | python | def get_string_from_view(self, request, view_name, url_kwargs,
render_type='string'):
"""
Returns a string that is a rendering of the view given a
request, view_name, and the original url_kwargs. Makes the
following changes the view before... | [
"def",
"get_string_from_view",
"(",
"self",
",",
"request",
",",
"view_name",
",",
"url_kwargs",
",",
"render_type",
"=",
"'string'",
")",
":",
"response",
"=",
"\"\"",
"try",
":",
"view",
",",
"name",
"=",
"self",
".",
"get_initialized_view_and_name",
"(",
... | Returns a string that is a rendering of the view given a
request, view_name, and the original url_kwargs. Makes the
following changes the view before rendering:
* Sets can_submit to False.
* Adds action_url to the context. This is the url where \
this view actually lives.
... | [
"Returns",
"a",
"string",
"that",
"is",
"a",
"rendering",
"of",
"the",
"view",
"given",
"a",
"request",
"view_name",
"and",
"the",
"original",
"url_kwargs",
".",
"Makes",
"the",
"following",
"changes",
"the",
"view",
"before",
"rendering",
":"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L342-L392 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_view_url | def get_view_url(self, view_name, user,
url_kwargs=None, context_kwargs=None,
follow_parent=True, check_permissions=True):
"""
Returns the url for a given view_name. If the view isn't
found or the user does not have permission None is returned.
A... | python | def get_view_url(self, view_name, user,
url_kwargs=None, context_kwargs=None,
follow_parent=True, check_permissions=True):
"""
Returns the url for a given view_name. If the view isn't
found or the user does not have permission None is returned.
A... | [
"def",
"get_view_url",
"(",
"self",
",",
"view_name",
",",
"user",
",",
"url_kwargs",
"=",
"None",
",",
"context_kwargs",
"=",
"None",
",",
"follow_parent",
"=",
"True",
",",
"check_permissions",
"=",
"True",
")",
":",
"view",
",",
"url_name",
"=",
"self",... | Returns the url for a given view_name. If the view isn't
found or the user does not have permission None is returned.
A NoReverseMatch error may be raised if the view was unable
to find the correct keyword arguments for the reverse function
from the given url_kwargs and context_kwargs.
... | [
"Returns",
"the",
"url",
"for",
"a",
"given",
"view_name",
".",
"If",
"the",
"view",
"isn",
"t",
"found",
"or",
"the",
"user",
"does",
"not",
"have",
"permission",
"None",
"is",
"returned",
".",
"A",
"NoReverseMatch",
"error",
"may",
"be",
"raised",
"if"... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L400-L452 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_initialized_view_and_name | def get_initialized_view_and_name(self, view_name,
follow_parent=True, **extra_kwargs):
"""
Creates and returns a new instance of a CMSView \
and it's url_name.
:param view_name: The name of the view to return.
:param follow_parent: If we enco... | python | def get_initialized_view_and_name(self, view_name,
follow_parent=True, **extra_kwargs):
"""
Creates and returns a new instance of a CMSView \
and it's url_name.
:param view_name: The name of the view to return.
:param follow_parent: If we enco... | [
"def",
"get_initialized_view_and_name",
"(",
"self",
",",
"view_name",
",",
"follow_parent",
"=",
"True",
",",
"*",
"*",
"extra_kwargs",
")",
":",
"view",
",",
"name",
"=",
"self",
".",
"get_view_and_name",
"(",
"view_name",
")",
"# Initialize the view with the ri... | Creates and returns a new instance of a CMSView \
and it's url_name.
:param view_name: The name of the view to return.
:param follow_parent: If we encounter a parent reference should \
we follow it. Defaults to True.
:param extra_kwargs: Keyword arguments to pass to the view. | [
"Creates",
"and",
"returns",
"a",
"new",
"instance",
"of",
"a",
"CMSView",
"\\",
"and",
"it",
"s",
"url_name",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L483-L515 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_title | def get_title(self, plural=True):
"""
Get's the title of the bundle. Titles can be singular
or plural.
"""
value = self.title
if value == self.parent_attr:
return self.parent.get_title(plural=plural)
if not value and self._meta.model:
valu... | python | def get_title(self, plural=True):
"""
Get's the title of the bundle. Titles can be singular
or plural.
"""
value = self.title
if value == self.parent_attr:
return self.parent.get_title(plural=plural)
if not value and self._meta.model:
valu... | [
"def",
"get_title",
"(",
"self",
",",
"plural",
"=",
"True",
")",
":",
"value",
"=",
"self",
".",
"title",
"if",
"value",
"==",
"self",
".",
"parent_attr",
":",
"return",
"self",
".",
"parent",
".",
"get_title",
"(",
"plural",
"=",
"plural",
")",
"if... | Get's the title of the bundle. Titles can be singular
or plural. | [
"Get",
"s",
"the",
"title",
"of",
"the",
"bundle",
".",
"Titles",
"can",
"be",
"singular",
"or",
"plural",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L520-L537 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_view_and_name | def get_view_and_name(self, attname):
"""
Gets a view or bundle and returns it
and it's url_name.
"""
view = getattr(self, attname, None)
if attname in self._children:
view = self._get_bundle_from_promise(attname)
if view:
if attname in se... | python | def get_view_and_name(self, attname):
"""
Gets a view or bundle and returns it
and it's url_name.
"""
view = getattr(self, attname, None)
if attname in self._children:
view = self._get_bundle_from_promise(attname)
if view:
if attname in se... | [
"def",
"get_view_and_name",
"(",
"self",
",",
"attname",
")",
":",
"view",
"=",
"getattr",
"(",
"self",
",",
"attname",
",",
"None",
")",
"if",
"attname",
"in",
"self",
".",
"_children",
":",
"view",
"=",
"self",
".",
"_get_bundle_from_promise",
"(",
"at... | Gets a view or bundle and returns it
and it's url_name. | [
"Gets",
"a",
"view",
"or",
"bundle",
"and",
"returns",
"it",
"and",
"it",
"s",
"url_name",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L551-L580 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_urls | def get_urls(self):
"""
Returns urls handling bundles and views.
This processes the 'item view' first in order
and then adds any non item views at the end.
"""
parts = []
seen = set()
# Process item views in order
for v in list(self._meta.item_vie... | python | def get_urls(self):
"""
Returns urls handling bundles and views.
This processes the 'item view' first in order
and then adds any non item views at the end.
"""
parts = []
seen = set()
# Process item views in order
for v in list(self._meta.item_vie... | [
"def",
"get_urls",
"(",
"self",
")",
":",
"parts",
"=",
"[",
"]",
"seen",
"=",
"set",
"(",
")",
"# Process item views in order",
"for",
"v",
"in",
"list",
"(",
"self",
".",
"_meta",
".",
"item_views",
")",
"+",
"list",
"(",
"self",
".",
"_meta",
".",... | Returns urls handling bundles and views.
This processes the 'item view' first in order
and then adds any non item views at the end. | [
"Returns",
"urls",
"handling",
"bundles",
"and",
"views",
".",
"This",
"processes",
"the",
"item",
"view",
"first",
"in",
"order",
"and",
"then",
"adds",
"any",
"non",
"item",
"views",
"at",
"the",
"end",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L614-L638 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.get_navigation | def get_navigation(self, request, **kwargs):
"""
Generates a list of tuples based on the values
in `self.navigation` that are the side navigation links
for this bundle. The tuple format is (url, title).
"""
if self.navigation == self.parent_attr:
if self.pare... | python | def get_navigation(self, request, **kwargs):
"""
Generates a list of tuples based on the values
in `self.navigation` that are the side navigation links
for this bundle. The tuple format is (url, title).
"""
if self.navigation == self.parent_attr:
if self.pare... | [
"def",
"get_navigation",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"navigation",
"==",
"self",
".",
"parent_attr",
":",
"if",
"self",
".",
"parent",
":",
"return",
"self",
".",
"parent",
".",
"get_navigation",
"... | Generates a list of tuples based on the values
in `self.navigation` that are the side navigation links
for this bundle. The tuple format is (url, title). | [
"Generates",
"a",
"list",
"of",
"tuples",
"based",
"on",
"the",
"values",
"in",
"self",
".",
"navigation",
"that",
"are",
"the",
"side",
"navigation",
"links",
"for",
"this",
"bundle",
".",
"The",
"tuple",
"format",
"is",
"(",
"url",
"title",
")",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L679-L692 |
ff0000/scarlet | scarlet/cms/bundles.py | Bundle.as_subbundle | def as_subbundle(cls, name=None, title=None, title_plural=None):
"""
Wraps the given bundle so that it can be lazily
instantiated.
:param name: The slug for this bundle.
:param title: The verbose name for this bundle.
"""
return PromiseBundle(cls, name=name, titl... | python | def as_subbundle(cls, name=None, title=None, title_plural=None):
"""
Wraps the given bundle so that it can be lazily
instantiated.
:param name: The slug for this bundle.
:param title: The verbose name for this bundle.
"""
return PromiseBundle(cls, name=name, titl... | [
"def",
"as_subbundle",
"(",
"cls",
",",
"name",
"=",
"None",
",",
"title",
"=",
"None",
",",
"title_plural",
"=",
"None",
")",
":",
"return",
"PromiseBundle",
"(",
"cls",
",",
"name",
"=",
"name",
",",
"title",
"=",
"title",
",",
"title_plural",
"=",
... | Wraps the given bundle so that it can be lazily
instantiated.
:param name: The slug for this bundle.
:param title: The verbose name for this bundle. | [
"Wraps",
"the",
"given",
"bundle",
"so",
"that",
"it",
"can",
"be",
"lazily",
"instantiated",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/bundles.py#L695-L704 |
Jaza/flask-thumbnails-s3 | flask_thumbnails_s3/__init__.py | Thumbnail._thumbnail_resize | def _thumbnail_resize(self, image, thumb_size, crop=None, bg=None):
"""Performs the actual image cropping operation with PIL."""
if crop == 'fit':
img = ImageOps.fit(image, thumb_size, Image.ANTIALIAS)
else:
img = image.copy()
img.thumbnail(thumb_size, Image.... | python | def _thumbnail_resize(self, image, thumb_size, crop=None, bg=None):
"""Performs the actual image cropping operation with PIL."""
if crop == 'fit':
img = ImageOps.fit(image, thumb_size, Image.ANTIALIAS)
else:
img = image.copy()
img.thumbnail(thumb_size, Image.... | [
"def",
"_thumbnail_resize",
"(",
"self",
",",
"image",
",",
"thumb_size",
",",
"crop",
"=",
"None",
",",
"bg",
"=",
"None",
")",
":",
"if",
"crop",
"==",
"'fit'",
":",
"img",
"=",
"ImageOps",
".",
"fit",
"(",
"image",
",",
"thumb_size",
",",
"Image",... | Performs the actual image cropping operation with PIL. | [
"Performs",
"the",
"actual",
"image",
"cropping",
"operation",
"with",
"PIL",
"."
] | train | https://github.com/Jaza/flask-thumbnails-s3/blob/a4f20fa643cea175f7b7c22315f4ae8a3edc7636/flask_thumbnails_s3/__init__.py#L51-L63 |
Jaza/flask-thumbnails-s3 | flask_thumbnails_s3/__init__.py | Thumbnail._thumbnail_local | def _thumbnail_local(self, original_filename, thumb_filename,
thumb_size, thumb_url, crop=None, bg=None,
quality=85):
"""Finds or creates a thumbnail for the specified image on the local filesystem."""
# create folders
self._get_path(thumb_filen... | python | def _thumbnail_local(self, original_filename, thumb_filename,
thumb_size, thumb_url, crop=None, bg=None,
quality=85):
"""Finds or creates a thumbnail for the specified image on the local filesystem."""
# create folders
self._get_path(thumb_filen... | [
"def",
"_thumbnail_local",
"(",
"self",
",",
"original_filename",
",",
"thumb_filename",
",",
"thumb_size",
",",
"thumb_url",
",",
"crop",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"quality",
"=",
"85",
")",
":",
"# create folders",
"self",
".",
"_get_path",... | Finds or creates a thumbnail for the specified image on the local filesystem. | [
"Finds",
"or",
"creates",
"a",
"thumbnail",
"for",
"the",
"specified",
"image",
"on",
"the",
"local",
"filesystem",
"."
] | train | https://github.com/Jaza/flask-thumbnails-s3/blob/a4f20fa643cea175f7b7c22315f4ae8a3edc7636/flask_thumbnails_s3/__init__.py#L65-L88 |
Jaza/flask-thumbnails-s3 | flask_thumbnails_s3/__init__.py | Thumbnail._thumbnail_s3 | def _thumbnail_s3(self, original_filename, thumb_filename,
thumb_size, thumb_url, bucket_name,
crop=None, bg=None, quality=85):
"""Finds or creates a thumbnail for the specified image on Amazon S3."""
scheme = self.app.config.get('THUMBNAIL_S3_USE_HTTPS') and... | python | def _thumbnail_s3(self, original_filename, thumb_filename,
thumb_size, thumb_url, bucket_name,
crop=None, bg=None, quality=85):
"""Finds or creates a thumbnail for the specified image on Amazon S3."""
scheme = self.app.config.get('THUMBNAIL_S3_USE_HTTPS') and... | [
"def",
"_thumbnail_s3",
"(",
"self",
",",
"original_filename",
",",
"thumb_filename",
",",
"thumb_size",
",",
"thumb_url",
",",
"bucket_name",
",",
"crop",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"quality",
"=",
"85",
")",
":",
"scheme",
"=",
"self",
"... | Finds or creates a thumbnail for the specified image on Amazon S3. | [
"Finds",
"or",
"creates",
"a",
"thumbnail",
"for",
"the",
"specified",
"image",
"on",
"Amazon",
"S3",
"."
] | train | https://github.com/Jaza/flask-thumbnails-s3/blob/a4f20fa643cea175f7b7c22315f4ae8a3edc7636/flask_thumbnails_s3/__init__.py#L90-L147 |
Jaza/flask-thumbnails-s3 | flask_thumbnails_s3/__init__.py | Thumbnail.thumbnail | def thumbnail(self, img_url, size, crop=None, bg=None, quality=85,
storage_type=None, bucket_name=None):
"""
:param img_url: url img - '/assets/media/summer.jpg'
:param size: size return thumb - '100x100'
:param crop: crop return thumb - 'fit' or None
:param bg:... | python | def thumbnail(self, img_url, size, crop=None, bg=None, quality=85,
storage_type=None, bucket_name=None):
"""
:param img_url: url img - '/assets/media/summer.jpg'
:param size: size return thumb - '100x100'
:param crop: crop return thumb - 'fit' or None
:param bg:... | [
"def",
"thumbnail",
"(",
"self",
",",
"img_url",
",",
"size",
",",
"crop",
"=",
"None",
",",
"bg",
"=",
"None",
",",
"quality",
"=",
"85",
",",
"storage_type",
"=",
"None",
",",
"bucket_name",
"=",
"None",
")",
":",
"width",
",",
"height",
"=",
"["... | :param img_url: url img - '/assets/media/summer.jpg'
:param size: size return thumb - '100x100'
:param crop: crop return thumb - 'fit' or None
:param bg: tuple color or None - (255, 255, 255, 0)
:param quality: JPEG quality 1-100
:param storage_type: either 's3' or None
:... | [
":",
"param",
"img_url",
":",
"url",
"img",
"-",
"/",
"assets",
"/",
"media",
"/",
"summer",
".",
"jpg",
":",
"param",
"size",
":",
"size",
"return",
"thumb",
"-",
"100x100",
":",
"param",
"crop",
":",
"crop",
"return",
"thumb",
"-",
"fit",
"or",
"... | train | https://github.com/Jaza/flask-thumbnails-s3/blob/a4f20fa643cea175f7b7c22315f4ae8a3edc7636/flask_thumbnails_s3/__init__.py#L149-L193 |
ff0000/scarlet | scarlet/cms/renders.py | RenderResponse.update_kwargs | def update_kwargs(self, request, **kwargs):
"""
Hook for adding data to the context before
rendering a template.
:param kwargs: The current context keyword arguments.
:param request: The current request object.
"""
if not 'base' in kwargs:
kwargs['bas... | python | def update_kwargs(self, request, **kwargs):
"""
Hook for adding data to the context before
rendering a template.
:param kwargs: The current context keyword arguments.
:param request: The current request object.
"""
if not 'base' in kwargs:
kwargs['bas... | [
"def",
"update_kwargs",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"'base'",
"in",
"kwargs",
":",
"kwargs",
"[",
"'base'",
"]",
"=",
"self",
".",
"base",
"if",
"request",
".",
"is_ajax",
"(",
")",
"or",
"request",
... | Hook for adding data to the context before
rendering a template.
:param kwargs: The current context keyword arguments.
:param request: The current request object. | [
"Hook",
"for",
"adding",
"data",
"to",
"the",
"context",
"before",
"rendering",
"a",
"template",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/renders.py#L32-L45 |
ff0000/scarlet | scarlet/cms/renders.py | RenderResponse.render | def render(self, request, redirect_url=None, **kwargs):
"""
Uses `self.template` to render a response.
:param request: The current request object.
:param redirect_url: If given this will return the \
redirect method instead of rendering the normal template. \
Renders pro... | python | def render(self, request, redirect_url=None, **kwargs):
"""
Uses `self.template` to render a response.
:param request: The current request object.
:param redirect_url: If given this will return the \
redirect method instead of rendering the normal template. \
Renders pro... | [
"def",
"render",
"(",
"self",
",",
"request",
",",
"redirect_url",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"redirect_url",
":",
"# Redirection is used when we click on `Save` for ordering",
"# items on `ListView`. `kwargs` contains `message` but that",
"# one ... | Uses `self.template` to render a response.
:param request: The current request object.
:param redirect_url: If given this will return the \
redirect method instead of rendering the normal template. \
Renders providing this argument are referred to as a \
'render redirect' in thi... | [
"Uses",
"self",
".",
"template",
"to",
"render",
"a",
"response",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/renders.py#L47-L68 |
ff0000/scarlet | scarlet/cms/renders.py | CMSRender.update_kwargs | def update_kwargs(self, request, **kwargs):
"""
Adds variables to the context that are expected by the
base cms templates.
* **navigation** - The side navigation for this bundle and user.
* **dashboard** - The list of dashboard links for this user.
* **object_header** - ... | python | def update_kwargs(self, request, **kwargs):
"""
Adds variables to the context that are expected by the
base cms templates.
* **navigation** - The side navigation for this bundle and user.
* **dashboard** - The list of dashboard links for this user.
* **object_header** - ... | [
"def",
"update_kwargs",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"super",
"(",
"CMSRender",
",",
"self",
")",
".",
"update_kwargs",
"(",
"request",
",",
"*",
"*",
"kwargs",
")",
"# Check if we need to to include a separa... | Adds variables to the context that are expected by the
base cms templates.
* **navigation** - The side navigation for this bundle and user.
* **dashboard** - The list of dashboard links for this user.
* **object_header** - If no 'object_header' was passed in the \
current contex... | [
"Adds",
"variables",
"to",
"the",
"context",
"that",
"are",
"expected",
"by",
"the",
"base",
"cms",
"templates",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/renders.py#L89-L124 |
ff0000/scarlet | scarlet/cms/renders.py | ChoicesRender.get_different_page | def get_different_page(self, request, page):
"""
Returns a url that preserves the current querystring
while changing the page requested to `page`.
"""
if page:
qs = request.GET.copy()
qs['page'] = page
return "%s?%s" % (request.path_info, qs.u... | python | def get_different_page(self, request, page):
"""
Returns a url that preserves the current querystring
while changing the page requested to `page`.
"""
if page:
qs = request.GET.copy()
qs['page'] = page
return "%s?%s" % (request.path_info, qs.u... | [
"def",
"get_different_page",
"(",
"self",
",",
"request",
",",
"page",
")",
":",
"if",
"page",
":",
"qs",
"=",
"request",
".",
"GET",
".",
"copy",
"(",
")",
"qs",
"[",
"'page'",
"]",
"=",
"page",
"return",
"\"%s?%s\"",
"%",
"(",
"request",
".",
"pa... | Returns a url that preserves the current querystring
while changing the page requested to `page`. | [
"Returns",
"a",
"url",
"that",
"preserves",
"the",
"current",
"querystring",
"while",
"changing",
"the",
"page",
"requested",
"to",
"page",
"."
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/renders.py#L133-L143 |
ff0000/scarlet | scarlet/cms/renders.py | ChoicesRender.render | def render(self, request, **kwargs):
"""
Returns a JSON representation of a objects list page.
The json has the following attributes:
* **is_paginated** - Is the list paginated.
* **results** - A list of objects, where each object has an \
attribute/value for each field ... | python | def render(self, request, **kwargs):
"""
Returns a JSON representation of a objects list page.
The json has the following attributes:
* **is_paginated** - Is the list paginated.
* **results** - A list of objects, where each object has an \
attribute/value for each field ... | [
"def",
"render",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"{",
"'is_paginated'",
":",
"kwargs",
".",
"get",
"(",
"'is_paginated'",
")",
"}",
"if",
"data",
".",
"get",
"(",
"'is_paginated'",
")",
":",
"page",
"=",
... | Returns a JSON representation of a objects list page.
The json has the following attributes:
* **is_paginated** - Is the list paginated.
* **results** - A list of objects, where each object has an \
attribute/value for each field in the list. An 'id' attribute \
is always includ... | [
"Returns",
"a",
"JSON",
"representation",
"of",
"a",
"objects",
"list",
"page",
".",
"The",
"json",
"has",
"the",
"following",
"attributes",
":"
] | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/renders.py#L179-L268 |
ff0000/scarlet | scarlet/cms/options.py | Meta.get_kwargs_for_view | def get_kwargs_for_view(self, name):
"""
Returns the full list of keyword arguments
for the given view name as a dictionary.
First the default_kwargs dictionary is copied.
Then it is updated with the any of the 'view values'
that can be specified directly on this instance... | python | def get_kwargs_for_view(self, name):
"""
Returns the full list of keyword arguments
for the given view name as a dictionary.
First the default_kwargs dictionary is copied.
Then it is updated with the any of the 'view values'
that can be specified directly on this instance... | [
"def",
"get_kwargs_for_view",
"(",
"self",
",",
"name",
")",
":",
"data",
"=",
"dict",
"(",
"self",
".",
"default_kwargs",
")",
"for",
"k",
"in",
"self",
".",
"view_attributes",
":",
"if",
"hasattr",
"(",
"self",
",",
"k",
")",
":",
"data",
"[",
"k",... | Returns the full list of keyword arguments
for the given view name as a dictionary.
First the default_kwargs dictionary is copied.
Then it is updated with the any of the 'view values'
that can be specified directly on this instance. IE: models.
Then that dictionary is updated wit... | [
"Returns",
"the",
"full",
"list",
"of",
"keyword",
"arguments",
"for",
"the",
"given",
"view",
"name",
"as",
"a",
"dictionary",
".",
"First",
"the",
"default_kwargs",
"dictionary",
"is",
"copied",
".",
"Then",
"it",
"is",
"updated",
"with",
"the",
"any",
"... | train | https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/options.py#L121-L137 |
klahnakoski/pyLibrary | mo_json_config/__init__.py | get | def get(url):
"""
USE json.net CONVENTIONS TO LINK TO INLINE OTHER JSON
"""
url = text_type(url)
if url.find("://") == -1:
Log.error("{{url}} must have a prototcol (eg http://) declared", url=url)
base = URL("")
if url.startswith("file://") and url[7] != "/":
if os.sep=="\\"... | python | def get(url):
"""
USE json.net CONVENTIONS TO LINK TO INLINE OTHER JSON
"""
url = text_type(url)
if url.find("://") == -1:
Log.error("{{url}} must have a prototcol (eg http://) declared", url=url)
base = URL("")
if url.startswith("file://") and url[7] != "/":
if os.sep=="\\"... | [
"def",
"get",
"(",
"url",
")",
":",
"url",
"=",
"text_type",
"(",
"url",
")",
"if",
"url",
".",
"find",
"(",
"\"://\"",
")",
"==",
"-",
"1",
":",
"Log",
".",
"error",
"(",
"\"{{url}} must have a prototcol (eg http://) declared\"",
",",
"url",
"=",
"url",... | USE json.net CONVENTIONS TO LINK TO INLINE OTHER JSON | [
"USE",
"json",
".",
"net",
"CONVENTIONS",
"TO",
"LINK",
"TO",
"INLINE",
"OTHER",
"JSON"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_json_config/__init__.py#L36-L58 |
klahnakoski/pyLibrary | mo_json_config/__init__.py | expand | def expand(doc, doc_url="param://", params=None):
"""
ASSUMING YOU ALREADY PULED THE doc FROM doc_url, YOU CAN STILL USE THE
EXPANDING FEATURE
USE mo_json_config.expand({}) TO ASSUME CURRENT WORKING DIRECTORY
:param doc: THE DATA STRUCTURE FROM JSON SOURCE
:param doc_url: THE URL THIS doc CAME... | python | def expand(doc, doc_url="param://", params=None):
"""
ASSUMING YOU ALREADY PULED THE doc FROM doc_url, YOU CAN STILL USE THE
EXPANDING FEATURE
USE mo_json_config.expand({}) TO ASSUME CURRENT WORKING DIRECTORY
:param doc: THE DATA STRUCTURE FROM JSON SOURCE
:param doc_url: THE URL THIS doc CAME... | [
"def",
"expand",
"(",
"doc",
",",
"doc_url",
"=",
"\"param://\"",
",",
"params",
"=",
"None",
")",
":",
"if",
"doc_url",
".",
"find",
"(",
"\"://\"",
")",
"==",
"-",
"1",
":",
"Log",
".",
"error",
"(",
"\"{{url}} must have a prototcol (eg http://) declared\"... | ASSUMING YOU ALREADY PULED THE doc FROM doc_url, YOU CAN STILL USE THE
EXPANDING FEATURE
USE mo_json_config.expand({}) TO ASSUME CURRENT WORKING DIRECTORY
:param doc: THE DATA STRUCTURE FROM JSON SOURCE
:param doc_url: THE URL THIS doc CAME FROM (DEFAULT USES params AS A DOCUMENT SOURCE)
:param pa... | [
"ASSUMING",
"YOU",
"ALREADY",
"PULED",
"THE",
"doc",
"FROM",
"doc_url",
"YOU",
"CAN",
"STILL",
"USE",
"THE",
"EXPANDING",
"FEATURE"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_json_config/__init__.py#L61-L80 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | safe_size | def safe_size(source):
"""
READ THE source UP TO SOME LIMIT, THEN COPY TO A FILE IF TOO BIG
RETURN A str() OR A FileString()
"""
if source is None:
return None
total_bytes = 0
bytes = []
b = source.read(MIN_READ_SIZE)
while b:
total_bytes += len(b)
bytes.app... | python | def safe_size(source):
"""
READ THE source UP TO SOME LIMIT, THEN COPY TO A FILE IF TOO BIG
RETURN A str() OR A FileString()
"""
if source is None:
return None
total_bytes = 0
bytes = []
b = source.read(MIN_READ_SIZE)
while b:
total_bytes += len(b)
bytes.app... | [
"def",
"safe_size",
"(",
"source",
")",
":",
"if",
"source",
"is",
"None",
":",
"return",
"None",
"total_bytes",
"=",
"0",
"bytes",
"=",
"[",
"]",
"b",
"=",
"source",
".",
"read",
"(",
"MIN_READ_SIZE",
")",
"while",
"b",
":",
"total_bytes",
"+=",
"le... | READ THE source UP TO SOME LIMIT, THEN COPY TO A FILE IF TOO BIG
RETURN A str() OR A FileString() | [
"READ",
"THE",
"source",
"UP",
"TO",
"SOME",
"LIMIT",
"THEN",
"COPY",
"TO",
"A",
"FILE",
"IF",
"TOO",
"BIG",
"RETURN",
"A",
"str",
"()",
"OR",
"A",
"FileString",
"()"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L122-L159 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | compressed_bytes2ibytes | def compressed_bytes2ibytes(compressed, size):
"""
CONVERT AN ARRAY OF BYTES TO A BYTE-BLOCK GENERATOR
USEFUL IN THE CASE WHEN WE WANT TO LIMIT HOW MUCH WE FEED ANOTHER
GENERATOR (LIKE A DECOMPRESSOR)
"""
decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
for i in range(0, mo_math.ceilin... | python | def compressed_bytes2ibytes(compressed, size):
"""
CONVERT AN ARRAY OF BYTES TO A BYTE-BLOCK GENERATOR
USEFUL IN THE CASE WHEN WE WANT TO LIMIT HOW MUCH WE FEED ANOTHER
GENERATOR (LIKE A DECOMPRESSOR)
"""
decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
for i in range(0, mo_math.ceilin... | [
"def",
"compressed_bytes2ibytes",
"(",
"compressed",
",",
"size",
")",
":",
"decompressor",
"=",
"zlib",
".",
"decompressobj",
"(",
"16",
"+",
"zlib",
".",
"MAX_WBITS",
")",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"mo_math",
".",
"ceiling",
"(",
"len",... | CONVERT AN ARRAY OF BYTES TO A BYTE-BLOCK GENERATOR
USEFUL IN THE CASE WHEN WE WANT TO LIMIT HOW MUCH WE FEED ANOTHER
GENERATOR (LIKE A DECOMPRESSOR) | [
"CONVERT",
"AN",
"ARRAY",
"OF",
"BYTES",
"TO",
"A",
"BYTE",
"-",
"BLOCK",
"GENERATOR",
"USEFUL",
"IN",
"THE",
"CASE",
"WHEN",
"WE",
"WANT",
"TO",
"LIMIT",
"HOW",
"MUCH",
"WE",
"FEED",
"ANOTHER",
"GENERATOR",
"(",
"LIKE",
"A",
"DECOMPRESSOR",
")"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L269-L281 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | ibytes2ilines | def ibytes2ilines(generator, encoding="utf8", flexible=False, closer=None):
"""
CONVERT A GENERATOR OF (ARBITRARY-SIZED) byte BLOCKS
TO A LINE (CR-DELIMITED) GENERATOR
:param generator:
:param encoding: None TO DO NO DECODING
:param closer: OPTIONAL FUNCTION TO RUN WHEN DONE ITERATING
:retu... | python | def ibytes2ilines(generator, encoding="utf8", flexible=False, closer=None):
"""
CONVERT A GENERATOR OF (ARBITRARY-SIZED) byte BLOCKS
TO A LINE (CR-DELIMITED) GENERATOR
:param generator:
:param encoding: None TO DO NO DECODING
:param closer: OPTIONAL FUNCTION TO RUN WHEN DONE ITERATING
:retu... | [
"def",
"ibytes2ilines",
"(",
"generator",
",",
"encoding",
"=",
"\"utf8\"",
",",
"flexible",
"=",
"False",
",",
"closer",
"=",
"None",
")",
":",
"decode",
"=",
"get_decoder",
"(",
"encoding",
"=",
"encoding",
",",
"flexible",
"=",
"flexible",
")",
"_buffer... | CONVERT A GENERATOR OF (ARBITRARY-SIZED) byte BLOCKS
TO A LINE (CR-DELIMITED) GENERATOR
:param generator:
:param encoding: None TO DO NO DECODING
:param closer: OPTIONAL FUNCTION TO RUN WHEN DONE ITERATING
:return: | [
"CONVERT",
"A",
"GENERATOR",
"OF",
"(",
"ARBITRARY",
"-",
"SIZED",
")",
"byte",
"BLOCKS",
"TO",
"A",
"LINE",
"(",
"CR",
"-",
"DELIMITED",
")",
"GENERATOR"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L284-L316 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | icompressed2ibytes | def icompressed2ibytes(source):
"""
:param source: GENERATOR OF COMPRESSED BYTES
:return: GENERATOR OF BYTES
"""
decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
last_bytes_count = 0 # Track the last byte count, so we do not show too many debug lines
bytes_count = 0
for bytes_ in ... | python | def icompressed2ibytes(source):
"""
:param source: GENERATOR OF COMPRESSED BYTES
:return: GENERATOR OF BYTES
"""
decompressor = zlib.decompressobj(16 + zlib.MAX_WBITS)
last_bytes_count = 0 # Track the last byte count, so we do not show too many debug lines
bytes_count = 0
for bytes_ in ... | [
"def",
"icompressed2ibytes",
"(",
"source",
")",
":",
"decompressor",
"=",
"zlib",
".",
"decompressobj",
"(",
"16",
"+",
"zlib",
".",
"MAX_WBITS",
")",
"last_bytes_count",
"=",
"0",
"# Track the last byte count, so we do not show too many debug lines",
"bytes_count",
"=... | :param source: GENERATOR OF COMPRESSED BYTES
:return: GENERATOR OF BYTES | [
":",
"param",
"source",
":",
"GENERATOR",
"OF",
"COMPRESSED",
"BYTES",
":",
"return",
":",
"GENERATOR",
"OF",
"BYTES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L370-L387 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | scompressed2ibytes | def scompressed2ibytes(stream):
"""
:param stream: SOMETHING WITH read() METHOD TO GET MORE BYTES
:return: GENERATOR OF UNCOMPRESSED BYTES
"""
def more():
try:
while True:
bytes_ = stream.read(4096)
if not bytes_:
return
... | python | def scompressed2ibytes(stream):
"""
:param stream: SOMETHING WITH read() METHOD TO GET MORE BYTES
:return: GENERATOR OF UNCOMPRESSED BYTES
"""
def more():
try:
while True:
bytes_ = stream.read(4096)
if not bytes_:
return
... | [
"def",
"scompressed2ibytes",
"(",
"stream",
")",
":",
"def",
"more",
"(",
")",
":",
"try",
":",
"while",
"True",
":",
"bytes_",
"=",
"stream",
".",
"read",
"(",
"4096",
")",
"if",
"not",
"bytes_",
":",
"return",
"yield",
"bytes_",
"except",
"Exception"... | :param stream: SOMETHING WITH read() METHOD TO GET MORE BYTES
:return: GENERATOR OF UNCOMPRESSED BYTES | [
":",
"param",
"stream",
":",
"SOMETHING",
"WITH",
"read",
"()",
"METHOD",
"TO",
"GET",
"MORE",
"BYTES",
":",
"return",
":",
"GENERATOR",
"OF",
"UNCOMPRESSED",
"BYTES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L390-L408 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | sbytes2ilines | def sbytes2ilines(stream, encoding="utf8", closer=None):
"""
CONVERT A STREAM (with read() method) OF (ARBITRARY-SIZED) byte BLOCKS
TO A LINE (CR-DELIMITED) GENERATOR
"""
def read():
try:
while True:
bytes_ = stream.read(4096)
if not bytes_:
... | python | def sbytes2ilines(stream, encoding="utf8", closer=None):
"""
CONVERT A STREAM (with read() method) OF (ARBITRARY-SIZED) byte BLOCKS
TO A LINE (CR-DELIMITED) GENERATOR
"""
def read():
try:
while True:
bytes_ = stream.read(4096)
if not bytes_:
... | [
"def",
"sbytes2ilines",
"(",
"stream",
",",
"encoding",
"=",
"\"utf8\"",
",",
"closer",
"=",
"None",
")",
":",
"def",
"read",
"(",
")",
":",
"try",
":",
"while",
"True",
":",
"bytes_",
"=",
"stream",
".",
"read",
"(",
"4096",
")",
"if",
"not",
"byt... | CONVERT A STREAM (with read() method) OF (ARBITRARY-SIZED) byte BLOCKS
TO A LINE (CR-DELIMITED) GENERATOR | [
"CONVERT",
"A",
"STREAM",
"(",
"with",
"read",
"()",
"method",
")",
"OF",
"(",
"ARBITRARY",
"-",
"SIZED",
")",
"byte",
"BLOCKS",
"TO",
"A",
"LINE",
"(",
"CR",
"-",
"DELIMITED",
")",
"GENERATOR"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L411-L437 |
klahnakoski/pyLibrary | pyLibrary/env/big_data.py | get_decoder | def get_decoder(encoding, flexible=False):
"""
RETURN FUNCTION TO PERFORM DECODE
:param encoding: STRING OF THE ENCODING
:param flexible: True IF YOU WISH TO TRY OUR BEST, AND KEEP GOING
:return: FUNCTION
"""
if encoding == None:
def no_decode(v):
return v
return ... | python | def get_decoder(encoding, flexible=False):
"""
RETURN FUNCTION TO PERFORM DECODE
:param encoding: STRING OF THE ENCODING
:param flexible: True IF YOU WISH TO TRY OUR BEST, AND KEEP GOING
:return: FUNCTION
"""
if encoding == None:
def no_decode(v):
return v
return ... | [
"def",
"get_decoder",
"(",
"encoding",
",",
"flexible",
"=",
"False",
")",
":",
"if",
"encoding",
"==",
"None",
":",
"def",
"no_decode",
"(",
"v",
")",
":",
"return",
"v",
"return",
"no_decode",
"elif",
"flexible",
":",
"def",
"do_decode1",
"(",
"v",
"... | RETURN FUNCTION TO PERFORM DECODE
:param encoding: STRING OF THE ENCODING
:param flexible: True IF YOU WISH TO TRY OUR BEST, AND KEEP GOING
:return: FUNCTION | [
"RETURN",
"FUNCTION",
"TO",
"PERFORM",
"DECODE",
":",
"param",
"encoding",
":",
"STRING",
"OF",
"THE",
"ENCODING",
":",
"param",
"flexible",
":",
"True",
"IF",
"YOU",
"WISH",
"TO",
"TRY",
"OUR",
"BEST",
"AND",
"KEEP",
"GOING",
":",
"return",
":",
"FUNCTI... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/pyLibrary/env/big_data.py#L440-L458 |
ralphbean/raptorizemw | examples/tg2-raptorized/tg2raptorized/websetup/__init__.py | setup_app | def setup_app(command, conf, vars):
"""Place any commands to setup tg2raptorized here"""
load_environment(conf.global_conf, conf.local_conf)
setup_schema(command, conf, vars)
bootstrap.bootstrap(command, conf, vars) | python | def setup_app(command, conf, vars):
"""Place any commands to setup tg2raptorized here"""
load_environment(conf.global_conf, conf.local_conf)
setup_schema(command, conf, vars)
bootstrap.bootstrap(command, conf, vars) | [
"def",
"setup_app",
"(",
"command",
",",
"conf",
",",
"vars",
")",
":",
"load_environment",
"(",
"conf",
".",
"global_conf",
",",
"conf",
".",
"local_conf",
")",
"setup_schema",
"(",
"command",
",",
"conf",
",",
"vars",
")",
"bootstrap",
".",
"bootstrap",
... | Place any commands to setup tg2raptorized here | [
"Place",
"any",
"commands",
"to",
"setup",
"tg2raptorized",
"here"
] | train | https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/examples/tg2-raptorized/tg2raptorized/websetup/__init__.py#L15-L19 |
tetframework/Tonnikala | tonnikala/languages/javascript/generator.py | FreeVariableAnalyzerVisitor.visit_Identifier | def visit_Identifier(self, node):
"""Mangle names."""
if not self._is_mangle_candidate(node):
return
name = node.value
symbol = node.scope.resolve(node.value)
if symbol is None:
self.free_variables.add(name) | python | def visit_Identifier(self, node):
"""Mangle names."""
if not self._is_mangle_candidate(node):
return
name = node.value
symbol = node.scope.resolve(node.value)
if symbol is None:
self.free_variables.add(name) | [
"def",
"visit_Identifier",
"(",
"self",
",",
"node",
")",
":",
"if",
"not",
"self",
".",
"_is_mangle_candidate",
"(",
"node",
")",
":",
"return",
"name",
"=",
"node",
".",
"value",
"symbol",
"=",
"node",
".",
"scope",
".",
"resolve",
"(",
"node",
".",
... | Mangle names. | [
"Mangle",
"names",
"."
] | train | https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/languages/javascript/generator.py#L49-L58 |
Galarzaa90/tibia.py | tibiapy/enums.py | VocationFilter.from_name | def from_name(cls, name, all_fallback=True):
"""Gets a vocation filter from a vocation's name.
Parameters
----------
name: :class:`str`
The name of the vocation.
all_fallback: :class:`bool`
Whether to return :py:attr:`ALL` if no match is found. Otherwise,... | python | def from_name(cls, name, all_fallback=True):
"""Gets a vocation filter from a vocation's name.
Parameters
----------
name: :class:`str`
The name of the vocation.
all_fallback: :class:`bool`
Whether to return :py:attr:`ALL` if no match is found. Otherwise,... | [
"def",
"from_name",
"(",
"cls",
",",
"name",
",",
"all_fallback",
"=",
"True",
")",
":",
"name",
"=",
"name",
".",
"upper",
"(",
")",
"for",
"vocation",
"in",
"cls",
":",
"# type: VocationFilter",
"if",
"vocation",
".",
"name",
"in",
"name",
"or",
"voc... | Gets a vocation filter from a vocation's name.
Parameters
----------
name: :class:`str`
The name of the vocation.
all_fallback: :class:`bool`
Whether to return :py:attr:`ALL` if no match is found. Otherwise, ``None`` will be returned.
Returns
---... | [
"Gets",
"a",
"vocation",
"filter",
"from",
"a",
"vocation",
"s",
"name",
"."
] | train | https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/enums.py#L91-L112 |
jmoiron/micromongo | micromongo/models.py | connect | def connect(*args, **kwargs):
"""Connect to the database. Passes arguments along to
``pymongo.connection.Connection`` unmodified.
The Connection returned by this proxy method will be used by micromongo
for all of its queries. Micromongo will alter the behavior of this
conneciton object in some su... | python | def connect(*args, **kwargs):
"""Connect to the database. Passes arguments along to
``pymongo.connection.Connection`` unmodified.
The Connection returned by this proxy method will be used by micromongo
for all of its queries. Micromongo will alter the behavior of this
conneciton object in some su... | [
"def",
"connect",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"global",
"__connection",
",",
"__connection_args",
"__connection_args",
"=",
"(",
"args",
",",
"dict",
"(",
"kwargs",
")",
")",
"# inject our class_router",
"kwargs",
"[",
"'class_router'"... | Connect to the database. Passes arguments along to
``pymongo.connection.Connection`` unmodified.
The Connection returned by this proxy method will be used by micromongo
for all of its queries. Micromongo will alter the behavior of this
conneciton object in some subtle ways; if you want a clean one, ... | [
"Connect",
"to",
"the",
"database",
".",
"Passes",
"arguments",
"along",
"to",
"pymongo",
".",
"connection",
".",
"Connection",
"unmodified",
"."
] | train | https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/models.py#L23-L36 |
jmoiron/micromongo | micromongo/models.py | Model.new | def new(cls, *args, **kwargs):
"""Create a new instance of this model based on its spec and either
a map or the provided kwargs."""
new = cls(make_default(getattr(cls, 'spec', {})))
new.update(args[0] if args and not kwargs else kwargs)
return new | python | def new(cls, *args, **kwargs):
"""Create a new instance of this model based on its spec and either
a map or the provided kwargs."""
new = cls(make_default(getattr(cls, 'spec', {})))
new.update(args[0] if args and not kwargs else kwargs)
return new | [
"def",
"new",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"new",
"=",
"cls",
"(",
"make_default",
"(",
"getattr",
"(",
"cls",
",",
"'spec'",
",",
"{",
"}",
")",
")",
")",
"new",
".",
"update",
"(",
"args",
"[",
"0",
"]",
... | Create a new instance of this model based on its spec and either
a map or the provided kwargs. | [
"Create",
"a",
"new",
"instance",
"of",
"this",
"model",
"based",
"on",
"its",
"spec",
"and",
"either",
"a",
"map",
"or",
"the",
"provided",
"kwargs",
"."
] | train | https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/models.py#L93-L98 |
jmoiron/micromongo | micromongo/models.py | Model.find_one | def find_one(cls, *args, **kwargs):
"""Run a find_one on this model's collection. The arguments to
``Model.find_one`` are the same as to ``pymongo.Collection.find_one``."""
database, collection = cls._collection_key.split('.')
return current()[database][collection].find_one(*args, **kwa... | python | def find_one(cls, *args, **kwargs):
"""Run a find_one on this model's collection. The arguments to
``Model.find_one`` are the same as to ``pymongo.Collection.find_one``."""
database, collection = cls._collection_key.split('.')
return current()[database][collection].find_one(*args, **kwa... | [
"def",
"find_one",
"(",
"cls",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"database",
",",
"collection",
"=",
"cls",
".",
"_collection_key",
".",
"split",
"(",
"'.'",
")",
"return",
"current",
"(",
")",
"[",
"database",
"]",
"[",
"collectio... | Run a find_one on this model's collection. The arguments to
``Model.find_one`` are the same as to ``pymongo.Collection.find_one``. | [
"Run",
"a",
"find_one",
"on",
"this",
"model",
"s",
"collection",
".",
"The",
"arguments",
"to",
"Model",
".",
"find_one",
"are",
"the",
"same",
"as",
"to",
"pymongo",
".",
"Collection",
".",
"find_one",
"."
] | train | https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/models.py#L108-L112 |
jmoiron/micromongo | micromongo/models.py | Model.save | def save(self):
"""Save this object to the database. Behaves very similarly to
whatever collection.save(document) would, ie. does upserts on _id
presence. If methods ``pre_save`` or ``post_save`` are defined, those
are called. If there is a spec document, then the document is
... | python | def save(self):
"""Save this object to the database. Behaves very similarly to
whatever collection.save(document) would, ie. does upserts on _id
presence. If methods ``pre_save`` or ``post_save`` are defined, those
are called. If there is a spec document, then the document is
... | [
"def",
"save",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'pre_save'",
")",
":",
"self",
".",
"pre_save",
"(",
")",
"database",
",",
"collection",
"=",
"self",
".",
"_collection_key",
".",
"split",
"(",
"'.'",
")",
"self",
".",
"valid... | Save this object to the database. Behaves very similarly to
whatever collection.save(document) would, ie. does upserts on _id
presence. If methods ``pre_save`` or ``post_save`` are defined, those
are called. If there is a spec document, then the document is
validated against it after ... | [
"Save",
"this",
"object",
"to",
"the",
"database",
".",
"Behaves",
"very",
"similarly",
"to",
"whatever",
"collection",
".",
"save",
"(",
"document",
")",
"would",
"ie",
".",
"does",
"upserts",
"on",
"_id",
"presence",
".",
"If",
"methods",
"pre_save",
"or... | train | https://github.com/jmoiron/micromongo/blob/0d7dd1396e2f25ece6648619ccff32345bc306a1/micromongo/models.py#L118-L131 |
dantezhu/melon | melon/worker.py | Worker.write | def write(self, msg):
"""
接收消息
:param msg:
:return:
"""
self.app.events.before_response(self, msg)
for bp in self.app.blueprints:
bp.events.before_app_response(self, msg)
try:
self.child_output.put_nowait(msg)
result =... | python | def write(self, msg):
"""
接收消息
:param msg:
:return:
"""
self.app.events.before_response(self, msg)
for bp in self.app.blueprints:
bp.events.before_app_response(self, msg)
try:
self.child_output.put_nowait(msg)
result =... | [
"def",
"write",
"(",
"self",
",",
"msg",
")",
":",
"self",
".",
"app",
".",
"events",
".",
"before_response",
"(",
"self",
",",
"msg",
")",
"for",
"bp",
"in",
"self",
".",
"app",
".",
"blueprints",
":",
"bp",
".",
"events",
".",
"before_app_response"... | 接收消息
:param msg:
:return: | [
"接收消息",
":",
"param",
"msg",
":",
":",
"return",
":"
] | train | https://github.com/dantezhu/melon/blob/44d859fa85fbfb2d77479e01eade925a0d26e4f7/melon/worker.py#L59-L81 |
dantezhu/melon | melon/worker.py | Worker._handle_request | def _handle_request(self, request):
"""
出现任何异常的时候,服务器不再主动关闭连接
"""
if not request.is_valid:
return False
if not request.view_func:
logger.error('cmd invalid. request: %s' % request)
request.write(dict(ret=constants.RET_INVALID_CMD))
... | python | def _handle_request(self, request):
"""
出现任何异常的时候,服务器不再主动关闭连接
"""
if not request.is_valid:
return False
if not request.view_func:
logger.error('cmd invalid. request: %s' % request)
request.write(dict(ret=constants.RET_INVALID_CMD))
... | [
"def",
"_handle_request",
"(",
"self",
",",
"request",
")",
":",
"if",
"not",
"request",
".",
"is_valid",
":",
"return",
"False",
"if",
"not",
"request",
".",
"view_func",
":",
"logger",
".",
"error",
"(",
"'cmd invalid. request: %s'",
"%",
"request",
")",
... | 出现任何异常的时候,服务器不再主动关闭连接 | [
"出现任何异常的时候,服务器不再主动关闭连接"
] | train | https://github.com/dantezhu/melon/blob/44d859fa85fbfb2d77479e01eade925a0d26e4f7/melon/worker.py#L83-L129 |
dantezhu/melon | melon/worker.py | Worker._handle_signals | def _handle_signals(self):
"""
因为主进程的reactor重新处理了SIGINT,会导致子进程也会响应,改为SIG_IGN之后,就可以保证父进程先退出,之后再由父进程term所有的子进程
:return:
"""
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.SIG_IGN) | python | def _handle_signals(self):
"""
因为主进程的reactor重新处理了SIGINT,会导致子进程也会响应,改为SIG_IGN之后,就可以保证父进程先退出,之后再由父进程term所有的子进程
:return:
"""
signal.signal(signal.SIGTERM, signal.SIG_DFL)
signal.signal(signal.SIGINT, signal.SIG_IGN) | [
"def",
"_handle_signals",
"(",
"self",
")",
":",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGTERM",
",",
"signal",
".",
"SIG_DFL",
")",
"signal",
".",
"signal",
"(",
"signal",
".",
"SIGINT",
",",
"signal",
".",
"SIG_IGN",
")"
] | 因为主进程的reactor重新处理了SIGINT,会导致子进程也会响应,改为SIG_IGN之后,就可以保证父进程先退出,之后再由父进程term所有的子进程
:return: | [
"因为主进程的reactor重新处理了SIGINT,会导致子进程也会响应,改为SIG_IGN之后,就可以保证父进程先退出,之后再由父进程term所有的子进程",
":",
"return",
":"
] | train | https://github.com/dantezhu/melon/blob/44d859fa85fbfb2d77479e01eade925a0d26e4f7/melon/worker.py#L131-L137 |
inveniosoftware/invenio-collections | invenio_collections/contrib/search/collection_filter.py | apply | def apply(query, collection=None):
"""Enhance the query restricting not permitted collections.
Get the permitted restricted collection for the current user from the
user_info object and all the restriced collections from the
restricted_collection_cache.
"""
if not collection:
return que... | python | def apply(query, collection=None):
"""Enhance the query restricting not permitted collections.
Get the permitted restricted collection for the current user from the
user_info object and all the restriced collections from the
restricted_collection_cache.
"""
if not collection:
return que... | [
"def",
"apply",
"(",
"query",
",",
"collection",
"=",
"None",
")",
":",
"if",
"not",
"collection",
":",
"return",
"query",
"result_tree",
"=",
"create_collection_query",
"(",
"collection",
")",
"return",
"AndOp",
"(",
"query",
",",
"result_tree",
")"
] | Enhance the query restricting not permitted collections.
Get the permitted restricted collection for the current user from the
user_info object and all the restriced collections from the
restricted_collection_cache. | [
"Enhance",
"the",
"query",
"restricting",
"not",
"permitted",
"collections",
"."
] | train | https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/contrib/search/collection_filter.py#L41-L51 |
note35/sinon | sinon/lib/spy.py | SinonSpy.__remove_args_first_item | def __remove_args_first_item(self):
"""
# Todo: finding a better solution
This is a dirty solution
Because the first argument of inspectors' args will be itself
For current implementation, it should be ignore
"""
if len(self.args) > 0:
new_args_list = ... | python | def __remove_args_first_item(self):
"""
# Todo: finding a better solution
This is a dirty solution
Because the first argument of inspectors' args will be itself
For current implementation, it should be ignore
"""
if len(self.args) > 0:
new_args_list = ... | [
"def",
"__remove_args_first_item",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"args",
")",
">",
"0",
":",
"new_args_list",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"args",
":",
"if",
"len",
"(",
"item",
")",
">",
"0",
"and",
"s... | # Todo: finding a better solution
This is a dirty solution
Because the first argument of inspectors' args will be itself
For current implementation, it should be ignore | [
"#",
"Todo",
":",
"finding",
"a",
"better",
"solution",
"This",
"is",
"a",
"dirty",
"solution",
"Because",
"the",
"first",
"argument",
"of",
"inspectors",
"args",
"will",
"be",
"itself",
"For",
"current",
"implementation",
"it",
"should",
"be",
"ignore"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L51-L65 |
note35/sinon | sinon/lib/spy.py | SinonSpy.lastCall | def lastCall(self): #pylint: disable=invalid-name
"""
Return: SpyCall object for this spy's most recent call
"""
last_index = len(super(SinonSpy, self)._get_wrapper().call_list) - 1
return self.getCall(last_index) | python | def lastCall(self): #pylint: disable=invalid-name
"""
Return: SpyCall object for this spy's most recent call
"""
last_index = len(super(SinonSpy, self)._get_wrapper().call_list) - 1
return self.getCall(last_index) | [
"def",
"lastCall",
"(",
"self",
")",
":",
"#pylint: disable=invalid-name",
"last_index",
"=",
"len",
"(",
"super",
"(",
"SinonSpy",
",",
"self",
")",
".",
"_get_wrapper",
"(",
")",
".",
"call_list",
")",
"-",
"1",
"return",
"self",
".",
"getCall",
"(",
"... | Return: SpyCall object for this spy's most recent call | [
"Return",
":",
"SpyCall",
"object",
"for",
"this",
"spy",
"s",
"most",
"recent",
"call"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L154-L159 |
note35/sinon | sinon/lib/spy.py | SinonSpy.calledBefore | def calledBefore(self, spy): #pylint: disable=invalid-name
"""
Compares the order in which two spies were called
E.g.
spy_a()
spy_b()
spy_a.calledBefore(spy_b) # True
spy_b.calledBefore(spy_a) # False
spy_a()
spy_b.calledBe... | python | def calledBefore(self, spy): #pylint: disable=invalid-name
"""
Compares the order in which two spies were called
E.g.
spy_a()
spy_b()
spy_a.calledBefore(spy_b) # True
spy_b.calledBefore(spy_a) # False
spy_a()
spy_b.calledBe... | [
"def",
"calledBefore",
"(",
"self",
",",
"spy",
")",
":",
"#pylint: disable=invalid-name",
"this_call",
"=",
"self",
".",
"firstCall",
"if",
"self",
".",
"firstCall",
"is",
"not",
"None",
"else",
"False",
"given_call",
"=",
"spy",
".",
"lastCall",
"if",
"spy... | Compares the order in which two spies were called
E.g.
spy_a()
spy_b()
spy_a.calledBefore(spy_b) # True
spy_b.calledBefore(spy_a) # False
spy_a()
spy_b.calledBefore(spy_a) # True
Args: a Spy to compare with
Return: Boolean... | [
"Compares",
"the",
"order",
"in",
"which",
"two",
"spies",
"were",
"called"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L161-L178 |
note35/sinon | sinon/lib/spy.py | SinonSpy.calledWith | def calledWith(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are called previously
Eg.
f(1, 2, 3)
spy.calledWith(1, 2) will return True, because they are called partially
f(a=1, b=2, c=3)
spy.calledWith(a... | python | def calledWith(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are called previously
Eg.
f(1, 2, 3)
spy.calledWith(1, 2) will return True, because they are called partially
f(a=1, b=2, c=3)
spy.calledWith(a... | [
"def",
"calledWith",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"self",
".",
"__get_func",
"=",
"SinonSpy",
".",
"__get_directly",
"return",
"self",
".",
"calledWithMatch",
"(",
"*",
"args",
",",
"*",
... | Determining whether args/kwargs are called previously
Eg.
f(1, 2, 3)
spy.calledWith(1, 2) will return True, because they are called partially
f(a=1, b=2, c=3)
spy.calledWith(a=1, b=3) will return True, because they are called partially
Return: Boolean | [
"Determining",
"whether",
"args",
"/",
"kwargs",
"are",
"called",
"previously",
"Eg",
".",
"f",
"(",
"1",
"2",
"3",
")",
"spy",
".",
"calledWith",
"(",
"1",
"2",
")",
"will",
"return",
"True",
"because",
"they",
"are",
"called",
"partially",
"f",
"(",
... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L199-L210 |
note35/sinon | sinon/lib/spy.py | SinonSpy.alwaysCalledWith | def alwaysCalledWith(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are the ONLY args/kwargs called previously
Eg.
f(1, 2, 3)
f(1, 2, 3)
spy.alwaysCalledWith(1, 2) will return True, because they are the ONLY called ar... | python | def alwaysCalledWith(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are the ONLY args/kwargs called previously
Eg.
f(1, 2, 3)
f(1, 2, 3)
spy.alwaysCalledWith(1, 2) will return True, because they are the ONLY called ar... | [
"def",
"alwaysCalledWith",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"self",
".",
"__get_func",
"=",
"SinonSpy",
".",
"__get_directly",
"return",
"self",
".",
"alwaysCalledWithMatch",
"(",
"*",
"args",
"... | Determining whether args/kwargs are the ONLY args/kwargs called previously
Eg.
f(1, 2, 3)
f(1, 2, 3)
spy.alwaysCalledWith(1, 2) will return True, because they are the ONLY called args
f(1, 3)
spy.alwaysCalledWith(1) will return True, because 1 is the O... | [
"Determining",
"whether",
"args",
"/",
"kwargs",
"are",
"the",
"ONLY",
"args",
"/",
"kwargs",
"called",
"previously",
"Eg",
".",
"f",
"(",
"1",
"2",
"3",
")",
"f",
"(",
"1",
"2",
"3",
")",
"spy",
".",
"alwaysCalledWith",
"(",
"1",
"2",
")",
"will",... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L212-L225 |
note35/sinon | sinon/lib/spy.py | SinonSpy.calledWithExactly | def calledWithExactly(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are fully matched args/kwargs called previously
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2) will return False, because they are not fully matched
spy.... | python | def calledWithExactly(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are fully matched args/kwargs called previously
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2) will return False, because they are not fully matched
spy.... | [
"def",
"calledWithExactly",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"self",
".",
"__remove_args_first_item",
"(",
")",
"if",
"args",
"and",
"kwargs",
":",
"return",
"True",
"if",
"(",
"uch",
".",
"... | Determining whether args/kwargs are fully matched args/kwargs called previously
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2) will return False, because they are not fully matched
spy.alwaysCalledWith(1, 2, 3) will return True, because they are fully matched
Return: Boole... | [
"Determining",
"whether",
"args",
"/",
"kwargs",
"are",
"fully",
"matched",
"args",
"/",
"kwargs",
"called",
"previously",
"Eg",
".",
"f",
"(",
"1",
"2",
"3",
")",
"spy",
".",
"alwaysCalledWith",
"(",
"1",
"2",
")",
"will",
"return",
"False",
"because",
... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L227-L245 |
note35/sinon | sinon/lib/spy.py | SinonSpy.alwaysCalledWithExactly | def alwaysCalledWithExactly(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are the ONLY fully matched args/kwargs called previously
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2, 3) will return True, because they are fully matched
... | python | def alwaysCalledWithExactly(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are the ONLY fully matched args/kwargs called previously
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2, 3) will return True, because they are fully matched
... | [
"def",
"alwaysCalledWithExactly",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"self",
".",
"__remove_args_first_item",
"(",
")",
"if",
"args",
"and",
"kwargs",
":",
"return",
"True",
"if",
"(",
"uch",
".... | Determining whether args/kwargs are the ONLY fully matched args/kwargs called previously
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2, 3) will return True, because they are fully matched
f(1, 2, 4)
spy.alwaysCalledWith(1, 2, 4) will return False, because they are not ... | [
"Determining",
"whether",
"args",
"/",
"kwargs",
"are",
"the",
"ONLY",
"fully",
"matched",
"args",
"/",
"kwargs",
"called",
"previously",
"Eg",
".",
"f",
"(",
"1",
"2",
"3",
")",
"spy",
".",
"alwaysCalledWith",
"(",
"1",
"2",
"3",
")",
"will",
"return"... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L247-L266 |
note35/sinon | sinon/lib/spy.py | SinonSpy.calledWithMatch | def calledWithMatch(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are matched args/kwargs called previously
Handle each arg/kwarg as a SinonMatcher
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2, 3) will return True, because t... | python | def calledWithMatch(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are matched args/kwargs called previously
Handle each arg/kwarg as a SinonMatcher
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2, 3) will return True, because t... | [
"def",
"calledWithMatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"self",
".",
"__remove_args_first_item",
"(",
")",
"if",
"args",
"and",
"kwargs",
":",
"return",
"(",
"uch",
".",
"tuple_partial_cmp",
... | Determining whether args/kwargs are matched args/kwargs called previously
Handle each arg/kwarg as a SinonMatcher
Eg.
f(1, 2, 3)
spy.alwaysCalledWith(1, 2, 3) will return True, because they are fully matched
spy.alwaysCalledWith(int) will return True, because type are... | [
"Determining",
"whether",
"args",
"/",
"kwargs",
"are",
"matched",
"args",
"/",
"kwargs",
"called",
"previously",
"Handle",
"each",
"arg",
"/",
"kwarg",
"as",
"a",
"SinonMatcher",
"Eg",
".",
"f",
"(",
"1",
"2",
"3",
")",
"spy",
".",
"alwaysCalledWith",
"... | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L268-L305 |
note35/sinon | sinon/lib/spy.py | SinonSpy.alwaysCalledWithMatch | def alwaysCalledWithMatch(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are the ONLY matched args/kwargs called previously
Handle each arg/kwarg as a SinonMatcher
Return: Boolean
"""
self.__remove_args_first_item()
alist... | python | def alwaysCalledWithMatch(self, *args, **kwargs): #pylint: disable=invalid-name
"""
Determining whether args/kwargs are the ONLY matched args/kwargs called previously
Handle each arg/kwarg as a SinonMatcher
Return: Boolean
"""
self.__remove_args_first_item()
alist... | [
"def",
"alwaysCalledWithMatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"#pylint: disable=invalid-name",
"self",
".",
"__remove_args_first_item",
"(",
")",
"alist",
",",
"klist",
",",
"gfunc",
"=",
"self",
".",
"args",
",",
"self",
... | Determining whether args/kwargs are the ONLY matched args/kwargs called previously
Handle each arg/kwarg as a SinonMatcher
Return: Boolean | [
"Determining",
"whether",
"args",
"/",
"kwargs",
"are",
"the",
"ONLY",
"matched",
"args",
"/",
"kwargs",
"called",
"previously",
"Handle",
"each",
"arg",
"/",
"kwarg",
"as",
"a",
"SinonMatcher",
"Return",
":",
"Boolean"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L307-L324 |
note35/sinon | sinon/lib/spy.py | SinonSpy.threw | def threw(self, error_type=None):
"""
Determining whether the exception is thrown
Args:
error_type:
None: checking without specified exception
Specified Exception
Return: Boolean
"""
if not error_type:
return True if... | python | def threw(self, error_type=None):
"""
Determining whether the exception is thrown
Args:
error_type:
None: checking without specified exception
Specified Exception
Return: Boolean
"""
if not error_type:
return True if... | [
"def",
"threw",
"(",
"self",
",",
"error_type",
"=",
"None",
")",
":",
"if",
"not",
"error_type",
":",
"return",
"True",
"if",
"len",
"(",
"self",
".",
"exceptions",
")",
">",
"0",
"else",
"False",
"else",
":",
"return",
"uch",
".",
"obj_in_list",
"(... | Determining whether the exception is thrown
Args:
error_type:
None: checking without specified exception
Specified Exception
Return: Boolean | [
"Determining",
"whether",
"the",
"exception",
"is",
"thrown",
"Args",
":",
"error_type",
":",
"None",
":",
"checking",
"without",
"specified",
"exception",
"Specified",
"Exception",
"Return",
":",
"Boolean"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L332-L344 |
note35/sinon | sinon/lib/spy.py | SinonSpy.alwaysThrew | def alwaysThrew(self, error_type=None): #pylint: disable=invalid-name
"""
Determining whether the specified exception is the ONLY thrown exception
Args:
error_type:
None: checking without specified exception
Specified Exception
Return: Boolean
... | python | def alwaysThrew(self, error_type=None): #pylint: disable=invalid-name
"""
Determining whether the specified exception is the ONLY thrown exception
Args:
error_type:
None: checking without specified exception
Specified Exception
Return: Boolean
... | [
"def",
"alwaysThrew",
"(",
"self",
",",
"error_type",
"=",
"None",
")",
":",
"#pylint: disable=invalid-name",
"if",
"self",
".",
"callCount",
"==",
"0",
":",
"return",
"False",
"if",
"not",
"error_type",
":",
"return",
"True",
"if",
"len",
"(",
"self",
"."... | Determining whether the specified exception is the ONLY thrown exception
Args:
error_type:
None: checking without specified exception
Specified Exception
Return: Boolean | [
"Determining",
"whether",
"the",
"specified",
"exception",
"is",
"the",
"ONLY",
"thrown",
"exception",
"Args",
":",
"error_type",
":",
"None",
":",
"checking",
"without",
"specified",
"exception",
"Specified",
"Exception",
"Return",
":",
"Boolean"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L346-L360 |
note35/sinon | sinon/lib/spy.py | SinonSpy.reset | def reset(self):
"""
Reseting wrapped function
"""
super(SinonSpy, self).unwrap()
super(SinonSpy, self).wrap2spy() | python | def reset(self):
"""
Reseting wrapped function
"""
super(SinonSpy, self).unwrap()
super(SinonSpy, self).wrap2spy() | [
"def",
"reset",
"(",
"self",
")",
":",
"super",
"(",
"SinonSpy",
",",
"self",
")",
".",
"unwrap",
"(",
")",
"super",
"(",
"SinonSpy",
",",
"self",
")",
".",
"wrap2spy",
"(",
")"
] | Reseting wrapped function | [
"Reseting",
"wrapped",
"function"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L378-L383 |
note35/sinon | sinon/lib/spy.py | SinonSpy.getCall | def getCall(self, n): #pylint: disable=invalid-name
"""
Args:
n: integer (index of function call)
Return:
SpyCall object (or None if the index is not valid)
"""
call_list = super(SinonSpy, self)._get_wrapper().call_list
if n >= 0 and n < len(call_l... | python | def getCall(self, n): #pylint: disable=invalid-name
"""
Args:
n: integer (index of function call)
Return:
SpyCall object (or None if the index is not valid)
"""
call_list = super(SinonSpy, self)._get_wrapper().call_list
if n >= 0 and n < len(call_l... | [
"def",
"getCall",
"(",
"self",
",",
"n",
")",
":",
"#pylint: disable=invalid-name",
"call_list",
"=",
"super",
"(",
"SinonSpy",
",",
"self",
")",
".",
"_get_wrapper",
"(",
")",
".",
"call_list",
"if",
"n",
">=",
"0",
"and",
"n",
"<",
"len",
"(",
"call_... | Args:
n: integer (index of function call)
Return:
SpyCall object (or None if the index is not valid) | [
"Args",
":",
"n",
":",
"integer",
"(",
"index",
"of",
"function",
"call",
")",
"Return",
":",
"SpyCall",
"object",
"(",
"or",
"None",
"if",
"the",
"index",
"is",
"not",
"valid",
")"
] | train | https://github.com/note35/sinon/blob/f1d551b679b393d64d926a8a279320904c38d0f5/sinon/lib/spy.py#L385-L398 |
cathalgarvey/deadlock | deadlock/crypto.py | b64decode | def b64decode(foo, *args):
'Only here for consistency with the above.'
if isinstance(foo, str):
foo = foo.encode('utf8')
return base64.b64decode(foo, *args) | python | def b64decode(foo, *args):
'Only here for consistency with the above.'
if isinstance(foo, str):
foo = foo.encode('utf8')
return base64.b64decode(foo, *args) | [
"def",
"b64decode",
"(",
"foo",
",",
"*",
"args",
")",
":",
"if",
"isinstance",
"(",
"foo",
",",
"str",
")",
":",
"foo",
"=",
"foo",
".",
"encode",
"(",
"'utf8'",
")",
"return",
"base64",
".",
"b64decode",
"(",
"foo",
",",
"*",
"args",
")"
] | Only here for consistency with the above. | [
"Only",
"here",
"for",
"consistency",
"with",
"the",
"above",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L28-L32 |
cathalgarvey/deadlock | deadlock/crypto.py | assert_type_and_length | def assert_type_and_length(varname, var, T, L = None, minL = None, maxL = None):
'Facilitates simultaneous or one-line type/length checks.'
if not isinstance(var, T):
raise TypeError("Variable '{}' is supposed to be type '{}' but is '{}'".format(varname, T, type(var)))
if isinstance(L, int):
... | python | def assert_type_and_length(varname, var, T, L = None, minL = None, maxL = None):
'Facilitates simultaneous or one-line type/length checks.'
if not isinstance(var, T):
raise TypeError("Variable '{}' is supposed to be type '{}' but is '{}'".format(varname, T, type(var)))
if isinstance(L, int):
... | [
"def",
"assert_type_and_length",
"(",
"varname",
",",
"var",
",",
"T",
",",
"L",
"=",
"None",
",",
"minL",
"=",
"None",
",",
"maxL",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"var",
",",
"T",
")",
":",
"raise",
"TypeError",
"(",
"\"Var... | Facilitates simultaneous or one-line type/length checks. | [
"Facilitates",
"simultaneous",
"or",
"one",
"-",
"line",
"type",
"/",
"length",
"checks",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L34-L46 |
cathalgarvey/deadlock | deadlock/crypto.py | UserLock.from_passphrase | def from_passphrase(cls, email, passphrase):
"""
This performs key derivation from an email address and passphrase according
to the miniLock specification.
Specifically, the passphrase is digested with a standard blake2s 32-bit digest,
then it is passed through scrypt wi... | python | def from_passphrase(cls, email, passphrase):
"""
This performs key derivation from an email address and passphrase according
to the miniLock specification.
Specifically, the passphrase is digested with a standard blake2s 32-bit digest,
then it is passed through scrypt wi... | [
"def",
"from_passphrase",
"(",
"cls",
",",
"email",
",",
"passphrase",
")",
":",
"pp_blake",
"=",
"pyblake2",
".",
"blake2s",
"(",
"cls",
".",
"ensure_bytes",
"(",
"passphrase",
")",
")",
".",
"digest",
"(",
")",
"#pp_scrypt = scrypt.hash(pp_blake, cls.ensure_by... | This performs key derivation from an email address and passphrase according
to the miniLock specification.
Specifically, the passphrase is digested with a standard blake2s 32-bit digest,
then it is passed through scrypt with the email address as salt value using
N = 217, r = 8, ... | [
"This",
"performs",
"key",
"derivation",
"from",
"an",
"email",
"address",
"and",
"passphrase",
"according",
"to",
"the",
"miniLock",
"specification",
".",
"Specifically",
"the",
"passphrase",
"is",
"digested",
"with",
"a",
"standard",
"blake2s",
"32",
"-",
"bit... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L71-L87 |
cathalgarvey/deadlock | deadlock/crypto.py | UserLock.from_id | def from_id(cls, id):
"""
This decodes an ID to a public key and verifies the checksum byte. ID
structure in miniLock is the base58 encoded form of the public key
appended with a single-byte digest from blake2s of the public key, as a
simple check-sum.
"""
decoded... | python | def from_id(cls, id):
"""
This decodes an ID to a public key and verifies the checksum byte. ID
structure in miniLock is the base58 encoded form of the public key
appended with a single-byte digest from blake2s of the public key, as a
simple check-sum.
"""
decoded... | [
"def",
"from_id",
"(",
"cls",
",",
"id",
")",
":",
"decoded",
"=",
"cls",
".",
"ensure_bytes",
"(",
"base58",
".",
"b58decode",
"(",
"id",
")",
")",
"assert_type_and_length",
"(",
"'id'",
",",
"decoded",
",",
"bytes",
",",
"L",
"=",
"33",
")",
"pk",
... | This decodes an ID to a public key and verifies the checksum byte. ID
structure in miniLock is the base58 encoded form of the public key
appended with a single-byte digest from blake2s of the public key, as a
simple check-sum. | [
"This",
"decodes",
"an",
"ID",
"to",
"a",
"public",
"key",
"and",
"verifies",
"the",
"checksum",
"byte",
".",
"ID",
"structure",
"in",
"miniLock",
"is",
"the",
"base58",
"encoded",
"form",
"of",
"the",
"public",
"key",
"appended",
"with",
"a",
"single",
... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L99-L112 |
cathalgarvey/deadlock | deadlock/crypto.py | UserLock.ephemeral | def ephemeral(cls):
"""
Creates a new ephemeral key constructed using a raw 32-byte string from urandom.
Ephemeral keys are used once for each encryption task and are then discarded;
they are not intended for long-term or repeat use.
"""
private_key = nacl.public.PrivateK... | python | def ephemeral(cls):
"""
Creates a new ephemeral key constructed using a raw 32-byte string from urandom.
Ephemeral keys are used once for each encryption task and are then discarded;
they are not intended for long-term or repeat use.
"""
private_key = nacl.public.PrivateK... | [
"def",
"ephemeral",
"(",
"cls",
")",
":",
"private_key",
"=",
"nacl",
".",
"public",
".",
"PrivateKey",
"(",
"os",
".",
"urandom",
"(",
"32",
")",
")",
"return",
"cls",
"(",
"private_key",
".",
"public_key",
",",
"private_key",
")"
] | Creates a new ephemeral key constructed using a raw 32-byte string from urandom.
Ephemeral keys are used once for each encryption task and are then discarded;
they are not intended for long-term or repeat use. | [
"Creates",
"a",
"new",
"ephemeral",
"key",
"constructed",
"using",
"a",
"raw",
"32",
"-",
"byte",
"string",
"from",
"urandom",
".",
"Ephemeral",
"keys",
"are",
"used",
"once",
"for",
"each",
"encryption",
"task",
"and",
"are",
"then",
"discarded",
";",
"th... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L129-L136 |
cathalgarvey/deadlock | deadlock/crypto.py | UserLock.fancy | def fancy(cls, contains, max_tries, inner=False, keepcase=False):
"""
Try to create a key with a chosen prefix, by starting with a 26-bit
urandom number and appending with 8-byte integers until prefix matches.
This function is naive, but has a max_tries argument which will abort when
... | python | def fancy(cls, contains, max_tries, inner=False, keepcase=False):
"""
Try to create a key with a chosen prefix, by starting with a 26-bit
urandom number and appending with 8-byte integers until prefix matches.
This function is naive, but has a max_tries argument which will abort when
... | [
"def",
"fancy",
"(",
"cls",
",",
"contains",
",",
"max_tries",
",",
"inner",
"=",
"False",
",",
"keepcase",
"=",
"False",
")",
":",
"contains",
"=",
"contains",
"if",
"keepcase",
"else",
"contains",
".",
"lower",
"(",
")",
"if",
"not",
"set",
"(",
"c... | Try to create a key with a chosen prefix, by starting with a 26-bit
urandom number and appending with 8-byte integers until prefix matches.
This function is naive, but has a max_tries argument which will abort when
reached with a ValueError.
TODO: make this smarter, in general. Variable ... | [
"Try",
"to",
"create",
"a",
"key",
"with",
"a",
"chosen",
"prefix",
"by",
"starting",
"with",
"a",
"26",
"-",
"bit",
"urandom",
"number",
"and",
"appending",
"with",
"8",
"-",
"byte",
"integers",
"until",
"prefix",
"matches",
".",
"This",
"function",
"is... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L139-L167 |
cathalgarvey/deadlock | deadlock/crypto.py | SymmetricMiniLock.pieces | def pieces(array, chunk_size):
"""Yield successive chunks from array/list/string.
Final chunk may be truncated if array is not evenly divisible by chunk_size."""
for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size] | python | def pieces(array, chunk_size):
"""Yield successive chunks from array/list/string.
Final chunk may be truncated if array is not evenly divisible by chunk_size."""
for i in range(0, len(array), chunk_size): yield array[i:i+chunk_size] | [
"def",
"pieces",
"(",
"array",
",",
"chunk_size",
")",
":",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"array",
")",
",",
"chunk_size",
")",
":",
"yield",
"array",
"[",
"i",
":",
"i",
"+",
"chunk_size",
"]"
] | Yield successive chunks from array/list/string.
Final chunk may be truncated if array is not evenly divisible by chunk_size. | [
"Yield",
"successive",
"chunks",
"from",
"array",
"/",
"list",
"/",
"string",
".",
"Final",
"chunk",
"may",
"be",
"truncated",
"if",
"array",
"is",
"not",
"evenly",
"divisible",
"by",
"chunk_size",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L218-L221 |
cathalgarvey/deadlock | deadlock/crypto.py | SymmetricMiniLock.piece_file | def piece_file(input_f, chunk_size):
"""
Provides a streaming interface to file data in chunks of even size, which
avoids memoryerrors from loading whole files into RAM to pass to `pieces`.
"""
chunk = input_f.read(chunk_size)
total_bytes = 0
while chunk:
... | python | def piece_file(input_f, chunk_size):
"""
Provides a streaming interface to file data in chunks of even size, which
avoids memoryerrors from loading whole files into RAM to pass to `pieces`.
"""
chunk = input_f.read(chunk_size)
total_bytes = 0
while chunk:
... | [
"def",
"piece_file",
"(",
"input_f",
",",
"chunk_size",
")",
":",
"chunk",
"=",
"input_f",
".",
"read",
"(",
"chunk_size",
")",
"total_bytes",
"=",
"0",
"while",
"chunk",
":",
"yield",
"chunk",
"chunk",
"=",
"input_f",
".",
"read",
"(",
"chunk_size",
")"... | Provides a streaming interface to file data in chunks of even size, which
avoids memoryerrors from loading whole files into RAM to pass to `pieces`. | [
"Provides",
"a",
"streaming",
"interface",
"to",
"file",
"data",
"in",
"chunks",
"of",
"even",
"size",
"which",
"avoids",
"memoryerrors",
"from",
"loading",
"whole",
"files",
"into",
"RAM",
"to",
"pass",
"to",
"pieces",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L224-L234 |
cathalgarvey/deadlock | deadlock/crypto.py | MiniLockHeader.new | def new(cls, file_info, sender, recipients, version=1):
"""
Constructs (encrypts) a new MiniLockHeader object.
file_info: dict, with 'fileKey', 'fileNonce', 'fileHash' as bytes entries
sender: UserLock for sender
recipients: list of UserLock for recipients
"""
eph... | python | def new(cls, file_info, sender, recipients, version=1):
"""
Constructs (encrypts) a new MiniLockHeader object.
file_info: dict, with 'fileKey', 'fileNonce', 'fileHash' as bytes entries
sender: UserLock for sender
recipients: list of UserLock for recipients
"""
eph... | [
"def",
"new",
"(",
"cls",
",",
"file_info",
",",
"sender",
",",
"recipients",
",",
"version",
"=",
"1",
")",
":",
"ephem_key",
"=",
"UserLock",
".",
"ephemeral",
"(",
")",
"decryptInfo",
"=",
"{",
"}",
"for",
"recipient",
"in",
"recipients",
":",
"if",... | Constructs (encrypts) a new MiniLockHeader object.
file_info: dict, with 'fileKey', 'fileNonce', 'fileHash' as bytes entries
sender: UserLock for sender
recipients: list of UserLock for recipients | [
"Constructs",
"(",
"encrypts",
")",
"a",
"new",
"MiniLockHeader",
"object",
".",
"file_info",
":",
"dict",
"with",
"fileKey",
"fileNonce",
"fileHash",
"as",
"bytes",
"entries",
"sender",
":",
"UserLock",
"for",
"sender",
"recipients",
":",
"list",
"of",
"UserL... | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L289-L325 |
cathalgarvey/deadlock | deadlock/crypto.py | MiniLockHeader.decrypt | def decrypt(self, recipient_key):
"""
Attempt decryption of header with a private key; returns decryptInfo.
Returns a dictionary, not a new MiniLockHeader!
"""
ephem = UserLock.from_b64(self.dict['ephemeral'])
ephem_box = nacl.public.Box(recipient_key.private_key, ephem.p... | python | def decrypt(self, recipient_key):
"""
Attempt decryption of header with a private key; returns decryptInfo.
Returns a dictionary, not a new MiniLockHeader!
"""
ephem = UserLock.from_b64(self.dict['ephemeral'])
ephem_box = nacl.public.Box(recipient_key.private_key, ephem.p... | [
"def",
"decrypt",
"(",
"self",
",",
"recipient_key",
")",
":",
"ephem",
"=",
"UserLock",
".",
"from_b64",
"(",
"self",
".",
"dict",
"[",
"'ephemeral'",
"]",
")",
"ephem_box",
"=",
"nacl",
".",
"public",
".",
"Box",
"(",
"recipient_key",
".",
"private_key... | Attempt decryption of header with a private key; returns decryptInfo.
Returns a dictionary, not a new MiniLockHeader! | [
"Attempt",
"decryption",
"of",
"header",
"with",
"a",
"private",
"key",
";",
"returns",
"decryptInfo",
".",
"Returns",
"a",
"dictionary",
"not",
"a",
"new",
"MiniLockHeader!"
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L340-L372 |
cathalgarvey/deadlock | deadlock/crypto.py | MiniLockFile.new | def new(cls, file_name, file_or_contents, sender, recipients):
"""
Constructs (that is, encrypts) a new miniLock file from sender to recipients.
"""
assert_type_and_length('recipients', recipients, list, minL=1)
assert_type_and_length('sender', sender, UserLock)
for R in ... | python | def new(cls, file_name, file_or_contents, sender, recipients):
"""
Constructs (that is, encrypts) a new miniLock file from sender to recipients.
"""
assert_type_and_length('recipients', recipients, list, minL=1)
assert_type_and_length('sender', sender, UserLock)
for R in ... | [
"def",
"new",
"(",
"cls",
",",
"file_name",
",",
"file_or_contents",
",",
"sender",
",",
"recipients",
")",
":",
"assert_type_and_length",
"(",
"'recipients'",
",",
"recipients",
",",
"list",
",",
"minL",
"=",
"1",
")",
"assert_type_and_length",
"(",
"'sender'... | Constructs (that is, encrypts) a new miniLock file from sender to recipients. | [
"Constructs",
"(",
"that",
"is",
"encrypts",
")",
"a",
"new",
"miniLock",
"file",
"from",
"sender",
"to",
"recipients",
"."
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L389-L411 |
cathalgarvey/deadlock | deadlock/crypto.py | MiniLockFile.iter_chunks | def iter_chunks(self, start_count=0):
"""
Iterate over the chunks of the file according to their length prefixes.
yields: index <int>, encrypted chunks without length prefixes <bytes>, lastchunk <bool>
"""
ciphertext = self.chunks_block
chunknum = start_count
idx ... | python | def iter_chunks(self, start_count=0):
"""
Iterate over the chunks of the file according to their length prefixes.
yields: index <int>, encrypted chunks without length prefixes <bytes>, lastchunk <bool>
"""
ciphertext = self.chunks_block
chunknum = start_count
idx ... | [
"def",
"iter_chunks",
"(",
"self",
",",
"start_count",
"=",
"0",
")",
":",
"ciphertext",
"=",
"self",
".",
"chunks_block",
"chunknum",
"=",
"start_count",
"idx",
"=",
"0",
"lastchunk",
"=",
"False",
"while",
"idx",
"<",
"len",
"(",
"ciphertext",
")",
":"... | Iterate over the chunks of the file according to their length prefixes.
yields: index <int>, encrypted chunks without length prefixes <bytes>, lastchunk <bool> | [
"Iterate",
"over",
"the",
"chunks",
"of",
"the",
"file",
"according",
"to",
"their",
"length",
"prefixes",
".",
"yields",
":",
"index",
"<int",
">",
"encrypted",
"chunks",
"without",
"length",
"prefixes",
"<bytes",
">",
"lastchunk",
"<bool",
">"
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L449-L467 |
cathalgarvey/deadlock | deadlock/crypto.py | MiniLockFile.decrypt | def decrypt(self, recipient_key):
"""
recipient_key: UserLock with a private key part.
returns: filename, decrypted file contents
"""
if recipient_key.private_key is None:
raise ValueError("Cannot decrypt with this key; no private key part found.")
header = Mi... | python | def decrypt(self, recipient_key):
"""
recipient_key: UserLock with a private key part.
returns: filename, decrypted file contents
"""
if recipient_key.private_key is None:
raise ValueError("Cannot decrypt with this key; no private key part found.")
header = Mi... | [
"def",
"decrypt",
"(",
"self",
",",
"recipient_key",
")",
":",
"if",
"recipient_key",
".",
"private_key",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"Cannot decrypt with this key; no private key part found.\"",
")",
"header",
"=",
"MiniLockHeader",
"(",
"self",
... | recipient_key: UserLock with a private key part.
returns: filename, decrypted file contents | [
"recipient_key",
":",
"UserLock",
"with",
"a",
"private",
"key",
"part",
".",
"returns",
":",
"filename",
"decrypted",
"file",
"contents"
] | train | https://github.com/cathalgarvey/deadlock/blob/30099b476ff767611ce617150a0c574fc03fdf79/deadlock/crypto.py#L469-L491 |
dotzero/tilda-api-python | tilda/base.py | TildaBase.to_json | def to_json(self):
"""
Returns:
str:
"""
data = dict()
for key, value in self.__dict__.items():
if value:
if hasattr(value, 'to_dict'):
data[key] = value.to_dict()
elif isinstance(value, datetime):
... | python | def to_json(self):
"""
Returns:
str:
"""
data = dict()
for key, value in self.__dict__.items():
if value:
if hasattr(value, 'to_dict'):
data[key] = value.to_dict()
elif isinstance(value, datetime):
... | [
"def",
"to_json",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"value",
":",
"if",
"hasattr",
"(",
"value",
",",
"'to_dict'",
")",
":",
"data",... | Returns:
str: | [
"Returns",
":",
"str",
":"
] | train | https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/base.py#L54-L70 |
dotzero/tilda-api-python | tilda/base.py | TildaBase.to_dict | def to_dict(self):
"""
Returns:
dict:
"""
data = dict()
for key, value in self.__dict__.items():
if value:
if hasattr(value, 'to_dict'):
data[key] = value.to_dict()
else:
data[key] = ... | python | def to_dict(self):
"""
Returns:
dict:
"""
data = dict()
for key, value in self.__dict__.items():
if value:
if hasattr(value, 'to_dict'):
data[key] = value.to_dict()
else:
data[key] = ... | [
"def",
"to_dict",
"(",
"self",
")",
":",
"data",
"=",
"dict",
"(",
")",
"for",
"key",
",",
"value",
"in",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"value",
":",
"if",
"hasattr",
"(",
"value",
",",
"'to_dict'",
")",
":",
"data",... | Returns:
dict: | [
"Returns",
":",
"dict",
":"
] | train | https://github.com/dotzero/tilda-api-python/blob/0ab984e0236cbfb676b0fbddc1ab37202d92e0a8/tilda/base.py#L72-L86 |
klahnakoski/pyLibrary | jx_python/jx.py | run | def run(query, container=Null):
"""
THIS FUNCTION IS SIMPLY SWITCHING BASED ON THE query["from"] CONTAINER,
BUT IT IS ALSO PROCESSING A list CONTAINER; SEPARATE TO A ListContainer
"""
if container == None:
container = wrap(query)["from"]
query_op = QueryOp.wrap(query, container=conta... | python | def run(query, container=Null):
"""
THIS FUNCTION IS SIMPLY SWITCHING BASED ON THE query["from"] CONTAINER,
BUT IT IS ALSO PROCESSING A list CONTAINER; SEPARATE TO A ListContainer
"""
if container == None:
container = wrap(query)["from"]
query_op = QueryOp.wrap(query, container=conta... | [
"def",
"run",
"(",
"query",
",",
"container",
"=",
"Null",
")",
":",
"if",
"container",
"==",
"None",
":",
"container",
"=",
"wrap",
"(",
"query",
")",
"[",
"\"from\"",
"]",
"query_op",
"=",
"QueryOp",
".",
"wrap",
"(",
"query",
",",
"container",
"="... | THIS FUNCTION IS SIMPLY SWITCHING BASED ON THE query["from"] CONTAINER,
BUT IT IS ALSO PROCESSING A list CONTAINER; SEPARATE TO A ListContainer | [
"THIS",
"FUNCTION",
"IS",
"SIMPLY",
"SWITCHING",
"BASED",
"ON",
"THE",
"query",
"[",
"from",
"]",
"CONTAINER",
"BUT",
"IT",
"IS",
"ALSO",
"PROCESSING",
"A",
"list",
"CONTAINER",
";",
"SEPARATE",
"TO",
"A",
"ListContainer"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L54-L115 |
klahnakoski/pyLibrary | jx_python/jx.py | unique_index | def unique_index(data, keys=None, fail_on_dup=True):
"""
RETURN dict THAT USES KEYS TO INDEX DATA
ONLY ONE VALUE ALLOWED PER UNIQUE KEY
"""
o = UniqueIndex(listwrap(keys), fail_on_dup=fail_on_dup)
for d in data:
try:
o.add(d)
except Exception as e:
o.add(... | python | def unique_index(data, keys=None, fail_on_dup=True):
"""
RETURN dict THAT USES KEYS TO INDEX DATA
ONLY ONE VALUE ALLOWED PER UNIQUE KEY
"""
o = UniqueIndex(listwrap(keys), fail_on_dup=fail_on_dup)
for d in data:
try:
o.add(d)
except Exception as e:
o.add(... | [
"def",
"unique_index",
"(",
"data",
",",
"keys",
"=",
"None",
",",
"fail_on_dup",
"=",
"True",
")",
":",
"o",
"=",
"UniqueIndex",
"(",
"listwrap",
"(",
"keys",
")",
",",
"fail_on_dup",
"=",
"fail_on_dup",
")",
"for",
"d",
"in",
"data",
":",
"try",
":... | RETURN dict THAT USES KEYS TO INDEX DATA
ONLY ONE VALUE ALLOWED PER UNIQUE KEY | [
"RETURN",
"dict",
"THAT",
"USES",
"KEYS",
"TO",
"INDEX",
"DATA",
"ONLY",
"ONE",
"VALUE",
"ALLOWED",
"PER",
"UNIQUE",
"KEY"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L145-L165 |
klahnakoski/pyLibrary | jx_python/jx.py | map2set | def map2set(data, relation):
"""
EXPECTING A is_data(relation) THAT MAPS VALUES TO lists
THE LISTS ARE EXPECTED TO POINT TO MEMBERS OF A SET
A set() IS RETURNED
"""
if data == None:
return Null
if isinstance(relation, Data):
Log.error("Does not accept a Data")
if is_data... | python | def map2set(data, relation):
"""
EXPECTING A is_data(relation) THAT MAPS VALUES TO lists
THE LISTS ARE EXPECTED TO POINT TO MEMBERS OF A SET
A set() IS RETURNED
"""
if data == None:
return Null
if isinstance(relation, Data):
Log.error("Does not accept a Data")
if is_data... | [
"def",
"map2set",
"(",
"data",
",",
"relation",
")",
":",
"if",
"data",
"==",
"None",
":",
"return",
"Null",
"if",
"isinstance",
"(",
"relation",
",",
"Data",
")",
":",
"Log",
".",
"error",
"(",
"\"Does not accept a Data\"",
")",
"if",
"is_data",
"(",
... | EXPECTING A is_data(relation) THAT MAPS VALUES TO lists
THE LISTS ARE EXPECTED TO POINT TO MEMBERS OF A SET
A set() IS RETURNED | [
"EXPECTING",
"A",
"is_data",
"(",
"relation",
")",
"THAT",
"MAPS",
"VALUES",
"TO",
"lists",
"THE",
"LISTS",
"ARE",
"EXPECTED",
"TO",
"POINT",
"TO",
"MEMBERS",
"OF",
"A",
"SET",
"A",
"set",
"()",
"IS",
"RETURNED"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L168-L203 |
klahnakoski/pyLibrary | jx_python/jx.py | tuple | def tuple(data, field_name):
"""
RETURN LIST OF TUPLES
"""
if isinstance(data, Cube):
Log.error("not supported yet")
if isinstance(data, FlatList):
Log.error("not supported yet")
if is_data(field_name) and "value" in field_name:
# SIMPLIFY {"value":value} AS STRING
... | python | def tuple(data, field_name):
"""
RETURN LIST OF TUPLES
"""
if isinstance(data, Cube):
Log.error("not supported yet")
if isinstance(data, FlatList):
Log.error("not supported yet")
if is_data(field_name) and "value" in field_name:
# SIMPLIFY {"value":value} AS STRING
... | [
"def",
"tuple",
"(",
"data",
",",
"field_name",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"Cube",
")",
":",
"Log",
".",
"error",
"(",
"\"not supported yet\"",
")",
"if",
"isinstance",
"(",
"data",
",",
"FlatList",
")",
":",
"Log",
".",
"error",
... | RETURN LIST OF TUPLES | [
"RETURN",
"LIST",
"OF",
"TUPLES"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L206-L238 |
klahnakoski/pyLibrary | jx_python/jx.py | _tuple_deep | def _tuple_deep(v, field, depth, record):
"""
field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
"""
if hasattr(field.value, "__call__"):
return 0, None, record + (field.value(v),)
for i, f in enumer... | python | def _tuple_deep(v, field, depth, record):
"""
field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
"""
if hasattr(field.value, "__call__"):
return 0, None, record + (field.value(v),)
for i, f in enumer... | [
"def",
"_tuple_deep",
"(",
"v",
",",
"field",
",",
"depth",
",",
"record",
")",
":",
"if",
"hasattr",
"(",
"field",
".",
"value",
",",
"\"__call__\"",
")",
":",
"return",
"0",
",",
"None",
",",
"record",
"+",
"(",
"field",
".",
"value",
"(",
"v",
... | field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH | [
"field",
"=",
"{",
"name",
":",
"name",
"value",
":",
"[",
"attribute",
"path",
"]",
"}",
"r",
"[",
"field",
".",
"name",
"]",
"=",
"v",
"[",
"field",
".",
"value",
"]",
"BUT",
"WE",
"MUST",
"DEAL",
"WITH",
"POSSIBLE",
"LIST",
"IN",
"field",
".",... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L261-L275 |
klahnakoski/pyLibrary | jx_python/jx.py | select | def select(data, field_name):
"""
return list with values from field_name
"""
if isinstance(data, Cube):
return data._select(_normalize_selects(field_name))
if isinstance(data, PartFlatList):
return data.select(field_name)
if isinstance(data, UniqueIndex):
data = (
... | python | def select(data, field_name):
"""
return list with values from field_name
"""
if isinstance(data, Cube):
return data._select(_normalize_selects(field_name))
if isinstance(data, PartFlatList):
return data.select(field_name)
if isinstance(data, UniqueIndex):
data = (
... | [
"def",
"select",
"(",
"data",
",",
"field_name",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"Cube",
")",
":",
"return",
"data",
".",
"_select",
"(",
"_normalize_selects",
"(",
"field_name",
")",
")",
"if",
"isinstance",
"(",
"data",
",",
"PartFlatLi... | return list with values from field_name | [
"return",
"list",
"with",
"values",
"from",
"field_name"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L278-L319 |
klahnakoski/pyLibrary | jx_python/jx.py | _select_deep | def _select_deep(v, field, depth, record):
"""
field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
"""
if hasattr(field.value, "__call__"):
try:
record[field.name] = field.value(wrap(v))
... | python | def _select_deep(v, field, depth, record):
"""
field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
"""
if hasattr(field.value, "__call__"):
try:
record[field.name] = field.value(wrap(v))
... | [
"def",
"_select_deep",
"(",
"v",
",",
"field",
",",
"depth",
",",
"record",
")",
":",
"if",
"hasattr",
"(",
"field",
".",
"value",
",",
"\"__call__\"",
")",
":",
"try",
":",
"record",
"[",
"field",
".",
"name",
"]",
"=",
"field",
".",
"value",
"(",... | field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH | [
"field",
"=",
"{",
"name",
":",
"name",
"value",
":",
"[",
"attribute",
"path",
"]",
"}",
"r",
"[",
"field",
".",
"name",
"]",
"=",
"v",
"[",
"field",
".",
"value",
"]",
"BUT",
"WE",
"MUST",
"DEAL",
"WITH",
"POSSIBLE",
"LIST",
"IN",
"field",
".",... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L362-L391 |
klahnakoski/pyLibrary | jx_python/jx.py | _select_deep_meta | def _select_deep_meta(field, depth):
"""
field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
RETURN FUNCTION THAT PERFORMS THE MAPPING
"""
name = field.name
if hasattr(field.value, "__call__"):
try... | python | def _select_deep_meta(field, depth):
"""
field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
RETURN FUNCTION THAT PERFORMS THE MAPPING
"""
name = field.name
if hasattr(field.value, "__call__"):
try... | [
"def",
"_select_deep_meta",
"(",
"field",
",",
"depth",
")",
":",
"name",
"=",
"field",
".",
"name",
"if",
"hasattr",
"(",
"field",
".",
"value",
",",
"\"__call__\"",
")",
":",
"try",
":",
"def",
"assign",
"(",
"source",
",",
"destination",
")",
":",
... | field = {"name":name, "value":["attribute", "path"]}
r[field.name]=v[field.value], BUT WE MUST DEAL WITH POSSIBLE LIST IN field.value PATH
RETURN FUNCTION THAT PERFORMS THE MAPPING | [
"field",
"=",
"{",
"name",
":",
"name",
"value",
":",
"[",
"attribute",
"path",
"]",
"}",
"r",
"[",
"field",
".",
"name",
"]",
"=",
"v",
"[",
"field",
".",
"value",
"]",
"BUT",
"WE",
"MUST",
"DEAL",
"WITH",
"POSSIBLE",
"LIST",
"IN",
"field",
".",... | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L394-L467 |
klahnakoski/pyLibrary | jx_python/jx.py | sort | def sort(data, fieldnames=None, already_normalized=False):
"""
PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction}
"""
try:
if data == None:
return Null
if not fieldnames:
return wrap(sort_using_cmp(data, valu... | python | def sort(data, fieldnames=None, already_normalized=False):
"""
PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction}
"""
try:
if data == None:
return Null
if not fieldnames:
return wrap(sort_using_cmp(data, valu... | [
"def",
"sort",
"(",
"data",
",",
"fieldnames",
"=",
"None",
",",
"already_normalized",
"=",
"False",
")",
":",
"try",
":",
"if",
"data",
"==",
"None",
":",
"return",
"Null",
"if",
"not",
"fieldnames",
":",
"return",
"wrap",
"(",
"sort_using_cmp",
"(",
... | PASS A FIELD NAME, OR LIST OF FIELD NAMES, OR LIST OF STRUCTS WITH {"field":field_name, "sort":direction} | [
"PASS",
"A",
"FIELD",
"NAME",
"OR",
"LIST",
"OF",
"FIELD",
"NAMES",
"OR",
"LIST",
"OF",
"STRUCTS",
"WITH",
"{",
"field",
":",
"field_name",
"sort",
":",
"direction",
"}"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L548-L588 |
klahnakoski/pyLibrary | jx_python/jx.py | filter | def filter(data, where):
"""
where - a function that accepts (record, rownum, rows) and returns boolean
"""
if len(data) == 0 or where == None or where == TRUE:
return data
if isinstance(data, Container):
return data.filter(where)
if is_container(data):
temp = jx_expre... | python | def filter(data, where):
"""
where - a function that accepts (record, rownum, rows) and returns boolean
"""
if len(data) == 0 or where == None or where == TRUE:
return data
if isinstance(data, Container):
return data.filter(where)
if is_container(data):
temp = jx_expre... | [
"def",
"filter",
"(",
"data",
",",
"where",
")",
":",
"if",
"len",
"(",
"data",
")",
"==",
"0",
"or",
"where",
"==",
"None",
"or",
"where",
"==",
"TRUE",
":",
"return",
"data",
"if",
"isinstance",
"(",
"data",
",",
"Container",
")",
":",
"return",
... | where - a function that accepts (record, rownum, rows) and returns boolean | [
"where",
"-",
"a",
"function",
"that",
"accepts",
"(",
"record",
"rownum",
"rows",
")",
"and",
"returns",
"boolean"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L611-L636 |
klahnakoski/pyLibrary | jx_python/jx.py | drill_filter | def drill_filter(esfilter, data):
"""
PARTIAL EVALUATE THE FILTER BASED ON DATA GIVEN
TODO: FIX THIS MONUMENALLY BAD IDEA
"""
esfilter = unwrap(esfilter)
primary_nested = [] # track if nested, changes if not
primary_column = [] # only one path allowed
primary_branch = (
[]
... | python | def drill_filter(esfilter, data):
"""
PARTIAL EVALUATE THE FILTER BASED ON DATA GIVEN
TODO: FIX THIS MONUMENALLY BAD IDEA
"""
esfilter = unwrap(esfilter)
primary_nested = [] # track if nested, changes if not
primary_column = [] # only one path allowed
primary_branch = (
[]
... | [
"def",
"drill_filter",
"(",
"esfilter",
",",
"data",
")",
":",
"esfilter",
"=",
"unwrap",
"(",
"esfilter",
")",
"primary_nested",
"=",
"[",
"]",
"# track if nested, changes if not",
"primary_column",
"=",
"[",
"]",
"# only one path allowed",
"primary_branch",
"=",
... | PARTIAL EVALUATE THE FILTER BASED ON DATA GIVEN
TODO: FIX THIS MONUMENALLY BAD IDEA | [
"PARTIAL",
"EVALUATE",
"THE",
"FILTER",
"BASED",
"ON",
"DATA",
"GIVEN"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L639-L911 |
klahnakoski/pyLibrary | jx_python/jx.py | wrap_function | def wrap_function(func):
"""
RETURN A THREE-PARAMETER WINDOW FUNCTION TO MATCH
"""
if is_text(func):
return compile_expression(func)
numarg = func.__code__.co_argcount
if numarg == 0:
def temp(row, rownum, rows):
return func()
return temp
elif numarg ==... | python | def wrap_function(func):
"""
RETURN A THREE-PARAMETER WINDOW FUNCTION TO MATCH
"""
if is_text(func):
return compile_expression(func)
numarg = func.__code__.co_argcount
if numarg == 0:
def temp(row, rownum, rows):
return func()
return temp
elif numarg ==... | [
"def",
"wrap_function",
"(",
"func",
")",
":",
"if",
"is_text",
"(",
"func",
")",
":",
"return",
"compile_expression",
"(",
"func",
")",
"numarg",
"=",
"func",
".",
"__code__",
".",
"co_argcount",
"if",
"numarg",
"==",
"0",
":",
"def",
"temp",
"(",
"ro... | RETURN A THREE-PARAMETER WINDOW FUNCTION TO MATCH | [
"RETURN",
"A",
"THREE",
"-",
"PARAMETER",
"WINDOW",
"FUNCTION",
"TO",
"MATCH"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L914-L941 |
klahnakoski/pyLibrary | jx_python/jx.py | window | def window(data, param):
"""
MAYBE WE CAN DO THIS WITH NUMPY (no, the edges of windows are not graceful with numpy)
data - list of records
"""
name = param.name # column to assign window function result
edges = param.edges # columns to gourp by
where = param.where # DO NOT CONSIDER THESE ... | python | def window(data, param):
"""
MAYBE WE CAN DO THIS WITH NUMPY (no, the edges of windows are not graceful with numpy)
data - list of records
"""
name = param.name # column to assign window function result
edges = param.edges # columns to gourp by
where = param.where # DO NOT CONSIDER THESE ... | [
"def",
"window",
"(",
"data",
",",
"param",
")",
":",
"name",
"=",
"param",
".",
"name",
"# column to assign window function result",
"edges",
"=",
"param",
".",
"edges",
"# columns to gourp by",
"where",
"=",
"param",
".",
"where",
"# DO NOT CONSIDER THESE VALUES",... | MAYBE WE CAN DO THIS WITH NUMPY (no, the edges of windows are not graceful with numpy)
data - list of records | [
"MAYBE",
"WE",
"CAN",
"DO",
"THIS",
"WITH",
"NUMPY",
"(",
"no",
"the",
"edges",
"of",
"windows",
"are",
"not",
"graceful",
"with",
"numpy",
")",
"data",
"-",
"list",
"of",
"records"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L944-L1017 |
klahnakoski/pyLibrary | jx_python/jx.py | intervals | def intervals(_min, _max=None, size=1):
"""
RETURN (min, max) PAIRS OF GIVEN SIZE, WHICH COVER THE _min, _max RANGE
THE LAST PAIR MAY BE SMALLER
Yes! It's just like range(), only cooler!
"""
if _max == None:
_max = _min
_min = 0
_max = int(mo_math.ceiling(_max))
_min = i... | python | def intervals(_min, _max=None, size=1):
"""
RETURN (min, max) PAIRS OF GIVEN SIZE, WHICH COVER THE _min, _max RANGE
THE LAST PAIR MAY BE SMALLER
Yes! It's just like range(), only cooler!
"""
if _max == None:
_max = _min
_min = 0
_max = int(mo_math.ceiling(_max))
_min = i... | [
"def",
"intervals",
"(",
"_min",
",",
"_max",
"=",
"None",
",",
"size",
"=",
"1",
")",
":",
"if",
"_max",
"==",
"None",
":",
"_max",
"=",
"_min",
"_min",
"=",
"0",
"_max",
"=",
"int",
"(",
"mo_math",
".",
"ceiling",
"(",
"_max",
")",
")",
"_min... | RETURN (min, max) PAIRS OF GIVEN SIZE, WHICH COVER THE _min, _max RANGE
THE LAST PAIR MAY BE SMALLER
Yes! It's just like range(), only cooler! | [
"RETURN",
"(",
"min",
"max",
")",
"PAIRS",
"OF",
"GIVEN",
"SIZE",
"WHICH",
"COVER",
"THE",
"_min",
"_max",
"RANGE",
"THE",
"LAST",
"PAIR",
"MAY",
"BE",
"SMALLER",
"Yes!",
"It",
"s",
"just",
"like",
"range",
"()",
"only",
"cooler!"
] | train | https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_python/jx.py#L1020-L1033 |
ambitioninc/django-entity-event | entity_event/context_loader.py | get_context_hints_per_source | def get_context_hints_per_source(context_renderers):
"""
Given a list of context renderers, return a dictionary of context hints per source.
"""
# Merge the context render hints for each source as there can be multiple context hints for
# sources depending on the render target. Merging them together... | python | def get_context_hints_per_source(context_renderers):
"""
Given a list of context renderers, return a dictionary of context hints per source.
"""
# Merge the context render hints for each source as there can be multiple context hints for
# sources depending on the render target. Merging them together... | [
"def",
"get_context_hints_per_source",
"(",
"context_renderers",
")",
":",
"# Merge the context render hints for each source as there can be multiple context hints for",
"# sources depending on the render target. Merging them together involves combining select",
"# and prefetch related hints for eac... | Given a list of context renderers, return a dictionary of context hints per source. | [
"Given",
"a",
"list",
"of",
"context",
"renderers",
"return",
"a",
"dictionary",
"of",
"context",
"hints",
"per",
"source",
"."
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L21-L42 |
ambitioninc/django-entity-event | entity_event/context_loader.py | get_querysets_for_context_hints | def get_querysets_for_context_hints(context_hints_per_source):
"""
Given a list of context hint dictionaries, return a dictionary
of querysets for efficient context loading. The return value
is structured as follows:
{
model: queryset,
...
}
"""
model_select_relateds = d... | python | def get_querysets_for_context_hints(context_hints_per_source):
"""
Given a list of context hint dictionaries, return a dictionary
of querysets for efficient context loading. The return value
is structured as follows:
{
model: queryset,
...
}
"""
model_select_relateds = d... | [
"def",
"get_querysets_for_context_hints",
"(",
"context_hints_per_source",
")",
":",
"model_select_relateds",
"=",
"defaultdict",
"(",
"set",
")",
"model_prefetch_relateds",
"=",
"defaultdict",
"(",
"set",
")",
"model_querysets",
"=",
"{",
"}",
"for",
"context_hints",
... | Given a list of context hint dictionaries, return a dictionary
of querysets for efficient context loading. The return value
is structured as follows:
{
model: queryset,
...
} | [
"Given",
"a",
"list",
"of",
"context",
"hint",
"dictionaries",
"return",
"a",
"dictionary",
"of",
"querysets",
"for",
"efficient",
"context",
"loading",
".",
"The",
"return",
"value",
"is",
"structured",
"as",
"follows",
":"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L45-L74 |
ambitioninc/django-entity-event | entity_event/context_loader.py | dict_find | def dict_find(d, which_key):
"""
Finds key values in a nested dictionary. Returns a tuple of the dictionary in which
the key was found along with the value
"""
# If the starting point is a list, iterate recursively over all values
if isinstance(d, (list, tuple)):
for i in d:
... | python | def dict_find(d, which_key):
"""
Finds key values in a nested dictionary. Returns a tuple of the dictionary in which
the key was found along with the value
"""
# If the starting point is a list, iterate recursively over all values
if isinstance(d, (list, tuple)):
for i in d:
... | [
"def",
"dict_find",
"(",
"d",
",",
"which_key",
")",
":",
"# If the starting point is a list, iterate recursively over all values",
"if",
"isinstance",
"(",
"d",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"i",
"in",
"d",
":",
"for",
"result",
"in",
... | Finds key values in a nested dictionary. Returns a tuple of the dictionary in which
the key was found along with the value | [
"Finds",
"key",
"values",
"in",
"a",
"nested",
"dictionary",
".",
"Returns",
"a",
"tuple",
"of",
"the",
"dictionary",
"in",
"which",
"the",
"key",
"was",
"found",
"along",
"with",
"the",
"value"
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L77-L94 |
ambitioninc/django-entity-event | entity_event/context_loader.py | get_model_ids_to_fetch | def get_model_ids_to_fetch(events, context_hints_per_source):
"""
Obtains the ids of all models that need to be fetched. Returns a dictionary of models that
point to sets of ids that need to be fetched. Return output is as follows:
{
model: [id1, id2, ...],
...
}
"""
number_... | python | def get_model_ids_to_fetch(events, context_hints_per_source):
"""
Obtains the ids of all models that need to be fetched. Returns a dictionary of models that
point to sets of ids that need to be fetched. Return output is as follows:
{
model: [id1, id2, ...],
...
}
"""
number_... | [
"def",
"get_model_ids_to_fetch",
"(",
"events",
",",
"context_hints_per_source",
")",
":",
"number_types",
"=",
"(",
"complex",
",",
"float",
")",
"+",
"six",
".",
"integer_types",
"model_ids_to_fetch",
"=",
"defaultdict",
"(",
"set",
")",
"for",
"event",
"in",
... | Obtains the ids of all models that need to be fetched. Returns a dictionary of models that
point to sets of ids that need to be fetched. Return output is as follows:
{
model: [id1, id2, ...],
...
} | [
"Obtains",
"the",
"ids",
"of",
"all",
"models",
"that",
"need",
"to",
"be",
"fetched",
".",
"Returns",
"a",
"dictionary",
"of",
"models",
"that",
"point",
"to",
"sets",
"of",
"ids",
"that",
"need",
"to",
"be",
"fetched",
".",
"Return",
"output",
"is",
... | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L97-L119 |
ambitioninc/django-entity-event | entity_event/context_loader.py | fetch_model_data | def fetch_model_data(model_querysets, model_ids_to_fetch):
"""
Given a dictionary of models to querysets and model IDs to models, fetch the IDs
for every model and return the objects in the following structure.
{
model: {
id: obj,
...
},
...
}
"""... | python | def fetch_model_data(model_querysets, model_ids_to_fetch):
"""
Given a dictionary of models to querysets and model IDs to models, fetch the IDs
for every model and return the objects in the following structure.
{
model: {
id: obj,
...
},
...
}
"""... | [
"def",
"fetch_model_data",
"(",
"model_querysets",
",",
"model_ids_to_fetch",
")",
":",
"return",
"{",
"model",
":",
"id_dict",
"(",
"model_querysets",
"[",
"model",
"]",
".",
"filter",
"(",
"id__in",
"=",
"ids_to_fetch",
")",
")",
"for",
"model",
",",
"ids_... | Given a dictionary of models to querysets and model IDs to models, fetch the IDs
for every model and return the objects in the following structure.
{
model: {
id: obj,
...
},
...
} | [
"Given",
"a",
"dictionary",
"of",
"models",
"to",
"querysets",
"and",
"model",
"IDs",
"to",
"models",
"fetch",
"the",
"IDs",
"for",
"every",
"model",
"and",
"return",
"the",
"objects",
"in",
"the",
"following",
"structure",
"."
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L122-L138 |
ambitioninc/django-entity-event | entity_event/context_loader.py | load_fetched_objects_into_contexts | def load_fetched_objects_into_contexts(events, model_data, context_hints_per_source):
"""
Given the fetched model data and the context hints for each source, go through each
event and populate the contexts with the loaded information.
"""
for event in events:
context_hints = context_hints_pe... | python | def load_fetched_objects_into_contexts(events, model_data, context_hints_per_source):
"""
Given the fetched model data and the context hints for each source, go through each
event and populate the contexts with the loaded information.
"""
for event in events:
context_hints = context_hints_pe... | [
"def",
"load_fetched_objects_into_contexts",
"(",
"events",
",",
"model_data",
",",
"context_hints_per_source",
")",
":",
"for",
"event",
"in",
"events",
":",
"context_hints",
"=",
"context_hints_per_source",
".",
"get",
"(",
"event",
".",
"source",
",",
"{",
"}",... | Given the fetched model data and the context hints for each source, go through each
event and populate the contexts with the loaded information. | [
"Given",
"the",
"fetched",
"model",
"data",
"and",
"the",
"context",
"hints",
"for",
"each",
"source",
"go",
"through",
"each",
"event",
"and",
"populate",
"the",
"contexts",
"with",
"the",
"loaded",
"information",
"."
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L141-L155 |
ambitioninc/django-entity-event | entity_event/context_loader.py | load_renderers_into_events | def load_renderers_into_events(events, mediums, context_renderers, default_rendering_style):
"""
Given the events and the context renderers, load the renderers into the event objects
so that they may be able to call the 'render' method later on.
"""
# Make a mapping of source groups and rendering st... | python | def load_renderers_into_events(events, mediums, context_renderers, default_rendering_style):
"""
Given the events and the context renderers, load the renderers into the event objects
so that they may be able to call the 'render' method later on.
"""
# Make a mapping of source groups and rendering st... | [
"def",
"load_renderers_into_events",
"(",
"events",
",",
"mediums",
",",
"context_renderers",
",",
"default_rendering_style",
")",
":",
"# Make a mapping of source groups and rendering styles to context renderers. Do",
"# the same for sources and rendering styles to context renderers",
"... | Given the events and the context renderers, load the renderers into the event objects
so that they may be able to call the 'render' method later on. | [
"Given",
"the",
"events",
"and",
"the",
"context",
"renderers",
"load",
"the",
"renderers",
"into",
"the",
"event",
"objects",
"so",
"that",
"they",
"may",
"be",
"able",
"to",
"call",
"the",
"render",
"method",
"later",
"on",
"."
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L158-L191 |
ambitioninc/django-entity-event | entity_event/context_loader.py | load_contexts_and_renderers | def load_contexts_and_renderers(events, mediums):
"""
Given a list of events and mediums, load the context model data into the contexts of the events.
"""
sources = {event.source for event in events}
rendering_styles = {medium.rendering_style for medium in mediums if medium.rendering_style}
# F... | python | def load_contexts_and_renderers(events, mediums):
"""
Given a list of events and mediums, load the context model data into the contexts of the events.
"""
sources = {event.source for event in events}
rendering_styles = {medium.rendering_style for medium in mediums if medium.rendering_style}
# F... | [
"def",
"load_contexts_and_renderers",
"(",
"events",
",",
"mediums",
")",
":",
"sources",
"=",
"{",
"event",
".",
"source",
"for",
"event",
"in",
"events",
"}",
"rendering_styles",
"=",
"{",
"medium",
".",
"rendering_style",
"for",
"medium",
"in",
"mediums",
... | Given a list of events and mediums, load the context model data into the contexts of the events. | [
"Given",
"a",
"list",
"of",
"events",
"and",
"mediums",
"load",
"the",
"context",
"model",
"data",
"into",
"the",
"contexts",
"of",
"the",
"events",
"."
] | train | https://github.com/ambitioninc/django-entity-event/blob/70f50df133e42a7bf38d0f07fccc6d2890e5fd12/entity_event/context_loader.py#L202-L226 |
ralphbean/raptorizemw | examples/pyramid-raptorized/pyramidraptorized/__init__.py | main | def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
config = Configurator(settings=settings)
config.add_static_view('static', 'pyramidraptorized:static', cache_max_age=3600)
... | python | def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, 'sqlalchemy.')
initialize_sql(engine)
config = Configurator(settings=settings)
config.add_static_view('static', 'pyramidraptorized:static', cache_max_age=3600)
... | [
"def",
"main",
"(",
"global_config",
",",
"*",
"*",
"settings",
")",
":",
"engine",
"=",
"engine_from_config",
"(",
"settings",
",",
"'sqlalchemy.'",
")",
"initialize_sql",
"(",
"engine",
")",
"config",
"=",
"Configurator",
"(",
"settings",
"=",
"settings",
... | This function returns a Pyramid WSGI application. | [
"This",
"function",
"returns",
"a",
"Pyramid",
"WSGI",
"application",
"."
] | train | https://github.com/ralphbean/raptorizemw/blob/aee001e1f17ee4b9ad27aac6dde21d8ff545144e/examples/pyramid-raptorized/pyramidraptorized/__init__.py#L8-L21 |
ofir123/py-printer | pyprinter/printer.py | get_printer | def get_printer(colors: bool = True, width_limit: bool = True, disabled: bool = False) -> Printer:
"""
Returns an already initialized instance of the printer.
:param colors: If False, no colors will be printed.
:param width_limit: If True, printing width will be limited by console width.
:param dis... | python | def get_printer(colors: bool = True, width_limit: bool = True, disabled: bool = False) -> Printer:
"""
Returns an already initialized instance of the printer.
:param colors: If False, no colors will be printed.
:param width_limit: If True, printing width will be limited by console width.
:param dis... | [
"def",
"get_printer",
"(",
"colors",
":",
"bool",
"=",
"True",
",",
"width_limit",
":",
"bool",
"=",
"True",
",",
"disabled",
":",
"bool",
"=",
"False",
")",
"->",
"Printer",
":",
"global",
"_printer",
"global",
"_colors",
"# Make sure we can print colors if n... | Returns an already initialized instance of the printer.
:param colors: If False, no colors will be printed.
:param width_limit: If True, printing width will be limited by console width.
:param disabled: If True, nothing will be printed. | [
"Returns",
"an",
"already",
"initialized",
"instance",
"of",
"the",
"printer",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L328-L343 |
ofir123/py-printer | pyprinter/printer.py | _get_windows_console_width | def _get_windows_console_width() -> int:
"""
A small utility function for getting the current console window's width, in Windows.
:return: The current console window's width.
"""
from ctypes import byref, windll
import pyreadline
out = windll.kernel32.GetStdHandle(-11)
info = pyreadlin... | python | def _get_windows_console_width() -> int:
"""
A small utility function for getting the current console window's width, in Windows.
:return: The current console window's width.
"""
from ctypes import byref, windll
import pyreadline
out = windll.kernel32.GetStdHandle(-11)
info = pyreadlin... | [
"def",
"_get_windows_console_width",
"(",
")",
"->",
"int",
":",
"from",
"ctypes",
"import",
"byref",
",",
"windll",
"import",
"pyreadline",
"out",
"=",
"windll",
".",
"kernel32",
".",
"GetStdHandle",
"(",
"-",
"11",
")",
"info",
"=",
"pyreadline",
".",
"c... | A small utility function for getting the current console window's width, in Windows.
:return: The current console window's width. | [
"A",
"small",
"utility",
"function",
"for",
"getting",
"the",
"current",
"console",
"window",
"s",
"width",
"in",
"Windows",
"."
] | train | https://github.com/ofir123/py-printer/blob/876c83b32120f3b6a7b06989b2cd9b86915d1a50/pyprinter/printer.py#L346-L358 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.