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
get_platform
(archive_root)
Return our platform name 'win32', 'linux_x86_64
Return our platform name 'win32', 'linux_x86_64
def get_platform(archive_root): """Return our platform name 'win32', 'linux_x86_64'""" # XXX remove distutils dependency result = distutils.util.get_platform() if result.startswith("macosx") and archive_root is not None: result = calculate_macosx_platform_tag(archive_root, result) result = r...
[ "def", "get_platform", "(", "archive_root", ")", ":", "# XXX remove distutils dependency", "result", "=", "distutils", ".", "util", ".", "get_platform", "(", ")", "if", "result", ".", "startswith", "(", "\"macosx\"", ")", "and", "archive_root", "is", "not", "Non...
[ 174, 0 ]
[ 185, 17 ]
python
en
['fr', 'en', 'en']
True
get_supported
(archive_root, versions=None, supplied_platform=None)
Return a list of supported tags for each version specified in `versions`. :param versions: a list of string versions, of the form ["33", "32"], or None. The first version will be assumed to support our ABI.
Return a list of supported tags for each version specified in `versions`.
def get_supported(archive_root, versions=None, supplied_platform=None): """Return a list of supported tags for each version specified in `versions`. :param versions: a list of string versions, of the form ["33", "32"], or None. The first version will be assumed to support our ABI. """ suppo...
[ "def", "get_supported", "(", "archive_root", ",", "versions", "=", "None", ",", "supplied_platform", "=", "None", ")", ":", "supported", "=", "[", "]", "# Versions must be given with respect to the preference", "if", "versions", "is", "None", ":", "versions", "=", ...
[ 188, 0 ]
[ 260, 20 ]
python
en
['en', 'en', 'en']
True
register
(*models, site=None)
Register the given model(s) classes and wrapped ModelAdmin class with admin site: @register(Author) class AuthorAdmin(admin.ModelAdmin): pass The `site` kwarg is an admin site to use instead of the default admin site.
Register the given model(s) classes and wrapped ModelAdmin class with admin site:
def register(*models, site=None): """ Register the given model(s) classes and wrapped ModelAdmin class with admin site: @register(Author) class AuthorAdmin(admin.ModelAdmin): pass The `site` kwarg is an admin site to use instead of the default admin site. """ from django.contri...
[ "def", "register", "(", "*", "models", ",", "site", "=", "None", ")", ":", "from", "django", ".", "contrib", ".", "admin", "import", "ModelAdmin", "from", "django", ".", "contrib", ".", "admin", ".", "sites", "import", "site", "as", "default_site", ",", ...
[ 0, 0 ]
[ 29, 31 ]
python
en
['en', 'error', 'th']
False
_issubclass
(cls, classinfo)
issubclass() variant that doesn't raise an exception if cls isn't a class.
issubclass() variant that doesn't raise an exception if cls isn't a class.
def _issubclass(cls, classinfo): """ issubclass() variant that doesn't raise an exception if cls isn't a class. """ try: return issubclass(cls, classinfo) except TypeError: return False
[ "def", "_issubclass", "(", "cls", ",", "classinfo", ")", ":", "try", ":", "return", "issubclass", "(", "cls", ",", "classinfo", ")", "except", "TypeError", ":", "return", "False" ]
[ 20, 0 ]
[ 28, 20 ]
python
en
['en', 'error', 'th']
False
_contains_subclass
(class_path, candidate_paths)
Return whether or not a dotted class path (or a subclass of that class) is found in a list of candidate paths.
Return whether or not a dotted class path (or a subclass of that class) is found in a list of candidate paths.
def _contains_subclass(class_path, candidate_paths): """ Return whether or not a dotted class path (or a subclass of that class) is found in a list of candidate paths. """ cls = import_string(class_path) for path in candidate_paths: try: candidate_cls = import_string(path) ...
[ "def", "_contains_subclass", "(", "class_path", ",", "candidate_paths", ")", ":", "cls", "=", "import_string", "(", "class_path", ")", "for", "path", "in", "candidate_paths", ":", "try", ":", "candidate_cls", "=", "import_string", "(", "path", ")", "except", "...
[ 31, 0 ]
[ 45, 16 ]
python
en
['en', 'error', 'th']
False
check_dependencies
(**kwargs)
Check that the admin's dependencies are correctly installed.
Check that the admin's dependencies are correctly installed.
def check_dependencies(**kwargs): """ Check that the admin's dependencies are correctly installed. """ if not apps.is_installed('django.contrib.admin'): return [] errors = [] app_dependencies = ( ('django.contrib.contenttypes', 401), ('django.contrib.auth', 405), ...
[ "def", "check_dependencies", "(", "*", "*", "kwargs", ")", ":", "if", "not", "apps", ".", "is_installed", "(", "'django.contrib.admin'", ")", ":", "return", "[", "]", "errors", "=", "[", "]", "app_dependencies", "=", "(", "(", "'django.contrib.contenttypes'", ...
[ 56, 0 ]
[ 125, 17 ]
python
en
['en', 'error', 'th']
False
BaseModelAdminChecks._check_autocomplete_fields
(self, obj)
Check that `autocomplete_fields` is a list or tuple of model fields.
Check that `autocomplete_fields` is a list or tuple of model fields.
def _check_autocomplete_fields(self, obj): """ Check that `autocomplete_fields` is a list or tuple of model fields. """ if not isinstance(obj.autocomplete_fields, (list, tuple)): return must_be('a list or tuple', option='autocomplete_fields', obj=obj, id='admin.E036') ...
[ "def", "_check_autocomplete_fields", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "autocomplete_fields", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'a...
[ 147, 4 ]
[ 157, 15 ]
python
en
['en', 'error', 'th']
False
BaseModelAdminChecks._check_autocomplete_fields_item
(self, obj, field_name, label)
Check that an item in `autocomplete_fields` is a ForeignKey or a ManyToManyField and that the item has a related ModelAdmin with search_fields defined.
Check that an item in `autocomplete_fields` is a ForeignKey or a ManyToManyField and that the item has a related ModelAdmin with search_fields defined.
def _check_autocomplete_fields_item(self, obj, field_name, label): """ Check that an item in `autocomplete_fields` is a ForeignKey or a ManyToManyField and that the item has a related ModelAdmin with search_fields defined. """ try: field = obj.model._meta.get_...
[ "def", "_check_autocomplete_fields_item", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "try", ":", "field", "=", "obj", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return",...
[ 159, 4 ]
[ 200, 21 ]
python
en
['en', 'error', 'th']
False
BaseModelAdminChecks._check_raw_id_fields
(self, obj)
Check that `raw_id_fields` only contains field names that are listed on the model.
Check that `raw_id_fields` only contains field names that are listed on the model.
def _check_raw_id_fields(self, obj): """ Check that `raw_id_fields` only contains field names that are listed on the model. """ if not isinstance(obj.raw_id_fields, (list, tuple)): return must_be('a list or tuple', option='raw_id_fields', obj=obj, id='admin.E001') else: ...
[ "def", "_check_raw_id_fields", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "raw_id_fields", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'raw_id_fields...
[ 202, 4 ]
[ 212, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_raw_id_fields_item
(self, obj, field_name, label)
Check an item of `raw_id_fields`, i.e. check that field named `field_name` exists in model `model` and is a ForeignKey or a ManyToManyField.
Check an item of `raw_id_fields`, i.e. check that field named `field_name` exists in model `model` and is a ForeignKey or a ManyToManyField.
def _check_raw_id_fields_item(self, obj, field_name, label): """ Check an item of `raw_id_fields`, i.e. check that field named `field_name` exists in model `model` and is a ForeignKey or a ManyToManyField. """ try: field = obj.model._meta.get_field(field_name) except...
[ "def", "_check_raw_id_fields_item", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "try", ":", "field", "=", "obj", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return", "re...
[ 214, 4 ]
[ 227, 25 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_fields
(self, obj)
Check that `fields` only refer to existing fields, doesn't contain duplicates. Check if at most one of `fields` and `fieldsets` is defined.
Check that `fields` only refer to existing fields, doesn't contain duplicates. Check if at most one of `fields` and `fieldsets` is defined.
def _check_fields(self, obj): """ Check that `fields` only refer to existing fields, doesn't contain duplicates. Check if at most one of `fields` and `fieldsets` is defined. """ if obj.fields is None: return [] elif not isinstance(obj.fields, (list, tuple)): ...
[ "def", "_check_fields", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "fields", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "fields", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be"...
[ 229, 4 ]
[ 259, 10 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_fieldsets
(self, obj)
Check that fieldsets is properly formatted and doesn't contain duplicates.
Check that fieldsets is properly formatted and doesn't contain duplicates.
def _check_fieldsets(self, obj): """ Check that fieldsets is properly formatted and doesn't contain duplicates. """ if obj.fieldsets is None: return [] elif not isinstance(obj.fieldsets, (list, tuple)): return must_be('a list or tuple', option='fieldsets', obj=ob...
[ "def", "_check_fieldsets", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "fieldsets", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "fieldsets", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", ...
[ 261, 4 ]
[ 274, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_fieldsets_item
(self, obj, fieldset, label, seen_fields)
Check an item of `fieldsets`, i.e. check that this is a pair of a set name and a dictionary containing "fields" key.
Check an item of `fieldsets`, i.e. check that this is a pair of a set name and a dictionary containing "fields" key.
def _check_fieldsets_item(self, obj, fieldset, label, seen_fields): """ Check an item of `fieldsets`, i.e. check that this is a pair of a set name and a dictionary containing "fields" key. """ if not isinstance(fieldset, (list, tuple)): return must_be('a list or tuple', option=label...
[ "def", "_check_fieldsets_item", "(", "self", ",", "obj", ",", "fieldset", ",", "label", ",", "seen_fields", ")", ":", "if", "not", "isinstance", "(", "fieldset", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ...
[ 276, 4 ]
[ 309, 10 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_field_spec
(self, obj, fields, label)
`fields` should be an item of `fields` or an item of fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a field name or a tuple of field names.
`fields` should be an item of `fields` or an item of fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a field name or a tuple of field names.
def _check_field_spec(self, obj, fields, label): """ `fields` should be an item of `fields` or an item of fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a field name or a tuple of field names. """ if isinstance(fields, tuple): return list(chain.from_it...
[ "def", "_check_field_spec", "(", "self", ",", "obj", ",", "fields", ",", "label", ")", ":", "if", "isinstance", "(", "fields", ",", "tuple", ")", ":", "return", "list", "(", "chain", ".", "from_iterable", "(", "self", ".", "_check_field_spec_item", "(", ...
[ 311, 4 ]
[ 322, 66 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_exclude
(self, obj)
Check that exclude is a sequence without duplicates.
Check that exclude is a sequence without duplicates.
def _check_exclude(self, obj): """ Check that exclude is a sequence without duplicates. """ if obj.exclude is None: # default value is None return [] elif not isinstance(obj.exclude, (list, tuple)): return must_be('a list or tuple', option='exclude', obj=obj, id='admin....
[ "def", "_check_exclude", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "exclude", "is", "None", ":", "# default value is None", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "exclude", ",", "(", "list", ",", "tuple", ")", ")"...
[ 352, 4 ]
[ 368, 21 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_form
(self, obj)
Check that form subclasses BaseModelForm.
Check that form subclasses BaseModelForm.
def _check_form(self, obj): """ Check that form subclasses BaseModelForm. """ if not _issubclass(obj.form, BaseModelForm): return must_inherit_from(parent='BaseModelForm', option='form', obj=obj, id='admin.E016') else: return []
[ "def", "_check_form", "(", "self", ",", "obj", ")", ":", "if", "not", "_issubclass", "(", "obj", ".", "form", ",", "BaseModelForm", ")", ":", "return", "must_inherit_from", "(", "parent", "=", "'BaseModelForm'", ",", "option", "=", "'form'", ",", "obj", ...
[ 370, 4 ]
[ 376, 21 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_filter_vertical
(self, obj)
Check that filter_vertical is a sequence of field names.
Check that filter_vertical is a sequence of field names.
def _check_filter_vertical(self, obj): """ Check that filter_vertical is a sequence of field names. """ if not isinstance(obj.filter_vertical, (list, tuple)): return must_be('a list or tuple', option='filter_vertical', obj=obj, id='admin.E017') else: return list(chain.fro...
[ "def", "_check_filter_vertical", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "filter_vertical", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'filter_ve...
[ 378, 4 ]
[ 386, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_filter_horizontal
(self, obj)
Check that filter_horizontal is a sequence of field names.
Check that filter_horizontal is a sequence of field names.
def _check_filter_horizontal(self, obj): """ Check that filter_horizontal is a sequence of field names. """ if not isinstance(obj.filter_horizontal, (list, tuple)): return must_be('a list or tuple', option='filter_horizontal', obj=obj, id='admin.E018') else: return list(c...
[ "def", "_check_filter_horizontal", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "filter_horizontal", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'filte...
[ 388, 4 ]
[ 396, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_filter_item
(self, obj, field_name, label)
Check one item of `filter_vertical` or `filter_horizontal`, i.e. check that given field exists and is a ManyToManyField.
Check one item of `filter_vertical` or `filter_horizontal`, i.e. check that given field exists and is a ManyToManyField.
def _check_filter_item(self, obj, field_name, label): """ Check one item of `filter_vertical` or `filter_horizontal`, i.e. check that given field exists and is a ManyToManyField. """ try: field = obj.model._meta.get_field(field_name) except FieldDoesNotExist: ret...
[ "def", "_check_filter_item", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "try", ":", "field", "=", "obj", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return", "refer_to_...
[ 398, 4 ]
[ 410, 25 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_radio_fields
(self, obj)
Check that `radio_fields` is a dictionary.
Check that `radio_fields` is a dictionary.
def _check_radio_fields(self, obj): """ Check that `radio_fields` is a dictionary. """ if not isinstance(obj.radio_fields, dict): return must_be('a dictionary', option='radio_fields', obj=obj, id='admin.E021') else: return list(chain.from_iterable( self._c...
[ "def", "_check_radio_fields", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "radio_fields", ",", "dict", ")", ":", "return", "must_be", "(", "'a dictionary'", ",", "option", "=", "'radio_fields'", ",", "obj", "=", "obj", ...
[ 412, 4 ]
[ 421, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_radio_fields_key
(self, obj, field_name, label)
Check that a key of `radio_fields` dictionary is name of existing field and that the field is a ForeignKey or has `choices` defined.
Check that a key of `radio_fields` dictionary is name of existing field and that the field is a ForeignKey or has `choices` defined.
def _check_radio_fields_key(self, obj, field_name, label): """ Check that a key of `radio_fields` dictionary is name of existing field and that the field is a ForeignKey or has `choices` defined. """ try: field = obj.model._meta.get_field(field_name) except FieldDoesNotExist...
[ "def", "_check_radio_fields_key", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "try", ":", "field", "=", "obj", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return", "refe...
[ 423, 4 ]
[ 444, 25 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_radio_fields_value
(self, obj, val, label)
Check type of a value of `radio_fields` dictionary.
Check type of a value of `radio_fields` dictionary.
def _check_radio_fields_value(self, obj, val, label): """ Check type of a value of `radio_fields` dictionary. """ from django.contrib.admin.options import HORIZONTAL, VERTICAL if val not in (HORIZONTAL, VERTICAL): return [ checks.Error( "The valu...
[ "def", "_check_radio_fields_value", "(", "self", ",", "obj", ",", "val", ",", "label", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "options", "import", "HORIZONTAL", ",", "VERTICAL", "if", "val", "not", "in", "(", "HORIZONTAL", ",", "V...
[ 446, 4 ]
[ 460, 21 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_prepopulated_fields
(self, obj)
Check that `prepopulated_fields` is a dictionary containing allowed field types.
Check that `prepopulated_fields` is a dictionary containing allowed field types.
def _check_prepopulated_fields(self, obj): """ Check that `prepopulated_fields` is a dictionary containing allowed field types. """ if not isinstance(obj.prepopulated_fields, dict): return must_be('a dictionary', option='prepopulated_fields', obj=obj, id='admin.E026') else: ...
[ "def", "_check_prepopulated_fields", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "prepopulated_fields", ",", "dict", ")", ":", "return", "must_be", "(", "'a dictionary'", ",", "option", "=", "'prepopulated_fields'", ",", "obj...
[ 474, 4 ]
[ 484, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_prepopulated_fields_key
(self, obj, field_name, label)
Check a key of `prepopulated_fields` dictionary, i.e. check that it is a name of existing field and the field is one of the allowed types.
Check a key of `prepopulated_fields` dictionary, i.e. check that it is a name of existing field and the field is one of the allowed types.
def _check_prepopulated_fields_key(self, obj, field_name, label): """ Check a key of `prepopulated_fields` dictionary, i.e. check that it is a name of existing field and the field is one of the allowed types. """ try: field = obj.model._meta.get_field(field_name) exc...
[ "def", "_check_prepopulated_fields_key", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "try", ":", "field", "=", "obj", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return", ...
[ 486, 4 ]
[ 506, 25 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_prepopulated_fields_value
(self, obj, val, label)
Check a value of `prepopulated_fields` dictionary, i.e. it's an iterable of existing fields.
Check a value of `prepopulated_fields` dictionary, i.e. it's an iterable of existing fields.
def _check_prepopulated_fields_value(self, obj, val, label): """ Check a value of `prepopulated_fields` dictionary, i.e. it's an iterable of existing fields. """ if not isinstance(val, (list, tuple)): return must_be('a list or tuple', option=label, obj=obj, id='admin.E029') ...
[ "def", "_check_prepopulated_fields_value", "(", "self", ",", "obj", ",", "val", ",", "label", ")", ":", "if", "not", "isinstance", "(", "val", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=...
[ 508, 4 ]
[ 518, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_prepopulated_fields_value_item
(self, obj, field_name, label)
For `prepopulated_fields` equal to {"slug": ("title",)}, `field_name` is "title".
For `prepopulated_fields` equal to {"slug": ("title",)}, `field_name` is "title".
def _check_prepopulated_fields_value_item(self, obj, field_name, label): """ For `prepopulated_fields` equal to {"slug": ("title",)}, `field_name` is "title". """ try: obj.model._meta.get_field(field_name) except FieldDoesNotExist: return refer_to_missing_field(f...
[ "def", "_check_prepopulated_fields_value_item", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "try", ":", "obj", ".", "model", ".", "_meta", ".", "get_field", "(", "field_name", ")", "except", "FieldDoesNotExist", ":", "return", "refer_to...
[ 520, 4 ]
[ 529, 21 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_ordering
(self, obj)
Check that ordering refers to existing fields or is random.
Check that ordering refers to existing fields or is random.
def _check_ordering(self, obj): """ Check that ordering refers to existing fields or is random. """ # ordering = None if obj.ordering is None: # The default value is None return [] elif not isinstance(obj.ordering, (list, tuple)): return must_be('a list or tuple...
[ "def", "_check_ordering", "(", "self", ",", "obj", ")", ":", "# ordering = None", "if", "obj", ".", "ordering", "is", "None", ":", "# The default value is None", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "ordering", ",", "(", "list", ...
[ 531, 4 ]
[ 543, 14 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_ordering_item
(self, obj, field_name, label)
Check that `ordering` refers to existing fields.
Check that `ordering` refers to existing fields.
def _check_ordering_item(self, obj, field_name, label): """ Check that `ordering` refers to existing fields. """ if isinstance(field_name, (Combinable, OrderBy)): if not isinstance(field_name, OrderBy): field_name = field_name.asc() if isinstance(field_name.expres...
[ "def", "_check_ordering_item", "(", "self", ",", "obj", ",", "field_name", ",", "label", ")", ":", "if", "isinstance", "(", "field_name", ",", "(", "Combinable", ",", "OrderBy", ")", ")", ":", "if", "not", "isinstance", "(", "field_name", ",", "OrderBy", ...
[ 545, 4 ]
[ 580, 25 ]
python
en
['en', 'en', 'en']
True
BaseModelAdminChecks._check_readonly_fields
(self, obj)
Check that readonly_fields refers to proper attribute or field.
Check that readonly_fields refers to proper attribute or field.
def _check_readonly_fields(self, obj): """ Check that readonly_fields refers to proper attribute or field. """ if obj.readonly_fields == (): return [] elif not isinstance(obj.readonly_fields, (list, tuple)): return must_be('a list or tuple', option='readonly_fields', obj...
[ "def", "_check_readonly_fields", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "readonly_fields", "==", "(", ")", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "readonly_fields", ",", "(", "list", ",", "tuple", ")", ")",...
[ 582, 4 ]
[ 593, 14 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_save_as
(self, obj)
Check save_as is a boolean.
Check save_as is a boolean.
def _check_save_as(self, obj): """ Check save_as is a boolean. """ if not isinstance(obj.save_as, bool): return must_be('a boolean', option='save_as', obj=obj, id='admin.E101') else: return []
[ "def", "_check_save_as", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "save_as", ",", "bool", ")", ":", "return", "must_be", "(", "'a boolean'", ",", "option", "=", "'save_as'", ",", "obj", "=", "obj", ",", "id", "="...
[ 640, 4 ]
[ 647, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_save_on_top
(self, obj)
Check save_on_top is a boolean.
Check save_on_top is a boolean.
def _check_save_on_top(self, obj): """ Check save_on_top is a boolean. """ if not isinstance(obj.save_on_top, bool): return must_be('a boolean', option='save_on_top', obj=obj, id='admin.E102') else: return []
[ "def", "_check_save_on_top", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "save_on_top", ",", "bool", ")", ":", "return", "must_be", "(", "'a boolean'", ",", "option", "=", "'save_on_top'", ",", "obj", "=", "obj", ",", ...
[ 649, 4 ]
[ 656, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_inlines
(self, obj)
Check all inline model admin classes.
Check all inline model admin classes.
def _check_inlines(self, obj): """ Check all inline model admin classes. """ if not isinstance(obj.inlines, (list, tuple)): return must_be('a list or tuple', option='inlines', obj=obj, id='admin.E103') else: return list(chain.from_iterable( self._check_in...
[ "def", "_check_inlines", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "inlines", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'inlines'", ",", "obj"...
[ 658, 4 ]
[ 667, 14 ]
python
en
['sv', 'it', 'en']
False
ModelAdminChecks._check_inlines_item
(self, obj, inline, label)
Check one inline model admin.
Check one inline model admin.
def _check_inlines_item(self, obj, inline, label): """ Check one inline model admin. """ try: inline_label = inline.__module__ + '.' + inline.__name__ except AttributeError: return [ checks.Error( "'%s' must inherit from 'InlineModelAdm...
[ "def", "_check_inlines_item", "(", "self", ",", "obj", ",", "inline", ",", "label", ")", ":", "try", ":", "inline_label", "=", "inline", ".", "__module__", "+", "'.'", "+", "inline", ".", "__name__", "except", "AttributeError", ":", "return", "[", "checks"...
[ 669, 4 ]
[ 703, 60 ]
python
en
['es', 'en', 'en']
True
ModelAdminChecks._check_list_display
(self, obj)
Check that list_display only contains fields or usable attributes.
Check that list_display only contains fields or usable attributes.
def _check_list_display(self, obj): """ Check that list_display only contains fields or usable attributes. """ if not isinstance(obj.list_display, (list, tuple)): return must_be('a list or tuple', option='list_display', obj=obj, id='admin.E107') else: return list...
[ "def", "_check_list_display", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_display", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'list_display'",...
[ 705, 4 ]
[ 715, 14 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_display_links
(self, obj)
Check that list_display_links is a unique subset of list_display.
Check that list_display_links is a unique subset of list_display.
def _check_list_display_links(self, obj): """ Check that list_display_links is a unique subset of list_display. """ from django.contrib.admin.options import ModelAdmin if obj.list_display_links is None: return [] elif not isinstance(obj.list_display_links, (list, tup...
[ "def", "_check_list_display_links", "(", "self", ",", "obj", ")", ":", "from", "django", ".", "contrib", ".", "admin", ".", "options", "import", "ModelAdmin", "if", "obj", ".", "list_display_links", "is", "None", ":", "return", "[", "]", "elif", "not", "is...
[ 750, 4 ]
[ 765, 17 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_filter_item
(self, obj, item, label)
Check one item of `list_filter`, i.e. check if it is one of three options: 1. 'field' -- a basic field filter, possibly w/ relationships (e.g. 'field__rel') 2. ('field', SomeFieldListFilter) - a field-based list filter class 3. SomeListFilter - a non-field list filter class ...
Check one item of `list_filter`, i.e. check if it is one of three options: 1. 'field' -- a basic field filter, possibly w/ relationships (e.g. 'field__rel') 2. ('field', SomeFieldListFilter) - a field-based list filter class 3. SomeListFilter - a non-field list filter class ...
def _check_list_filter_item(self, obj, item, label): """ Check one item of `list_filter`, i.e. check if it is one of three options: 1. 'field' -- a basic field filter, possibly w/ relationships (e.g. 'field__rel') 2. ('field', SomeFieldListFilter) - a field-based list filter c...
[ "def", "_check_list_filter_item", "(", "self", ",", "obj", ",", "item", ",", "label", ")", ":", "from", "django", ".", "contrib", ".", "admin", "import", "ListFilter", ",", "FieldListFilter", "if", "callable", "(", "item", ")", "and", "not", "isinstance", ...
[ 790, 4 ]
[ 840, 25 ]
python
en
['en', 'error', 'th']
False
ModelAdminChecks._check_list_select_related
(self, obj)
Check that list_select_related is a boolean, a list or a tuple.
Check that list_select_related is a boolean, a list or a tuple.
def _check_list_select_related(self, obj): """ Check that list_select_related is a boolean, a list or a tuple. """ if not isinstance(obj.list_select_related, (bool, list, tuple)): return must_be('a boolean, tuple or list', option='list_select_related', obj=obj, id='admin.E117') else...
[ "def", "_check_list_select_related", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_select_related", ",", "(", "bool", ",", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a boolean, tuple or list'", ","...
[ 842, 4 ]
[ 848, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_per_page
(self, obj)
Check that list_per_page is an integer.
Check that list_per_page is an integer.
def _check_list_per_page(self, obj): """ Check that list_per_page is an integer. """ if not isinstance(obj.list_per_page, int): return must_be('an integer', option='list_per_page', obj=obj, id='admin.E118') else: return []
[ "def", "_check_list_per_page", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_per_page", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", ",", "option", "=", "'list_per_page'", ",", "obj", "=", "obj", ...
[ 850, 4 ]
[ 856, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_max_show_all
(self, obj)
Check that list_max_show_all is an integer.
Check that list_max_show_all is an integer.
def _check_list_max_show_all(self, obj): """ Check that list_max_show_all is an integer. """ if not isinstance(obj.list_max_show_all, int): return must_be('an integer', option='list_max_show_all', obj=obj, id='admin.E119') else: return []
[ "def", "_check_list_max_show_all", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_max_show_all", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", ",", "option", "=", "'list_max_show_all'", ",", "obj", "=",...
[ 858, 4 ]
[ 864, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_list_editable
(self, obj)
Check that list_editable is a sequence of editable fields from list_display without first element.
Check that list_editable is a sequence of editable fields from list_display without first element.
def _check_list_editable(self, obj): """ Check that list_editable is a sequence of editable fields from list_display without first element. """ if not isinstance(obj.list_editable, (list, tuple)): return must_be('a list or tuple', option='list_editable', obj=obj, id='admin.E120') ...
[ "def", "_check_list_editable", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "list_editable", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'list_editable...
[ 866, 4 ]
[ 876, 14 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_search_fields
(self, obj)
Check search_fields is a sequence.
Check search_fields is a sequence.
def _check_search_fields(self, obj): """ Check search_fields is a sequence. """ if not isinstance(obj.search_fields, (list, tuple)): return must_be('a list or tuple', option='search_fields', obj=obj, id='admin.E126') else: return []
[ "def", "_check_search_fields", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "search_fields", ",", "(", "list", ",", "tuple", ")", ")", ":", "return", "must_be", "(", "'a list or tuple'", ",", "option", "=", "'search_fields...
[ 928, 4 ]
[ 934, 21 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_date_hierarchy
(self, obj)
Check that date_hierarchy refers to DateField or DateTimeField.
Check that date_hierarchy refers to DateField or DateTimeField.
def _check_date_hierarchy(self, obj): """ Check that date_hierarchy refers to DateField or DateTimeField. """ if obj.date_hierarchy is None: return [] else: try: field = get_fields_from_path(obj.model, obj.date_hierarchy)[-1] except (NotRelati...
[ "def", "_check_date_hierarchy", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "date_hierarchy", "is", "None", ":", "return", "[", "]", "else", ":", "try", ":", "field", "=", "get_fields_from_path", "(", "obj", ".", "model", ",", "obj", ".", "dat...
[ 936, 4 ]
[ 957, 29 ]
python
en
['en', 'en', 'en']
True
ModelAdminChecks._check_action_permission_methods
(self, obj)
Actions with an allowed_permission attribute require the ModelAdmin to implement a has_<perm>_permission() method for each permission.
Actions with an allowed_permission attribute require the ModelAdmin to implement a has_<perm>_permission() method for each permission.
def _check_action_permission_methods(self, obj): """ Actions with an allowed_permission attribute require the ModelAdmin to implement a has_<perm>_permission() method for each permission. """ actions = obj._get_base_actions() errors = [] for func, name, _ in actio...
[ "def", "_check_action_permission_methods", "(", "self", ",", "obj", ")", ":", "actions", "=", "obj", ".", "_get_base_actions", "(", ")", "errors", "=", "[", "]", "for", "func", ",", "name", ",", "_", "in", "actions", ":", "if", "not", "hasattr", "(", "...
[ 959, 4 ]
[ 983, 21 ]
python
en
['en', 'error', 'th']
False
ModelAdminChecks._check_actions_uniqueness
(self, obj)
Check that every action has a unique __name__.
Check that every action has a unique __name__.
def _check_actions_uniqueness(self, obj): """Check that every action has a unique __name__.""" names = [name for _, name, _ in obj._get_base_actions()] if len(names) != len(set(names)): return [checks.Error( '__name__ attributes of actions defined in %s must be ' ...
[ "def", "_check_actions_uniqueness", "(", "self", ",", "obj", ")", ":", "names", "=", "[", "name", "for", "_", ",", "name", ",", "_", "in", "obj", ".", "_get_base_actions", "(", ")", "]", "if", "len", "(", "names", ")", "!=", "len", "(", "set", "(",...
[ 985, 4 ]
[ 995, 17 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_extra
(self, obj)
Check that extra is an integer.
Check that extra is an integer.
def _check_extra(self, obj): """ Check that extra is an integer. """ if not isinstance(obj.extra, int): return must_be('an integer', option='extra', obj=obj, id='admin.E203') else: return []
[ "def", "_check_extra", "(", "self", ",", "obj", ")", ":", "if", "not", "isinstance", "(", "obj", ".", "extra", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", ",", "option", "=", "'extra'", ",", "obj", "=", "obj", ",", "id", "=", "'...
[ 1049, 4 ]
[ 1055, 21 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_max_num
(self, obj)
Check that max_num is an integer.
Check that max_num is an integer.
def _check_max_num(self, obj): """ Check that max_num is an integer. """ if obj.max_num is None: return [] elif not isinstance(obj.max_num, int): return must_be('an integer', option='max_num', obj=obj, id='admin.E204') else: return []
[ "def", "_check_max_num", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "max_num", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "max_num", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", "...
[ 1057, 4 ]
[ 1065, 21 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_min_num
(self, obj)
Check that min_num is an integer.
Check that min_num is an integer.
def _check_min_num(self, obj): """ Check that min_num is an integer. """ if obj.min_num is None: return [] elif not isinstance(obj.min_num, int): return must_be('an integer', option='min_num', obj=obj, id='admin.E205') else: return []
[ "def", "_check_min_num", "(", "self", ",", "obj", ")", ":", "if", "obj", ".", "min_num", "is", "None", ":", "return", "[", "]", "elif", "not", "isinstance", "(", "obj", ".", "min_num", ",", "int", ")", ":", "return", "must_be", "(", "'an integer'", "...
[ 1067, 4 ]
[ 1075, 21 ]
python
en
['en', 'en', 'en']
True
InlineModelAdminChecks._check_formset
(self, obj)
Check formset is a subclass of BaseModelFormSet.
Check formset is a subclass of BaseModelFormSet.
def _check_formset(self, obj): """ Check formset is a subclass of BaseModelFormSet. """ if not _issubclass(obj.formset, BaseModelFormSet): return must_inherit_from(parent='BaseModelFormSet', option='formset', obj=obj, id='admin.E206') else: return []
[ "def", "_check_formset", "(", "self", ",", "obj", ")", ":", "if", "not", "_issubclass", "(", "obj", ".", "formset", ",", "BaseModelFormSet", ")", ":", "return", "must_inherit_from", "(", "parent", "=", "'BaseModelFormSet'", ",", "option", "=", "'formset'", "...
[ 1077, 4 ]
[ 1083, 21 ]
python
en
['en', 'en', 'en']
True
open
(fp, mode="r")
Load texture from a GD image file. :param filename: GD file name, or an opened file handle. :param mode: Optional mode. In this version, if the mode argument is given, it must be "r". :returns: An image instance. :raises OSError: If the image could not be read.
Load texture from a GD image file.
def open(fp, mode="r"): """ Load texture from a GD image file. :param filename: GD file name, or an opened file handle. :param mode: Optional mode. In this version, if the mode argument is given, it must be "r". :returns: An image instance. :raises OSError: If the image could not be re...
[ "def", "open", "(", "fp", ",", "mode", "=", "\"r\"", ")", ":", "if", "mode", "!=", "\"r\"", ":", "raise", "ValueError", "(", "\"bad mode\"", ")", "try", ":", "return", "GdImageFile", "(", "fp", ")", "except", "SyntaxError", "as", "e", ":", "raise", "...
[ 72, 0 ]
[ 88, 78 ]
python
en
['en', 'error', 'th']
False
OracleSpatialAdapter.__init__
(self, geom)
Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise
Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise
def __init__(self, geom): """ Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise """ ...
[ "def", "__init__", "(", "self", ",", "geom", ")", ":", "if", "isinstance", "(", "geom", ",", "Polygon", ")", ":", "self", ".", "_fix_polygon", "(", "geom", ")", "elif", "isinstance", "(", "geom", ",", "GeometryCollection", ")", ":", "self", ".", "_fix_...
[ 9, 4 ]
[ 23, 29 ]
python
en
['en', 'error', 'th']
False
OracleSpatialAdapter._fix_polygon
(self, poly)
Fix single polygon orientation as described in __init__().
Fix single polygon orientation as described in __init__().
def _fix_polygon(self, poly): """Fix single polygon orientation as described in __init__().""" if self._isClockwise(poly.exterior_ring): poly.exterior_ring = list(reversed(poly.exterior_ring)) for i in range(1, len(poly)): if not self._isClockwise(poly[i]): ...
[ "def", "_fix_polygon", "(", "self", ",", "poly", ")", ":", "if", "self", ".", "_isClockwise", "(", "poly", ".", "exterior_ring", ")", ":", "poly", ".", "exterior_ring", "=", "list", "(", "reversed", "(", "poly", ".", "exterior_ring", ")", ")", "for", "...
[ 25, 4 ]
[ 34, 19 ]
python
en
['en', 'es', 'en']
True
OracleSpatialAdapter._fix_geometry_collection
(self, coll)
Fix polygon orientations in geometry collections as described in __init__().
Fix polygon orientations in geometry collections as described in __init__().
def _fix_geometry_collection(self, coll): """ Fix polygon orientations in geometry collections as described in __init__(). """ for i, geom in enumerate(coll): if isinstance(geom, Polygon): coll[i] = self._fix_polygon(geom)
[ "def", "_fix_geometry_collection", "(", "self", ",", "coll", ")", ":", "for", "i", ",", "geom", "in", "enumerate", "(", "coll", ")", ":", "if", "isinstance", "(", "geom", ",", "Polygon", ")", ":", "coll", "[", "i", "]", "=", "self", ".", "_fix_polygo...
[ 36, 4 ]
[ 43, 49 ]
python
en
['en', 'error', 'th']
False
OracleSpatialAdapter._isClockwise
(self, coords)
A modified shoelace algorithm to determine polygon orientation. See https://en.wikipedia.org/wiki/Shoelace_formula.
A modified shoelace algorithm to determine polygon orientation. See https://en.wikipedia.org/wiki/Shoelace_formula.
def _isClockwise(self, coords): """ A modified shoelace algorithm to determine polygon orientation. See https://en.wikipedia.org/wiki/Shoelace_formula. """ n = len(coords) area = 0.0 for i in range(n): j = (i + 1) % n area += coords[i][0] *...
[ "def", "_isClockwise", "(", "self", ",", "coords", ")", ":", "n", "=", "len", "(", "coords", ")", "area", "=", "0.0", "for", "i", "in", "range", "(", "n", ")", ":", "j", "=", "(", "i", "+", "1", ")", "%", "n", "area", "+=", "coords", "[", "...
[ 45, 4 ]
[ 56, 25 ]
python
en
['en', 'error', 'th']
False
email_is_not_mit_mailing_list
(email: str)
Prevent MIT mailing lists from signing up for Zulip
Prevent MIT mailing lists from signing up for Zulip
def email_is_not_mit_mailing_list(email: str) -> None: """Prevent MIT mailing lists from signing up for Zulip""" if "@mit.edu" in email: username = email.rsplit("@", 1)[0] # Check whether the user exists and can get mail. try: DNS.dnslookup(f"{username}.pobox.ns.athena.mit.ed...
[ "def", "email_is_not_mit_mailing_list", "(", "email", ":", "str", ")", "->", "None", ":", "if", "\"@mit.edu\"", "in", "email", ":", "username", "=", "email", ".", "rsplit", "(", "\"@\"", ",", "1", ")", "[", "0", "]", "# Check whether the user exists and can ge...
[ 63, 0 ]
[ 74, 60 ]
python
en
['en', 'en', 'en']
True
HomepageForm.clean_email
(self)
Returns the email if and only if the user's email address is allowed to join the realm they are trying to join.
Returns the email if and only if the user's email address is allowed to join the realm they are trying to join.
def clean_email(self) -> str: """Returns the email if and only if the user's email address is allowed to join the realm they are trying to join.""" email = self.cleaned_data["email"] # Otherwise, the user is trying to join a specific realm. realm = self.realm from_multiu...
[ "def", "clean_email", "(", "self", ")", "->", "str", ":", "email", "=", "self", ".", "cleaned_data", "[", "\"email\"", "]", "# Otherwise, the user is trying to join a specific realm.", "realm", "=", "self", ".", "realm", "from_multiuse_invite", "=", "self", ".", "...
[ 162, 4 ]
[ 206, 20 ]
python
en
['en', 'en', 'en']
True
ZulipPasswordResetForm.save
( self, domain_override: Optional[bool] = None, subject_template_name: str = "registration/password_reset_subject.txt", email_template_name: str = "registration/password_reset_email.html", use_https: bool = False, token_generator: PasswordResetTokenGenerator = default_tok...
If the email address has an account in the target realm, generates a one-use only link for resetting password and sends to the user. We send a different email if an associated account does not exist in the database, or an account does exist, but not in the realm. Note:...
If the email address has an account in the target realm, generates a one-use only link for resetting password and sends to the user.
def save( self, domain_override: Optional[bool] = None, subject_template_name: str = "registration/password_reset_subject.txt", email_template_name: str = "registration/password_reset_email.html", use_https: bool = False, token_generator: PasswordResetTokenGenerator = def...
[ "def", "save", "(", "self", ",", "domain_override", ":", "Optional", "[", "bool", "]", "=", "None", ",", "subject_template_name", ":", "str", "=", "\"registration/password_reset_subject.txt\"", ",", "email_template_name", ":", "str", "=", "\"registration/password_rese...
[ 258, 4 ]
[ 350, 13 ]
python
en
['en', 'error', 'th']
False
OurAuthenticationForm.add_prefix
(self, field_name: str)
Disable prefix, since Zulip doesn't use this Django forms feature (and django-two-factor does use it), and we'd like both to be happy with this form.
Disable prefix, since Zulip doesn't use this Django forms feature (and django-two-factor does use it), and we'd like both to be happy with this form.
def add_prefix(self, field_name: str) -> str: """Disable prefix, since Zulip doesn't use this Django forms feature (and django-two-factor does use it), and we'd like both to be happy with this form. """ return field_name
[ "def", "add_prefix", "(", "self", ",", "field_name", ":", "str", ")", "->", "str", ":", "return", "field_name" ]
[ 425, 4 ]
[ 430, 25 ]
python
en
['en', 'en', 'en']
True
MultiEmailField.to_python
(self, emails: str)
Normalize data to a list of strings.
Normalize data to a list of strings.
def to_python(self, emails: str) -> List[str]: """Normalize data to a list of strings.""" if not emails: return [] return [email.strip() for email in emails.split(",")]
[ "def", "to_python", "(", "self", ",", "emails", ":", "str", ")", "->", "List", "[", "str", "]", ":", "if", "not", "emails", ":", "return", "[", "]", "return", "[", "email", ".", "strip", "(", ")", "for", "email", "in", "emails", ".", "split", "("...
[ 446, 4 ]
[ 451, 61 ]
python
en
['en', 'en', 'en']
True
MultiEmailField.validate
(self, emails: List[str])
Check if value consists only of valid emails.
Check if value consists only of valid emails.
def validate(self, emails: List[str]) -> None: """Check if value consists only of valid emails.""" super().validate(emails) for email in emails: validate_email(email)
[ "def", "validate", "(", "self", ",", "emails", ":", "List", "[", "str", "]", ")", "->", "None", ":", "super", "(", ")", ".", "validate", "(", "emails", ")", "for", "email", "in", "emails", ":", "validate_email", "(", "email", ")" ]
[ 453, 4 ]
[ 457, 33 ]
python
en
['en', 'en', 'en']
True
HttpResponseBase.serialize_headers
(self)
HTTP headers as a bytestring.
HTTP headers as a bytestring.
def serialize_headers(self): """HTTP headers as a bytestring.""" def to_bytes(val, encoding): return val if isinstance(val, bytes) else val.encode(encoding) headers = [ (b': '.join([to_bytes(key, 'ascii'), to_bytes(value, 'latin-1')])) for key, value in self....
[ "def", "serialize_headers", "(", "self", ")", ":", "def", "to_bytes", "(", "val", ",", "encoding", ")", ":", "return", "val", "if", "isinstance", "(", "val", ",", "bytes", ")", "else", "val", ".", "encode", "(", "encoding", ")", "headers", "=", "[", ...
[ 142, 4 ]
[ 151, 36 ]
python
en
['en', 'sv', 'en']
True
HttpResponseBase._convert_to_charset
(self, value, charset, mime_encode=False)
Converts headers key/value to ascii/latin-1 native strings. `charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and `value` can't be represented in the given charset, MIME-encoding is applied.
Converts headers key/value to ascii/latin-1 native strings.
def _convert_to_charset(self, value, charset, mime_encode=False): """Converts headers key/value to ascii/latin-1 native strings. `charset` must be 'ascii' or 'latin-1'. If `mime_encode` is True and `value` can't be represented in the given charset, MIME-encoding is applied. """ ...
[ "def", "_convert_to_charset", "(", "self", ",", "value", ",", "charset", ",", "mime_encode", "=", "False", ")", ":", "if", "not", "isinstance", "(", "value", ",", "(", "bytes", ",", "six", ".", "text_type", ")", ")", ":", "value", "=", "str", "(", "v...
[ 158, 4 ]
[ 191, 20 ]
python
en
['en', 'en', 'en']
True
HttpResponseBase.has_header
(self, header)
Case-insensitive check for a header.
Case-insensitive check for a header.
def has_header(self, header): """Case-insensitive check for a header.""" return header.lower() in self._headers
[ "def", "has_header", "(", "self", ",", "header", ")", ":", "return", "header", ".", "lower", "(", ")", "in", "self", ".", "_headers" ]
[ 218, 4 ]
[ 220, 46 ]
python
en
['en', 'en', 'en']
True
HttpResponseBase.set_cookie
(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False)
Sets a cookie. ``expires`` can be: - a string in the correct format, - a naive ``datetime.datetime`` object in UTC, - an aware ``datetime.datetime`` object in any time zone. If it is a ``datetime.datetime`` object then ``max_age`` will be calculated.
Sets a cookie.
def set_cookie(self, key, value='', max_age=None, expires=None, path='/', domain=None, secure=False, httponly=False): """ Sets a cookie. ``expires`` can be: - a string in the correct format, - a naive ``datetime.datetime`` object in UTC, - an aware ``d...
[ "def", "set_cookie", "(", "self", ",", "key", ",", "value", "=", "''", ",", "max_age", "=", "None", ",", "expires", "=", "None", ",", "path", "=", "'/'", ",", "domain", "=", "None", ",", "secure", "=", "False", ",", "httponly", "=", "False", ")", ...
[ 230, 4 ]
[ 271, 48 ]
python
en
['en', 'error', 'th']
False
HttpResponseBase.make_bytes
(self, value)
Turn a value into a bytestring encoded in the output charset.
Turn a value into a bytestring encoded in the output charset.
def make_bytes(self, value): """Turn a value into a bytestring encoded in the output charset.""" # Per PEP 3333, this response body must be bytes. To avoid returning # an instance of a subclass, this function returns `bytes(value)`. # This doesn't make a copy when `value` already contain...
[ "def", "make_bytes", "(", "self", ",", "value", ")", ":", "# Per PEP 3333, this response body must be bytes. To avoid returning", "# an instance of a subclass, this function returns `bytes(value)`.", "# This doesn't make a copy when `value` already contains bytes.", "# If content is already en...
[ 283, 4 ]
[ 302, 47 ]
python
en
['en', 'en', 'en']
True
HttpResponse.serialize
(self)
Full HTTP message, including headers, as a bytestring.
Full HTTP message, including headers, as a bytestring.
def serialize(self): """Full HTTP message, including headers, as a bytestring.""" return self.serialize_headers() + b'\r\n\r\n' + self.content
[ "def", "serialize", "(", "self", ")", ":", "return", "self", ".", "serialize_headers", "(", ")", "+", "b'\\r\\n\\r\\n'", "+", "self", ".", "content" ]
[ 341, 4 ]
[ 343, 68 ]
python
en
['en', 'en', 'en']
True
default_types
()
We use our own set of default media types rather than the system-supplied ones. This ensures consistent media type behaviour across varied environments. The defaults are based on those shipped with nginx, with some custom additions.
We use our own set of default media types rather than the system-supplied ones. This ensures consistent media type behaviour across varied environments. The defaults are based on those shipped with nginx, with some custom additions.
def default_types(): """ We use our own set of default media types rather than the system-supplied ones. This ensures consistent media type behaviour across varied environments. The defaults are based on those shipped with nginx, with some custom additions. """ return { ".3gp": "vi...
[ "def", "default_types", "(", ")", ":", "return", "{", "\".3gp\"", ":", "\"video/3gpp\"", ",", "\".3gpp\"", ":", "\"video/3gpp\"", ",", "\".7z\"", ":", "\"application/x-7z-compressed\"", ",", "\".ai\"", ":", "\"application/postscript\"", ",", "\".asf\"", ":", "\"vide...
[ 19, 0 ]
[ 127, 5 ]
python
en
['en', 'error', 'th']
False
PostGISGeometryColumns.table_name_col
(cls)
Return the name of the metadata column used to store the feature table name.
Return the name of the metadata column used to store the feature table name.
def table_name_col(cls): """ Return the name of the metadata column used to store the feature table name. """ return 'f_table_name'
[ "def", "table_name_col", "(", "cls", ")", ":", "return", "'f_table_name'" ]
[ 35, 4 ]
[ 40, 29 ]
python
en
['en', 'error', 'th']
False
PostGISGeometryColumns.geom_col_name
(cls)
Return the name of the metadata column used to store the feature geometry column.
Return the name of the metadata column used to store the feature geometry column.
def geom_col_name(cls): """ Return the name of the metadata column used to store the feature geometry column. """ return 'f_geometry_column'
[ "def", "geom_col_name", "(", "cls", ")", ":", "return", "'f_geometry_column'" ]
[ 43, 4 ]
[ 48, 34 ]
python
en
['en', 'error', 'th']
False
AdminNotifyHandlerTest.test_basic
(self, mock_function: MagicMock)
A random exception passes happily through AdminNotifyHandler
A random exception passes happily through AdminNotifyHandler
def test_basic(self, mock_function: MagicMock) -> None: mock_function.return_value = None """A random exception passes happily through AdminNotifyHandler""" handler = self.get_admin_zulip_handler() try: raise Exception("Testing error!") except Exception: e...
[ "def", "test_basic", "(", "self", ",", "mock_function", ":", "MagicMock", ")", "->", "None", ":", "mock_function", ".", "return_value", "=", "None", "handler", "=", "self", ".", "get_admin_zulip_handler", "(", ")", "try", ":", "raise", "Exception", "(", "\"T...
[ 64, 4 ]
[ 75, 28 ]
python
en
['en', 'en', 'en']
True
AdminNotifyHandlerTest.test_long_exception_request
(self, mock_function: MagicMock)
A request with no stack and multi-line report.getMessage() is handled properly
A request with no stack and multi-line report.getMessage() is handled properly
def test_long_exception_request(self, mock_function: MagicMock) -> None: mock_function.return_value = None """A request with no stack and multi-line report.getMessage() is handled properly""" record = self.simulate_error() record.exc_info = None record.msg = "message\nmoremesssag...
[ "def", "test_long_exception_request", "(", "self", ",", "mock_function", ":", "MagicMock", ")", "->", "None", ":", "mock_function", ".", "return_value", "=", "None", "record", "=", "self", ".", "simulate_error", "(", ")", "record", ".", "exc_info", "=", "None"...
[ 116, 4 ]
[ 130, 54 ]
python
en
['en', 'en', 'en']
True
AdminNotifyHandlerTest.test_request
(self, mock_function: MagicMock)
A normal request is handled properly
A normal request is handled properly
def test_request(self, mock_function: MagicMock) -> None: mock_function.return_value = None """A normal request is handled properly""" record = self.simulate_error() assert isinstance(record, HasRequest) report = self.run_handler(record) self.assertIn("user", report) ...
[ "def", "test_request", "(", "self", ",", "mock_function", ":", "MagicMock", ")", "->", "None", ":", "mock_function", ".", "return_value", "=", "None", "record", "=", "self", ".", "simulate_error", "(", ")", "assert", "isinstance", "(", "record", ",", "HasReq...
[ 133, 4 ]
[ 237, 44 ]
python
en
['en', 'en', 'en']
True
default_filter
(src, dst)
The default progress/filter callback; returns True for all files
The default progress/filter callback; returns True for all files
def default_filter(src, dst): """The default progress/filter callback; returns True for all files""" return dst
[ "def", "default_filter", "(", "src", ",", "dst", ")", ":", "return", "dst" ]
[ 22, 0 ]
[ 24, 14 ]
python
en
['en', 'sv', 'en']
True
unpack_archive
( filename, extract_dir, progress_filter=default_filter, drivers=None)
Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path where it will be extracted. The callback must return the desired extract path (which may be the same as...
Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat``
def unpack_archive( filename, extract_dir, progress_filter=default_filter, drivers=None): """Unpack `filename` to `extract_dir`, or raise ``UnrecognizedFormat`` `progress_filter` is a function taking two arguments: a source path internal to the archive ('/'-separated), and a filesystem path...
[ "def", "unpack_archive", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ",", "drivers", "=", "None", ")", ":", "for", "driver", "in", "drivers", "or", "extraction_drivers", ":", "try", ":", "driver", "(", "filename", ",", ...
[ 27, 0 ]
[ 60, 9 ]
python
en
['en', 'la', 'en']
True
unpack_directory
(filename, extract_dir, progress_filter=default_filter)
Unpack" a directory, using the same interface as for archives Raises ``UnrecognizedFormat`` if `filename` is not a directory
Unpack" a directory, using the same interface as for archives
def unpack_directory(filename, extract_dir, progress_filter=default_filter): """"Unpack" a directory, using the same interface as for archives Raises ``UnrecognizedFormat`` if `filename` is not a directory """ if not os.path.isdir(filename): raise UnrecognizedFormat("%s is not a directory" % fi...
[ "def", "unpack_directory", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "filename", ")", ":", "raise", "UnrecognizedFormat", "(", "\"%s is not a directory\"", "%"...
[ 63, 0 ]
[ 87, 38 ]
python
en
['en', 'en', 'en']
True
unpack_zipfile
(filename, extract_dir, progress_filter=default_filter)
Unpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument.
Unpack zip `filename` to `extract_dir`
def unpack_zipfile(filename, extract_dir, progress_filter=default_filter): """Unpack zip `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a zipfile (as determined by ``zipfile.is_zipfile()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument. ...
[ "def", "unpack_zipfile", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ")", ":", "if", "not", "zipfile", ".", "is_zipfile", "(", "filename", ")", ":", "raise", "UnrecognizedFormat", "(", "\"%s is not a zip file\"", "%", "(", ...
[ 90, 0 ]
[ 124, 49 ]
python
en
['en', 'nl', 'ur']
False
unpack_tarfile
(filename, extract_dir, progress_filter=default_filter)
Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` argument.
Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir`
def unpack_tarfile(filename, extract_dir, progress_filter=default_filter): """Unpack tar/tar.gz/tar.bz2 `filename` to `extract_dir` Raises ``UnrecognizedFormat`` if `filename` is not a tarfile (as determined by ``tarfile.open()``). See ``unpack_archive()`` for an explanation of the `progress_filter` a...
[ "def", "unpack_tarfile", "(", "filename", ",", "extract_dir", ",", "progress_filter", "=", "default_filter", ")", ":", "try", ":", "tarobj", "=", "tarfile", ".", "open", "(", "filename", ")", "except", "tarfile", ".", "TarError", "as", "e", ":", "raise", "...
[ 127, 0 ]
[ 171, 19 ]
python
en
['en', 'id', 'hi']
False
EmailBackend.send_messages
(self, email_messages)
Write all messages to the stream in a thread-safe way.
Write all messages to the stream in a thread-safe way.
def send_messages(self, email_messages): """Write all messages to the stream in a thread-safe way.""" if not email_messages: return msg_count = 0 with self._lock: try: stream_created = self.open() for message in email_messages: ...
[ "def", "send_messages", "(", "self", ",", "email_messages", ")", ":", "if", "not", "email_messages", ":", "return", "msg_count", "=", "0", "with", "self", ".", "_lock", ":", "try", ":", "stream_created", "=", "self", ".", "open", "(", ")", "for", "messag...
[ 26, 4 ]
[ 43, 24 ]
python
en
['en', 'en', 'en']
True
Project.exists
(self)
Whether this project exists. Returns: bool: True if it exists
Whether this project exists.
def exists(self) -> bool: """Whether this project exists. Returns: bool: True if it exists """ return self.info_path.exists()
[ "def", "exists", "(", "self", ")", "->", "bool", ":", "return", "self", ".", "info_path", ".", "exists", "(", ")" ]
[ 47, 4 ]
[ 54, 38 ]
python
en
['en', 'en', 'en']
True
Project.config
(self)
Project Configuration. Returns: Config: Project Config Instance
Project Configuration.
def config(self) -> Config: """Project Configuration. Returns: Config: Project Config Instance """ return self._config
[ "def", "config", "(", "self", ")", "->", "Config", ":", "return", "self", ".", "_config" ]
[ 57, 4 ]
[ 64, 27 ]
python
en
['en', 'en', 'en']
False
Project.context
(self)
Project context used in templates. Returns: Config: Current context
Project context used in templates.
def context(self) -> Config: """Project context used in templates. Returns: Config: Current context """ return self._context
[ "def", "context", "(", "self", ")", "->", "Config", ":", "return", "self", ".", "_context" ]
[ 67, 4 ]
[ 74, 28 ]
python
en
['en', 'en', 'en']
True
Project.cache
(self)
Project wide cache. Returns: Cache instance
Project wide cache.
def cache(self) -> Config: """Project wide cache. Returns: Cache instance """ return self._cache
[ "def", "cache", "(", "self", ")", "->", "Config", ":", "return", "self", ".", "_cache" ]
[ 77, 4 ]
[ 84, 26 ]
python
en
['en', 'en', 'en']
True
Project.iter_children_by_priority
(self)
Iterate project modules by priority. Yields: the next child item
Iterate project modules by priority.
def iter_children_by_priority(self) -> Iterator[Type[ProjectModule]]: """Iterate project modules by priority. Yields: the next child item """ pq = PriorityQueue() for i in self._children: pq.add(i, i.PRIORITY) more = pq.peek(default=False) ...
[ "def", "iter_children_by_priority", "(", "self", ")", "->", "Iterator", "[", "Type", "[", "ProjectModule", "]", "]", ":", "pq", "=", "PriorityQueue", "(", ")", "for", "i", "in", "self", ".", "_children", ":", "pq", ".", "add", "(", "i", ",", "i", "."...
[ 86, 4 ]
[ 99, 41 ]
python
en
['en', 'en', 'en']
True
Project.add
(self, component, *args, **kwargs)
Adds project component. Args: component (Any): Component to add.
Adds project component.
def add(self, component, *args, **kwargs): """Adds project component. Args: component (Any): Component to add. """ child = component(*args, **kwargs, log=self.log, parent=self) self._children.append(child) self.log.debug(f"adding module: {type(child).__name_...
[ "def", "add", "(", "self", ",", "component", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "child", "=", "component", "(", "*", "args", ",", "*", "*", "kwargs", ",", "log", "=", "self", ".", "log", ",", "parent", "=", "self", ")", "self"...
[ 101, 4 ]
[ 110, 64 ]
python
en
['de', 'en', 'en']
True
Project.remove
(self, component)
Removes project component. Args: component (Any): Component to remove.
Removes project component.
def remove(self, component): """Removes project component. Args: component (Any): Component to remove. """ child = next(i for i in self._children if isinstance(i, component)) self._children.remove(child)
[ "def", "remove", "(", "self", ",", "component", ")", ":", "child", "=", "next", "(", "i", "for", "i", "in", "self", ".", "_children", "if", "isinstance", "(", "i", ",", "component", ")", ")", "self", ".", "_children", ".", "remove", "(", "child", "...
[ 112, 4 ]
[ 120, 36 ]
python
en
['da', 'en', 'en']
True
Project.load
(self, **kwargs: Any)
Loads all components in Project. Returns: Current Project Instance
Loads all components in Project.
def load(self, **kwargs: Any) -> "Project": """Loads all components in Project. Returns: Current Project Instance """ self.name = self._config.get("name") self.data_path.mkdir(exist_ok=True) for child in self.iter_children_by_priority(): child.lo...
[ "def", "load", "(", "self", ",", "*", "*", "kwargs", ":", "Any", ")", "->", "\"Project\"", ":", "self", ".", "name", "=", "self", ".", "_config", ".", "get", "(", "\"name\"", ")", "self", ".", "data_path", ".", "mkdir", "(", "exist_ok", "=", "True"...
[ 122, 4 ]
[ 133, 19 ]
python
en
['en', 'en', 'en']
True
Project.create
(self)
Creates new Project. Returns: Path: Path relative to current active directory.
Creates new Project.
def create(self): """Creates new Project. Returns: Path: Path relative to current active directory. """ self.log.title(f"Initiating $[{self.name}]") self.data_path.mkdir(exist_ok=True, parents=True) ignore_data = self.data_path / ".gitignore" ignore_...
[ "def", "create", "(", "self", ")", ":", "self", ".", "log", ".", "title", "(", "f\"Initiating $[{self.name}]\"", ")", "self", ".", "data_path", ".", "mkdir", "(", "exist_ok", "=", "True", ",", "parents", "=", "True", ")", "ignore_data", "=", "self", ".",...
[ 135, 4 ]
[ 152, 24 ]
python
en
['en', 'en', 'en']
True
Project.update
(self)
Updates all project components. Returns: Current active project.
Updates all project components.
def update(self): """Updates all project components. Returns: Current active project. """ self.log.debug("Updating all project modules...") for child in self.iter_children_by_priority(): child.update() return self
[ "def", "update", "(", "self", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Updating all project modules...\"", ")", "for", "child", "in", "self", ".", "iter_children_by_priority", "(", ")", ":", "child", ".", "update", "(", ")", "return", "self" ]
[ 154, 4 ]
[ 164, 19 ]
python
en
['en', 'en', 'en']
True
sql_flush
(style, connection, only_django=False, reset_sequences=True, allow_cascade=False)
Return a list of the SQL statements used to flush the database. If only_django is True, only include the table names that have associated Django models and are in INSTALLED_APPS .
Return a list of the SQL statements used to flush the database.
def sql_flush(style, connection, only_django=False, reset_sequences=True, allow_cascade=False): """ Return a list of the SQL statements used to flush the database. If only_django is True, only include the table names that have associated Django models and are in INSTALLED_APPS . """ if only_dja...
[ "def", "sql_flush", "(", "style", ",", "connection", ",", "only_django", "=", "False", ",", "reset_sequences", "=", "True", ",", "allow_cascade", "=", "False", ")", ":", "if", "only_django", ":", "tables", "=", "connection", ".", "introspection", ".", "djang...
[ 4, 0 ]
[ 16, 71 ]
python
en
['en', 'error', 'th']
False
get_version
(version=None)
Returns a PEP 386-compliant version number from VERSION.
Returns a PEP 386-compliant version number from VERSION.
def get_version(version=None): "Returns a PEP 386-compliant version number from VERSION." version = get_complete_version(version) # Now build the two parts of the version number: # major = X.Y[.Z] # sub = .devN - for pre-alpha releases # | {a|b|c}N - for alpha, beta and rc releases maj...
[ "def", "get_version", "(", "version", "=", "None", ")", ":", "version", "=", "get_complete_version", "(", "version", ")", "# Now build the two parts of the version number:", "# major = X.Y[.Z]", "# sub = .devN - for pre-alpha releases", "# | {a|b|c}N - for alpha, beta and rc re...
[ 9, 0 ]
[ 30, 27 ]
python
en
['en', 'en', 'en']
True
get_major_version
(version=None)
Returns major version from VERSION.
Returns major version from VERSION.
def get_major_version(version=None): "Returns major version from VERSION." version = get_complete_version(version) parts = 2 if version[2] == 0 else 3 major = '.'.join(str(x) for x in version[:parts]) return major
[ "def", "get_major_version", "(", "version", "=", "None", ")", ":", "version", "=", "get_complete_version", "(", "version", ")", "parts", "=", "2", "if", "version", "[", "2", "]", "==", "0", "else", "3", "major", "=", "'.'", ".", "join", "(", "str", "...
[ 33, 0 ]
[ 38, 16 ]
python
en
['en', 'sv', 'en']
True
get_complete_version
(version=None)
Returns a tuple of the django version. If version argument is non-empty, then checks for correctness of the tuple provided.
Returns a tuple of the django version. If version argument is non-empty, then checks for correctness of the tuple provided.
def get_complete_version(version=None): """Returns a tuple of the django version. If version argument is non-empty, then checks for correctness of the tuple provided. """ if version is None: from django import VERSION as version else: assert len(version) == 5 assert version[3...
[ "def", "get_complete_version", "(", "version", "=", "None", ")", ":", "if", "version", "is", "None", ":", "from", "django", "import", "VERSION", "as", "version", "else", ":", "assert", "len", "(", "version", ")", "==", "5", "assert", "version", "[", "3",...
[ 41, 0 ]
[ 51, 18 ]
python
en
['en', 'en', 'en']
True
get_git_changeset
()
Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers.
Returns a numeric identifier of the latest git changeset.
def get_git_changeset(): """Returns a numeric identifier of the latest git changeset. The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format. This value isn't guaranteed to be unique, but collisions are very unlikely, so it's sufficient for generating the development version numbers....
[ "def", "get_git_changeset", "(", ")", ":", "repo_dir", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ")", "git_log", "=", "subprocess", ".", "Popen",...
[ 55, 0 ]
[ 71, 45 ]
python
en
['en', 'en', 'en']
True
specialspaceless
(parser, token)
Removes whitespace between HTML tags, and introduces a whitespace after buttons an inputs, necessary for Bootstrap to place them correctly in the layout.
Removes whitespace between HTML tags, and introduces a whitespace after buttons an inputs, necessary for Bootstrap to place them correctly in the layout.
def specialspaceless(parser, token): """ Removes whitespace between HTML tags, and introduces a whitespace after buttons an inputs, necessary for Bootstrap to place them correctly in the layout. """ nodelist = parser.parse(("endspecialspaceless",)) parser.delete_first_token() r...
[ "def", "specialspaceless", "(", "parser", ",", "token", ")", ":", "nodelist", "=", "parser", ".", "parse", "(", "(", "\"endspecialspaceless\"", ",", ")", ")", "parser", ".", "delete_first_token", "(", ")", "return", "SpecialSpacelessNode", "(", "nodelist", ")"...
[ 24, 0 ]
[ 33, 41 ]
python
en
['en', 'ja', 'th']
False
get_asgi_application
()
The public interface to Django's ASGI support. Return an ASGI 3 callable. Avoids making django.core.handlers.ASGIHandler a public API, in case the internal implementation changes or moves in the future.
The public interface to Django's ASGI support. Return an ASGI 3 callable.
def get_asgi_application(): """ The public interface to Django's ASGI support. Return an ASGI 3 callable. Avoids making django.core.handlers.ASGIHandler a public API, in case the internal implementation changes or moves in the future. """ django.setup(set_prefix=False) return ASGIHandler()
[ "def", "get_asgi_application", "(", ")", ":", "django", ".", "setup", "(", "set_prefix", "=", "False", ")", "return", "ASGIHandler", "(", ")" ]
[ 4, 0 ]
[ 12, 24 ]
python
en
['en', 'error', 'th']
False
pad_method_dict
(method_dict: Dict[str, bool])
Pads an authentication methods dict to contain all auth backends supported by the software, regardless of whether they are configured on this server
Pads an authentication methods dict to contain all auth backends supported by the software, regardless of whether they are configured on this server
def pad_method_dict(method_dict: Dict[str, bool]) -> Dict[str, bool]: """Pads an authentication methods dict to contain all auth backends supported by the software, regardless of whether they are configured on this server""" for key in AUTH_BACKEND_NAME_MAP: if key not in method_dict: ...
[ "def", "pad_method_dict", "(", "method_dict", ":", "Dict", "[", "str", ",", "bool", "]", ")", "->", "Dict", "[", "str", ",", "bool", "]", ":", "for", "key", "in", "AUTH_BACKEND_NAME_MAP", ":", "if", "key", "not", "in", "method_dict", ":", "method_dict", ...
[ 100, 0 ]
[ 107, 22 ]
python
en
['en', 'en', 'en']
True
any_social_backend_enabled
(realm: Optional[Realm] = None)
Used by the login page process to determine whether to show the 'OR' for login with Google
Used by the login page process to determine whether to show the 'OR' for login with Google
def any_social_backend_enabled(realm: Optional[Realm] = None) -> bool: """Used by the login page process to determine whether to show the 'OR' for login with Google""" social_backend_names = [ social_auth_subclass.auth_backend_name for social_auth_subclass in EXTERNAL_AUTH_METHODS ] return a...
[ "def", "any_social_backend_enabled", "(", "realm", ":", "Optional", "[", "Realm", "]", "=", "None", ")", "->", "bool", ":", "social_backend_names", "=", "[", "social_auth_subclass", ".", "auth_backend_name", "for", "social_auth_subclass", "in", "EXTERNAL_AUTH_METHODS"...
[ 161, 0 ]
[ 167, 59 ]
python
en
['en', 'en', 'en']
True
common_get_active_user
( email: str, realm: Realm, return_data: Optional[Dict[str, Any]] = None )
This is the core common function used by essentially all authentication backends to check if there's an active user account with a given email address in the organization, handling both user-level and realm-level deactivation correctly.
This is the core common function used by essentially all authentication backends to check if there's an active user account with a given email address in the organization, handling both user-level and realm-level deactivation correctly.
def common_get_active_user( email: str, realm: Realm, return_data: Optional[Dict[str, Any]] = None ) -> Optional[UserProfile]: """This is the core common function used by essentially all authentication backends to check if there's an active user account with a given email address in the organization, ha...
[ "def", "common_get_active_user", "(", "email", ":", "str", ",", "realm", ":", "Realm", ",", "return_data", ":", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", "=", "None", ")", "->", "Optional", "[", "UserProfile", "]", ":", "try", ":", "...
[ 194, 0 ]
[ 217, 23 ]
python
en
['en', 'en', 'en']
True
check_password_strength
(password: str)
Returns True if the password is strong enough, False otherwise.
Returns True if the password is strong enough, False otherwise.
def check_password_strength(password: str) -> bool: """ Returns True if the password is strong enough, False otherwise. """ if len(password) < settings.PASSWORD_MIN_LENGTH: return False if password == "": # zxcvbn throws an exception when passed the empty string, so # we...
[ "def", "check_password_strength", "(", "password", ":", "str", ")", "->", "bool", ":", "if", "len", "(", "password", ")", "<", "settings", ".", "PASSWORD_MIN_LENGTH", ":", "return", "False", "if", "password", "==", "\"\"", ":", "# zxcvbn throws an exception when...
[ 349, 0 ]
[ 365, 15 ]
python
en
['en', 'error', 'th']
False
find_ldap_users_by_email
(email: str)
Returns list of _LDAPUsers matching the email search, or None if no matches are found.
Returns list of _LDAPUsers matching the email search, or None if no matches are found.
def find_ldap_users_by_email(email: str) -> Optional[List[_LDAPUser]]: """ Returns list of _LDAPUsers matching the email search, or None if no matches are found. """ email_search = LDAPReverseEmailSearch(LDAPBackend(), email) return email_search.search_for_users(should_populate=False)
[ "def", "find_ldap_users_by_email", "(", "email", ":", "str", ")", "->", "Optional", "[", "List", "[", "_LDAPUser", "]", "]", ":", "email_search", "=", "LDAPReverseEmailSearch", "(", "LDAPBackend", "(", ")", ",", "email", ")", "return", "email_search", ".", "...
[ 424, 0 ]
[ 430, 63 ]
python
en
['en', 'error', 'th']
False
email_belongs_to_ldap
(realm: Realm, email: str)
Used to make determinations on whether a user's email address is managed by LDAP. For environments using both LDAP and Email+Password authentication, we do not allow EmailAuthBackend authentication for email addresses managed by LDAP (to avoid a security issue where one create separate credentials for ...
Used to make determinations on whether a user's email address is managed by LDAP. For environments using both LDAP and Email+Password authentication, we do not allow EmailAuthBackend authentication for email addresses managed by LDAP (to avoid a security issue where one create separate credentials for ...
def email_belongs_to_ldap(realm: Realm, email: str) -> bool: """Used to make determinations on whether a user's email address is managed by LDAP. For environments using both LDAP and Email+Password authentication, we do not allow EmailAuthBackend authentication for email addresses managed by LDAP (to a...
[ "def", "email_belongs_to_ldap", "(", "realm", ":", "Realm", ",", "email", ":", "str", ")", "->", "bool", ":", "if", "not", "ldap_auth_enabled", "(", "realm", ")", ":", "return", "False", "check_ldap_config", "(", ")", "if", "settings", ".", "LDAP_APPEND_DOMA...
[ 433, 0 ]
[ 453, 20 ]
python
en
['en', 'en', 'en']
True