Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
ModelAdmin.response_change | (self, request, obj) |
Determine the HttpResponse for the change_view stage.
|
Determine the HttpResponse for the change_view stage.
| def response_change(self, request, obj):
"""
Determine the HttpResponse for the change_view stage.
"""
if IS_POPUP_VAR in request.POST:
opts = obj._meta
to_field = request.POST.get(TO_FIELD_VAR)
attr = str(to_field) if to_field else opts.pk.attname
... | [
"def",
"response_change",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"if",
"IS_POPUP_VAR",
"in",
"request",
".",
"POST",
":",
"opts",
"=",
"obj",
".",
"_meta",
"to_field",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"TO_FIELD_VAR",
")",
"attr... | [
1234,
4
] | [
1307,
63
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_post_save_add | (self, request, obj) |
Figure out where to redirect after the 'Save' button has been pressed
when adding a new object.
|
Figure out where to redirect after the 'Save' button has been pressed
when adding a new object.
| def response_post_save_add(self, request, obj):
"""
Figure out where to redirect after the 'Save' button has been pressed
when adding a new object.
"""
return self._response_post_save(request, obj) | [
"def",
"response_post_save_add",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"return",
"self",
".",
"_response_post_save",
"(",
"request",
",",
"obj",
")"
] | [
1322,
4
] | [
1327,
53
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_post_save_change | (self, request, obj) |
Figure out where to redirect after the 'Save' button has been pressed
when editing an existing object.
|
Figure out where to redirect after the 'Save' button has been pressed
when editing an existing object.
| def response_post_save_change(self, request, obj):
"""
Figure out where to redirect after the 'Save' button has been pressed
when editing an existing object.
"""
return self._response_post_save(request, obj) | [
"def",
"response_post_save_change",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"return",
"self",
".",
"_response_post_save",
"(",
"request",
",",
"obj",
")"
] | [
1329,
4
] | [
1334,
53
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_action | (self, request, queryset) |
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
|
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
| def response_action(self, request, queryset):
"""
Handle an admin action. This is called if a request is POSTed to the
changelist; it returns an HttpResponse if the action was handled, and
None otherwise.
"""
# There can be multiple action forms on the page (at the top
... | [
"def",
"response_action",
"(",
"self",
",",
"request",
",",
"queryset",
")",
":",
"# There can be multiple action forms on the page (at the top",
"# and bottom of the change list, for example). Get the action",
"# whose button was pushed.",
"try",
":",
"action_index",
"=",
"int",
... | [
1336,
4
] | [
1401,
23
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.response_delete | (self, request, obj_display, obj_id) |
Determine the HttpResponse for the delete_view stage.
|
Determine the HttpResponse for the delete_view stage.
| def response_delete(self, request, obj_display, obj_id):
"""
Determine the HttpResponse for the delete_view stage.
"""
opts = self.model._meta
if IS_POPUP_VAR in request.POST:
popup_response_data = json.dumps({
'action': 'delete',
'val... | [
"def",
"response_delete",
"(",
"self",
",",
"request",
",",
"obj_display",
",",
"obj_id",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"if",
"IS_POPUP_VAR",
"in",
"request",
".",
"POST",
":",
"popup_response_data",
"=",
"json",
".",
"dumps",
... | [
1403,
4
] | [
1442,
45
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_changeform_initial_data | (self, request) |
Get the initial form data from the request's GET params.
|
Get the initial form data from the request's GET params.
| def get_changeform_initial_data(self, request):
"""
Get the initial form data from the request's GET params.
"""
initial = dict(request.GET.items())
for k in initial:
try:
f = self.model._meta.get_field(k)
except FieldDoesNotExist:
... | [
"def",
"get_changeform_initial_data",
"(",
"self",
",",
"request",
")",
":",
"initial",
"=",
"dict",
"(",
"request",
".",
"GET",
".",
"items",
"(",
")",
")",
"for",
"k",
"in",
"initial",
":",
"try",
":",
"f",
"=",
"self",
".",
"model",
".",
"_meta",
... | [
1490,
4
] | [
1503,
22
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._get_obj_does_not_exist_redirect | (self, request, opts, object_id) |
Create a message informing the user that the object doesn't exist
and return a redirect to the admin index page.
|
Create a message informing the user that the object doesn't exist
and return a redirect to the admin index page.
| def _get_obj_does_not_exist_redirect(self, request, opts, object_id):
"""
Create a message informing the user that the object doesn't exist
and return a redirect to the admin index page.
"""
msg = _('%(name)s with ID “%(key)s” doesn’t exist. Perhaps it was deleted?') % {
... | [
"def",
"_get_obj_does_not_exist_redirect",
"(",
"self",
",",
"request",
",",
"opts",
",",
"object_id",
")",
":",
"msg",
"=",
"_",
"(",
"'%(name)s with ID “%(key)s” doesn’t exist. Perhaps it was deleted?') % {",
"",
"",
"",
"'name'",
":",
"opts",
".",
"verbose_name",
... | [
1505,
4
] | [
1516,
40
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._get_edited_object_pks | (self, request, prefix) | Return POST data values of list_editable primary keys. | Return POST data values of list_editable primary keys. | def _get_edited_object_pks(self, request, prefix):
"""Return POST data values of list_editable primary keys."""
pk_pattern = re.compile(
r'{}-\d+-{}$'.format(re.escape(prefix), self.model._meta.pk.name)
)
return [value for key, value in request.POST.items() if pk_pattern.matc... | [
"def",
"_get_edited_object_pks",
"(",
"self",
",",
"request",
",",
"prefix",
")",
":",
"pk_pattern",
"=",
"re",
".",
"compile",
"(",
"r'{}-\\d+-{}$'",
".",
"format",
"(",
"re",
".",
"escape",
"(",
"prefix",
")",
",",
"self",
".",
"model",
".",
"_meta",
... | [
1642,
4
] | [
1647,
86
] | python | en | ['en', 'et', 'en'] | True |
ModelAdmin._get_list_editable_queryset | (self, request, prefix) |
Based on POST data, return a queryset of the objects that were edited
via list_editable.
|
Based on POST data, return a queryset of the objects that were edited
via list_editable.
| def _get_list_editable_queryset(self, request, prefix):
"""
Based on POST data, return a queryset of the objects that were edited
via list_editable.
"""
object_pks = self._get_edited_object_pks(request, prefix)
queryset = self.get_queryset(request)
validate = quer... | [
"def",
"_get_list_editable_queryset",
"(",
"self",
",",
"request",
",",
"prefix",
")",
":",
"object_pks",
"=",
"self",
".",
"_get_edited_object_pks",
"(",
"request",
",",
"prefix",
")",
"queryset",
"=",
"self",
".",
"get_queryset",
"(",
"request",
")",
"valida... | [
1649,
4
] | [
1663,
49
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.changelist_view | (self, request, extra_context=None) |
The 'change list' admin view for this model.
|
The 'change list' admin view for this model.
| def changelist_view(self, request, extra_context=None):
"""
The 'change list' admin view for this model.
"""
from django.contrib.admin.views.main import ERROR_FLAG
opts = self.model._meta
app_label = opts.app_label
if not self.has_view_or_change_permission(request... | [
"def",
"changelist_view",
"(",
"self",
",",
"request",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"views",
".",
"main",
"import",
"ERROR_FLAG",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"app_l... | [
1666,
4
] | [
1818,
19
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin.get_deleted_objects | (self, objs, request) |
Hook for customizing the delete process for the delete view and the
"delete selected" action.
|
Hook for customizing the delete process for the delete view and the
"delete selected" action.
| def get_deleted_objects(self, objs, request):
"""
Hook for customizing the delete process for the delete view and the
"delete selected" action.
"""
return get_deleted_objects(objs, request, self.admin_site) | [
"def",
"get_deleted_objects",
"(",
"self",
",",
"objs",
",",
"request",
")",
":",
"return",
"get_deleted_objects",
"(",
"objs",
",",
"request",
",",
"self",
".",
"admin_site",
")"
] | [
1820,
4
] | [
1825,
66
] | python | en | ['en', 'error', 'th'] | False |
ModelAdmin._delete_view | (self, request, object_id, extra_context) | The 'delete' admin view for this model. | The 'delete' admin view for this model. | def _delete_view(self, request, object_id, extra_context):
"The 'delete' admin view for this model."
opts = self.model._meta
app_label = opts.app_label
to_field = request.POST.get(TO_FIELD_VAR, request.GET.get(TO_FIELD_VAR))
if to_field and not self.to_field_allowed(request, to_... | [
"def",
"_delete_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"app_label",
"=",
"opts",
".",
"app_label",
"to_field",
"=",
"request",
".",
"POST",
".",
"get",
"(",
... | [
1832,
4
] | [
1888,
56
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin.history_view | (self, request, object_id, extra_context=None) | The 'history' admin view for this model. | The 'history' admin view for this model. | def history_view(self, request, object_id, extra_context=None):
"The 'history' admin view for this model."
from django.contrib.admin.models import LogEntry
# First check if the user can see this history.
model = self.model
obj = self.get_object(request, unquote(object_id))
... | [
"def",
"history_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
"=",
"None",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"models",
"import",
"LogEntry",
"# First check if the user can see this history.",
"model",
"=",... | [
1890,
4
] | [
1927,
19
] | python | en | ['en', 'en', 'en'] | True |
ModelAdmin._create_formsets | (self, request, obj, change) | Helper function to generate formsets for add/change_view. | Helper function to generate formsets for add/change_view. | def _create_formsets(self, request, obj, change):
"Helper function to generate formsets for add/change_view."
formsets = []
inline_instances = []
prefixes = {}
get_formsets_args = [request]
if change:
get_formsets_args.append(obj)
for FormSet, inline i... | [
"def",
"_create_formsets",
"(",
"self",
",",
"request",
",",
"obj",
",",
"change",
")",
":",
"formsets",
"=",
"[",
"]",
"inline_instances",
"=",
"[",
"]",
"prefixes",
"=",
"{",
"}",
"get_formsets_args",
"=",
"[",
"request",
"]",
"if",
"change",
":",
"g... | [
1929,
4
] | [
1972,
41
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_extra | (self, request, obj=None, **kwargs) | Hook for customizing the number of extra inline forms. | Hook for customizing the number of extra inline forms. | def get_extra(self, request, obj=None, **kwargs):
"""Hook for customizing the number of extra inline forms."""
return self.extra | [
"def",
"get_extra",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"extra"
] | [
2019,
4
] | [
2021,
25
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_min_num | (self, request, obj=None, **kwargs) | Hook for customizing the min number of inline forms. | Hook for customizing the min number of inline forms. | def get_min_num(self, request, obj=None, **kwargs):
"""Hook for customizing the min number of inline forms."""
return self.min_num | [
"def",
"get_min_num",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"min_num"
] | [
2023,
4
] | [
2025,
27
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_max_num | (self, request, obj=None, **kwargs) | Hook for customizing the max number of extra inline forms. | Hook for customizing the max number of extra inline forms. | def get_max_num(self, request, obj=None, **kwargs):
"""Hook for customizing the max number of extra inline forms."""
return self.max_num | [
"def",
"get_max_num",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"max_num"
] | [
2027,
4
] | [
2029,
27
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_formset | (self, request, obj=None, **kwargs) | Return a BaseInlineFormSet class for use in admin add/change views. | Return a BaseInlineFormSet class for use in admin add/change views. | def get_formset(self, request, obj=None, **kwargs):
"""Return a BaseInlineFormSet class for use in admin add/change views."""
if 'fields' in kwargs:
fields = kwargs.pop('fields')
else:
fields = flatten_fieldsets(self.get_fieldsets(request, obj))
excluded = self.ge... | [
"def",
"get_formset",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'fields'",
"in",
"kwargs",
":",
"fields",
"=",
"kwargs",
".",
"pop",
"(",
"'fields'",
")",
"else",
":",
"fields",
"=",
"flatten_fiel... | [
2031,
4
] | [
2118,
79
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin._has_any_perms_for_target_model | (self, request, perms) |
This method is called only when the ModelAdmin's model is for an
ManyToManyField's implicit through model (if self.opts.auto_created).
Return True if the user has any of the given permissions ('add',
'change', etc.) for the model that points to the through model.
|
This method is called only when the ModelAdmin's model is for an
ManyToManyField's implicit through model (if self.opts.auto_created).
Return True if the user has any of the given permissions ('add',
'change', etc.) for the model that points to the through model.
| def _has_any_perms_for_target_model(self, request, perms):
"""
This method is called only when the ModelAdmin's model is for an
ManyToManyField's implicit through model (if self.opts.auto_created).
Return True if the user has any of the given permissions ('add',
'change', etc.) f... | [
"def",
"_has_any_perms_for_target_model",
"(",
"self",
",",
"request",
",",
"perms",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"# Find the target model of an auto-created many-to-many relationship.",
"for",
"field",
"in",
"opts",
".",
"fields",
":",
"if",
"field",
... | [
2129,
4
] | [
2145,
9
] | python | en | ['en', 'error', 'th'] | False |
merge_setting | (request_setting, session_setting, dict_class=OrderedDict) | Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
| def merge_setting(request_setting, session_setting, dict_class=OrderedDict):
"""Determines appropriate setting for a given request, taking into account
the explicit setting on that request, and the setting in the session. If a
setting is a dictionary, they will be merged together using `dict_class`
"""
... | [
"def",
"merge_setting",
"(",
"request_setting",
",",
"session_setting",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_setting",
"is",
"None",
":",
"return",
"request_setting",
"if",
"request_setting",
"is",
"None",
":",
"return",
"session_setting",... | [
49,
0
] | [
77,
25
] | python | en | ['en', 'en', 'en'] | True |
merge_hooks | (request_hooks, session_hooks, dict_class=OrderedDict) | Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
| Properly merges both requests and session hooks. | def merge_hooks(request_hooks, session_hooks, dict_class=OrderedDict):
"""Properly merges both requests and session hooks.
This is necessary because when request_hooks == {'response': []}, the
merge breaks Session hooks entirely.
"""
if session_hooks is None or session_hooks.get('response') == []:
... | [
"def",
"merge_hooks",
"(",
"request_hooks",
",",
"session_hooks",
",",
"dict_class",
"=",
"OrderedDict",
")",
":",
"if",
"session_hooks",
"is",
"None",
"or",
"session_hooks",
".",
"get",
"(",
"'response'",
")",
"==",
"[",
"]",
":",
"return",
"request_hooks",
... | [
80,
0
] | [
92,
66
] | python | en | ['en', 'en', 'en'] | True |
session | () |
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be removed at a future date.... |
Returns a :class:`Session` for context-management. | def session():
"""
Returns a :class:`Session` for context-management.
.. deprecated:: 1.0.0
This method has been deprecated since version 1.0.0 and is only kept for
backwards compatibility. New code should use :class:`~requests.sessions.Session`
to create a session. This may be rem... | [
"def",
"session",
"(",
")",
":",
"return",
"Session",
"(",
")"
] | [
754,
0
] | [
766,
20
] | python | en | ['en', 'error', 'th'] | False |
SessionRedirectMixin.get_redirect_target | (self, resp) | Receives a Response. Returns a redirect URI or ``None`` | Receives a Response. Returns a redirect URI or ``None`` | def get_redirect_target(self, resp):
"""Receives a Response. Returns a redirect URI or ``None``"""
# Due to the nature of how requests processes redirects this method will
# be called at least once upon the original response and at least twice
# on each subsequent redirect response (if a... | [
"def",
"get_redirect_target",
"(",
"self",
",",
"resp",
")",
":",
"# Due to the nature of how requests processes redirects this method will",
"# be called at least once upon the original response and at least twice",
"# on each subsequent redirect response (if any).",
"# If a custom mixin is u... | [
97,
4
] | [
116,
19
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.should_strip_auth | (self, old_url, new_url) | Decide whether Authorization header should be removed when redirecting | Decide whether Authorization header should be removed when redirecting | def should_strip_auth(self, old_url, new_url):
"""Decide whether Authorization header should be removed when redirecting"""
old_parsed = urlparse(old_url)
new_parsed = urlparse(new_url)
if old_parsed.hostname != new_parsed.hostname:
return True
# Special case: allow h... | [
"def",
"should_strip_auth",
"(",
"self",
",",
"old_url",
",",
"new_url",
")",
":",
"old_parsed",
"=",
"urlparse",
"(",
"old_url",
")",
"new_parsed",
"=",
"urlparse",
"(",
"new_url",
")",
"if",
"old_parsed",
".",
"hostname",
"!=",
"new_parsed",
".",
"hostname... | [
118,
4
] | [
141,
45
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.resolve_redirects | (self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs) | Receives a Response. Returns a generator of Responses or Requests. | Receives a Response. Returns a generator of Responses or Requests. | def resolve_redirects(self, resp, req, stream=False, timeout=None,
verify=True, cert=None, proxies=None, yield_requests=False, **adapter_kwargs):
"""Receives a Response. Returns a generator of Responses or Requests."""
hist = [] # keep track of history
url = self.get... | [
"def",
"resolve_redirects",
"(",
"self",
",",
"resp",
",",
"req",
",",
"stream",
"=",
"False",
",",
"timeout",
"=",
"None",
",",
"verify",
"=",
"True",
",",
"cert",
"=",
"None",
",",
"proxies",
"=",
"None",
",",
"yield_requests",
"=",
"False",
",",
"... | [
143,
4
] | [
251,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_auth | (self, prepared_request, response) | When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
| def rebuild_auth(self, prepared_request, response):
"""When being redirected we may want to strip authentication from the
request to avoid leaking credentials. This method intelligently removes
and reapplies authentication where possible to avoid credential loss.
"""
headers = pr... | [
"def",
"rebuild_auth",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
".",
"url",
"if",
"'Authorization'",
"in",
"headers",
"and",
"self",
".",
"should_strip_au... | [
253,
4
] | [
269,
51
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_proxies | (self, prepared_request, proxies) | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect).
... | This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in case they were stripped by a previous
redirect). | def rebuild_proxies(self, prepared_request, proxies):
"""This method re-evaluates the proxy configuration by considering the
environment variables. If we are redirected to a URL covered by
NO_PROXY, we strip the proxy configuration. Otherwise, we set missing
proxy keys for this URL (in c... | [
"def",
"rebuild_proxies",
"(",
"self",
",",
"prepared_request",
",",
"proxies",
")",
":",
"proxies",
"=",
"proxies",
"if",
"proxies",
"is",
"not",
"None",
"else",
"{",
"}",
"headers",
"=",
"prepared_request",
".",
"headers",
"url",
"=",
"prepared_request",
"... | [
272,
4
] | [
311,
26
] | python | en | ['en', 'en', 'en'] | True |
SessionRedirectMixin.rebuild_method | (self, prepared_request, response) | When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
| def rebuild_method(self, prepared_request, response):
"""When being redirected we may want to change the method of the request
based on certain specs or browser behavior.
"""
method = prepared_request.method
# https://tools.ietf.org/html/rfc7231#section-6.4.4
if response... | [
"def",
"rebuild_method",
"(",
"self",
",",
"prepared_request",
",",
"response",
")",
":",
"method",
"=",
"prepared_request",
".",
"method",
"# https://tools.ietf.org/html/rfc7231#section-6.4.4",
"if",
"response",
".",
"status_code",
"==",
"codes",
".",
"see_other",
"a... | [
313,
4
] | [
333,
40
] | python | en | ['en', 'en', 'en'] | True |
Session.prepare_request | (self, request) | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class:`Request` instance to prepare with this
... | Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`. | def prepare_request(self, request):
"""Constructs a :class:`PreparedRequest <PreparedRequest>` for
transmission and returns it. The :class:`PreparedRequest` has settings
merged from the :class:`Request <Request>` instance and those of the
:class:`Session`.
:param request: :class... | [
"def",
"prepare_request",
"(",
"self",
",",
"request",
")",
":",
"cookies",
"=",
"request",
".",
"cookies",
"or",
"{",
"}",
"# Bootstrap CookieJar.",
"if",
"not",
"isinstance",
"(",
"cookies",
",",
"cookielib",
".",
"CookieJar",
")",
":",
"cookies",
"=",
"... | [
422,
4
] | [
460,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.request | (self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None) | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object.
:param method: method for the new :class:`Request` object.
:param url: URL for the new :class:`Request` object.
:param params: (optional) Dictionary or bytes to be sent in the... | Constructs a :class:`Request <Request>`, prepares it and sends it.
Returns :class:`Response <Response>` object. | def request(self, method, url,
params=None, data=None, headers=None, cookies=None, files=None,
auth=None, timeout=None, allow_redirects=True, proxies=None,
hooks=None, stream=None, verify=None, cert=None, json=None):
"""Constructs a :class:`Request <Request>`, prepares it and... | [
"def",
"request",
"(",
"self",
",",
"method",
",",
"url",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"cookies",
"=",
"None",
",",
"files",
"=",
"None",
",",
"auth",
"=",
"None",
",",
"timeout",
"=",
"N... | [
462,
4
] | [
531,
19
] | python | en | ['en', 'en', 'en'] | True |
Session.get | (self, url, **kwargs) | r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a GET request. Returns :class:`Response` object. | def get(self, url, **kwargs):
r"""Sends a GET request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects',... | [
"def",
"get",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'GET'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
533,
4
] | [
542,
49
] | python | en | ['en', 'lb', 'en'] | True |
Session.options | (self, url, **kwargs) | r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a OPTIONS request. Returns :class:`Response` object. | def options(self, url, **kwargs):
r"""Sends a OPTIONS request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_red... | [
"def",
"options",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"True",
")",
"return",
"self",
".",
"request",
"(",
"'OPTIONS'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
544,
4
] | [
553,
53
] | python | en | ['en', 'en', 'en'] | True |
Session.head | (self, url, **kwargs) | r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a HEAD request. Returns :class:`Response` object. | def head(self, url, **kwargs):
r"""Sends a HEAD request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
kwargs.setdefault('allow_redirects... | [
"def",
"head",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'allow_redirects'",
",",
"False",
")",
"return",
"self",
".",
"request",
"(",
"'HEAD'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
555,
4
] | [
564,
50
] | python | en | ['en', 'lb', 'en'] | True |
Session.post | (self, url, data=None, json=None, **kwargs) | r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param json: (optional) json to send in the bo... | r"""Sends a POST request. Returns :class:`Response` object. | def post(self, url, data=None, json=None, **kwargs):
r"""Sends a POST request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Req... | [
"def",
"post",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"json",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'POST'",
",",
"url",
",",
"data",
"=",
"data",
",",
"json",
"=",
"json",
",",... | [
566,
4
] | [
577,
72
] | python | en | ['en', 'lb', 'en'] | True |
Session.put | (self, url, data=None, **kwargs) | r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``re... | r"""Sends a PUT request. Returns :class:`Response` object. | def put(self, url, data=None, **kwargs):
r"""Sends a PUT request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"put",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PUT'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
579,
4
] | [
589,
60
] | python | en | ['en', 'lb', 'en'] | True |
Session.patch | (self, url, data=None, **kwargs) | r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
:param \*\*kwargs: Optional arguments that ``... | r"""Sends a PATCH request. Returns :class:`Response` object. | def patch(self, url, data=None, **kwargs):
r"""Sends a PATCH request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param data: (optional) Dictionary, list of tuples, bytes, or file-like
object to send in the body of the :class:`Request`.
... | [
"def",
"patch",
"(",
"self",
",",
"url",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'PATCH'",
",",
"url",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | [
591,
4
] | [
601,
62
] | python | en | ['en', 'en', 'en'] | True |
Session.delete | (self, url, **kwargs) | r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
| r"""Sends a DELETE request. Returns :class:`Response` object. | def delete(self, url, **kwargs):
r"""Sends a DELETE request. Returns :class:`Response` object.
:param url: URL for the new :class:`Request` object.
:param \*\*kwargs: Optional arguments that ``request`` takes.
:rtype: requests.Response
"""
return self.request('DELETE', ... | [
"def",
"delete",
"(",
"self",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"request",
"(",
"'DELETE'",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | [
603,
4
] | [
611,
52
] | python | en | ['en', 'en', 'en'] | True |
Session.send | (self, request, **kwargs) | Send a given PreparedRequest.
:rtype: requests.Response
| Send a given PreparedRequest. | def send(self, request, **kwargs):
"""Send a given PreparedRequest.
:rtype: requests.Response
"""
# Set defaults that the hooks can utilize to ensure they always have
# the correct parameters to reproduce the previous request.
kwargs.setdefault('stream', self.stream)
... | [
"def",
"send",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Set defaults that the hooks can utilize to ensure they always have",
"# the correct parameters to reproduce the previous request.",
"kwargs",
".",
"setdefault",
"(",
"'stream'",
",",
"self",
"... | [
613,
4
] | [
684,
16
] | python | en | ['en', 'co', 'en'] | True |
Session.merge_environment_settings | (self, url, proxies, stream, verify, cert) |
Check the environment and merge it with some settings.
:rtype: dict
|
Check the environment and merge it with some settings. | def merge_environment_settings(self, url, proxies, stream, verify, cert):
"""
Check the environment and merge it with some settings.
:rtype: dict
"""
# Gather clues from the surrounding environment.
if self.trust_env:
# Set environment's proxies.
... | [
"def",
"merge_environment_settings",
"(",
"self",
",",
"url",
",",
"proxies",
",",
"stream",
",",
"verify",
",",
"cert",
")",
":",
"# Gather clues from the surrounding environment.",
"if",
"self",
".",
"trust_env",
":",
"# Set environment's proxies.",
"no_proxy",
"=",... | [
686,
4
] | [
713,
29
] | python | en | ['en', 'error', 'th'] | False |
Session.get_adapter | (self, url) |
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
|
Returns the appropriate connection adapter for the given URL. | def get_adapter(self, url):
"""
Returns the appropriate connection adapter for the given URL.
:rtype: requests.adapters.BaseAdapter
"""
for (prefix, adapter) in self.adapters.items():
if url.lower().startswith(prefix.lower()):
return adapter
... | [
"def",
"get_adapter",
"(",
"self",
",",
"url",
")",
":",
"for",
"(",
"prefix",
",",
"adapter",
")",
"in",
"self",
".",
"adapters",
".",
"items",
"(",
")",
":",
"if",
"url",
".",
"lower",
"(",
")",
".",
"startswith",
"(",
"prefix",
".",
"lower",
"... | [
715,
4
] | [
727,
85
] | python | en | ['en', 'error', 'th'] | False |
Session.close | (self) | Closes all adapters and as such the session | Closes all adapters and as such the session | def close(self):
"""Closes all adapters and as such the session"""
for v in self.adapters.values():
v.close() | [
"def",
"close",
"(",
"self",
")",
":",
"for",
"v",
"in",
"self",
".",
"adapters",
".",
"values",
"(",
")",
":",
"v",
".",
"close",
"(",
")"
] | [
729,
4
] | [
732,
21
] | python | en | ['en', 'en', 'en'] | True |
Session.mount | (self, prefix, adapter) | Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
| Registers a connection adapter to a prefix. | def mount(self, prefix, adapter):
"""Registers a connection adapter to a prefix.
Adapters are sorted in descending order by prefix length.
"""
self.adapters[prefix] = adapter
keys_to_move = [k for k in self.adapters if len(k) < len(prefix)]
for key in keys_to_move:
... | [
"def",
"mount",
"(",
"self",
",",
"prefix",
",",
"adapter",
")",
":",
"self",
".",
"adapters",
"[",
"prefix",
"]",
"=",
"adapter",
"keys_to_move",
"=",
"[",
"k",
"for",
"k",
"in",
"self",
".",
"adapters",
"if",
"len",
"(",
"k",
")",
"<",
"len",
"... | [
734,
4
] | [
743,
55
] | python | en | ['en', 'en', 'en'] | True |
sdist_add_defaults.add_defaults | (self) | Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as... | Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_files.
- all files defined as... | def add_defaults(self):
"""Add all the default files to self.filelist:
- README or README.txt
- setup.py
- test/test*.py
- all pure Python modules mentioned in setup script
- all files pointed by package_data (build_py)
- all files defined in data_file... | [
"def",
"add_defaults",
"(",
"self",
")",
":",
"self",
".",
"_add_defaults_standards",
"(",
")",
"self",
".",
"_add_defaults_optional",
"(",
")",
"self",
".",
"_add_defaults_python",
"(",
")",
"self",
".",
"_add_defaults_data_files",
"(",
")",
"self",
".",
"_ad... | [
17,
4
] | [
37,
36
] | python | en | ['en', 'en', 'en'] | True |
sdist_add_defaults._cs_path_exists | (fspath) |
Case-sensitive path existence check
>>> sdist_add_defaults._cs_path_exists(__file__)
True
>>> sdist_add_defaults._cs_path_exists(__file__.upper())
False
|
Case-sensitive path existence check | def _cs_path_exists(fspath):
"""
Case-sensitive path existence check
>>> sdist_add_defaults._cs_path_exists(__file__)
True
>>> sdist_add_defaults._cs_path_exists(__file__.upper())
False
"""
if not os.path.exists(fspath):
return False
#... | [
"def",
"_cs_path_exists",
"(",
"fspath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"fspath",
")",
":",
"return",
"False",
"# make absolute so we always have a directory",
"abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"fspath",
"... | [
40,
4
] | [
54,
48
] | python | en | ['en', 'error', 'th'] | False |
ValidationError.__init__ | (self, message, code=None, params=None) |
The `message` argument can be a single error, a list of errors, or a
dictionary that maps field names to lists of errors. What we define as
an "error" can be either a simple string or an instance of
ValidationError with its message attribute set, and what we define as
list or di... |
The `message` argument can be a single error, a list of errors, or a
dictionary that maps field names to lists of errors. What we define as
an "error" can be either a simple string or an instance of
ValidationError with its message attribute set, and what we define as
list or di... | def __init__(self, message, code=None, params=None):
"""
The `message` argument can be a single error, a list of errors, or a
dictionary that maps field names to lists of errors. What we define as
an "error" can be either a simple string or an instance of
ValidationError with its... | [
"def",
"__init__",
"(",
"self",
",",
"message",
",",
"code",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"# PY2 can't pickle naive exception: http://bugs.python.org/issue1692335.",
"super",
"(",
"ValidationError",
",",
"self",
")",
".",
"__init__",
"(",
"me... | [
83,
4
] | [
126,
36
] | python | en | ['en', 'error', 'th'] | False |
OpenLayersWidget.map_options | (self) | Builds the map options hash for the OpenLayers template. | Builds the map options hash for the OpenLayers template. | def map_options(self):
"Builds the map options hash for the OpenLayers template."
# JavaScript construction utilities for the Bounds and Projection.
def ol_bounds(extent):
return 'new OpenLayers.Bounds(%s)' % str(extent)
def ol_projection(srid):
return 'new Open... | [
"def",
"map_options",
"(",
"self",
")",
":",
"# JavaScript construction utilities for the Bounds and Projection.",
"def",
"ol_bounds",
"(",
"extent",
")",
":",
"return",
"'new OpenLayers.Bounds(%s)'",
"%",
"str",
"(",
"extent",
")",
"def",
"ol_projection",
"(",
"srid",
... | [
86,
4
] | [
123,
26
] | python | en | ['en', 'en', 'en'] | True |
get_func_full_args | (func) |
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
|
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
| def get_func_full_args(func):
"""
Return a list of (argument name, default value) tuples. If the argument
does not have a default value, omit it in the tuple. Arguments such as
*args and **kwargs are also included.
"""
sig = inspect.signature(func)
args = []
for arg_name, param in sig.pa... | [
"def",
"get_func_full_args",
"(",
"func",
")",
":",
"sig",
"=",
"inspect",
".",
"signature",
"(",
"func",
")",
"args",
"=",
"[",
"]",
"for",
"arg_name",
",",
"param",
"in",
"sig",
".",
"parameters",
".",
"items",
"(",
")",
":",
"name",
"=",
"arg_name... | [
11,
0
] | [
32,
15
] | python | en | ['en', 'error', 'th'] | False |
func_accepts_var_args | (func) |
Return True if function 'func' accepts positional arguments *args.
|
Return True if function 'func' accepts positional arguments *args.
| def func_accepts_var_args(func):
"""
Return True if function 'func' accepts positional arguments *args.
"""
return any(
p for p in inspect.signature(func).parameters.values()
if p.kind == p.VAR_POSITIONAL
) | [
"def",
"func_accepts_var_args",
"(",
"func",
")",
":",
"return",
"any",
"(",
"p",
"for",
"p",
"in",
"inspect",
".",
"signature",
"(",
"func",
")",
".",
"parameters",
".",
"values",
"(",
")",
"if",
"p",
".",
"kind",
"==",
"p",
".",
"VAR_POSITIONAL",
"... | [
42,
0
] | [
49,
5
] | python | en | ['en', 'error', 'th'] | False |
method_has_no_args | (meth) | Return True if a method only accepts 'self'. | Return True if a method only accepts 'self'. | def method_has_no_args(meth):
"""Return True if a method only accepts 'self'."""
count = len([
p for p in inspect.signature(meth).parameters.values()
if p.kind == p.POSITIONAL_OR_KEYWORD
])
return count == 0 if inspect.ismethod(meth) else count == 1 | [
"def",
"method_has_no_args",
"(",
"meth",
")",
":",
"count",
"=",
"len",
"(",
"[",
"p",
"for",
"p",
"in",
"inspect",
".",
"signature",
"(",
"meth",
")",
".",
"parameters",
".",
"values",
"(",
")",
"if",
"p",
".",
"kind",
"==",
"p",
".",
"POSITIONAL... | [
52,
0
] | [
58,
63
] | python | en | ['en', 'en', 'en'] | True |
_have_cython | () |
Return True if Cython can be imported.
|
Return True if Cython can be imported.
| def _have_cython():
"""
Return True if Cython can be imported.
"""
cython_impl = 'Cython.Distutils.build_ext'
try:
# from (cython_impl) import build_ext
__import__(cython_impl, fromlist=['build_ext']).build_ext
return True
except Exception:
pass
return False | [
"def",
"_have_cython",
"(",
")",
":",
"cython_impl",
"=",
"'Cython.Distutils.build_ext'",
"try",
":",
"# from (cython_impl) import build_ext",
"__import__",
"(",
"cython_impl",
",",
"fromlist",
"=",
"[",
"'build_ext'",
"]",
")",
".",
"build_ext",
"return",
"True",
"... | [
11,
0
] | [
22,
16
] | python | en | ['en', 'error', 'th'] | False |
Extension._convert_pyx_sources_to_lang | (self) |
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
|
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
| def _convert_pyx_sources_to_lang(self):
"""
Replace sources with .pyx extensions to sources with the target
language extension. This mechanism allows language authors to supply
pre-converted sources but to prefer the .pyx sources.
"""
if _have_cython():
# the ... | [
"def",
"_convert_pyx_sources_to_lang",
"(",
"self",
")",
":",
"if",
"_have_cython",
"(",
")",
":",
"# the build has Cython, so allow it to compile the .pyx files",
"return",
"lang",
"=",
"self",
".",
"language",
"or",
"''",
"target_ext",
"=",
"'.cpp'",
"if",
"lang",
... | [
40,
4
] | [
52,
51
] | python | en | ['en', 'error', 'th'] | False |
handle_event_payload | (event: Dict[str, Any]) | Handle either an exception type event or a message type event payload. | Handle either an exception type event or a message type event payload. | def handle_event_payload(event: Dict[str, Any]) -> Tuple[str, str]:
""" Handle either an exception type event or a message type event payload."""
# We shouldn't support the officially deprecated Raven series of SDKs.
if int(event["version"]) < 7:
raise UnsupportedWebhookEventType("Raven SDK")
s... | [
"def",
"handle_event_payload",
"(",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"# We shouldn't support the officially deprecated Raven series of SDKs.",
"if",
"int",
"(",
"event",
"[",
"\"version\"",
... | [
93,
0
] | [
163,
26
] | python | en | ['en', 'en', 'en'] | True |
handle_issue_payload | (
action: str, issue: Dict[str, Any], actor: Dict[str, Any]
) | Handle either an issue type event. | Handle either an issue type event. | def handle_issue_payload(
action: str, issue: Dict[str, Any], actor: Dict[str, Any]
) -> Tuple[str, str]:
""" Handle either an issue type event. """
subject = issue["title"]
datetime = issue["lastSeen"].split(".")[0].replace("T", " ")
if issue["assignedTo"]:
if issue["assignedTo"]["type"] =... | [
"def",
"handle_issue_payload",
"(",
"action",
":",
"str",
",",
"issue",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"actor",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Tuple",
"[",
"str",
",",
"str",
"]",
":",
"subject",
"=",
"issue... | [
166,
0
] | [
215,
26
] | python | en | ['en', 'en', 'en'] | True |
transform_webhook_payload | (payload: Dict[str, Any]) | Attempt to use webhook payload for the notification.
When the integration is configured as a webhook, instead of being added as
an Internal Integration, the payload is slightly different, but has all the
required information for sending a notification. We transform this payload to
look like the payload... | Attempt to use webhook payload for the notification. | def transform_webhook_payload(payload: Dict[str, Any]) -> Optional[Dict[str, Any]]:
"""Attempt to use webhook payload for the notification.
When the integration is configured as a webhook, instead of being added as
an Internal Integration, the payload is slightly different, but has all the
required inf... | [
"def",
"transform_webhook_payload",
"(",
"payload",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"Optional",
"[",
"Dict",
"[",
"str",
",",
"Any",
"]",
"]",
":",
"event",
"=",
"payload",
".",
"get",
"(",
"\"event\"",
",",
"{",
"}",
")",
"# d... | [
228,
0
] | [
246,
18
] | python | en | ['en', 'en', 'en'] | True |
CurrentThreadExecutor.run_until_future | (self, future) |
Runs the code in the work queue until a result is available from the future.
Should be run from the thread the executor is initialised in.
|
Runs the code in the work queue until a result is available from the future.
Should be run from the thread the executor is initialised in.
| def run_until_future(self, future):
"""
Runs the code in the work queue until a result is available from the future.
Should be run from the thread the executor is initialised in.
"""
# Check we're in the right thread
if threading.current_thread() != self._work_thread:
... | [
"def",
"run_until_future",
"(",
"self",
",",
"future",
")",
":",
"# Check we're in the right thread",
"if",
"threading",
".",
"current_thread",
"(",
")",
"!=",
"self",
".",
"_work_thread",
":",
"raise",
"RuntimeError",
"(",
"\"You cannot run CurrentThreadExecutor from a... | [
43,
4
] | [
69,
31
] | python | en | ['en', 'error', 'th'] | False |
Func._get_repr_options | (self) | Return a dict of extra __init__() options to include in the repr. | Return a dict of extra __init__() options to include in the repr. | def _get_repr_options(self):
"""Return a dict of extra __init__() options to include in the repr."""
return {} | [
"def",
"_get_repr_options",
"(",
"self",
")",
":",
"return",
"{",
"}"
] | [
612,
4
] | [
614,
17
] | python | en | ['en', 'en', 'en'] | True |
Value.__init__ | (self, value, output_field=None) |
Arguments:
* value: the value this expression represents. The value will be
added into the sql parameter list and properly quoted.
* output_field: an instance of the model field type that this
expression will return, such as IntegerField() or CharField().
|
Arguments:
* value: the value this expression represents. The value will be
added into the sql parameter list and properly quoted. | def __init__(self, value, output_field=None):
"""
Arguments:
* value: the value this expression represents. The value will be
added into the sql parameter list and properly quoted.
* output_field: an instance of the model field type that this
expression will retu... | [
"def",
"__init__",
"(",
"self",
",",
"value",
",",
"output_field",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
"output_field",
"=",
"output_field",
")",
"self",
".",
"value",
"=",
"value"
] | [
659,
4
] | [
669,
26
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.get_field_type | (self, data_type, description) |
Hook for a database backend to use the cursor description to
match a Django field type to a database column.
For Oracle, the column data_type on its own is insufficient to
distinguish between a FloatField and IntegerField, for example.
|
Hook for a database backend to use the cursor description to
match a Django field type to a database column. | def get_field_type(self, data_type, description):
"""
Hook for a database backend to use the cursor description to
match a Django field type to a database column.
For Oracle, the column data_type on its own is insufficient to
distinguish between a FloatField and IntegerField, fo... | [
"def",
"get_field_type",
"(",
"self",
",",
"data_type",
",",
"description",
")",
":",
"return",
"self",
".",
"data_types_reverse",
"[",
"data_type",
"]"
] | [
16,
4
] | [
24,
49
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.identifier_converter | (self, name) |
Apply a conversion to the identifier for the purposes of comparison.
The default identifier converter is for case sensitive comparison.
|
Apply a conversion to the identifier for the purposes of comparison. | def identifier_converter(self, name):
"""
Apply a conversion to the identifier for the purposes of comparison.
The default identifier converter is for case sensitive comparison.
"""
return name | [
"def",
"identifier_converter",
"(",
"self",
",",
"name",
")",
":",
"return",
"name"
] | [
26,
4
] | [
32,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.table_names | (self, cursor=None, include_views=False) |
Return a list of names of all tables that exist in the database.
Sort the returned table list by Python's default sorting. Do NOT use
the database's ORDER BY here to avoid subtle differences in sorting
order between databases.
|
Return a list of names of all tables that exist in the database.
Sort the returned table list by Python's default sorting. Do NOT use
the database's ORDER BY here to avoid subtle differences in sorting
order between databases.
| def table_names(self, cursor=None, include_views=False):
"""
Return a list of names of all tables that exist in the database.
Sort the returned table list by Python's default sorting. Do NOT use
the database's ORDER BY here to avoid subtle differences in sorting
order between dat... | [
"def",
"table_names",
"(",
"self",
",",
"cursor",
"=",
"None",
",",
"include_views",
"=",
"False",
")",
":",
"def",
"get_names",
"(",
"cursor",
")",
":",
"return",
"sorted",
"(",
"ti",
".",
"name",
"for",
"ti",
"in",
"self",
".",
"get_table_list",
"(",... | [
34,
4
] | [
47,
32
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.get_table_list | (self, cursor) |
Return an unsorted list of TableInfo named tuples of all tables and
views that exist in the database.
|
Return an unsorted list of TableInfo named tuples of all tables and
views that exist in the database.
| def get_table_list(self, cursor):
"""
Return an unsorted list of TableInfo named tuples of all tables and
views that exist in the database.
"""
raise NotImplementedError('subclasses of BaseDatabaseIntrospection may require a get_table_list() method') | [
"def",
"get_table_list",
"(",
"self",
",",
"cursor",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseIntrospection may require a get_table_list() method'",
")"
] | [
49,
4
] | [
54,
114
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.django_table_names | (self, only_existing=False, include_views=True) |
Return a list of all table names that have associated Django models and
are in INSTALLED_APPS.
If only_existing is True, include only the tables in the database.
|
Return a list of all table names that have associated Django models and
are in INSTALLED_APPS. | def django_table_names(self, only_existing=False, include_views=True):
"""
Return a list of all table names that have associated Django models and
are in INSTALLED_APPS.
If only_existing is True, include only the tables in the database.
"""
tables = set()
for mod... | [
"def",
"django_table_names",
"(",
"self",
",",
"only_existing",
"=",
"False",
",",
"include_views",
"=",
"True",
")",
":",
"tables",
"=",
"set",
"(",
")",
"for",
"model",
"in",
"self",
".",
"get_migratable_models",
"(",
")",
":",
"if",
"not",
"model",
".... | [
66,
4
] | [
90,
21
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.installed_models | (self, tables) |
Return a set of all models represented by the provided list of table
names.
|
Return a set of all models represented by the provided list of table
names.
| def installed_models(self, tables):
"""
Return a set of all models represented by the provided list of table
names.
"""
tables = set(map(self.identifier_converter, tables))
return {
m for m in self.get_migratable_models()
if self.identifier_convert... | [
"def",
"installed_models",
"(",
"self",
",",
"tables",
")",
":",
"tables",
"=",
"set",
"(",
"map",
"(",
"self",
".",
"identifier_converter",
",",
"tables",
")",
")",
"return",
"{",
"m",
"for",
"m",
"in",
"self",
".",
"get_migratable_models",
"(",
")",
... | [
92,
4
] | [
101,
9
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.sequence_list | (self) |
Return a list of information about all DB sequences for all models in
all apps.
|
Return a list of information about all DB sequences for all models in
all apps.
| def sequence_list(self):
"""
Return a list of information about all DB sequences for all models in
all apps.
"""
sequence_list = []
with self.connection.cursor() as cursor:
for model in self.get_migratable_models():
if not model._meta.managed:
... | [
"def",
"sequence_list",
"(",
"self",
")",
":",
"sequence_list",
"=",
"[",
"]",
"with",
"self",
".",
"connection",
".",
"cursor",
"(",
")",
"as",
"cursor",
":",
"for",
"model",
"in",
"self",
".",
"get_migratable_models",
"(",
")",
":",
"if",
"not",
"mod... | [
103,
4
] | [
122,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.get_sequences | (self, cursor, table_name, table_fields=()) |
Return a list of introspected sequences for table_name. Each sequence
is a dict: {'table': <table_name>, 'column': <column_name>}. An optional
'name' key can be added if the backend supports named sequences.
|
Return a list of introspected sequences for table_name. Each sequence
is a dict: {'table': <table_name>, 'column': <column_name>}. An optional
'name' key can be added if the backend supports named sequences.
| def get_sequences(self, cursor, table_name, table_fields=()):
"""
Return a list of introspected sequences for table_name. Each sequence
is a dict: {'table': <table_name>, 'column': <column_name>}. An optional
'name' key can be added if the backend supports named sequences.
"""
... | [
"def",
"get_sequences",
"(",
"self",
",",
"cursor",
",",
"table_name",
",",
"table_fields",
"=",
"(",
")",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseIntrospection may require a get_sequences() method'",
")"
] | [
124,
4
] | [
130,
113
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.get_key_columns | (self, cursor, table_name) |
Backends can override this to return a list of:
(column_name, referenced_table_name, referenced_column_name)
for all key columns in given table.
|
Backends can override this to return a list of:
(column_name, referenced_table_name, referenced_column_name)
for all key columns in given table.
| def get_key_columns(self, cursor, table_name):
"""
Backends can override this to return a list of:
(column_name, referenced_table_name, referenced_column_name)
for all key columns in given table.
"""
raise NotImplementedError('subclasses of BaseDatabaseIntrospection m... | [
"def",
"get_key_columns",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseIntrospection may require a get_key_columns() method'",
")"
] | [
132,
4
] | [
138,
115
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.get_primary_key_column | (self, cursor, table_name) |
Return the name of the primary key column for the given table.
|
Return the name of the primary key column for the given table.
| def get_primary_key_column(self, cursor, table_name):
"""
Return the name of the primary key column for the given table.
"""
for constraint in self.get_constraints(cursor, table_name).values():
if constraint['primary_key']:
return constraint['columns'][0]
... | [
"def",
"get_primary_key_column",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"for",
"constraint",
"in",
"self",
".",
"get_constraints",
"(",
"cursor",
",",
"table_name",
")",
".",
"values",
"(",
")",
":",
"if",
"constraint",
"[",
"'primary_key'"... | [
140,
4
] | [
147,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseDatabaseIntrospection.get_constraints | (self, cursor, table_name) |
Retrieve any constraints or keys (unique, pk, fk, check, index)
across one or more columns.
Return a dict mapping constraint names to their attributes,
where attributes is a dict with keys:
* columns: List of columns this covers
* primary_key: True if primary key, Fal... |
Retrieve any constraints or keys (unique, pk, fk, check, index)
across one or more columns. | def get_constraints(self, cursor, table_name):
"""
Retrieve any constraints or keys (unique, pk, fk, check, index)
across one or more columns.
Return a dict mapping constraint names to their attributes,
where attributes is a dict with keys:
* columns: List of columns th... | [
"def",
"get_constraints",
"(",
"self",
",",
"cursor",
",",
"table_name",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseDatabaseIntrospection may require a get_constraints() method'",
")"
] | [
149,
4
] | [
168,
115
] | python | en | ['en', 'error', 'th'] | False |
serve | (request, path, document_root=None, show_indexes=False) |
Serve static files below a given point in the directory structure.
To use, put a URL pattern such as::
from django.views.static import serve
url(r'^(?P<path>.*)$', serve, {'document_root': '/path/to/my/files/'})
in your URLconf. You must provide the ``document_root`` param. You may
... |
Serve static files below a given point in the directory structure. | def serve(request, path, document_root=None, show_indexes=False):
"""
Serve static files below a given point in the directory structure.
To use, put a URL pattern such as::
from django.views.static import serve
url(r'^(?P<path>.*)$', serve, {'document_root': '/path/to/my/files/'})
in... | [
"def",
"serve",
"(",
"request",
",",
"path",
",",
"document_root",
"=",
"None",
",",
"show_indexes",
"=",
"False",
")",
":",
"path",
"=",
"posixpath",
".",
"normpath",
"(",
"unquote",
"(",
"path",
")",
")",
"path",
"=",
"path",
".",
"lstrip",
"(",
"'... | [
20,
0
] | [
72,
19
] | python | en | ['en', 'error', 'th'] | False |
was_modified_since | (header=None, mtime=0, size=0) |
Was something modified since the user last downloaded it?
header
This is the value of the If-Modified-Since header. If this is None,
I'll just return True.
mtime
This is the modification time of the item we're talking about.
size
This is the size of the item we're talking ab... |
Was something modified since the user last downloaded it? | def was_modified_since(header=None, mtime=0, size=0):
"""
Was something modified since the user last downloaded it?
header
This is the value of the If-Modified-Since header. If this is None,
I'll just return True.
mtime
This is the modification time of the item we're talking about.
... | [
"def",
"was_modified_since",
"(",
"header",
"=",
"None",
",",
"mtime",
"=",
"0",
",",
"size",
"=",
"0",
")",
":",
"try",
":",
"if",
"header",
"is",
"None",
":",
"raise",
"ValueError",
"matches",
"=",
"re",
".",
"match",
"(",
"r\"^([^;]+)(; length=([0-9]+... | [
120,
0
] | [
147,
16
] | python | en | ['en', 'error', 'th'] | False |
ensure_no_empty_passwords | (apps: StateApps, schema_editor: DatabaseSchemaEditor) | With CVE-2019-18933, it was possible for certain users created
using social login (e.g. Google/GitHub auth) to have the empty
string as their password in the Zulip database, rather than
Django's "unusable password" (i.e. no password at all). This was a
serious security issue for organizations with both... | With CVE-2019-18933, it was possible for certain users created
using social login (e.g. Google/GitHub auth) to have the empty
string as their password in the Zulip database, rather than
Django's "unusable password" (i.e. no password at all). This was a
serious security issue for organizations with both... | def ensure_no_empty_passwords(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:
"""With CVE-2019-18933, it was possible for certain users created
using social login (e.g. Google/GitHub auth) to have the empty
string as their password in the Zulip database, rather than
Django's "unusable pas... | [
"def",
"ensure_no_empty_passwords",
"(",
"apps",
":",
"StateApps",
",",
"schema_editor",
":",
"DatabaseSchemaEditor",
")",
"->",
"None",
":",
"UserProfile",
"=",
"apps",
".",
"get_model",
"(",
"\"zerver\"",
",",
"\"UserProfile\"",
")",
"RealmAuditLog",
"=",
"apps"... | [
17,
0
] | [
211,
13
] | python | en | ['en', 'en', 'en'] | True |
make_setuptools_shim_args | (
setup_py_path, # type: str
global_options=None, # type: Sequence[str]
no_user_config=False, # type: bool
unbuffered_output=False # type: bool
) |
Get setuptools command arguments with shim wrapped setup file invocation.
:param setup_py_path: The path to setup.py to be wrapped.
:param global_options: Additional global options.
:param no_user_config: If True, disables personal user configuration.
:param unbuffered_output: If True, adds the un... |
Get setuptools command arguments with shim wrapped setup file invocation. | def make_setuptools_shim_args(
setup_py_path, # type: str
global_options=None, # type: Sequence[str]
no_user_config=False, # type: bool
unbuffered_output=False # type: bool
):
# type: (...) -> List[str]
"""
Get setuptools command arguments with shim wrapped setup file invocation.
:p... | [
"def",
"make_setuptools_shim_args",
"(",
"setup_py_path",
",",
"# type: str",
"global_options",
"=",
"None",
",",
"# type: Sequence[str]",
"no_user_config",
"=",
"False",
",",
"# type: bool",
"unbuffered_output",
"=",
"False",
"# type: bool",
")",
":",
"# type: (...) -> L... | [
22,
0
] | [
46,
15
] | python | en | ['en', 'error', 'th'] | False |
format_for_columns | (pkgs, options) |
Convert the package data into something usable
by output_package_listing_columns.
|
Convert the package data into something usable
by output_package_listing_columns.
| def format_for_columns(pkgs, options):
"""
Convert the package data into something usable
by output_package_listing_columns.
"""
running_outdated = options.outdated
# Adjust the header for the `pip list --outdated` case.
if running_outdated:
header = ["Package", "Version", "Latest", ... | [
"def",
"format_for_columns",
"(",
"pkgs",
",",
"options",
")",
":",
"running_outdated",
"=",
"options",
".",
"outdated",
"# Adjust the header for the `pip list --outdated` case.",
"if",
"running_outdated",
":",
"header",
"=",
"[",
"\"Package\"",
",",
"\"Version\"",
",",... | [
247,
0
] | [
281,
23
] | python | en | ['en', 'error', 'th'] | False |
ListCommand._build_package_finder | (self, options, session) |
Create a package finder appropriate to this list command.
|
Create a package finder appropriate to this list command.
| def _build_package_finder(self, options, session):
"""
Create a package finder appropriate to this list command.
"""
link_collector = make_link_collector(session, options=options)
# Pass allow_yanked=False to ignore yanked versions.
selection_prefs = SelectionPreferences... | [
"def",
"_build_package_finder",
"(",
"self",
",",
"options",
",",
"session",
")",
":",
"link_collector",
"=",
"make_link_collector",
"(",
"session",
",",
"options",
"=",
"options",
")",
"# Pass allow_yanked=False to ignore yanked versions.",
"selection_prefs",
"=",
"Sel... | [
117,
4
] | [
132,
9
] | python | en | ['en', 'error', 'th'] | False |
get_active_worker_queues | (only_test_queues: bool = False) | Returns all (either test, or real) worker queues. | Returns all (either test, or real) worker queues. | def get_active_worker_queues(only_test_queues: bool = False) -> List[str]:
"""Returns all (either test, or real) worker queues."""
return [
queue_name
for queue_name in worker_classes.keys()
if bool(queue_name in test_queues) == only_test_queues
] | [
"def",
"get_active_worker_queues",
"(",
"only_test_queues",
":",
"bool",
"=",
"False",
")",
"->",
"List",
"[",
"str",
"]",
":",
"return",
"[",
"queue_name",
"for",
"queue_name",
"in",
"worker_classes",
".",
"keys",
"(",
")",
"if",
"bool",
"(",
"queue_name",
... | [
152,
0
] | [
158,
5
] | python | en | ['en', 'en', 'en'] | True |
LoopQueueProcessingWorker.consume | (self, event: Dict[str, Any]) | In LoopQueueProcessingWorker, consume is used just for automated tests | In LoopQueueProcessingWorker, consume is used just for automated tests | def consume(self, event: Dict[str, Any]) -> None:
"""In LoopQueueProcessingWorker, consume is used just for automated tests"""
self.consume_batch([event]) | [
"def",
"consume",
"(",
"self",
",",
"event",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"self",
".",
"consume_batch",
"(",
"[",
"event",
"]",
")"
] | [
403,
4
] | [
405,
35
] | python | en | ['en', 'en', 'en'] | True |
get_integer_time | () | Returns current time in long integer format. | Returns current time in long integer format. | def get_integer_time():
"""Returns current time in long integer format."""
return int(time.time()) | [
"def",
"get_integer_time",
"(",
")",
":",
"return",
"int",
"(",
"time",
".",
"time",
"(",
")",
")"
] | [
40,
0
] | [
42,
27
] | python | en | ['en', 'da', 'en'] | True |
is_unclaimed | (work) | Returns True if work piece is unclaimed. | Returns True if work piece is unclaimed. | def is_unclaimed(work):
"""Returns True if work piece is unclaimed."""
if work["is_completed"]:
return False
cutoff_time = time.time() - MAX_PROCESSING_TIME
if (
work["claimed_worker_id"]
and work["claimed_worker_start_time"] is not None
and work["claimed_worker_start_tim... | [
"def",
"is_unclaimed",
"(",
"work",
")",
":",
"if",
"work",
"[",
"\"is_completed\"",
"]",
":",
"return",
"False",
"cutoff_time",
"=",
"time",
".",
"time",
"(",
")",
"-",
"MAX_PROCESSING_TIME",
"if",
"(",
"work",
"[",
"\"claimed_worker_id\"",
"]",
"and",
"w... | [
45,
0
] | [
56,
15
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.__init__ | (self, datastore_client, work_type_entity_id) | Initializes WorkPiecesBase class.
Args:
datastore_client: instance of CompetitionDatastoreClient.
work_type_entity_id: ID of the WorkType parent entity
| Initializes WorkPiecesBase class. | def __init__(self, datastore_client, work_type_entity_id):
"""Initializes WorkPiecesBase class.
Args:
datastore_client: instance of CompetitionDatastoreClient.
work_type_entity_id: ID of the WorkType parent entity
"""
self._datastore_client = datastore_client
... | [
"def",
"__init__",
"(",
"self",
",",
"datastore_client",
",",
"work_type_entity_id",
")",
":",
"self",
".",
"_datastore_client",
"=",
"datastore_client",
"self",
".",
"_work_type_entity_id",
"=",
"work_type_entity_id",
"# Dictionary: work_id -> dict with properties of the pie... | [
91,
4
] | [
115,
23
] | python | en | ['en', 'pl', 'en'] | True |
WorkPiecesBase.serialize | (self, fobj) | Serialize work pieces into file object. | Serialize work pieces into file object. | def serialize(self, fobj):
"""Serialize work pieces into file object."""
pickle.dump(self._work, fobj) | [
"def",
"serialize",
"(",
"self",
",",
"fobj",
")",
":",
"pickle",
".",
"dump",
"(",
"self",
".",
"_work",
",",
"fobj",
")"
] | [
117,
4
] | [
119,
37
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.deserialize | (self, fobj) | Deserialize work pieces from file object. | Deserialize work pieces from file object. | def deserialize(self, fobj):
"""Deserialize work pieces from file object."""
self._work = pickle.load(fobj) | [
"def",
"deserialize",
"(",
"self",
",",
"fobj",
")",
":",
"self",
".",
"_work",
"=",
"pickle",
".",
"load",
"(",
"fobj",
")"
] | [
121,
4
] | [
123,
38
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.work | (self) | Dictionary with all work pieces. | Dictionary with all work pieces. | def work(self):
"""Dictionary with all work pieces."""
return self._work | [
"def",
"work",
"(",
"self",
")",
":",
"return",
"self",
".",
"_work"
] | [
126,
4
] | [
128,
25
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.replace_work | (self, value) | Replaces work with provided value.
Generally this method should be called only by master, that's why it
separated from the property self.work.
Args:
value: dictionary with new work pieces
| Replaces work with provided value. | def replace_work(self, value):
"""Replaces work with provided value.
Generally this method should be called only by master, that's why it
separated from the property self.work.
Args:
value: dictionary with new work pieces
"""
assert isinstance(value, dict)
... | [
"def",
"replace_work",
"(",
"self",
",",
"value",
")",
":",
"assert",
"isinstance",
"(",
"value",
",",
"dict",
")",
"self",
".",
"_work",
"=",
"value"
] | [
130,
4
] | [
140,
26
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.is_all_work_competed | (self) | Returns whether all work pieces are completed or not. | Returns whether all work pieces are completed or not. | def is_all_work_competed(self):
"""Returns whether all work pieces are completed or not."""
return all([w["is_completed"] for w in itervalues(self.work)]) | [
"def",
"is_all_work_competed",
"(",
"self",
")",
":",
"return",
"all",
"(",
"[",
"w",
"[",
"\"is_completed\"",
"]",
"for",
"w",
"in",
"itervalues",
"(",
"self",
".",
"work",
")",
"]",
")"
] | [
145,
4
] | [
147,
70
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.write_all_to_datastore | (self) | Writes all work pieces into datastore.
Each work piece is identified by ID. This method writes/updates only those
work pieces which IDs are stored in this class. For examples, if this class
has only work pieces with IDs '1' ... '100' and datastore already contains
work pieces with IDs ... | Writes all work pieces into datastore. | def write_all_to_datastore(self):
"""Writes all work pieces into datastore.
Each work piece is identified by ID. This method writes/updates only those
work pieces which IDs are stored in this class. For examples, if this class
has only work pieces with IDs '1' ... '100' and datastore a... | [
"def",
"write_all_to_datastore",
"(",
"self",
")",
":",
"client",
"=",
"self",
".",
"_datastore_client",
"with",
"client",
".",
"no_transact_batch",
"(",
")",
"as",
"batch",
":",
"parent_key",
"=",
"client",
".",
"key",
"(",
"KIND_WORK_TYPE",
",",
"self",
".... | [
149,
4
] | [
168,
33
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.read_all_from_datastore | (self) | Reads all work pieces from the datastore. | Reads all work pieces from the datastore. | def read_all_from_datastore(self):
"""Reads all work pieces from the datastore."""
self._work = {}
client = self._datastore_client
parent_key = client.key(KIND_WORK_TYPE, self._work_type_entity_id)
for entity in client.query_fetch(kind=KIND_WORK, ancestor=parent_key):
... | [
"def",
"read_all_from_datastore",
"(",
"self",
")",
":",
"self",
".",
"_work",
"=",
"{",
"}",
"client",
"=",
"self",
".",
"_datastore_client",
"parent_key",
"=",
"client",
".",
"key",
"(",
"KIND_WORK_TYPE",
",",
"self",
".",
"_work_type_entity_id",
")",
"for... | [
170,
4
] | [
177,
45
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase._read_undone_shard_from_datastore | (self, shard_id=None) | Reads undone worke pieces which are assigned to shard with given id. | Reads undone worke pieces which are assigned to shard with given id. | def _read_undone_shard_from_datastore(self, shard_id=None):
"""Reads undone worke pieces which are assigned to shard with given id."""
self._work = {}
client = self._datastore_client
parent_key = client.key(KIND_WORK_TYPE, self._work_type_entity_id)
filters = [("is_completed", "=... | [
"def",
"_read_undone_shard_from_datastore",
"(",
"self",
",",
"shard_id",
"=",
"None",
")",
":",
"self",
".",
"_work",
"=",
"{",
"}",
"client",
"=",
"self",
".",
"_datastore_client",
"parent_key",
"=",
"client",
".",
"key",
"(",
"KIND_WORK_TYPE",
",",
"self"... | [
179,
4
] | [
193,
21
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.read_undone_from_datastore | (self, shard_id=None, num_shards=None) | Reads undone work from the datastore.
If shard_id and num_shards are specified then this method will attempt
to read undone work for shard with id shard_id. If no undone work was found
then it will try to read shard (shard_id+1) and so on until either found
shard with undone work or all... | Reads undone work from the datastore. | def read_undone_from_datastore(self, shard_id=None, num_shards=None):
"""Reads undone work from the datastore.
If shard_id and num_shards are specified then this method will attempt
to read undone work for shard with id shard_id. If no undone work was found
then it will try to read shar... | [
"def",
"read_undone_from_datastore",
"(",
"self",
",",
"shard_id",
"=",
"None",
",",
"num_shards",
"=",
"None",
")",
":",
"if",
"shard_id",
"is",
"not",
"None",
":",
"shards_list",
"=",
"[",
"(",
"i",
"+",
"shard_id",
")",
"%",
"num_shards",
"for",
"i",
... | [
195,
4
] | [
220,
19
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.try_pick_piece_of_work | (self, worker_id, submission_id=None) | Tries pick next unclaimed piece of work to do.
Attempt to claim work piece is done using Cloud Datastore transaction, so
only one worker can claim any work piece at a time.
Args:
worker_id: ID of current worker
submission_id: if not None then this method will try to pick
... | Tries pick next unclaimed piece of work to do. | def try_pick_piece_of_work(self, worker_id, submission_id=None):
"""Tries pick next unclaimed piece of work to do.
Attempt to claim work piece is done using Cloud Datastore transaction, so
only one worker can claim any work piece at a time.
Args:
worker_id: ID of current work... | [
"def",
"try_pick_piece_of_work",
"(",
"self",
",",
"worker_id",
",",
"submission_id",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_datastore_client",
"unclaimed_work_ids",
"=",
"None",
"if",
"submission_id",
":",
"unclaimed_work_ids",
"=",
"[",
"k",
"for... | [
222,
4
] | [
263,
27
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.update_work_as_completed | (
self, worker_id, work_id, other_values=None, error=None
) | Updates work piece in datastore as completed.
Args:
worker_id: ID of the worker which did the work
work_id: ID of the work which was done
other_values: dictionary with additonal values which should be saved
with the work piece
error: if not None then error oc... | Updates work piece in datastore as completed. | def update_work_as_completed(
self, worker_id, work_id, other_values=None, error=None
):
"""Updates work piece in datastore as completed.
Args:
worker_id: ID of the worker which did the work
work_id: ID of the work which was done
other_values: dictionary with a... | [
"def",
"update_work_as_completed",
"(",
"self",
",",
"worker_id",
",",
"work_id",
",",
"other_values",
"=",
"None",
",",
"error",
"=",
"None",
")",
":",
"client",
"=",
"self",
".",
"_datastore_client",
"try",
":",
"with",
"client",
".",
"transaction",
"(",
... | [
265,
4
] | [
298,
19
] | python | en | ['en', 'en', 'en'] | True |
WorkPiecesBase.compute_work_statistics | (self) | Computes statistics from all work pieces stored in this class. | Computes statistics from all work pieces stored in this class. | def compute_work_statistics(self):
"""Computes statistics from all work pieces stored in this class."""
result = {}
for v in itervalues(self.work):
submission_id = v["submission_id"]
if submission_id not in result:
result[submission_id] = {
... | [
"def",
"compute_work_statistics",
"(",
"self",
")",
":",
"result",
"=",
"{",
"}",
"for",
"v",
"in",
"itervalues",
"(",
"self",
".",
"work",
")",
":",
"submission_id",
"=",
"v",
"[",
"\"submission_id\"",
"]",
"if",
"submission_id",
"not",
"in",
"result",
... | [
300,
4
] | [
330,
21
] | python | en | ['en', 'en', 'en'] | True |
AttackWorkPieces.__init__ | (self, datastore_client) | Initializes AttackWorkPieces. | Initializes AttackWorkPieces. | def __init__(self, datastore_client):
"""Initializes AttackWorkPieces."""
super(AttackWorkPieces, self).__init__(
datastore_client=datastore_client,
work_type_entity_id=ID_ATTACKS_WORK_ENTITY,
) | [
"def",
"__init__",
"(",
"self",
",",
"datastore_client",
")",
":",
"super",
"(",
"AttackWorkPieces",
",",
"self",
")",
".",
"__init__",
"(",
"datastore_client",
"=",
"datastore_client",
",",
"work_type_entity_id",
"=",
"ID_ATTACKS_WORK_ENTITY",
",",
")"
] | [
347,
4
] | [
352,
9
] | python | en | ['en', 'en', 'en'] | False |
AttackWorkPieces.init_from_adversarial_batches | (self, adv_batches) | Initializes work pieces from adversarial batches.
Args:
adv_batches: dict with adversarial batches,
could be obtained as AversarialBatches.data
| Initializes work pieces from adversarial batches. | def init_from_adversarial_batches(self, adv_batches):
"""Initializes work pieces from adversarial batches.
Args:
adv_batches: dict with adversarial batches,
could be obtained as AversarialBatches.data
"""
for idx, (adv_batch_id, adv_batch_val) in enumerate(iteritem... | [
"def",
"init_from_adversarial_batches",
"(",
"self",
",",
"adv_batches",
")",
":",
"for",
"idx",
",",
"(",
"adv_batch_id",
",",
"adv_batch_val",
")",
"in",
"enumerate",
"(",
"iteritems",
"(",
"adv_batches",
")",
")",
":",
"work_id",
"=",
"ATTACK_WORK_ID_PATTERN"... | [
354,
4
] | [
372,
13
] | python | en | ['en', 'en', 'en'] | True |
DefenseWorkPieces.__init__ | (self, datastore_client) | Initializes DefenseWorkPieces. | Initializes DefenseWorkPieces. | def __init__(self, datastore_client):
"""Initializes DefenseWorkPieces."""
super(DefenseWorkPieces, self).__init__(
datastore_client=datastore_client,
work_type_entity_id=ID_DEFENSES_WORK_ENTITY,
) | [
"def",
"__init__",
"(",
"self",
",",
"datastore_client",
")",
":",
"super",
"(",
"DefenseWorkPieces",
",",
"self",
")",
".",
"__init__",
"(",
"datastore_client",
"=",
"datastore_client",
",",
"work_type_entity_id",
"=",
"ID_DEFENSES_WORK_ENTITY",
",",
")"
] | [
378,
4
] | [
383,
9
] | python | en | ['en', 'la', 'en'] | False |
DefenseWorkPieces.init_from_class_batches | (self, class_batches, num_shards=None) | Initializes work pieces from classification batches.
Args:
class_batches: dict with classification batches, could be obtained
as ClassificationBatches.data
num_shards: number of shards to split data into,
if None then no sharding is done.
| Initializes work pieces from classification batches. | def init_from_class_batches(self, class_batches, num_shards=None):
"""Initializes work pieces from classification batches.
Args:
class_batches: dict with classification batches, could be obtained
as ClassificationBatches.data
num_shards: number of shards to split data in... | [
"def",
"init_from_class_batches",
"(",
"self",
",",
"class_batches",
",",
"num_shards",
"=",
"None",
")",
":",
"shards_for_submissions",
"=",
"{",
"}",
"shard_idx",
"=",
"0",
"for",
"idx",
",",
"(",
"batch_id",
",",
"batch_val",
")",
"in",
"enumerate",
"(",
... | [
385,
4
] | [
417,
13
] | python | en | ['en', 'en', 'en'] | True |
DummyBackendTest.test_no_databases | (self) |
Test that empty DATABASES setting default to the dummy backend.
|
Test that empty DATABASES setting default to the dummy backend.
| def test_no_databases(self):
"""
Test that empty DATABASES setting default to the dummy backend.
"""
DATABASES = {}
conns = ConnectionHandler(DATABASES)
self.assertEqual(conns[DEFAULT_DB_ALIAS].settings_dict['ENGINE'],
'django.db.backends.dummy') | [
"def",
"test_no_databases",
"(",
"self",
")",
":",
"DATABASES",
"=",
"{",
"}",
"conns",
"=",
"ConnectionHandler",
"(",
"DATABASES",
")",
"self",
".",
"assertEqual",
"(",
"conns",
"[",
"DEFAULT_DB_ALIAS",
"]",
".",
"settings_dict",
"[",
"'ENGINE'",
"]",
",",
... | [
35,
4
] | [
42,
39
] | python | en | ['en', 'error', 'th'] | False |
DateQuotingTest.test_django_date_trunc | (self) |
Test the custom ``django_date_trunc method``, in particular against
fields which clash with strings passed to it (e.g. 'year') - see
#12818__.
__: http://code.djangoproject.com/ticket/12818
|
Test the custom ``django_date_trunc method``, in particular against
fields which clash with strings passed to it (e.g. 'year') - see
#12818__. | def test_django_date_trunc(self):
"""
Test the custom ``django_date_trunc method``, in particular against
fields which clash with strings passed to it (e.g. 'year') - see
#12818__.
__: http://code.djangoproject.com/ticket/12818
"""
updated = datetime.datetime(20... | [
"def",
"test_django_date_trunc",
"(",
"self",
")",
":",
"updated",
"=",
"datetime",
".",
"datetime",
"(",
"2010",
",",
"2",
",",
"20",
")",
"models",
".",
"SchoolClass",
".",
"objects",
".",
"create",
"(",
"year",
"=",
"2009",
",",
"last_updated",
"=",
... | [
251,
4
] | [
263,
66
] | python | en | ['en', 'error', 'th'] | False |
DateQuotingTest.test_django_date_extract | (self) |
Test the custom ``django_date_extract method``, in particular against fields
which clash with strings passed to it (e.g. 'day') - see #12818__.
__: http://code.djangoproject.com/ticket/12818
|
Test the custom ``django_date_extract method``, in particular against fields
which clash with strings passed to it (e.g. 'day') - see #12818__. | def test_django_date_extract(self):
"""
Test the custom ``django_date_extract method``, in particular against fields
which clash with strings passed to it (e.g. 'day') - see #12818__.
__: http://code.djangoproject.com/ticket/12818
"""
updated = datetime.datetime(2010, 2... | [
"def",
"test_django_date_extract",
"(",
"self",
")",
":",
"updated",
"=",
"datetime",
".",
"datetime",
"(",
"2010",
",",
"2",
",",
"20",
")",
"models",
".",
"SchoolClass",
".",
"objects",
".",
"create",
"(",
"year",
"=",
"2009",
",",
"last_updated",
"=",... | [
265,
4
] | [
276,
41
] | python | en | ['en', 'error', 'th'] | False |
ParameterHandlingTest.test_bad_parameter_count | (self) | An executemany call with too many/not enough parameters will raise an exception (Refs #12612) | An executemany call with too many/not enough parameters will raise an exception (Refs #12612) | def test_bad_parameter_count(self):
"An executemany call with too many/not enough parameters will raise an exception (Refs #12612)"
cursor = connection.cursor()
query = ('INSERT INTO %s (%s, %s) VALUES (%%s, %%s)' % (
connection.introspection.table_name_converter('backends_square'),
... | [
"def",
"test_bad_parameter_count",
"(",
"self",
")",
":",
"cursor",
"=",
"connection",
".",
"cursor",
"(",
")",
"query",
"=",
"(",
"'INSERT INTO %s (%s, %s) VALUES (%%s, %%s)'",
"%",
"(",
"connection",
".",
"introspection",
".",
"table_name_converter",
"(",
"'backen... | [
322,
4
] | [
331,
71
] | python | en | ['en', 'en', 'en'] | True |
LongNameTest.test_sequence_name_length_limits_create | (self) | Test creation of model with long name and long pk name doesn't error. Ref #8901 | Test creation of model with long name and long pk name doesn't error. Ref #8901 | def test_sequence_name_length_limits_create(self):
"""Test creation of model with long name and long pk name doesn't error. Ref #8901"""
models.VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ.objects.create() | [
"def",
"test_sequence_name_length_limits_create",
"(",
"self",
")",
":",
"models",
".",
"VeryLongModelNameZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ",
".",
"objects",
".",
"create",
"(",
")"
] | [
345,
4
] | [
347,
91
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.