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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
config.try_run | (self, body, headers=None, include_dirs=None, libraries=None,
library_dirs=None, lang="c") | Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
| Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
| def try_run(self, body, headers=None, include_dirs=None, libraries=None,
library_dirs=None, lang="c"):
"""Try to compile, link to an executable, and run a program
built from 'body' and 'headers'. Return true on success, false
otherwise.
"""
from distutils.ccompil... | [
"def",
"try_run",
"(",
"self",
",",
"body",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"from",
"distutils",
".",
"ccompiler",
"imp... | [
252,
4
] | [
270,
17
] | python | en | ['en', 'en', 'en'] | True |
config.check_func | (self, func, headers=None, include_dirs=None,
libraries=None, library_dirs=None, decl=0, call=0) | Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; otherwise returns false.
The constructed source file starts out by including the header
files listed in 'headers'. If 'decl' i... | Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; otherwise returns false. | def check_func(self, func, headers=None, include_dirs=None,
libraries=None, library_dirs=None, decl=0, call=0):
"""Determine if function 'func' is available by constructing a
source file that refers to 'func', and compiles and links it.
If everything succeeds, returns true; ot... | [
"def",
"check_func",
"(",
"self",
",",
"func",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"libraries",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"decl",
"=",
"0",
",",
"call",
"=",
"0",
")",
":",
"self",
".",
"_ch... | [
277,
4
] | [
305,
53
] | python | en | ['en', 'en', 'en'] | True |
config.check_lib | (self, library, library_dirs=None, headers=None,
include_dirs=None, other_libraries=[]) | Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing the source file to
be compiled, but the only effect of this is to check if all the
header files listed are available... | Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing the source file to
be compiled, but the only effect of this is to check if all the
header files listed are available... | def check_lib(self, library, library_dirs=None, headers=None,
include_dirs=None, other_libraries=[]):
"""Determine if 'library' is available to be linked against,
without actually checking that any particular symbols are provided
by it. 'headers' will be used in constructing t... | [
"def",
"check_lib",
"(",
"self",
",",
"library",
",",
"library_dirs",
"=",
"None",
",",
"headers",
"=",
"None",
",",
"include_dirs",
"=",
"None",
",",
"other_libraries",
"=",
"[",
"]",
")",
":",
"self",
".",
"_check_compiler",
"(",
")",
"return",
"self",... | [
307,
4
] | [
319,
71
] | python | en | ['en', 'en', 'en'] | True |
config.check_header | (self, header, include_dirs=None, library_dirs=None,
lang="c") | Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
| Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
| def check_header(self, header, include_dirs=None, library_dirs=None,
lang="c"):
"""Determine if the system header file named by 'header_file'
exists and can be found by the preprocessor; return true if so,
false otherwise.
"""
return self.try_cpp(body="/* No ... | [
"def",
"check_header",
"(",
"self",
",",
"header",
",",
"include_dirs",
"=",
"None",
",",
"library_dirs",
"=",
"None",
",",
"lang",
"=",
"\"c\"",
")",
":",
"return",
"self",
".",
"try_cpp",
"(",
"body",
"=",
"\"/* No body */\"",
",",
"headers",
"=",
"[",... | [
321,
4
] | [
328,
54
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdmin.formfield_for_dbfield | (self, db_field, request, **kwargs) |
Hook for specifying the form Field instance for a given database Field
instance.
If kwargs are given, they're passed to the form Field's constructor.
|
Hook for specifying the form Field instance for a given database Field
instance. | def formfield_for_dbfield(self, db_field, request, **kwargs):
"""
Hook for specifying the form Field instance for a given database Field
instance.
If kwargs are given, they're passed to the form Field's constructor.
"""
# If the field specifies choices, we don't need to ... | [
"def",
"formfield_for_dbfield",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# If the field specifies choices, we don't need to look for special",
"# admin widgets - we just need to use a select widget of some kind.",
"if",
"db_field",
".",
... | [
126,
4
] | [
180,
43
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.formfield_for_choice_field | (self, db_field, request, **kwargs) |
Get a form Field for a database Field that has declared choices.
|
Get a form Field for a database Field that has declared choices.
| def formfield_for_choice_field(self, db_field, request, **kwargs):
"""
Get a form Field for a database Field that has declared choices.
"""
# If the field is named as a radio_field, use a RadioSelect
if db_field.name in self.radio_fields:
# Avoid stomping on custom wi... | [
"def",
"formfield_for_choice_field",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# If the field is named as a radio_field, use a RadioSelect",
"if",
"db_field",
".",
"name",
"in",
"self",
".",
"radio_fields",
":",
"# Avoid stompin... | [
182,
4
] | [
198,
43
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_field_queryset | (self, db, db_field, request) |
If the ModelAdmin specifies ordering, the queryset should respect that
ordering. Otherwise don't specify the queryset, let the field decide
(returns None in that case).
|
If the ModelAdmin specifies ordering, the queryset should respect that
ordering. Otherwise don't specify the queryset, let the field decide
(returns None in that case).
| def get_field_queryset(self, db, db_field, request):
"""
If the ModelAdmin specifies ordering, the queryset should respect that
ordering. Otherwise don't specify the queryset, let the field decide
(returns None in that case).
"""
related_admin = self.admin_site._registry... | [
"def",
"get_field_queryset",
"(",
"self",
",",
"db",
",",
"db_field",
",",
"request",
")",
":",
"related_admin",
"=",
"self",
".",
"admin_site",
".",
"_registry",
".",
"get",
"(",
"db_field",
".",
"remote_field",
".",
"model",
")",
"if",
"related_admin",
"... | [
200,
4
] | [
211,
19
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.formfield_for_foreignkey | (self, db_field, request, **kwargs) |
Get a form Field for a ForeignKey.
|
Get a form Field for a ForeignKey.
| def formfield_for_foreignkey(self, db_field, request, **kwargs):
"""
Get a form Field for a ForeignKey.
"""
db = kwargs.get('using')
if db_field.name in self.raw_id_fields:
kwargs['widget'] = widgets.ForeignKeyRawIdWidget(db_field.remote_field, self.admin_site, using=... | [
"def",
"formfield_for_foreignkey",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"db",
"=",
"kwargs",
".",
"get",
"(",
"'using'",
")",
"if",
"db_field",
".",
"name",
"in",
"self",
".",
"raw_id_fields",
":",
"kwargs",
... | [
213,
4
] | [
231,
43
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.formfield_for_manytomany | (self, db_field, request, **kwargs) |
Get a form Field for a ManyToManyField.
|
Get a form Field for a ManyToManyField.
| def formfield_for_manytomany(self, db_field, request, **kwargs):
"""
Get a form Field for a ManyToManyField.
"""
# If it uses an intermediary model that isn't auto created, don't show
# a field in admin.
if not db_field.remote_field.through._meta.auto_created:
... | [
"def",
"formfield_for_manytomany",
"(",
"self",
",",
"db_field",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# If it uses an intermediary model that isn't auto created, don't show",
"# a field in admin.",
"if",
"not",
"db_field",
".",
"remote_field",
".",
"through... | [
233,
4
] | [
261,
25
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_empty_value_display | (self) |
Return the empty_value_display set on ModelAdmin or AdminSite.
|
Return the empty_value_display set on ModelAdmin or AdminSite.
| def get_empty_value_display(self):
"""
Return the empty_value_display set on ModelAdmin or AdminSite.
"""
try:
return mark_safe(self.empty_value_display)
except AttributeError:
return mark_safe(self.admin_site.empty_value_display) | [
"def",
"get_empty_value_display",
"(",
"self",
")",
":",
"try",
":",
"return",
"mark_safe",
"(",
"self",
".",
"empty_value_display",
")",
"except",
"AttributeError",
":",
"return",
"mark_safe",
"(",
"self",
".",
"admin_site",
".",
"empty_value_display",
")"
] | [
276,
4
] | [
283,
65
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_exclude | (self, request, obj=None) |
Hook for specifying exclude.
|
Hook for specifying exclude.
| def get_exclude(self, request, obj=None):
"""
Hook for specifying exclude.
"""
return self.exclude | [
"def",
"get_exclude",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"exclude"
] | [
285,
4
] | [
289,
27
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_fields | (self, request, obj=None) |
Hook for specifying fields.
|
Hook for specifying fields.
| def get_fields(self, request, obj=None):
"""
Hook for specifying fields.
"""
return self.fields | [
"def",
"get_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"fields"
] | [
291,
4
] | [
295,
26
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_fieldsets | (self, request, obj=None) |
Hook for specifying fieldsets.
|
Hook for specifying fieldsets.
| def get_fieldsets(self, request, obj=None):
"""
Hook for specifying fieldsets.
"""
if self.fieldsets:
return self.fieldsets
return [(None, {'fields': self.get_fields(request, obj)})] | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"if",
"self",
".",
"fieldsets",
":",
"return",
"self",
".",
"fieldsets",
"return",
"[",
"(",
"None",
",",
"{",
"'fields'",
":",
"self",
".",
"get_fields",
"(",
"r... | [
297,
4
] | [
303,
66
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_ordering | (self, request) |
Hook for specifying field ordering.
|
Hook for specifying field ordering.
| def get_ordering(self, request):
"""
Hook for specifying field ordering.
"""
return self.ordering or () | [
"def",
"get_ordering",
"(",
"self",
",",
"request",
")",
":",
"return",
"self",
".",
"ordering",
"or",
"(",
")"
] | [
305,
4
] | [
309,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_readonly_fields | (self, request, obj=None) |
Hook for specifying custom readonly fields.
|
Hook for specifying custom readonly fields.
| def get_readonly_fields(self, request, obj=None):
"""
Hook for specifying custom readonly fields.
"""
return self.readonly_fields | [
"def",
"get_readonly_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"readonly_fields"
] | [
311,
4
] | [
315,
35
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_prepopulated_fields | (self, request, obj=None) |
Hook for specifying custom prepopulated fields.
|
Hook for specifying custom prepopulated fields.
| def get_prepopulated_fields(self, request, obj=None):
"""
Hook for specifying custom prepopulated fields.
"""
return self.prepopulated_fields | [
"def",
"get_prepopulated_fields",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"return",
"self",
".",
"prepopulated_fields"
] | [
317,
4
] | [
321,
39
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.get_queryset | (self, request) |
Returns a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
|
Returns a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
| def get_queryset(self, request):
"""
Returns a QuerySet of all model instances that can be edited by the
admin site. This is used by changelist_view.
"""
qs = self.model._default_manager.get_queryset()
# TODO: this should be handled by some parameter to the ChangeList.
... | [
"def",
"get_queryset",
"(",
"self",
",",
"request",
")",
":",
"qs",
"=",
"self",
".",
"model",
".",
"_default_manager",
".",
"get_queryset",
"(",
")",
"# TODO: this should be handled by some parameter to the ChangeList.",
"ordering",
"=",
"self",
".",
"get_ordering",
... | [
323,
4
] | [
333,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.to_field_allowed | (self, request, to_field) |
Returns True if the model associated with this admin should be
allowed to be referenced by the specified field.
|
Returns True if the model associated with this admin should be
allowed to be referenced by the specified field.
| def to_field_allowed(self, request, to_field):
"""
Returns True if the model associated with this admin should be
allowed to be referenced by the specified field.
"""
opts = self.model._meta
try:
field = opts.get_field(to_field)
except FieldDoesNotExi... | [
"def",
"to_field_allowed",
"(",
"self",
",",
"request",
",",
"to_field",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"try",
":",
"field",
"=",
"opts",
".",
"get_field",
"(",
"to_field",
")",
"except",
"FieldDoesNotExist",
":",
"return",
"F... | [
386,
4
] | [
429,
20
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_add_permission | (self, request) |
Returns True if the given request has permission to add an object.
Can be overridden by the user in subclasses.
|
Returns True if the given request has permission to add an object.
Can be overridden by the user in subclasses.
| def has_add_permission(self, request):
"""
Returns True if the given request has permission to add an object.
Can be overridden by the user in subclasses.
"""
opts = self.opts
codename = get_permission_codename('add', opts)
return request.user.has_perm("%s.%s" % (... | [
"def",
"has_add_permission",
"(",
"self",
",",
"request",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename",
"=",
"get_permission_codename",
"(",
"'add'",
",",
"opts",
")",
"return",
"request",
".",
"user",
".",
"has_perm",
"(",
"\"%s.%s\"",
"%",
"(",... | [
431,
4
] | [
438,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_change_permission | (self, request, obj=None) |
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to cha... |
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter. | def has_change_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should... | [
"def",
"has_change_permission",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename",
"=",
"get_permission_codename",
"(",
"'change'",
",",
"opts",
")",
"return",
"request",
".",
"user",
".",
"has_per... | [
440,
4
] | [
453,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_delete_permission | (self, request, obj=None) |
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to del... |
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter. | def has_delete_permission(self, request, obj=None):
"""
Returns True if the given request has permission to change the given
Django model instance, the default implementation doesn't examine the
`obj` parameter.
Can be overridden by the user in subclasses. In such case it should... | [
"def",
"has_delete_permission",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"opts",
"codename",
"=",
"get_permission_codename",
"(",
"'delete'",
",",
"opts",
")",
"return",
"request",
".",
"user",
".",
"has_per... | [
455,
4
] | [
468,
74
] | python | en | ['en', 'error', 'th'] | False |
BaseModelAdmin.has_module_permission | (self, request) |
Returns True if the given request has any permission in the given
app label.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to view the module on
the admin index page and access the module's index page. Overri... |
Returns True if the given request has any permission in the given
app label. | def has_module_permission(self, request):
"""
Returns True if the given request has any permission in the given
app label.
Can be overridden by the user in subclasses. In such case it should
return True if the given request has permission to view the module on
the admin ... | [
"def",
"has_module_permission",
"(",
"self",
",",
"request",
")",
":",
"return",
"request",
".",
"user",
".",
"has_module_perms",
"(",
"self",
".",
"opts",
".",
"app_label",
")"
] | [
470,
4
] | [
481,
65
] | python | en | ['en', 'error', 'th'] | False |
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"
] | [
1865,
4
] | [
1867,
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"
] | [
1869,
4
] | [
1871,
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"
] | [
1873,
4
] | [
1875,
27
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdmin.get_formset | (self, request, obj=None, **kwargs) | Returns a BaseInlineFormSet class for use in admin add/change views. | Returns a BaseInlineFormSet class for use in admin add/change views. | def get_formset(self, request, obj=None, **kwargs):
"""Returns 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.g... | [
"def",
"get_formset",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'fields'",
"in",
"kwargs",
":",
"fields",
"=",
"kwargs",
".",
"pop",
"(",
"'fields'",
")",
"else",
":",
"fields",
"=",
"flatten_fiel... | [
1877,
4
] | [
1951,
79
] | python | en | ['en', 'en', 'en'] | True |
Filter.__init__ | (self, source, encoding) | Creates a Filter
:arg source: the source token stream
:arg encoding: the encoding to set
| Creates a Filter | def __init__(self, source, encoding):
"""Creates a Filter
:arg source: the source token stream
:arg encoding: the encoding to set
"""
base.Filter.__init__(self, source)
self.encoding = encoding | [
"def",
"__init__",
"(",
"self",
",",
"source",
",",
"encoding",
")",
":",
"base",
".",
"Filter",
".",
"__init__",
"(",
"self",
",",
"source",
")",
"self",
".",
"encoding",
"=",
"encoding"
] | [
7,
4
] | [
16,
32
] | python | en | ['en', 'gl', 'en'] | True |
cleanse_setting | (key, value) | Cleanse an individual setting key/value of sensitive content.
If the value is a dictionary, recursively cleanse the keys in
that dictionary.
| Cleanse an individual setting key/value of sensitive content. | def cleanse_setting(key, value):
"""Cleanse an individual setting key/value of sensitive content.
If the value is a dictionary, recursively cleanse the keys in
that dictionary.
"""
try:
if HIDDEN_SETTINGS.search(key):
cleansed = CLEANSED_SUBSTITUTE
else:
if i... | [
"def",
"cleanse_setting",
"(",
"key",
",",
"value",
")",
":",
"try",
":",
"if",
"HIDDEN_SETTINGS",
".",
"search",
"(",
"key",
")",
":",
"cleansed",
"=",
"CLEANSED_SUBSTITUTE",
"else",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"cleanse... | [
39,
0
] | [
61,
19
] | python | en | ['en', 'en', 'en'] | True |
get_safe_settings | () | Returns a dictionary of the settings module, with sensitive settings blurred out. | Returns a dictionary of the settings module, with sensitive settings blurred out. | def get_safe_settings():
"Returns a dictionary of the settings module, with sensitive settings blurred out."
settings_dict = {}
for k in dir(settings):
if k.isupper():
settings_dict[k] = cleanse_setting(k, getattr(settings, k))
return settings_dict | [
"def",
"get_safe_settings",
"(",
")",
":",
"settings_dict",
"=",
"{",
"}",
"for",
"k",
"in",
"dir",
"(",
"settings",
")",
":",
"if",
"k",
".",
"isupper",
"(",
")",
":",
"settings_dict",
"[",
"k",
"]",
"=",
"cleanse_setting",
"(",
"k",
",",
"getattr",... | [
64,
0
] | [
70,
24
] | python | en | ['en', 'en', 'en'] | True |
technical_500_response | (request, exc_type, exc_value, tb, status_code=500) |
Create a technical server error response. The last three arguments are
the values returned from sys.exc_info() and friends.
|
Create a technical server error response. The last three arguments are
the values returned from sys.exc_info() and friends.
| def technical_500_response(request, exc_type, exc_value, tb, status_code=500):
"""
Create a technical server error response. The last three arguments are
the values returned from sys.exc_info() and friends.
"""
reporter = ExceptionReporter(request, exc_type, exc_value, tb)
if request.is_ajax():
... | [
"def",
"technical_500_response",
"(",
"request",
",",
"exc_type",
",",
"exc_value",
",",
"tb",
",",
"status_code",
"=",
"500",
")",
":",
"reporter",
"=",
"ExceptionReporter",
"(",
"request",
",",
"exc_type",
",",
"exc_value",
",",
"tb",
")",
"if",
"request",... | [
73,
0
] | [
84,
79
] | python | en | ['en', 'error', 'th'] | False |
technical_404_response | (request, exception) | Create a technical 404 error response. The exception should be the Http404. | Create a technical 404 error response. The exception should be the Http404. | def technical_404_response(request, exception):
"Create a technical 404 error response. The exception should be the Http404."
try:
error_url = exception.args[0]['path']
except (IndexError, TypeError, KeyError):
error_url = request.path_info[1:] # Trim leading slash
try:
tried =... | [
"def",
"technical_404_response",
"(",
"request",
",",
"exception",
")",
":",
"try",
":",
"error_url",
"=",
"exception",
".",
"args",
"[",
"0",
"]",
"[",
"'path'",
"]",
"except",
"(",
"IndexError",
",",
"TypeError",
",",
"KeyError",
")",
":",
"error_url",
... | [
460,
0
] | [
512,
70
] | python | en | ['en', 'en', 'en'] | True |
default_urlconf | (request) | Create an empty URLconf 404 error response. | Create an empty URLconf 404 error response. | def default_urlconf(request):
"Create an empty URLconf 404 error response."
t = DEBUG_ENGINE.from_string(DEFAULT_URLCONF_TEMPLATE)
c = Context({
"title": _("Welcome to Django"),
"heading": _("It worked!"),
"subheading": _("Congratulations on your first Django-powered page."),
... | [
"def",
"default_urlconf",
"(",
"request",
")",
":",
"t",
"=",
"DEBUG_ENGINE",
".",
"from_string",
"(",
"DEFAULT_URLCONF_TEMPLATE",
")",
"c",
"=",
"Context",
"(",
"{",
"\"title\"",
":",
"_",
"(",
"\"Welcome to Django\"",
")",
",",
"\"heading\"",
":",
"_",
"("... | [
515,
0
] | [
531,
62
] | python | en | ['en', 'de', 'en'] | True |
SafeExceptionReporterFilter.is_active | (self, request) |
This filter is to add safety in production environments (i.e. DEBUG
is False). If DEBUG is True then your site is not safe anyway.
This hook is provided as a convenience to easily activate or
deactivate the filter on a per request basis.
|
This filter is to add safety in production environments (i.e. DEBUG
is False). If DEBUG is True then your site is not safe anyway.
This hook is provided as a convenience to easily activate or
deactivate the filter on a per request basis.
| def is_active(self, request):
"""
This filter is to add safety in production environments (i.e. DEBUG
is False). If DEBUG is True then your site is not safe anyway.
This hook is provided as a convenience to easily activate or
deactivate the filter on a per request basis.
... | [
"def",
"is_active",
"(",
"self",
",",
"request",
")",
":",
"return",
"settings",
".",
"DEBUG",
"is",
"False"
] | [
120,
4
] | [
127,
38
] | python | en | ['en', 'error', 'th'] | False |
SafeExceptionReporterFilter.get_cleansed_multivaluedict | (self, request, multivaluedict) |
Replaces the keys in a MultiValueDict marked as sensitive with stars.
This mitigates leaking sensitive POST parameters if something like
request.POST['nonexistent_key'] throws an exception (#21098).
|
Replaces the keys in a MultiValueDict marked as sensitive with stars.
This mitigates leaking sensitive POST parameters if something like
request.POST['nonexistent_key'] throws an exception (#21098).
| def get_cleansed_multivaluedict(self, request, multivaluedict):
"""
Replaces the keys in a MultiValueDict marked as sensitive with stars.
This mitigates leaking sensitive POST parameters if something like
request.POST['nonexistent_key'] throws an exception (#21098).
"""
s... | [
"def",
"get_cleansed_multivaluedict",
"(",
"self",
",",
"request",
",",
"multivaluedict",
")",
":",
"sensitive_post_parameters",
"=",
"getattr",
"(",
"request",
",",
"'sensitive_post_parameters'",
",",
"[",
"]",
")",
"if",
"self",
".",
"is_active",
"(",
"request",... | [
129,
4
] | [
141,
29
] | python | en | ['en', 'error', 'th'] | False |
SafeExceptionReporterFilter.get_post_parameters | (self, request) |
Replaces the values of POST parameters marked as sensitive with
stars (*********).
|
Replaces the values of POST parameters marked as sensitive with
stars (*********).
| def get_post_parameters(self, request):
"""
Replaces the values of POST parameters marked as sensitive with
stars (*********).
"""
if request is None:
return {}
else:
sensitive_post_parameters = getattr(request, 'sensitive_post_parameters', [])
... | [
"def",
"get_post_parameters",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
"is",
"None",
":",
"return",
"{",
"}",
"else",
":",
"sensitive_post_parameters",
"=",
"getattr",
"(",
"request",
",",
"'sensitive_post_parameters'",
",",
"[",
"]",
")",
"if... | [
143,
4
] | [
166,
35
] | python | en | ['en', 'error', 'th'] | False |
SafeExceptionReporterFilter.get_traceback_frame_variables | (self, request, tb_frame) |
Replaces the values of variables marked as sensitive with
stars (*********).
|
Replaces the values of variables marked as sensitive with
stars (*********).
| def get_traceback_frame_variables(self, request, tb_frame):
"""
Replaces the values of variables marked as sensitive with
stars (*********).
"""
# Loop through the frame's callers to see if the sensitive_variables
# decorator was used.
current_frame = tb_frame.f_b... | [
"def",
"get_traceback_frame_variables",
"(",
"self",
",",
"request",
",",
"tb_frame",
")",
":",
"# Loop through the frame's callers to see if the sensitive_variables",
"# decorator was used.",
"current_frame",
"=",
"tb_frame",
".",
"f_back",
"sensitive_variables",
"=",
"None",
... | [
182,
4
] | [
230,
31
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReporter.get_traceback_data | (self) | Return a dictionary containing traceback information. | Return a dictionary containing traceback information. | def get_traceback_data(self):
"""Return a dictionary containing traceback information."""
if self.exc_type and issubclass(self.exc_type, TemplateDoesNotExist):
self.template_does_not_exist = True
self.postmortem = self.exc_value.chain or [self.exc_value]
frames = self.ge... | [
"def",
"get_traceback_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"exc_type",
"and",
"issubclass",
"(",
"self",
".",
"exc_type",
",",
"TemplateDoesNotExist",
")",
":",
"self",
".",
"template_does_not_exist",
"=",
"True",
"self",
".",
"postmortem",
"=",
... | [
249,
4
] | [
321,
16
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporter.get_traceback_html | (self) | Return HTML version of debug 500 HTTP error page. | Return HTML version of debug 500 HTTP error page. | def get_traceback_html(self):
"Return HTML version of debug 500 HTTP error page."
t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEMPLATE)
c = Context(self.get_traceback_data(), use_l10n=False)
return t.render(c) | [
"def",
"get_traceback_html",
"(",
"self",
")",
":",
"t",
"=",
"DEBUG_ENGINE",
".",
"from_string",
"(",
"TECHNICAL_500_TEMPLATE",
")",
"c",
"=",
"Context",
"(",
"self",
".",
"get_traceback_data",
"(",
")",
",",
"use_l10n",
"=",
"False",
")",
"return",
"t",
... | [
323,
4
] | [
327,
26
] | python | en | ['en', 'da', 'en'] | True |
ExceptionReporter.get_traceback_text | (self) | Return plain text version of debug 500 HTTP error page. | Return plain text version of debug 500 HTTP error page. | def get_traceback_text(self):
"Return plain text version of debug 500 HTTP error page."
t = DEBUG_ENGINE.from_string(TECHNICAL_500_TEXT_TEMPLATE)
c = Context(self.get_traceback_data(), autoescape=False, use_l10n=False)
return t.render(c) | [
"def",
"get_traceback_text",
"(",
"self",
")",
":",
"t",
"=",
"DEBUG_ENGINE",
".",
"from_string",
"(",
"TECHNICAL_500_TEXT_TEMPLATE",
")",
"c",
"=",
"Context",
"(",
"self",
".",
"get_traceback_data",
"(",
")",
",",
"autoescape",
"=",
"False",
",",
"use_l10n",
... | [
329,
4
] | [
333,
26
] | python | en | ['en', 'en', 'en'] | True |
ExceptionReporter._get_lines_from_file | (self, filename, lineno, context_lines, loader=None, module_name=None) |
Returns context_lines before and after lineno from file.
Returns (pre_context_lineno, pre_context, context_line, post_context).
|
Returns context_lines before and after lineno from file.
Returns (pre_context_lineno, pre_context, context_line, post_context).
| def _get_lines_from_file(self, filename, lineno, context_lines, loader=None, module_name=None):
"""
Returns context_lines before and after lineno from file.
Returns (pre_context_lineno, pre_context, context_line, post_context).
"""
source = None
if loader is not None and ... | [
"def",
"_get_lines_from_file",
"(",
"self",
",",
"filename",
",",
"lineno",
",",
"context_lines",
",",
"loader",
"=",
"None",
",",
"module_name",
"=",
"None",
")",
":",
"source",
"=",
"None",
"if",
"loader",
"is",
"not",
"None",
"and",
"hasattr",
"(",
"l... | [
335,
4
] | [
378,
67
] | python | en | ['en', 'error', 'th'] | False |
ExceptionReporter.format_exception | (self) |
Return the same data as from traceback.format_exception.
|
Return the same data as from traceback.format_exception.
| def format_exception(self):
"""
Return the same data as from traceback.format_exception.
"""
import traceback
frames = self.get_traceback_frames()
tb = [(f['filename'], f['lineno'], f['function'], f['context_line']) for f in frames]
list = ['Traceback (most recent... | [
"def",
"format_exception",
"(",
"self",
")",
":",
"import",
"traceback",
"frames",
"=",
"self",
".",
"get_traceback_frames",
"(",
")",
"tb",
"=",
"[",
"(",
"f",
"[",
"'filename'",
"]",
",",
"f",
"[",
"'lineno'",
"]",
",",
"f",
"[",
"'function'",
"]",
... | [
447,
4
] | [
457,
19
] | python | en | ['en', 'error', 'th'] | False |
KPISet.error_item_skel | (error, ret_c, cnt, errtype, urls, tag) |
:type error: str
:type ret_c: str
:type tag: str
:type cnt: int
:type errtype: int
:type urls: collections.Counter
:rtype: dict
| def error_item_skel(error, ret_c, cnt, errtype, urls, tag):
"""
:type error: str
:type ret_c: str
:type tag: str
:type cnt: int
:type errtype: int
:type urls: collections.Counter
:rtype: dict
"""
assert isinstance(urls, collections.Counter... | [
"def",
"error_item_skel",
"(",
"error",
",",
"ret_c",
",",
"cnt",
",",
"errtype",
",",
"urls",
",",
"tag",
")",
":",
"assert",
"isinstance",
"(",
"urls",
",",
"collections",
".",
"Counter",
")",
"return",
"{",
"\"cnt\"",
":",
"cnt",
",",
"\"msg\"",
":"... | [
226,
4
] | [
245,
9
] | python | en | ['en', 'error', 'th'] | False | |
KPISet.add_sample | (self, sample) |
Add sample, consisting of: cnc, rt, cn, lt, rc, error, trname, byte_count
:type sample: tuple
|
Add sample, consisting of: cnc, rt, cn, lt, rc, error, trname, byte_count | def add_sample(self, sample):
"""
Add sample, consisting of: cnc, rt, cn, lt, rc, error, trname, byte_count
:type sample: tuple
"""
# TODO: introduce a flag to not count failed in resp times? or offer it always?
cnc, r_time, con_time, latency, r_code, error, trname, byte... | [
"def",
"add_sample",
"(",
"self",
",",
"sample",
")",
":",
"# TODO: introduce a flag to not count failed in resp times? or offer it always?",
"cnc",
",",
"r_time",
",",
"con_time",
",",
"latency",
",",
"r_code",
",",
"error",
",",
"trname",
",",
"byte_count",
"=",
"... | [
247,
4
] | [
279,
47
] | python | en | ['en', 'error', 'th'] | False |
KPISet.inc_list | (values, selector, value) |
Increment list item, based on selector criteria
:param values: list to update
:param selector: tuple of 2 values, field name and value to match
:param value: dict to put into list
:type values: list[dict]
:type selector: tuple
:type value: dict
|
Increment list item, based on selector criteria | def inc_list(values, selector, value):
"""
Increment list item, based on selector criteria
:param values: list to update
:param selector: tuple of 2 values, field name and value to match
:param value: dict to put into list
:type values: list[dict]
:type selector:... | [
"def",
"inc_list",
"(",
"values",
",",
"selector",
",",
"value",
")",
":",
"found",
"=",
"False",
"for",
"item",
"in",
"values",
":",
"if",
"item",
"[",
"selector",
"[",
"0",
"]",
"]",
"==",
"selector",
"[",
"1",
"]",
":",
"item",
"[",
"'cnt'",
"... | [
287,
4
] | [
307,
47
] | python | en | ['en', 'error', 'th'] | False |
KPISet.recalculate | (self) |
Recalculate averages, stdev and percentiles
:return:
|
Recalculate averages, stdev and percentiles | def recalculate(self): # FIXME: get rid of it at all?
"""
Recalculate averages, stdev and percentiles
:return:
"""
if self[self.SAMPLE_COUNT]:
self[self.AVG_CONN_TIME] = self.sum_cn / self[self.SAMPLE_COUNT]
self[self.AVG_LATENCY] = self.sum_lt / self[se... | [
"def",
"recalculate",
"(",
"self",
")",
":",
"# FIXME: get rid of it at all?",
"if",
"self",
"[",
"self",
".",
"SAMPLE_COUNT",
"]",
":",
"self",
"[",
"self",
".",
"AVG_CONN_TIME",
"]",
"=",
"self",
".",
"sum_cn",
"/",
"self",
"[",
"self",
".",
"SAMPLE_COUN... | [
340,
4
] | [
354,
19
] | python | en | ['en', 'error', 'th'] | False |
KPISet.merge_kpis | (self, src, sid=None) |
Merge other instance into self
:param sid: source ID to use when suming up concurrency
:type src: KPISet
:return:
|
Merge other instance into self | def merge_kpis(self, src, sid=None):
"""
Merge other instance into self
:param sid: source ID to use when suming up concurrency
:type src: KPISet
:return:
"""
src.recalculate() # TODO: could be not resource efficient strat
self.sum_cn += src.sum_cn
... | [
"def",
"merge_kpis",
"(",
"self",
",",
"src",
",",
"sid",
"=",
"None",
")",
":",
"src",
".",
"recalculate",
"(",
")",
"# TODO: could be not resource efficient strat",
"self",
".",
"sum_cn",
"+=",
"src",
".",
"sum_cn",
"self",
".",
"sum_lt",
"+=",
"src",
".... | [
356,
4
] | [
388,
80
] | python | en | ['en', 'error', 'th'] | False |
KPISet.from_dict | (obj) |
:type obj: dict
:rtype: KPISet
|
:type obj: dict
:rtype: KPISet
| def from_dict(obj):
"""
:type obj: dict
:rtype: KPISet
"""
prc_levels = [float(x) for x in obj[KPISet.PERCENTILES].keys()]
inst = KPISet(perc_levels=prc_levels)
assert inst.PERCENTILES in obj
for key, val in iteritems(obj):
if key == inst.RES... | [
"def",
"from_dict",
"(",
"obj",
")",
":",
"prc_levels",
"=",
"[",
"float",
"(",
"x",
")",
"for",
"x",
"in",
"obj",
"[",
"KPISet",
".",
"PERCENTILES",
"]",
".",
"keys",
"(",
")",
"]",
"inst",
"=",
"KPISet",
"(",
"perc_levels",
"=",
"prc_levels",
")"... | [
391,
4
] | [
414,
19
] | python | en | ['en', 'error', 'th'] | False |
DataPoint.__init__ | (self, ts, perc_levels=()) |
:type ts: int
:type perc_levels: list[float]
| def __init__(self, ts, perc_levels=()):
"""
:type ts: int
:type perc_levels: list[float]
"""
super(DataPoint, self).__init__()
self.perc_levels = perc_levels
self[self.SOURCE_ID] = None
self[self.TIMESTAMP] = ts
self[self.CUMULATIVE] = {}
... | [
"def",
"__init__",
"(",
"self",
",",
"ts",
",",
"perc_levels",
"=",
"(",
")",
")",
":",
"super",
"(",
"DataPoint",
",",
"self",
")",
".",
"__init__",
"(",
")",
"self",
".",
"perc_levels",
"=",
"perc_levels",
"self",
"[",
"self",
".",
"SOURCE_ID",
"]"... | [
430,
4
] | [
442,
34
] | python | en | ['en', 'error', 'th'] | False | |
DataPoint.__merge_kpis | (self, src, dst, sid) |
:param src: dict[str,KPISet]
:param dst: dict[str,KPISet]
:param sid: int
:return:
|
:param src: dict[str,KPISet]
:param dst: dict[str,KPISet]
:param sid: int
:return:
| def __merge_kpis(self, src, dst, sid):
"""
:param src: dict[str,KPISet]
:param dst: dict[str,KPISet]
:param sid: int
:return:
"""
for label, val in iteritems(src):
dest = dst.setdefault(label, KPISet(self.perc_levels, val[KPISet.RESP_TIMES].high))
... | [
"def",
"__merge_kpis",
"(",
"self",
",",
"src",
",",
"dst",
",",
"sid",
")",
":",
"for",
"label",
",",
"val",
"in",
"iteritems",
"(",
"src",
")",
":",
"dest",
"=",
"dst",
".",
"setdefault",
"(",
"label",
",",
"KPISet",
"(",
"self",
".",
"perc_level... | [
450,
4
] | [
462,
37
] | python | en | ['en', 'error', 'th'] | False |
DataPoint.recalculate | (self) |
Recalculate all KPISet's
|
Recalculate all KPISet's
| def recalculate(self):
"""
Recalculate all KPISet's
"""
for val in self[self.CURRENT].values():
val.recalculate()
for val in self[self.CUMULATIVE].values():
val.recalculate() | [
"def",
"recalculate",
"(",
"self",
")",
":",
"for",
"val",
"in",
"self",
"[",
"self",
".",
"CURRENT",
"]",
".",
"values",
"(",
")",
":",
"val",
".",
"recalculate",
"(",
")",
"for",
"val",
"in",
"self",
"[",
"self",
".",
"CUMULATIVE",
"]",
".",
"v... | [
464,
4
] | [
472,
29
] | python | en | ['en', 'error', 'th'] | False |
DataPoint.merge_point | (self, src, do_recalculate=True) |
:type src: DataPoint
| def merge_point(self, src, do_recalculate=True):
"""
:type src: DataPoint
"""
if self[self.TIMESTAMP] != src[self.TIMESTAMP]:
msg = "Cannot merge different timestamps (%s and %s)"
raise TaurusInternalException(msg % (self[self.TIMESTAMP], src[self.TIMESTAMP]))
... | [
"def",
"merge_point",
"(",
"self",
",",
"src",
",",
"do_recalculate",
"=",
"True",
")",
":",
"if",
"self",
"[",
"self",
".",
"TIMESTAMP",
"]",
"!=",
"src",
"[",
"self",
".",
"TIMESTAMP",
"]",
":",
"msg",
"=",
"\"Cannot merge different timestamps (%s and %s)\... | [
474,
4
] | [
489,
30
] | python | en | ['en', 'error', 'th'] | False | |
ResultsProvider._fuzzy_fold | (key, dataset, limit) |
:type key: str
:type dataset: fuzzyset.FuzzySet
:type limit: int
:rtype: str
|
:type key: str
:type dataset: fuzzyset.FuzzySet
:type limit: int
:rtype: str
| def _fuzzy_fold(key, dataset, limit):
"""
:type key: str
:type dataset: fuzzyset.FuzzySet
:type limit: int
:rtype: str
"""
if not key or limit <= 0:
return key
if not isinstance(key, str):
key = key.decode('utf-8')
if key.... | [
"def",
"_fuzzy_fold",
"(",
"key",
",",
"dataset",
",",
"limit",
")",
":",
"if",
"not",
"key",
"or",
"limit",
"<=",
"0",
":",
"return",
"key",
"if",
"not",
"isinstance",
"(",
"key",
",",
"str",
")",
":",
"key",
"=",
"key",
".",
"decode",
"(",
"'ut... | [
518,
4
] | [
547,
18
] | python | en | ['en', 'error', 'th'] | False |
ResultsProvider.add_listener | (self, listener) |
Add aggregate results listener
:type listener: AggregatorListener
|
Add aggregate results listener | def add_listener(self, listener):
"""
Add aggregate results listener
:type listener: AggregatorListener
"""
self.listeners.append(listener) | [
"def",
"add_listener",
"(",
"self",
",",
"listener",
")",
":",
"self",
".",
"listeners",
".",
"append",
"(",
"listener",
")"
] | [
555,
4
] | [
561,
39
] | python | en | ['en', 'error', 'th'] | False |
ResultsProvider.__merge_to_cumulative | (self, current) |
Merge current KPISet to cumulative
:param current: KPISet
|
Merge current KPISet to cumulative
:param current: KPISet
| def __merge_to_cumulative(self, current):
"""
Merge current KPISet to cumulative
:param current: KPISet
"""
for label, data in iteritems(current):
cumul = self.cumulative.setdefault(label, KPISet(self.track_percentiles, data[KPISet.RESP_TIMES].high))
cumul... | [
"def",
"__merge_to_cumulative",
"(",
"self",
",",
"current",
")",
":",
"for",
"label",
",",
"data",
"in",
"iteritems",
"(",
"current",
")",
":",
"cumul",
"=",
"self",
".",
"cumulative",
".",
"setdefault",
"(",
"label",
",",
"KPISet",
"(",
"self",
".",
... | [
563,
4
] | [
571,
31
] | python | en | ['en', 'error', 'th'] | False |
ResultsProvider.datapoints | (self, final_pass=False) |
Generator object that returns datapoints from the reader
:type final_pass: bool
|
Generator object that returns datapoints from the reader | def datapoints(self, final_pass=False):
"""
Generator object that returns datapoints from the reader
:type final_pass: bool
"""
for datapoint in self._calculate_datapoints(final_pass):
current = datapoint[DataPoint.CURRENT]
if datapoint[DataPoint.CUMULATI... | [
"def",
"datapoints",
"(",
"self",
",",
"final_pass",
"=",
"False",
")",
":",
"for",
"datapoint",
"in",
"self",
".",
"_calculate_datapoints",
"(",
"final_pass",
")",
":",
"current",
"=",
"datapoint",
"[",
"DataPoint",
".",
"CURRENT",
"]",
"if",
"datapoint",
... | [
573,
4
] | [
588,
27
] | python | en | ['en', 'error', 'th'] | False |
ResultsProvider._calculate_datapoints | (self, final_pass=False) |
:rtype : list[DataPoint]
|
:rtype : list[DataPoint]
| def _calculate_datapoints(self, final_pass=False):
"""
:rtype : list[DataPoint]
"""
yield | [
"def",
"_calculate_datapoints",
"(",
"self",
",",
"final_pass",
"=",
"False",
")",
":",
"yield"
] | [
591,
4
] | [
595,
13
] | python | en | ['en', 'error', 'th'] | False |
ResultsProvider._ramp_up_exclude | (self) |
:rtype : bool
|
:rtype : bool
| def _ramp_up_exclude(self):
"""
:rtype : bool
"""
return False | [
"def",
"_ramp_up_exclude",
"(",
"self",
")",
":",
"return",
"False"
] | [
598,
4
] | [
602,
20
] | python | en | ['en', 'error', 'th'] | False |
ResultsReader.__process_readers | (self, final_pass=False) |
:param final_pass: True if in post-process stage
:return:
| def __process_readers(self, final_pass=False):
"""
:param final_pass: True if in post-process stage
:return:
"""
for result in self._read(final_pass):
if result is None:
self.log.debug("No data from reader")
break
elif isin... | [
"def",
"__process_readers",
"(",
"self",
",",
"final_pass",
"=",
"False",
")",
":",
"for",
"result",
"in",
"self",
".",
"_read",
"(",
"final_pass",
")",
":",
"if",
"result",
"is",
"None",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"No data from reader... | [
634,
4
] | [
664,
104
] | python | en | ['en', 'error', 'th'] | False | |
ResultsReader.__aggregate_current | (self, datapoint, samples) |
:param datapoint: DataPoint
:param samples: list of samples
:return:
|
:param datapoint: DataPoint
:param samples: list of samples
:return:
| def __aggregate_current(self, datapoint, samples):
"""
:param datapoint: DataPoint
:param samples: list of samples
:return:
"""
current = datapoint[DataPoint.CURRENT]
for sample in samples:
# sample format: label, conc, r_time, con_time, latency, r_cod... | [
"def",
"__aggregate_current",
"(",
"self",
",",
"datapoint",
",",
"samples",
")",
":",
"current",
"=",
"datapoint",
"[",
"DataPoint",
".",
"CURRENT",
"]",
"for",
"sample",
"in",
"samples",
":",
"# sample format: label, conc, r_time, con_time, latency, r_code, error, trn... | [
666,
4
] | [
692,
22
] | python | en | ['en', 'error', 'th'] | False |
ResultsReader._calculate_datapoints | (self, final_pass=False) |
A generator to read available datapoints
:type final_pass: bool
:rtype: DataPoint
|
A generator to read available datapoints | def _calculate_datapoints(self, final_pass=False):
"""
A generator to read available datapoints
:type final_pass: bool
:rtype: DataPoint
"""
if final_pass or len(self.buffer) < self.buffer_len * 10: # safety valve to preserve RAM
self.__process_readers(final... | [
"def",
"_calculate_datapoints",
"(",
"self",
",",
"final_pass",
"=",
"False",
")",
":",
"if",
"final_pass",
"or",
"len",
"(",
"self",
".",
"buffer",
")",
"<",
"self",
".",
"buffer_len",
"*",
"10",
":",
"# safety valve to preserve RAM",
"self",
".",
"__proces... | [
717,
4
] | [
754,
21
] | python | en | ['en', 'error', 'th'] | False |
ResultsReader.__get_new_datapoint | (self, timestamp) |
:rtype: DataPoint
|
:rtype: DataPoint
| def __get_new_datapoint(self, timestamp):
"""
:rtype: DataPoint
"""
point = DataPoint(timestamp, self.track_percentiles)
point[DataPoint.SOURCE_ID] = id(self)
return point | [
"def",
"__get_new_datapoint",
"(",
"self",
",",
"timestamp",
")",
":",
"point",
"=",
"DataPoint",
"(",
"timestamp",
",",
"self",
".",
"track_percentiles",
")",
"point",
"[",
"DataPoint",
".",
"SOURCE_ID",
"]",
"=",
"id",
"(",
"self",
")",
"return",
"point"... | [
756,
4
] | [
762,
20
] | python | en | ['en', 'error', 'th'] | False |
ResultsReader._read | (self, final_pass=False) |
:param final_pass: True if called from post-process stage, when reader
should report possible rests of results
:rtype: list
:return: timestamp, label, concurrency, rt, latency, rc, error
| def _read(self, final_pass=False):
"""
:param final_pass: True if called from post-process stage, when reader
should report possible rests of results
:rtype: list
:return: timestamp, label, concurrency, rt, latency, rc, error
"""
yield | [
"def",
"_read",
"(",
"self",
",",
"final_pass",
"=",
"False",
")",
":",
"yield"
] | [
765,
4
] | [
773,
13
] | python | en | ['en', 'error', 'th'] | False | |
ConsolidatingAggregator.prepare | (self) |
Read aggregation options
|
Read aggregation options
| def prepare(self):
"""
Read aggregation options
"""
super(ConsolidatingAggregator, self).prepare()
# make unique & sort
self.track_percentiles = self.settings.get("percentiles", self.track_percentiles)
self.track_percentiles = list(set(self.track_percentiles))
... | [
"def",
"prepare",
"(",
"self",
")",
":",
"super",
"(",
"ConsolidatingAggregator",
",",
"self",
")",
".",
"prepare",
"(",
")",
"# make unique & sort",
"self",
".",
"track_percentiles",
"=",
"self",
".",
"settings",
".",
"get",
"(",
"\"percentiles\"",
",",
"se... | [
818,
4
] | [
859,
91
] | python | en | ['en', 'error', 'th'] | False |
ConsolidatingAggregator.add_underling | (self, underling) |
Add source for aggregating
:type underling: ResultsProvider
|
Add source for aggregating | def add_underling(self, underling):
"""
Add source for aggregating
:type underling: ResultsProvider
"""
underling.track_percentiles = self.track_percentiles
underling.ignored_labels = self.ignored_labels
underling.min_buffer_len = self.min_buffer_len
unde... | [
"def",
"add_underling",
"(",
"self",
",",
"underling",
")",
":",
"underling",
".",
"track_percentiles",
"=",
"self",
".",
"track_percentiles",
"underling",
".",
"ignored_labels",
"=",
"self",
".",
"ignored_labels",
"underling",
".",
"min_buffer_len",
"=",
"self",
... | [
868,
4
] | [
889,
41
] | python | en | ['en', 'error', 'th'] | False |
ConsolidatingAggregator.check | (self) |
Check if there is next aggregate data present
:rtype: bool
|
Check if there is next aggregate data present | def check(self):
"""
Check if there is next aggregate data present
:rtype: bool
"""
for point in self.datapoints():
self.log.debug("Processed datapoint: %s/%s with %d labels",
point[DataPoint.TIMESTAMP], point[DataPoint.SOURCE_ID], len(poin... | [
"def",
"check",
"(",
"self",
")",
":",
"for",
"point",
"in",
"self",
".",
"datapoints",
"(",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Processed datapoint: %s/%s with %d labels\"",
",",
"point",
"[",
"DataPoint",
".",
"TIMESTAMP",
"]",
",",
"poin... | [
891,
4
] | [
900,
59
] | python | en | ['en', 'error', 'th'] | False |
ConsolidatingAggregator.post_process | (self) |
Process all remaining aggregate data
|
Process all remaining aggregate data
| def post_process(self):
"""
Process all remaining aggregate data
"""
super(ConsolidatingAggregator, self).post_process()
for point in self.datapoints(True):
self.log.debug("Processed datapoint: %s/%s", point[DataPoint.TIMESTAMP], point[DataPoint.SOURCE_ID]) | [
"def",
"post_process",
"(",
"self",
")",
":",
"super",
"(",
"ConsolidatingAggregator",
",",
"self",
")",
".",
"post_process",
"(",
")",
"for",
"point",
"in",
"self",
".",
"datapoints",
"(",
"True",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Pr... | [
902,
4
] | [
908,
112
] | python | en | ['en', 'error', 'th'] | False |
ConsolidatingAggregator._calculate_datapoints | (self, final_pass=False) |
Override ResultsProvider._calculate_datapoints
|
Override ResultsProvider._calculate_datapoints
| def _calculate_datapoints(self, final_pass=False):
"""
Override ResultsProvider._calculate_datapoints
"""
self._process_underlings(final_pass)
self.log.debug("Consolidator buffer[%s]: %s", len(self.buffer), self.buffer.keys())
if not self.buffer:
return
... | [
"def",
"_calculate_datapoints",
"(",
"self",
",",
"final_pass",
"=",
"False",
")",
":",
"self",
".",
"_process_underlings",
"(",
"final_pass",
")",
"self",
".",
"log",
".",
"debug",
"(",
"\"Consolidator buffer[%s]: %s\"",
",",
"len",
"(",
"self",
".",
"buffer"... | [
943,
4
] | [
991,
23
] | python | en | ['en', 'error', 'th'] | False |
AggregatorListener.aggregated_second | (self, data) |
Notification about new data point
:param data: bzt.modules.reporting.DataPoint
|
Notification about new data point | def aggregated_second(self, data):
"""
Notification about new data point
:param data: bzt.modules.reporting.DataPoint
"""
pass | [
"def",
"aggregated_second",
"(",
"self",
",",
"data",
")",
":",
"pass"
] | [
1019,
4
] | [
1025,
12
] | python | en | ['en', 'error', 'th'] | False |
AggregatorListener.finalize | (self) |
This method is called at the end of run
to close open file descriptors etc.
|
This method is called at the end of run
to close open file descriptors etc.
| def finalize(self):
"""
This method is called at the end of run
to close open file descriptors etc.
"""
pass | [
"def",
"finalize",
"(",
"self",
")",
":",
"pass"
] | [
1027,
4
] | [
1032,
12
] | python | en | ['en', 'error', 'th'] | False |
construct_instance | (form, instance, fields=None, exclude=None) |
Constructs and returns a model instance from the bound ``form``'s
``cleaned_data``, but does not save the returned instance to the
database.
|
Constructs and returns a model instance from the bound ``form``'s
``cleaned_data``, but does not save the returned instance to the
database.
| def construct_instance(form, instance, fields=None, exclude=None):
"""
Constructs and returns a model instance from the bound ``form``'s
``cleaned_data``, but does not save the returned instance to the
database.
"""
from django.db import models
opts = instance._meta
cleaned_data = form.... | [
"def",
"construct_instance",
"(",
"form",
",",
"instance",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"from",
"django",
".",
"db",
"import",
"models",
"opts",
"=",
"instance",
".",
"_meta",
"cleaned_data",
"=",
"form",
".",
"clean... | [
35,
0
] | [
69,
19
] | python | en | ['en', 'error', 'th'] | False |
model_to_dict | (instance, fields=None, exclude=None) |
Returns a dict containing the data in ``instance`` suitable for passing as
a Form's ``initial`` keyword argument.
``fields`` is an optional list of field names. If provided, only the named
fields will be included in the returned dict.
``exclude`` is an optional list of field names. If provided, t... |
Returns a dict containing the data in ``instance`` suitable for passing as
a Form's ``initial`` keyword argument. | def model_to_dict(instance, fields=None, exclude=None):
"""
Returns a dict containing the data in ``instance`` suitable for passing as
a Form's ``initial`` keyword argument.
``fields`` is an optional list of field names. If provided, only the named
fields will be included in the returned dict.
... | [
"def",
"model_to_dict",
"(",
"instance",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
")",
":",
"opts",
"=",
"instance",
".",
"_meta",
"data",
"=",
"{",
"}",
"for",
"f",
"in",
"chain",
"(",
"opts",
".",
"concrete_fields",
",",
"opts",
"."... | [
74,
0
] | [
96,
15
] | python | en | ['en', 'error', 'th'] | False |
fields_for_model | (model, fields=None, exclude=None, widgets=None,
formfield_callback=None, localized_fields=None,
labels=None, help_texts=None, error_messages=None,
field_classes=None) |
Returns a ``OrderedDict`` containing form fields for the given model.
``fields`` is an optional list of field names. If provided, only the named
fields will be included in the returned fields.
``exclude`` is an optional list of field names. If provided, the named
fields will be excluded from the ... |
Returns a ``OrderedDict`` containing form fields for the given model. | def fields_for_model(model, fields=None, exclude=None, widgets=None,
formfield_callback=None, localized_fields=None,
labels=None, help_texts=None, error_messages=None,
field_classes=None):
"""
Returns a ``OrderedDict`` containing form fields for the... | [
"def",
"fields_for_model",
"(",
"model",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"widgets",
"=",
"None",
",",
"formfield_callback",
"=",
"None",
",",
"localized_fields",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"help_texts",
"=",... | [
99,
0
] | [
186,
21
] | python | en | ['en', 'error', 'th'] | False |
modelform_factory | (model, form=ModelForm, fields=None, exclude=None,
formfield_callback=None, widgets=None, localized_fields=None,
labels=None, help_texts=None, error_messages=None,
field_classes=None) |
Returns a ModelForm containing form fields for the given model.
``fields`` is an optional list of field names. If provided, only the named
fields will be included in the returned fields. If omitted or '__all__',
all fields will be used.
``exclude`` is an optional list of field names. If provided,... |
Returns a ModelForm containing form fields for the given model. | def modelform_factory(model, form=ModelForm, fields=None, exclude=None,
formfield_callback=None, widgets=None, localized_fields=None,
labels=None, help_texts=None, error_messages=None,
field_classes=None):
"""
Returns a ModelForm containing form ... | [
"def",
"modelform_factory",
"(",
"model",
",",
"form",
"=",
"ModelForm",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"formfield_callback",
"=",
"None",
",",
"widgets",
"=",
"None",
",",
"localized_fields",
"=",
"None",
",",
"labels",
"=",... | [
465,
0
] | [
545,
60
] | python | en | ['en', 'error', 'th'] | False |
modelformset_factory | (model, form=ModelForm, formfield_callback=None,
formset=BaseModelFormSet, extra=1, can_delete=False,
can_order=False, max_num=None, fields=None, exclude=None,
widgets=None, validate_max=False, localized_fields=None,
lab... |
Returns a FormSet class for the given Django model class.
|
Returns a FormSet class for the given Django model class.
| def modelformset_factory(model, form=ModelForm, formfield_callback=None,
formset=BaseModelFormSet, extra=1, can_delete=False,
can_order=False, max_num=None, fields=None, exclude=None,
widgets=None, validate_max=False, localized_fields=None,
... | [
"def",
"modelformset_factory",
"(",
"model",
",",
"form",
"=",
"ModelForm",
",",
"formfield_callback",
"=",
"None",
",",
"formset",
"=",
"BaseModelFormSet",
",",
"extra",
"=",
"1",
",",
"can_delete",
"=",
"False",
",",
"can_order",
"=",
"False",
",",
"max_nu... | [
831,
0
] | [
857,
18
] | python | en | ['en', 'error', 'th'] | False |
_get_foreign_key | (parent_model, model, fk_name=None, can_fail=False) |
Finds and returns the ForeignKey from model to parent if there is one
(returns None if can_fail is True and no such field exists). If fk_name is
provided, assume it is the name of the ForeignKey field. Unless can_fail is
True, an exception is raised if there is no ForeignKey from model to
parent_mo... |
Finds and returns the ForeignKey from model to parent if there is one
(returns None if can_fail is True and no such field exists). If fk_name is
provided, assume it is the name of the ForeignKey field. Unless can_fail is
True, an exception is raised if there is no ForeignKey from model to
parent_mo... | def _get_foreign_key(parent_model, model, fk_name=None, can_fail=False):
"""
Finds and returns the ForeignKey from model to parent if there is one
(returns None if can_fail is True and no such field exists). If fk_name is
provided, assume it is the name of the ForeignKey field. Unless can_fail is
Tr... | [
"def",
"_get_foreign_key",
"(",
"parent_model",
",",
"model",
",",
"fk_name",
"=",
"None",
",",
"can_fail",
"=",
"False",
")",
":",
"# avoid circular import",
"from",
"django",
".",
"db",
".",
"models",
"import",
"ForeignKey",
"opts",
"=",
"model",
".",
"_me... | [
964,
0
] | [
1016,
13
] | python | en | ['en', 'error', 'th'] | False |
inlineformset_factory | (parent_model, model, form=ModelForm,
formset=BaseInlineFormSet, fk_name=None,
fields=None, exclude=None, extra=3, can_order=False,
can_delete=True, max_num=None, formfield_callback=None,
widgets=None, validate_max=F... |
Returns an ``InlineFormSet`` for the given kwargs.
You must provide ``fk_name`` if ``model`` has more than one ``ForeignKey``
to ``parent_model``.
|
Returns an ``InlineFormSet`` for the given kwargs. | def inlineformset_factory(parent_model, model, form=ModelForm,
formset=BaseInlineFormSet, fk_name=None,
fields=None, exclude=None, extra=3, can_order=False,
can_delete=True, max_num=None, formfield_callback=None,
wid... | [
"def",
"inlineformset_factory",
"(",
"parent_model",
",",
"model",
",",
"form",
"=",
"ModelForm",
",",
"formset",
"=",
"BaseInlineFormSet",
",",
"fk_name",
"=",
"None",
",",
"fields",
"=",
"None",
",",
"exclude",
"=",
"None",
",",
"extra",
"=",
"3",
",",
... | [
1019,
0
] | [
1058,
18
] | python | en | ['en', 'error', 'th'] | False |
BaseModelForm._get_validation_exclusions | (self) |
For backwards-compatibility, several types of fields need to be
excluded from model validation. See the following tickets for
details: #12507, #12521, #12553
|
For backwards-compatibility, several types of fields need to be
excluded from model validation. See the following tickets for
details: #12507, #12521, #12553
| def _get_validation_exclusions(self):
"""
For backwards-compatibility, several types of fields need to be
excluded from model validation. See the following tickets for
details: #12507, #12521, #12553
"""
exclude = []
# Build up a list of fields that should be excl... | [
"def",
"_get_validation_exclusions",
"(",
"self",
")",
":",
"exclude",
"=",
"[",
"]",
"# Build up a list of fields that should be excluded from model field",
"# validation and unique checks.",
"for",
"f",
"in",
"self",
".",
"instance",
".",
"_meta",
".",
"fields",
":",
... | [
299,
4
] | [
339,
22
] | python | en | ['en', 'error', 'th'] | False |
BaseModelForm.validate_unique | (self) |
Calls the instance's validate_unique() method and updates the form's
validation errors if any were raised.
|
Calls the instance's validate_unique() method and updates the form's
validation errors if any were raised.
| def validate_unique(self):
"""
Calls the instance's validate_unique() method and updates the form's
validation errors if any were raised.
"""
exclude = self._get_validation_exclusions()
try:
self.instance.validate_unique(exclude=exclude)
except Validat... | [
"def",
"validate_unique",
"(",
"self",
")",
":",
"exclude",
"=",
"self",
".",
"_get_validation_exclusions",
"(",
")",
"try",
":",
"self",
".",
"instance",
".",
"validate_unique",
"(",
"exclude",
"=",
"exclude",
")",
"except",
"ValidationError",
"as",
"e",
":... | [
403,
4
] | [
412,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseModelForm._save_m2m | (self) |
Save the many-to-many fields and generic relations for this form.
|
Save the many-to-many fields and generic relations for this form.
| def _save_m2m(self):
"""
Save the many-to-many fields and generic relations for this form.
"""
cleaned_data = self.cleaned_data
exclude = self._meta.exclude
fields = self._meta.fields
opts = self.instance._meta
# Note that for historical reasons we want to... | [
"def",
"_save_m2m",
"(",
"self",
")",
":",
"cleaned_data",
"=",
"self",
".",
"cleaned_data",
"exclude",
"=",
"self",
".",
"_meta",
".",
"exclude",
"fields",
"=",
"self",
".",
"_meta",
".",
"fields",
"opts",
"=",
"self",
".",
"instance",
".",
"_meta",
"... | [
414,
4
] | [
433,
69
] | python | en | ['en', 'error', 'th'] | False |
BaseModelForm.save | (self, commit=True) |
Save this form's self.instance object if commit=True. Otherwise, add
a save_m2m() method to the form which can be called after the instance
is saved manually at a later time. Return the model instance.
|
Save this form's self.instance object if commit=True. Otherwise, add
a save_m2m() method to the form which can be called after the instance
is saved manually at a later time. Return the model instance.
| def save(self, commit=True):
"""
Save this form's self.instance object if commit=True. Otherwise, add
a save_m2m() method to the form which can be called after the instance
is saved manually at a later time. Return the model instance.
"""
if self.errors:
raise... | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"if",
"self",
".",
"errors",
":",
"raise",
"ValueError",
"(",
"\"The %s could not be %s because the data didn't validate.\"",
"%",
"(",
"self",
".",
"instance",
".",
"_meta",
".",
"object_name",
... | [
435,
4
] | [
456,
28
] | python | en | ['en', 'error', 'th'] | False |
BaseModelFormSet.initial_form_count | (self) | Returns the number of forms that are required in this FormSet. | Returns the number of forms that are required in this FormSet. | def initial_form_count(self):
"""Returns the number of forms that are required in this FormSet."""
if not (self.data or self.files):
return len(self.get_queryset())
return super(BaseModelFormSet, self).initial_form_count() | [
"def",
"initial_form_count",
"(",
"self",
")",
":",
"if",
"not",
"(",
"self",
".",
"data",
"or",
"self",
".",
"files",
")",
":",
"return",
"len",
"(",
"self",
".",
"get_queryset",
"(",
")",
")",
"return",
"super",
"(",
"BaseModelFormSet",
",",
"self",
... | [
567,
4
] | [
571,
65
] | python | en | ['en', 'en', 'en'] | True |
BaseModelFormSet._get_to_python | (self, field) |
If the field is a related field, fetch the concrete field's (that
is, the ultimate pointed-to field's) to_python.
|
If the field is a related field, fetch the concrete field's (that
is, the ultimate pointed-to field's) to_python.
| def _get_to_python(self, field):
"""
If the field is a related field, fetch the concrete field's (that
is, the ultimate pointed-to field's) to_python.
"""
while field.remote_field is not None:
field = field.remote_field.get_related_field()
return field.to_pyth... | [
"def",
"_get_to_python",
"(",
"self",
",",
"field",
")",
":",
"while",
"field",
".",
"remote_field",
"is",
"not",
"None",
":",
"field",
"=",
"field",
".",
"remote_field",
".",
"get_related_field",
"(",
")",
"return",
"field",
".",
"to_python"
] | [
578,
4
] | [
585,
30
] | python | en | ['en', 'error', 'th'] | False |
BaseModelFormSet.save_new | (self, form, commit=True) | Saves and returns a new model instance for the given form. | Saves and returns a new model instance for the given form. | def save_new(self, form, commit=True):
"""Saves and returns a new model instance for the given form."""
return form.save(commit=commit) | [
"def",
"save_new",
"(",
"self",
",",
"form",
",",
"commit",
"=",
"True",
")",
":",
"return",
"form",
".",
"save",
"(",
"commit",
"=",
"commit",
")"
] | [
624,
4
] | [
626,
39
] | python | en | ['en', 'en', 'en'] | True |
BaseModelFormSet.save_existing | (self, form, instance, commit=True) | Saves and returns an existing model instance for the given form. | Saves and returns an existing model instance for the given form. | def save_existing(self, form, instance, commit=True):
"""Saves and returns an existing model instance for the given form."""
return form.save(commit=commit) | [
"def",
"save_existing",
"(",
"self",
",",
"form",
",",
"instance",
",",
"commit",
"=",
"True",
")",
":",
"return",
"form",
".",
"save",
"(",
"commit",
"=",
"commit",
")"
] | [
628,
4
] | [
630,
39
] | python | en | ['en', 'en', 'en'] | True |
BaseModelFormSet.delete_existing | (self, obj, commit=True) | Deletes an existing model instance. | Deletes an existing model instance. | def delete_existing(self, obj, commit=True):
"""Deletes an existing model instance."""
if commit:
obj.delete() | [
"def",
"delete_existing",
"(",
"self",
",",
"obj",
",",
"commit",
"=",
"True",
")",
":",
"if",
"commit",
":",
"obj",
".",
"delete",
"(",
")"
] | [
632,
4
] | [
635,
24
] | python | en | ['en', 'en', 'en'] | True |
BaseModelFormSet.save | (self, commit=True) | Saves model instances for every form, adding and changing instances
as necessary, and returns the list of instances.
| Saves model instances for every form, adding and changing instances
as necessary, and returns the list of instances.
| def save(self, commit=True):
"""Saves model instances for every form, adding and changing instances
as necessary, and returns the list of instances.
"""
if not commit:
self.saved_forms = []
def save_m2m():
for form in self.saved_forms:
... | [
"def",
"save",
"(",
"self",
",",
"commit",
"=",
"True",
")",
":",
"if",
"not",
"commit",
":",
"self",
".",
"saved_forms",
"=",
"[",
"]",
"def",
"save_m2m",
"(",
")",
":",
"for",
"form",
"in",
"self",
".",
"saved_forms",
":",
"form",
".",
"save_m2m"... | [
637,
4
] | [
648,
81
] | python | en | ['en', 'en', 'en'] | True |
BaseModelFormSet.add_fields | (self, form, index) | Add a hidden field for the object's primary key. | Add a hidden field for the object's primary key. | def add_fields(self, form, index):
"""Add a hidden field for the object's primary key."""
from django.db.models import AutoField, OneToOneField, ForeignKey
self._pk_field = pk = self.model._meta.pk
# If a pk isn't editable, then it won't be on the form, so we need to
# add it her... | [
"def",
"add_fields",
"(",
"self",
",",
"form",
",",
"index",
")",
":",
"from",
"django",
".",
"db",
".",
"models",
"import",
"AutoField",
",",
"OneToOneField",
",",
"ForeignKey",
"self",
".",
"_pk_field",
"=",
"pk",
"=",
"self",
".",
"model",
".",
"_me... | [
787,
4
] | [
828,
61
] | python | en | ['en', 'en', 'en'] | True |
ModelChoiceField.get_limit_choices_to | (self) |
Returns ``limit_choices_to`` for this form field.
If it is a callable, it will be invoked and the result will be
returned.
|
Returns ``limit_choices_to`` for this form field. | def get_limit_choices_to(self):
"""
Returns ``limit_choices_to`` for this form field.
If it is a callable, it will be invoked and the result will be
returned.
"""
if callable(self.limit_choices_to):
return self.limit_choices_to()
return self.limit_cho... | [
"def",
"get_limit_choices_to",
"(",
"self",
")",
":",
"if",
"callable",
"(",
"self",
".",
"limit_choices_to",
")",
":",
"return",
"self",
".",
"limit_choices_to",
"(",
")",
"return",
"self",
".",
"limit_choices_to"
] | [
1153,
4
] | [
1162,
36
] | python | en | ['en', 'error', 'th'] | False |
ModelChoiceField.label_from_instance | (self, obj) |
This method is used to convert objects into strings; it's used to
generate the labels for the choices presented by this object. Subclasses
can override this method to customize the display of the choices.
|
This method is used to convert objects into strings; it's used to
generate the labels for the choices presented by this object. Subclasses
can override this method to customize the display of the choices.
| def label_from_instance(self, obj):
"""
This method is used to convert objects into strings; it's used to
generate the labels for the choices presented by this object. Subclasses
can override this method to customize the display of the choices.
"""
return force_text(obj) | [
"def",
"label_from_instance",
"(",
"self",
",",
"obj",
")",
":",
"return",
"force_text",
"(",
"obj",
")"
] | [
1182,
4
] | [
1188,
30
] | python | en | ['en', 'error', 'th'] | False |
ModelMultipleChoiceField._check_values | (self, value) |
Given a list of possible PK values, returns a QuerySet of the
corresponding objects. Raises a ValidationError if a given value is
invalid (not a valid PK, not in the queryset, etc.)
|
Given a list of possible PK values, returns a QuerySet of the
corresponding objects. Raises a ValidationError if a given value is
invalid (not a valid PK, not in the queryset, etc.)
| def _check_values(self, value):
"""
Given a list of possible PK values, returns a QuerySet of the
corresponding objects. Raises a ValidationError if a given value is
invalid (not a valid PK, not in the queryset, etc.)
"""
key = self.to_field_name or 'pk'
# dedupli... | [
"def",
"_check_values",
"(",
"self",
",",
"value",
")",
":",
"key",
"=",
"self",
".",
"to_field_name",
"or",
"'pk'",
"# deduplicate given values to avoid creating many querysets or",
"# requiring the database backend deduplicate efficiently.",
"try",
":",
"value",
"=",
"fro... | [
1271,
4
] | [
1306,
17
] | python | en | ['en', 'error', 'th'] | False |
patch_path | (path) |
Add path to front of sys.path for the duration of the context.
|
Add path to front of sys.path for the duration of the context.
| def patch_path(path):
"""
Add path to front of sys.path for the duration of the context.
"""
try:
sys.path.insert(0, path)
yield
finally:
sys.path.remove(path) | [
"def",
"patch_path",
"(",
"path",
")",
":",
"try",
":",
"sys",
".",
"path",
".",
"insert",
"(",
"0",
",",
"path",
")",
"yield",
"finally",
":",
"sys",
".",
"path",
".",
"remove",
"(",
"path",
")"
] | [
46,
0
] | [
54,
29
] | python | en | ['en', 'error', 'th'] | False |
read_configuration | (
filepath, find_others=False, ignore_option_errors=False) | Read given configuration file and returns options from it as a dict.
:param str|unicode filepath: Path to configuration file
to get options from.
:param bool find_others: Whether to search for other configuration files
which could be on in various places.
:param bool ignore_option_errors:... | Read given configuration file and returns options from it as a dict. | def read_configuration(
filepath, find_others=False, ignore_option_errors=False):
"""Read given configuration file and returns options from it as a dict.
:param str|unicode filepath: Path to configuration file
to get options from.
:param bool find_others: Whether to search for other config... | [
"def",
"read_configuration",
"(",
"filepath",
",",
"find_others",
"=",
"False",
",",
"ignore_option_errors",
"=",
"False",
")",
":",
"from",
"setuptools",
".",
"dist",
"import",
"Distribution",
",",
"_Distribution",
"filepath",
"=",
"os",
".",
"path",
".",
"ab... | [
57,
0
] | [
101,
42
] | python | en | ['en', 'en', 'en'] | True |
_get_option | (target_obj, key) |
Given a target object and option key, get that option from
the target object, either through a get_{key} method or
from an attribute directly.
|
Given a target object and option key, get that option from
the target object, either through a get_{key} method or
from an attribute directly.
| def _get_option(target_obj, key):
"""
Given a target object and option key, get that option from
the target object, either through a get_{key} method or
from an attribute directly.
"""
getter_name = 'get_{key}'.format(**locals())
by_attribute = functools.partial(getattr, target_obj, key)
... | [
"def",
"_get_option",
"(",
"target_obj",
",",
"key",
")",
":",
"getter_name",
"=",
"'get_{key}'",
".",
"format",
"(",
"*",
"*",
"locals",
"(",
")",
")",
"by_attribute",
"=",
"functools",
".",
"partial",
"(",
"getattr",
",",
"target_obj",
",",
"key",
")",... | [
104,
0
] | [
113,
19
] | python | en | ['en', 'error', 'th'] | False |
configuration_to_dict | (handlers) | Returns configuration data gathered by given handlers as a dict.
:param list[ConfigHandler] handlers: Handlers list,
usually from parse_configuration()
:rtype: dict
| Returns configuration data gathered by given handlers as a dict. | def configuration_to_dict(handlers):
"""Returns configuration data gathered by given handlers as a dict.
:param list[ConfigHandler] handlers: Handlers list,
usually from parse_configuration()
:rtype: dict
"""
config_dict = defaultdict(dict)
for handler in handlers:
for option ... | [
"def",
"configuration_to_dict",
"(",
"handlers",
")",
":",
"config_dict",
"=",
"defaultdict",
"(",
"dict",
")",
"for",
"handler",
"in",
"handlers",
":",
"for",
"option",
"in",
"handler",
".",
"set_options",
":",
"value",
"=",
"_get_option",
"(",
"handler",
"... | [
116,
0
] | [
131,
22
] | python | en | ['en', 'en', 'en'] | True |
parse_configuration | (
distribution, command_options, ignore_option_errors=False) | Performs additional parsing of configuration options
for a distribution.
Returns a list of used option handlers.
:param Distribution distribution:
:param dict command_options:
:param bool ignore_option_errors: Whether to silently ignore
options, values of which could not be resolved (e.g. ... | Performs additional parsing of configuration options
for a distribution. | def parse_configuration(
distribution, command_options, ignore_option_errors=False):
"""Performs additional parsing of configuration options
for a distribution.
Returns a list of used option handlers.
:param Distribution distribution:
:param dict command_options:
:param bool ignore_opt... | [
"def",
"parse_configuration",
"(",
"distribution",
",",
"command_options",
",",
"ignore_option_errors",
"=",
"False",
")",
":",
"options",
"=",
"ConfigOptionsHandler",
"(",
"distribution",
",",
"command_options",
",",
"ignore_option_errors",
")",
"options",
".",
"pars... | [
134,
0
] | [
158,
24
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler.parsers | (self) | Metadata item name to parser function mapping. | Metadata item name to parser function mapping. | def parsers(self):
"""Metadata item name to parser function mapping."""
raise NotImplementedError(
'%s must provide .parsers property' % self.__class__.__name__) | [
"def",
"parsers",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'%s must provide .parsers property'",
"%",
"self",
".",
"__class__",
".",
"__name__",
")"
] | [
194,
4
] | [
197,
74
] | python | en | ['en', 'jv', 'en'] | True |
ConfigHandler._parse_list | (cls, value, separator=',') | Represents value as a list.
Value is split either by separator (defaults to comma) or by lines.
:param value:
:param separator: List items separator character.
:rtype: list
| Represents value as a list. | def _parse_list(cls, value, separator=','):
"""Represents value as a list.
Value is split either by separator (defaults to comma) or by lines.
:param value:
:param separator: List items separator character.
:rtype: list
"""
if isinstance(value, list): # _get_pa... | [
"def",
"_parse_list",
"(",
"cls",
",",
"value",
",",
"separator",
"=",
"','",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"# _get_parser_compound case",
"return",
"value",
"if",
"'\\n'",
"in",
"value",
":",
"value",
"=",
"value",
"... | [
238,
4
] | [
255,
66
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._parse_dict | (cls, value) | Represents value as a dict.
:param value:
:rtype: dict
| Represents value as a dict. | def _parse_dict(cls, value):
"""Represents value as a dict.
:param value:
:rtype: dict
"""
separator = '='
result = {}
for line in cls._parse_list(value):
key, sep, val = line.partition(separator)
if sep != separator:
raise... | [
"def",
"_parse_dict",
"(",
"cls",
",",
"value",
")",
":",
"separator",
"=",
"'='",
"result",
"=",
"{",
"}",
"for",
"line",
"in",
"cls",
".",
"_parse_list",
"(",
"value",
")",
":",
"key",
",",
"sep",
",",
"val",
"=",
"line",
".",
"partition",
"(",
... | [
258,
4
] | [
273,
21
] | python | en | ['en', 'ca', 'en'] | True |
ConfigHandler._parse_bool | (cls, value) | Represents value as boolean.
:param value:
:rtype: bool
| Represents value as boolean. | def _parse_bool(cls, value):
"""Represents value as boolean.
:param value:
:rtype: bool
"""
value = value.lower()
return value in ('1', 'true', 'yes') | [
"def",
"_parse_bool",
"(",
"cls",
",",
"value",
")",
":",
"value",
"=",
"value",
".",
"lower",
"(",
")",
"return",
"value",
"in",
"(",
"'1'",
",",
"'true'",
",",
"'yes'",
")"
] | [
276,
4
] | [
283,
44
] | python | en | ['en', 'en', 'en'] | True |
ConfigHandler._exclude_files_parser | (cls, key) | Returns a parser function to make sure field inputs
are not files.
Parses a value after getting the key so error messages are
more informative.
:param key:
:rtype: callable
| Returns a parser function to make sure field inputs
are not files. | def _exclude_files_parser(cls, key):
"""Returns a parser function to make sure field inputs
are not files.
Parses a value after getting the key so error messages are
more informative.
:param key:
:rtype: callable
"""
def parser(value):
exclud... | [
"def",
"_exclude_files_parser",
"(",
"cls",
",",
"key",
")",
":",
"def",
"parser",
"(",
"value",
")",
":",
"exclude_directive",
"=",
"'file:'",
"if",
"value",
".",
"startswith",
"(",
"exclude_directive",
")",
":",
"raise",
"ValueError",
"(",
"'Only strings are... | [
286,
4
] | [
303,
21
] | 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.