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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
DateTimeField.to_python | (self, value) |
Validate that the input can be converted to a datetime. Return a
Python datetime.datetime object.
|
Validate that the input can be converted to a datetime. Return a
Python datetime.datetime object.
| def to_python(self, value):
"""
Validate that the input can be converted to a datetime. Return a
Python datetime.datetime object.
"""
if value in self.empty_values:
return None
if isinstance(value, datetime.datetime):
return from_current_timezone(v... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"self",
".",
"empty_values",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",
"from_current_timezone",
"(",
"value",... | [
450,
4
] | [
463,
44
] | python | en | ['en', 'error', 'th'] | False |
RegexField.__init__ | (self, regex, **kwargs) |
regex can be either a string or a compiled regular expression object.
|
regex can be either a string or a compiled regular expression object.
| def __init__(self, regex, **kwargs):
"""
regex can be either a string or a compiled regular expression object.
"""
kwargs.setdefault('strip', False)
super().__init__(**kwargs)
self._set_regex(regex) | [
"def",
"__init__",
"(",
"self",
",",
"regex",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
".",
"setdefault",
"(",
"'strip'",
",",
"False",
")",
"super",
"(",
")",
".",
"__init__",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"_set_regex",
"(",
"rege... | [
498,
4
] | [
504,
30
] | python | en | ['en', 'error', 'th'] | False |
ImageField.to_python | (self, data) |
Check that the file-upload field data contains a valid image (GIF, JPG,
PNG, etc. -- whatever Pillow supports).
|
Check that the file-upload field data contains a valid image (GIF, JPG,
PNG, etc. -- whatever Pillow supports).
| def to_python(self, data):
"""
Check that the file-upload field data contains a valid image (GIF, JPG,
PNG, etc. -- whatever Pillow supports).
"""
f = super().to_python(data)
if f is None:
return None
from PIL import Image
# We need to get a ... | [
"def",
"to_python",
"(",
"self",
",",
"data",
")",
":",
"f",
"=",
"super",
"(",
")",
".",
"to_python",
"(",
"data",
")",
"if",
"f",
"is",
"None",
":",
"return",
"None",
"from",
"PIL",
"import",
"Image",
"# We need to get a file object for Pillow. We might ha... | [
605,
4
] | [
646,
16
] | python | en | ['en', 'error', 'th'] | False |
BooleanField.to_python | (self, value) | Return a Python boolean object. | Return a Python boolean object. | def to_python(self, value):
"""Return a Python boolean object."""
# Explicitly check for the string 'False', which is what a hidden field
# will submit for False. Also check for '0', since this is what
# RadioSelect will provide. Because bool("True") == bool('1') == True,
# we do... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"# Explicitly check for the string 'False', which is what a hidden field",
"# will submit for False. Also check for '0', since this is what",
"# RadioSelect will provide. Because bool(\"True\") == bool('1') == True,",
"# we don't need to... | [
700,
4
] | [
710,
39
] | python | en | ['en', 'cy', 'en'] | True |
NullBooleanField.to_python | (self, value) |
Explicitly check for the string 'True' and 'False', which is what a
hidden field will submit for True and False, for 'true' and 'false',
which are likely to be returned by JavaScript serializations of forms,
and for '1' and '0', which is what a RadioField will submit. Unlike
the... |
Explicitly check for the string 'True' and 'False', which is what a
hidden field will submit for True and False, for 'true' and 'false',
which are likely to be returned by JavaScript serializations of forms,
and for '1' and '0', which is what a RadioField will submit. Unlike
the... | def to_python(self, value):
"""
Explicitly check for the string 'True' and 'False', which is what a
hidden field will submit for True and False, for 'true' and 'false',
which are likely to be returned by JavaScript serializations of forms,
and for '1' and '0', which is what a Rad... | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"(",
"True",
",",
"'True'",
",",
"'true'",
",",
"'1'",
")",
":",
"return",
"True",
"elif",
"value",
"in",
"(",
"False",
",",
"'False'",
",",
"'false'",
",",
"'0'",
")",
... | [
731,
4
] | [
745,
23
] | python | en | ['en', 'error', 'th'] | False |
ChoiceField.to_python | (self, value) | Return a string. | Return a string. | def to_python(self, value):
"""Return a string."""
if value in self.empty_values:
return ''
return str(value) | [
"def",
"to_python",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"in",
"self",
".",
"empty_values",
":",
"return",
"''",
"return",
"str",
"(",
"value",
")"
] | [
790,
4
] | [
794,
25
] | python | en | ['en', 'cy', 'en'] | True |
ChoiceField.validate | (self, value) | Validate that the input is in self.choices. | Validate that the input is in self.choices. | def validate(self, value):
"""Validate that the input is in self.choices."""
super().validate(value)
if value and not self.valid_value(value):
raise ValidationError(
self.error_messages['invalid_choice'],
code='invalid_choice',
params={... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"super",
"(",
")",
".",
"validate",
"(",
"value",
")",
"if",
"value",
"and",
"not",
"self",
".",
"valid_value",
"(",
"value",
")",
":",
"raise",
"ValidationError",
"(",
"self",
".",
"error_message... | [
796,
4
] | [
804,
13
] | python | en | ['en', 'en', 'en'] | True |
ChoiceField.valid_value | (self, value) | Check to see if the provided value is a valid choice. | Check to see if the provided value is a valid choice. | def valid_value(self, value):
"""Check to see if the provided value is a valid choice."""
text_value = str(value)
for k, v in self.choices:
if isinstance(v, (list, tuple)):
# This is an optgroup, so look inside the group for options
for k2, v2 in v:
... | [
"def",
"valid_value",
"(",
"self",
",",
"value",
")",
":",
"text_value",
"=",
"str",
"(",
"value",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"choices",
":",
"if",
"isinstance",
"(",
"v",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"# This ... | [
806,
4
] | [
818,
20
] | python | en | ['en', 'en', 'en'] | True |
TypedChoiceField._coerce | (self, value) |
Validate that the value can be coerced to the right type (if not empty).
|
Validate that the value can be coerced to the right type (if not empty).
| def _coerce(self, value):
"""
Validate that the value can be coerced to the right type (if not empty).
"""
if value == self.empty_value or value in self.empty_values:
return self.empty_value
try:
value = self.coerce(value)
except (ValueError, TypeE... | [
"def",
"_coerce",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"self",
".",
"empty_value",
"or",
"value",
"in",
"self",
".",
"empty_values",
":",
"return",
"self",
".",
"empty_value",
"try",
":",
"value",
"=",
"self",
".",
"coerce",
"(",
... | [
827,
4
] | [
841,
20
] | python | en | ['en', 'error', 'th'] | False |
MultipleChoiceField.validate | (self, value) | Validate that the input is a list or tuple. | Validate that the input is a list or tuple. | def validate(self, value):
"""Validate that the input is a list or tuple."""
if self.required and not value:
raise ValidationError(self.error_messages['required'], code='required')
# Validate that each value in the value list is in self.choices.
for val in value:
... | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"required",
"and",
"not",
"value",
":",
"raise",
"ValidationError",
"(",
"self",
".",
"error_messages",
"[",
"'required'",
"]",
",",
"code",
"=",
"'required'",
")",
"# Validate that... | [
863,
4
] | [
874,
17
] | python | en | ['en', 'en', 'en'] | True |
TypedMultipleChoiceField._coerce | (self, value) |
Validate that the values are in self.choices and can be coerced to the
right type.
|
Validate that the values are in self.choices and can be coerced to the
right type.
| def _coerce(self, value):
"""
Validate that the values are in self.choices and can be coerced to the
right type.
"""
if value == self.empty_value or value in self.empty_values:
return self.empty_value
new_value = []
for choice in value:
try... | [
"def",
"_coerce",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"==",
"self",
".",
"empty_value",
"or",
"value",
"in",
"self",
".",
"empty_values",
":",
"return",
"self",
".",
"empty_value",
"new_value",
"=",
"[",
"]",
"for",
"choice",
"in",
"val... | [
896,
4
] | [
913,
24
] | python | en | ['en', 'error', 'th'] | False |
ComboField.clean | (self, value) |
Validate the given value against all of self.fields, which is a
list of Field instances.
|
Validate the given value against all of self.fields, which is a
list of Field instances.
| def clean(self, value):
"""
Validate the given value against all of self.fields, which is a
list of Field instances.
"""
super().clean(value)
for field in self.fields:
value = field.clean(value)
return value | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"super",
"(",
")",
".",
"clean",
"(",
"value",
")",
"for",
"field",
"in",
"self",
".",
"fields",
":",
"value",
"=",
"field",
".",
"clean",
"(",
"value",
")",
"return",
"value"
] | [
939,
4
] | [
947,
20
] | python | en | ['en', 'error', 'th'] | False |
MultiValueField.clean | (self, value) |
Validate every value in the given list. A value is validated against
the corresponding Field in self.fields.
For example, if this MultiValueField was instantiated with
fields=(DateField(), TimeField()), clean() would call
DateField.clean(value[0]) and TimeField.clean(value[1]).... |
Validate every value in the given list. A value is validated against
the corresponding Field in self.fields. | def clean(self, value):
"""
Validate every value in the given list. A value is validated against
the corresponding Field in self.fields.
For example, if this MultiValueField was instantiated with
fields=(DateField(), TimeField()), clean() would call
DateField.clean(value... | [
"def",
"clean",
"(",
"self",
",",
"value",
")",
":",
"clean_data",
"=",
"[",
"]",
"errors",
"=",
"[",
"]",
"if",
"self",
".",
"disabled",
"and",
"not",
"isinstance",
"(",
"value",
",",
"list",
")",
":",
"value",
"=",
"self",
".",
"widget",
".",
"... | [
995,
4
] | [
1047,
18
] | python | en | ['en', 'error', 'th'] | False |
MultiValueField.compress | (self, data_list) |
Return a single value for the given list of values. The values can be
assumed to be valid.
For example, if this MultiValueField was instantiated with
fields=(DateField(), TimeField()), this might return a datetime
object created by combining the date and time in data_list.
... |
Return a single value for the given list of values. The values can be
assumed to be valid. | def compress(self, data_list):
"""
Return a single value for the given list of values. The values can be
assumed to be valid.
For example, if this MultiValueField was instantiated with
fields=(DateField(), TimeField()), this might return a datetime
object created by comb... | [
"def",
"compress",
"(",
"self",
",",
"data_list",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Subclasses must implement this method.'",
")"
] | [
1049,
4
] | [
1058,
75
] | python | en | ['en', 'error', 'th'] | False |
Loader.get_template_sources | (self, template_name) |
Return an Origin object pointing to an absolute path in each directory
in template_dirs. For security reasons, if a path doesn't lie inside
one of the template_dirs it is excluded from the result set.
|
Return an Origin object pointing to an absolute path in each directory
in template_dirs. For security reasons, if a path doesn't lie inside
one of the template_dirs it is excluded from the result set.
| def get_template_sources(self, template_name):
"""
Return an Origin object pointing to an absolute path in each directory
in template_dirs. For security reasons, if a path doesn't lie inside
one of the template_dirs it is excluded from the result set.
"""
for template_dir... | [
"def",
"get_template_sources",
"(",
"self",
",",
"template_name",
")",
":",
"for",
"template_dir",
"in",
"self",
".",
"get_dirs",
"(",
")",
":",
"try",
":",
"name",
"=",
"safe_join",
"(",
"template_dir",
",",
"template_name",
")",
"except",
"SuspiciousFileOper... | [
27,
4
] | [
45,
13
] | python | en | ['en', 'error', 'th'] | False |
get_order_dir | (field, default='ASC') |
Returns the field name and direction for an order specification. For
example, '-foo' is returned as ('foo', 'DESC').
The 'default' param is used to indicate which way no prefix (or a '+'
prefix) should sort. The '-' prefix always sorts the opposite way.
|
Returns the field name and direction for an order specification. For
example, '-foo' is returned as ('foo', 'DESC'). | def get_order_dir(field, default='ASC'):
"""
Returns the field name and direction for an order specification. For
example, '-foo' is returned as ('foo', 'DESC').
The 'default' param is used to indicate which way no prefix (or a '+'
prefix) should sort. The '-' prefix always sorts the opposite way.
... | [
"def",
"get_order_dir",
"(",
"field",
",",
"default",
"=",
"'ASC'",
")",
":",
"dirn",
"=",
"ORDER_DIR",
"[",
"default",
"]",
"if",
"field",
"[",
"0",
"]",
"==",
"'-'",
":",
"return",
"field",
"[",
"1",
":",
"]",
",",
"dirn",
"[",
"1",
"]",
"retur... | [
2004,
0
] | [
2015,
25
] | python | en | ['en', 'error', 'th'] | False |
add_to_dict | (data, key, value) |
A helper function to add "value" to the set of values for "key", whether or
not "key" already exists.
|
A helper function to add "value" to the set of values for "key", whether or
not "key" already exists.
| def add_to_dict(data, key, value):
"""
A helper function to add "value" to the set of values for "key", whether or
not "key" already exists.
"""
if key in data:
data[key].add(value)
else:
data[key] = {value} | [
"def",
"add_to_dict",
"(",
"data",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"in",
"data",
":",
"data",
"[",
"key",
"]",
".",
"add",
"(",
"value",
")",
"else",
":",
"data",
"[",
"key",
"]",
"=",
"{",
"value",
"}"
] | [
2018,
0
] | [
2026,
27
] | python | en | ['en', 'error', 'th'] | False |
is_reverse_o2o | (field) |
A little helper to check if the given field is reverse-o2o. The field is
expected to be some sort of relation field or related object.
|
A little helper to check if the given field is reverse-o2o. The field is
expected to be some sort of relation field or related object.
| def is_reverse_o2o(field):
"""
A little helper to check if the given field is reverse-o2o. The field is
expected to be some sort of relation field or related object.
"""
return not hasattr(field, 'rel') and field.field.unique | [
"def",
"is_reverse_o2o",
"(",
"field",
")",
":",
"return",
"not",
"hasattr",
"(",
"field",
",",
"'rel'",
")",
"and",
"field",
".",
"field",
".",
"unique"
] | [
2029,
0
] | [
2034,
59
] | python | en | ['en', 'error', 'th'] | False |
alias_diff | (refcounts_before, refcounts_after) |
Given the before and after copies of refcounts works out which aliases
have been added to the after copy.
|
Given the before and after copies of refcounts works out which aliases
have been added to the after copy.
| def alias_diff(refcounts_before, refcounts_after):
"""
Given the before and after copies of refcounts works out which aliases
have been added to the after copy.
"""
# Use -1 as default value so that any join that is created, then trimmed
# is seen as added.
return set(t for t in refcounts_af... | [
"def",
"alias_diff",
"(",
"refcounts_before",
",",
"refcounts_after",
")",
":",
"# Use -1 as default value so that any join that is created, then trimmed",
"# is seen as added.",
"return",
"set",
"(",
"t",
"for",
"t",
"in",
"refcounts_after",
"if",
"refcounts_after",
"[",
"... | [
2037,
0
] | [
2045,
67
] | python | en | ['en', 'error', 'th'] | False |
Query.__str__ | (self) |
Returns the query as a string of SQL with the parameter values
substituted in (use sql_with_params() to see the unsubstituted string).
Parameter values won't necessarily be quoted correctly, since that is
done by the database interface at execution time.
|
Returns the query as a string of SQL with the parameter values
substituted in (use sql_with_params() to see the unsubstituted string). | def __str__(self):
"""
Returns the query as a string of SQL with the parameter values
substituted in (use sql_with_params() to see the unsubstituted string).
Parameter values won't necessarily be quoted correctly, since that is
done by the database interface at execution time.
... | [
"def",
"__str__",
"(",
"self",
")",
":",
"sql",
",",
"params",
"=",
"self",
".",
"sql_with_params",
"(",
")",
"return",
"sql",
"%",
"params"
] | [
182,
4
] | [
191,
27
] | python | en | ['en', 'error', 'th'] | False |
Query.sql_with_params | (self) |
Returns the query as an SQL string and the parameters that will be
substituted into the query.
|
Returns the query as an SQL string and the parameters that will be
substituted into the query.
| def sql_with_params(self):
"""
Returns the query as an SQL string and the parameters that will be
substituted into the query.
"""
return self.get_compiler(DEFAULT_DB_ALIAS).as_sql() | [
"def",
"sql_with_params",
"(",
"self",
")",
":",
"return",
"self",
".",
"get_compiler",
"(",
"DEFAULT_DB_ALIAS",
")",
".",
"as_sql",
"(",
")"
] | [
193,
4
] | [
198,
59
] | python | en | ['en', 'error', 'th'] | False |
Query.get_meta | (self) |
Returns the Options instance (the model._meta) from which to start
processing. Normally, this is self.model._meta, but it can be changed
by subclasses.
|
Returns the Options instance (the model._meta) from which to start
processing. Normally, this is self.model._meta, but it can be changed
by subclasses.
| def get_meta(self):
"""
Returns the Options instance (the model._meta) from which to start
processing. Normally, this is self.model._meta, but it can be changed
by subclasses.
"""
return self.model._meta | [
"def",
"get_meta",
"(",
"self",
")",
":",
"return",
"self",
".",
"model",
".",
"_meta"
] | [
220,
4
] | [
226,
31
] | python | en | ['en', 'error', 'th'] | False |
Query.clone | (self, klass=None, memo=None, **kwargs) |
Creates a copy of the current instance. The 'kwargs' parameter can be
used by clients to update attributes after copying has taken place.
|
Creates a copy of the current instance. The 'kwargs' parameter can be
used by clients to update attributes after copying has taken place.
| def clone(self, klass=None, memo=None, **kwargs):
"""
Creates a copy of the current instance. The 'kwargs' parameter can be
used by clients to update attributes after copying has taken place.
"""
obj = Empty()
obj.__class__ = klass or self.__class__
obj.model = se... | [
"def",
"clone",
"(",
"self",
",",
"klass",
"=",
"None",
",",
"memo",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"obj",
"=",
"Empty",
"(",
")",
"obj",
".",
"__class__",
"=",
"klass",
"or",
"self",
".",
"__class__",
"obj",
".",
"model",
"=",
... | [
228,
4
] | [
299,
18
] | python | en | ['en', 'error', 'th'] | False |
Query.resolve_aggregate | (self, value, aggregate, connection) | Resolve the value of aggregates returned by the database to
consistent (and reasonable) types.
This is required because of the predisposition of certain backends
to return Decimal and long types when they are not needed.
| Resolve the value of aggregates returned by the database to
consistent (and reasonable) types. | def resolve_aggregate(self, value, aggregate, connection):
"""Resolve the value of aggregates returned by the database to
consistent (and reasonable) types.
This is required because of the predisposition of certain backends
to return Decimal and long types when they are not needed.
... | [
"def",
"resolve_aggregate",
"(",
"self",
",",
"value",
",",
"aggregate",
",",
"connection",
")",
":",
"if",
"value",
"is",
"None",
":",
"if",
"aggregate",
".",
"is_ordinal",
":",
"return",
"0",
"# Return None as-is",
"return",
"value",
"elif",
"aggregate",
"... | [
301,
4
] | [
327,
24
] | python | en | ['en', 'en', 'en'] | True |
Query.get_aggregation | (self, using, force_subq=False) |
Returns the dictionary with the values of the existing aggregations.
|
Returns the dictionary with the values of the existing aggregations.
| def get_aggregation(self, using, force_subq=False):
"""
Returns the dictionary with the values of the existing aggregations.
"""
if not self.aggregate_select:
return {}
# If there is a group by clause, aggregating does not add useful
# information but retriev... | [
"def",
"get_aggregation",
"(",
"self",
",",
"using",
",",
"force_subq",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"aggregate_select",
":",
"return",
"{",
"}",
"# If there is a group by clause, aggregating does not add useful",
"# information but retrieves only the... | [
329,
4
] | [
389,
9
] | python | en | ['en', 'error', 'th'] | False |
Query.get_count | (self, using) |
Performs a COUNT() query using the current filter constraints.
|
Performs a COUNT() query using the current filter constraints.
| def get_count(self, using):
"""
Performs a COUNT() query using the current filter constraints.
"""
obj = self.clone()
if len(self.select) > 1 or self.aggregate_select or (self.distinct and self.distinct_fields):
# If a select clause exists, then the query has already ... | [
"def",
"get_count",
"(",
"self",
",",
"using",
")",
":",
"obj",
"=",
"self",
".",
"clone",
"(",
")",
"if",
"len",
"(",
"self",
".",
"select",
")",
">",
"1",
"or",
"self",
".",
"aggregate_select",
"or",
"(",
"self",
".",
"distinct",
"and",
"self",
... | [
391,
4
] | [
424,
21
] | python | en | ['en', 'error', 'th'] | False |
Query.combine | (self, rhs, connector) |
Merge the 'rhs' query into the current one (with any 'rhs' effects
being applied *after* (that is, "to the right of") anything in the
current query. 'rhs' is not modified during a call to this function.
The 'connector' parameter describes how to connect filters from the
'rhs' q... |
Merge the 'rhs' query into the current one (with any 'rhs' effects
being applied *after* (that is, "to the right of") anything in the
current query. 'rhs' is not modified during a call to this function. | def combine(self, rhs, connector):
"""
Merge the 'rhs' query into the current one (with any 'rhs' effects
being applied *after* (that is, "to the right of") anything in the
current query. 'rhs' is not modified during a call to this function.
The 'connector' parameter describes h... | [
"def",
"combine",
"(",
"self",
",",
"rhs",
",",
"connector",
")",
":",
"assert",
"self",
".",
"model",
"==",
"rhs",
".",
"model",
",",
"\"Cannot combine queries on two different base models.\"",
"assert",
"self",
".",
"can_filter",
"(",
")",
",",
"\"Cannot combi... | [
438,
4
] | [
555,
71
] | python | en | ['en', 'error', 'th'] | False |
Query.deferred_to_data | (self, target, callback) |
Converts the self.deferred_loading data structure to an alternate data
structure, describing the field that *will* be loaded. This is used to
compute the columns to select from the database and also by the
QuerySet class to work out which fields are being initialized on each
mod... |
Converts the self.deferred_loading data structure to an alternate data
structure, describing the field that *will* be loaded. This is used to
compute the columns to select from the database and also by the
QuerySet class to work out which fields are being initialized on each
mod... | def deferred_to_data(self, target, callback):
"""
Converts the self.deferred_loading data structure to an alternate data
structure, describing the field that *will* be loaded. This is used to
compute the columns to select from the database and also by the
QuerySet class to work o... | [
"def",
"deferred_to_data",
"(",
"self",
",",
"target",
",",
"callback",
")",
":",
"field_names",
",",
"defer",
"=",
"self",
".",
"deferred_loading",
"if",
"not",
"field_names",
":",
"return",
"orig_opts",
"=",
"self",
".",
"get_meta",
"(",
")",
"seen",
"="... | [
557,
4
] | [
637,
47
] | python | en | ['en', 'error', 'th'] | False |
Query.deferred_to_columns_cb | (self, target, model, fields) |
Callback used by deferred_to_columns(). The "target" parameter should
be a set instance.
|
Callback used by deferred_to_columns(). The "target" parameter should
be a set instance.
| def deferred_to_columns_cb(self, target, model, fields):
"""
Callback used by deferred_to_columns(). The "target" parameter should
be a set instance.
"""
table = model._meta.db_table
if table not in target:
target[table] = set()
for field in fields:
... | [
"def",
"deferred_to_columns_cb",
"(",
"self",
",",
"target",
",",
"model",
",",
"fields",
")",
":",
"table",
"=",
"model",
".",
"_meta",
".",
"db_table",
"if",
"table",
"not",
"in",
"target",
":",
"target",
"[",
"table",
"]",
"=",
"set",
"(",
")",
"f... | [
639,
4
] | [
648,
43
] | python | en | ['en', 'error', 'th'] | False |
Query.table_alias | (self, table_name, create=False) |
Returns a table alias for the given table_name and whether this is a
new alias or not.
If 'create' is true, a new alias is always created. Otherwise, the
most recently created alias for the table (if one exists) is reused.
|
Returns a table alias for the given table_name and whether this is a
new alias or not. | def table_alias(self, table_name, create=False):
"""
Returns a table alias for the given table_name and whether this is a
new alias or not.
If 'create' is true, a new alias is always created. Otherwise, the
most recently created alias for the table (if one exists) is reused.
... | [
"def",
"table_alias",
"(",
"self",
",",
"table_name",
",",
"create",
"=",
"False",
")",
":",
"alias_list",
"=",
"self",
".",
"table_map",
".",
"get",
"(",
"table_name",
")",
"if",
"not",
"create",
"and",
"alias_list",
":",
"alias",
"=",
"alias_list",
"["... | [
650,
4
] | [
674,
26
] | python | en | ['en', 'error', 'th'] | False |
Query.ref_alias | (self, alias) | Increases the reference count for this alias. | Increases the reference count for this alias. | def ref_alias(self, alias):
""" Increases the reference count for this alias. """
self.alias_refcount[alias] += 1 | [
"def",
"ref_alias",
"(",
"self",
",",
"alias",
")",
":",
"self",
".",
"alias_refcount",
"[",
"alias",
"]",
"+=",
"1"
] | [
676,
4
] | [
678,
39
] | python | en | ['en', 'en', 'en'] | True |
Query.unref_alias | (self, alias, amount=1) | Decreases the reference count for this alias. | Decreases the reference count for this alias. | def unref_alias(self, alias, amount=1):
""" Decreases the reference count for this alias. """
self.alias_refcount[alias] -= amount | [
"def",
"unref_alias",
"(",
"self",
",",
"alias",
",",
"amount",
"=",
"1",
")",
":",
"self",
".",
"alias_refcount",
"[",
"alias",
"]",
"-=",
"amount"
] | [
680,
4
] | [
682,
44
] | python | en | ['en', 'en', 'en'] | True |
Query.promote_joins | (self, aliases) |
Promotes recursively the join type of given aliases and its children to
an outer join. If 'unconditional' is False, the join is only promoted if
it is nullable or the parent join is an outer join.
The children promotion is done to avoid join chains that contain a LOUTER
b INNER... |
Promotes recursively the join type of given aliases and its children to
an outer join. If 'unconditional' is False, the join is only promoted if
it is nullable or the parent join is an outer join. | def promote_joins(self, aliases):
"""
Promotes recursively the join type of given aliases and its children to
an outer join. If 'unconditional' is False, the join is only promoted if
it is nullable or the parent join is an outer join.
The children promotion is done to avoid join... | [
"def",
"promote_joins",
"(",
"self",
",",
"aliases",
")",
":",
"aliases",
"=",
"list",
"(",
"aliases",
")",
"while",
"aliases",
":",
"alias",
"=",
"aliases",
".",
"pop",
"(",
"0",
")",
"if",
"self",
".",
"alias_map",
"[",
"alias",
"]",
".",
"join_col... | [
684,
4
] | [
719,
49
] | python | en | ['en', 'error', 'th'] | False |
Query.demote_joins | (self, aliases) |
Change join type from LOUTER to INNER for all joins in aliases.
Similarly to promote_joins(), this method must ensure no join chains
containing first an outer, then an inner join are generated. If we
are demoting b->c join in chain a LOUTER b LOUTER c then we must
demote a->b a... |
Change join type from LOUTER to INNER for all joins in aliases. | def demote_joins(self, aliases):
"""
Change join type from LOUTER to INNER for all joins in aliases.
Similarly to promote_joins(), this method must ensure no join chains
containing first an outer, then an inner join are generated. If we
are demoting b->c join in chain a LOUTER b... | [
"def",
"demote_joins",
"(",
"self",
",",
"aliases",
")",
":",
"aliases",
"=",
"list",
"(",
"aliases",
")",
"while",
"aliases",
":",
"alias",
"=",
"aliases",
".",
"pop",
"(",
"0",
")",
"if",
"self",
".",
"alias_map",
"[",
"alias",
"]",
".",
"join_type... | [
721,
4
] | [
738,
48
] | python | en | ['en', 'error', 'th'] | False |
Query.reset_refcounts | (self, to_counts) |
This method will reset reference counts for aliases so that they match
the value passed in :param to_counts:.
|
This method will reset reference counts for aliases so that they match
the value passed in :param to_counts:.
| def reset_refcounts(self, to_counts):
"""
This method will reset reference counts for aliases so that they match
the value passed in :param to_counts:.
"""
for alias, cur_refcount in self.alias_refcount.copy().items():
unref_amount = cur_refcount - to_counts.get(alias... | [
"def",
"reset_refcounts",
"(",
"self",
",",
"to_counts",
")",
":",
"for",
"alias",
",",
"cur_refcount",
"in",
"self",
".",
"alias_refcount",
".",
"copy",
"(",
")",
".",
"items",
"(",
")",
":",
"unref_amount",
"=",
"cur_refcount",
"-",
"to_counts",
".",
"... | [
740,
4
] | [
747,
49
] | python | en | ['en', 'error', 'th'] | False |
Query.change_aliases | (self, change_map) |
Changes the aliases in change_map (which maps old-alias -> new-alias),
relabelling any references to them in select columns and the where
clause.
|
Changes the aliases in change_map (which maps old-alias -> new-alias),
relabelling any references to them in select columns and the where
clause.
| def change_aliases(self, change_map):
"""
Changes the aliases in change_map (which maps old-alias -> new-alias),
relabelling any references to them in select columns and the where
clause.
"""
assert set(change_map.keys()).intersection(set(change_map.values())) == set()
... | [
"def",
"change_aliases",
"(",
"self",
",",
"change_map",
")",
":",
"assert",
"set",
"(",
"change_map",
".",
"keys",
"(",
")",
")",
".",
"intersection",
"(",
"set",
"(",
"change_map",
".",
"values",
"(",
")",
")",
")",
"==",
"set",
"(",
")",
"def",
... | [
749,
4
] | [
807,
44
] | python | en | ['en', 'error', 'th'] | False |
Query.bump_prefix | (self, outer_query) |
Changes the alias prefix to the next letter in the alphabet in a way
that the outer query's aliases and this query's aliases will not
conflict. Even tables that previously had no alias will get an alias
after this call.
|
Changes the alias prefix to the next letter in the alphabet in a way
that the outer query's aliases and this query's aliases will not
conflict. Even tables that previously had no alias will get an alias
after this call.
| def bump_prefix(self, outer_query):
"""
Changes the alias prefix to the next letter in the alphabet in a way
that the outer query's aliases and this query's aliases will not
conflict. Even tables that previously had no alias will get an alias
after this call.
"""
... | [
"def",
"bump_prefix",
"(",
"self",
",",
"outer_query",
")",
":",
"if",
"self",
".",
"alias_prefix",
"!=",
"outer_query",
".",
"alias_prefix",
":",
"# No clashes between self and outer query should be possible.",
"return",
"self",
".",
"alias_prefix",
"=",
"chr",
"(",
... | [
809,
4
] | [
830,
39
] | python | en | ['en', 'error', 'th'] | False |
Query.get_initial_alias | (self) |
Returns the first alias for this query, after increasing its reference
count.
|
Returns the first alias for this query, after increasing its reference
count.
| def get_initial_alias(self):
"""
Returns the first alias for this query, after increasing its reference
count.
"""
if self.tables:
alias = self.tables[0]
self.ref_alias(alias)
else:
alias = self.join((None, self.get_meta().db_table, Non... | [
"def",
"get_initial_alias",
"(",
"self",
")",
":",
"if",
"self",
".",
"tables",
":",
"alias",
"=",
"self",
".",
"tables",
"[",
"0",
"]",
"self",
".",
"ref_alias",
"(",
"alias",
")",
"else",
":",
"alias",
"=",
"self",
".",
"join",
"(",
"(",
"None",
... | [
832,
4
] | [
842,
20
] | python | en | ['en', 'error', 'th'] | False |
Query.count_active_tables | (self) |
Returns the number of tables in this query with a non-zero reference
count. Note that after execution, the reference counts are zeroed, so
tables added in compiler will not be seen by this method.
|
Returns the number of tables in this query with a non-zero reference
count. Note that after execution, the reference counts are zeroed, so
tables added in compiler will not be seen by this method.
| def count_active_tables(self):
"""
Returns the number of tables in this query with a non-zero reference
count. Note that after execution, the reference counts are zeroed, so
tables added in compiler will not be seen by this method.
"""
return len([1 for count in self.alia... | [
"def",
"count_active_tables",
"(",
"self",
")",
":",
"return",
"len",
"(",
"[",
"1",
"for",
"count",
"in",
"self",
".",
"alias_refcount",
".",
"values",
"(",
")",
"if",
"count",
"]",
")"
] | [
844,
4
] | [
850,
74
] | python | en | ['en', 'error', 'th'] | False |
Query.join | (self, connection, reuse=None, nullable=False, join_field=None) |
Returns an alias for the join in 'connection', either reusing an
existing alias for that join or creating a new one. 'connection' is a
tuple (lhs, table, join_cols) where 'lhs' is either an existing
table alias or a table name. 'join_cols' is a tuple of tuples containing
columns... |
Returns an alias for the join in 'connection', either reusing an
existing alias for that join or creating a new one. 'connection' is a
tuple (lhs, table, join_cols) where 'lhs' is either an existing
table alias or a table name. 'join_cols' is a tuple of tuples containing
columns... | def join(self, connection, reuse=None, nullable=False, join_field=None):
"""
Returns an alias for the join in 'connection', either reusing an
existing alias for that join or creating a new one. 'connection' is a
tuple (lhs, table, join_cols) where 'lhs' is either an existing
tabl... | [
"def",
"join",
"(",
"self",
",",
"connection",
",",
"reuse",
"=",
"None",
",",
"nullable",
"=",
"False",
",",
"join_field",
"=",
"None",
")",
":",
"lhs",
",",
"table",
",",
"join_cols",
"=",
"connection",
"assert",
"lhs",
"is",
"None",
"or",
"join_fiel... | [
852,
4
] | [
910,
20
] | python | en | ['en', 'error', 'th'] | False |
Query.setup_inherited_models | (self) |
If the model that is the basis for this QuerySet inherits other models,
we need to ensure that those other models have their tables included in
the query.
We do this as a separate step so that subclasses know which
tables are going to be active in the query, without needing to ... |
If the model that is the basis for this QuerySet inherits other models,
we need to ensure that those other models have their tables included in
the query. | def setup_inherited_models(self):
"""
If the model that is the basis for this QuerySet inherits other models,
we need to ensure that those other models have their tables included in
the query.
We do this as a separate step so that subclasses know which
tables are going t... | [
"def",
"setup_inherited_models",
"(",
"self",
")",
":",
"opts",
"=",
"self",
".",
"get_meta",
"(",
")",
"root_alias",
"=",
"self",
".",
"tables",
"[",
"0",
"]",
"seen",
"=",
"{",
"None",
":",
"root_alias",
"}",
"for",
"field",
",",
"model",
"in",
"op... | [
912,
4
] | [
931,
45
] | python | en | ['en', 'error', 'th'] | False |
Query.join_parent_model | (self, opts, model, alias, seen) |
Makes sure the given 'model' is joined in the query. If 'model' isn't
a parent of 'opts' or if it is None this method is a no-op.
The 'alias' is the root alias for starting the join, 'seen' is a dict
of model -> alias of existing joins. It must also contain a mapping
of None ->... |
Makes sure the given 'model' is joined in the query. If 'model' isn't
a parent of 'opts' or if it is None this method is a no-op. | def join_parent_model(self, opts, model, alias, seen):
"""
Makes sure the given 'model' is joined in the query. If 'model' isn't
a parent of 'opts' or if it is None this method is a no-op.
The 'alias' is the root alias for starting the join, 'seen' is a dict
of model -> alias of... | [
"def",
"join_parent_model",
"(",
"self",
",",
"opts",
",",
"model",
",",
"alias",
",",
"seen",
")",
":",
"if",
"model",
"in",
"seen",
":",
"return",
"seen",
"[",
"model",
"]",
"chain",
"=",
"opts",
".",
"get_base_chain",
"(",
"model",
")",
"if",
"cha... | [
933,
4
] | [
963,
34
] | python | en | ['en', 'error', 'th'] | False |
Query.remove_inherited_models | (self) |
Undoes the effects of setup_inherited_models(). Should be called
whenever select columns (self.select) are set explicitly.
|
Undoes the effects of setup_inherited_models(). Should be called
whenever select columns (self.select) are set explicitly.
| def remove_inherited_models(self):
"""
Undoes the effects of setup_inherited_models(). Should be called
whenever select columns (self.select) are set explicitly.
"""
for key, alias in self.included_inherited_models.items():
if key:
self.unref_alias(ali... | [
"def",
"remove_inherited_models",
"(",
"self",
")",
":",
"for",
"key",
",",
"alias",
"in",
"self",
".",
"included_inherited_models",
".",
"items",
"(",
")",
":",
"if",
"key",
":",
"self",
".",
"unref_alias",
"(",
"alias",
")",
"self",
".",
"included_inheri... | [
965,
4
] | [
973,
43
] | python | en | ['en', 'error', 'th'] | False |
Query.add_aggregate | (self, aggregate, model, alias, is_summary) |
Adds a single aggregate expression to the Query
|
Adds a single aggregate expression to the Query
| def add_aggregate(self, aggregate, model, alias, is_summary):
"""
Adds a single aggregate expression to the Query
"""
opts = model._meta
field_list = aggregate.lookup.split(LOOKUP_SEP)
if len(field_list) == 1 and self._aggregates and aggregate.lookup in self.aggregates:
... | [
"def",
"add_aggregate",
"(",
"self",
",",
"aggregate",
",",
"model",
",",
"alias",
",",
"is_summary",
")",
":",
"opts",
"=",
"model",
".",
"_meta",
"field_list",
"=",
"aggregate",
".",
"lookup",
".",
"split",
"(",
"LOOKUP_SEP",
")",
"if",
"len",
"(",
"... | [
975,
4
] | [
1021,
90
] | python | en | ['en', 'error', 'th'] | False |
Query.solve_lookup_type | (self, lookup) |
Solve the lookup type from the lookup (eg: 'foobar__id__icontains')
|
Solve the lookup type from the lookup (eg: 'foobar__id__icontains')
| def solve_lookup_type(self, lookup):
"""
Solve the lookup type from the lookup (eg: 'foobar__id__icontains')
"""
lookup_splitted = lookup.split(LOOKUP_SEP)
if self._aggregates:
aggregate, aggregate_lookups = refs_aggregate(lookup_splitted, self.aggregates)
... | [
"def",
"solve_lookup_type",
"(",
"self",
",",
"lookup",
")",
":",
"lookup_splitted",
"=",
"lookup",
".",
"split",
"(",
"LOOKUP_SEP",
")",
"if",
"self",
".",
"_aggregates",
":",
"aggregate",
",",
"aggregate_lookups",
"=",
"refs_aggregate",
"(",
"lookup_splitted",... | [
1058,
4
] | [
1076,
47
] | python | en | ['en', 'error', 'th'] | False |
Query.check_query_object_type | (self, value, opts) |
Checks whether the object passed while querying is of the correct type.
If not, it raises a ValueError specifying the wrong object.
|
Checks whether the object passed while querying is of the correct type.
If not, it raises a ValueError specifying the wrong object.
| def check_query_object_type(self, value, opts):
"""
Checks whether the object passed while querying is of the correct type.
If not, it raises a ValueError specifying the wrong object.
"""
if hasattr(value, '_meta'):
if not (value._meta.concrete_model == opts.concrete_... | [
"def",
"check_query_object_type",
"(",
"self",
",",
"value",
",",
"opts",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'_meta'",
")",
":",
"if",
"not",
"(",
"value",
".",
"_meta",
".",
"concrete_model",
"==",
"opts",
".",
"concrete_model",
"or",
"opts"... | [
1078,
4
] | [
1089,
46
] | python | en | ['en', 'error', 'th'] | False |
Query.check_related_objects | (self, field, value, opts) |
Checks the type of object passed to query relations.
|
Checks the type of object passed to query relations.
| def check_related_objects(self, field, value, opts):
"""
Checks the type of object passed to query relations.
"""
if field.rel:
# testing for iterable of models
if hasattr(value, '__iter__'):
# Check if the iterable has a model attribute, if so
... | [
"def",
"check_related_objects",
"(",
"self",
",",
"field",
",",
"value",
",",
"opts",
")",
":",
"if",
"field",
".",
"rel",
":",
"# testing for iterable of models",
"if",
"hasattr",
"(",
"value",
",",
"'__iter__'",
")",
":",
"# Check if the iterable has a model att... | [
1091,
4
] | [
1113,
57
] | python | en | ['en', 'error', 'th'] | False |
Query.build_filter | (self, filter_expr, branch_negated=False, current_negated=False,
can_reuse=None, connector=AND) |
Builds a WhereNode for a single filter clause, but doesn't add it
to this Query. Query.add_q() will then add this filter to the where
or having Node.
The 'branch_negated' tells us if the current branch contains any
negations. This will be used to determine if subqueries are nee... |
Builds a WhereNode for a single filter clause, but doesn't add it
to this Query. Query.add_q() will then add this filter to the where
or having Node. | def build_filter(self, filter_expr, branch_negated=False, current_negated=False,
can_reuse=None, connector=AND):
"""
Builds a WhereNode for a single filter clause, but doesn't add it
to this Query. Query.add_q() will then add this filter to the where
or having Node.
... | [
"def",
"build_filter",
"(",
"self",
",",
"filter_expr",
",",
"branch_negated",
"=",
"False",
",",
"current_negated",
"=",
"False",
",",
"can_reuse",
"=",
"None",
",",
"connector",
"=",
"AND",
")",
":",
"arg",
",",
"value",
"=",
"filter_expr",
"if",
"not",
... | [
1136,
4
] | [
1252,
62
] | python | en | ['en', 'error', 'th'] | False |
Query.need_having | (self, obj) |
Returns whether or not all elements of this q_object need to be put
together in the HAVING clause.
|
Returns whether or not all elements of this q_object need to be put
together in the HAVING clause.
| def need_having(self, obj):
"""
Returns whether or not all elements of this q_object need to be put
together in the HAVING clause.
"""
if not self._aggregates:
return False
if not isinstance(obj, Node):
return (refs_aggregate(obj[0].split(LOOKUP_SE... | [
"def",
"need_having",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"self",
".",
"_aggregates",
":",
"return",
"False",
"if",
"not",
"isinstance",
"(",
"obj",
",",
"Node",
")",
":",
"return",
"(",
"refs_aggregate",
"(",
"obj",
"[",
"0",
"]",
".",
... | [
1257,
4
] | [
1268,
61
] | python | en | ['en', 'error', 'th'] | False |
Query.split_having_parts | (self, q_object, negated=False) |
Returns a list of q_objects which need to go into the having clause
instead of the where clause. Removes the splitted out nodes from the
given q_object. Note that the q_object is altered, so cloning it is
needed.
|
Returns a list of q_objects which need to go into the having clause
instead of the where clause. Removes the splitted out nodes from the
given q_object. Note that the q_object is altered, so cloning it is
needed.
| def split_having_parts(self, q_object, negated=False):
"""
Returns a list of q_objects which need to go into the having clause
instead of the where clause. Removes the splitted out nodes from the
given q_object. Note that the q_object is altered, so cloning it is
needed.
... | [
"def",
"split_having_parts",
"(",
"self",
",",
"q_object",
",",
"negated",
"=",
"False",
")",
":",
"having_parts",
"=",
"[",
"]",
"for",
"c",
"in",
"q_object",
".",
"children",
"[",
":",
"]",
":",
"# When constructing the having nodes we need to take care to",
"... | [
1270,
4
] | [
1297,
37
] | python | en | ['en', 'error', 'th'] | False |
Query.add_q | (self, q_object) |
A preprocessor for the internal _add_q(). Responsible for
splitting the given q_object into where and having parts and
setting up some internal variables.
|
A preprocessor for the internal _add_q(). Responsible for
splitting the given q_object into where and having parts and
setting up some internal variables.
| def add_q(self, q_object):
"""
A preprocessor for the internal _add_q(). Responsible for
splitting the given q_object into where and having parts and
setting up some internal variables.
"""
if not self.need_having(q_object):
where_part, having_parts = q_object... | [
"def",
"add_q",
"(",
"self",
",",
"q_object",
")",
":",
"if",
"not",
"self",
".",
"need_having",
"(",
"q_object",
")",
":",
"where_part",
",",
"having_parts",
"=",
"q_object",
",",
"[",
"]",
"else",
":",
"where_part",
",",
"having_parts",
"=",
"self",
... | [
1299,
4
] | [
1323,
41
] | python | en | ['en', 'error', 'th'] | False |
Query._add_q | (self, q_object, used_aliases, branch_negated=False,
current_negated=False) |
Adds a Q-object to the current filter.
|
Adds a Q-object to the current filter.
| def _add_q(self, q_object, used_aliases, branch_negated=False,
current_negated=False):
"""
Adds a Q-object to the current filter.
"""
connector = q_object.connector
current_negated = current_negated ^ q_object.negated
branch_negated = branch_negated or q_ob... | [
"def",
"_add_q",
"(",
"self",
",",
"q_object",
",",
"used_aliases",
",",
"branch_negated",
"=",
"False",
",",
"current_negated",
"=",
"False",
")",
":",
"connector",
"=",
"q_object",
".",
"connector",
"current_negated",
"=",
"current_negated",
"^",
"q_object",
... | [
1325,
4
] | [
1349,
42
] | python | en | ['en', 'error', 'th'] | False |
Query.names_to_path | (self, names, opts, allow_many=True, fail_on_missing=False) |
Walks the names path and turns them PathInfo tuples. Note that a
single name in 'names' can generate multiple PathInfos (m2m for
example).
'names' is the path of names to travel, 'opts' is the model Options we
start the name resolving from, 'allow_many' is as for setup_joins().... |
Walks the names path and turns them PathInfo tuples. Note that a
single name in 'names' can generate multiple PathInfos (m2m for
example). | def names_to_path(self, names, opts, allow_many=True, fail_on_missing=False):
"""
Walks the names path and turns them PathInfo tuples. Note that a
single name in 'names' can generate multiple PathInfos (m2m for
example).
'names' is the path of names to travel, 'opts' is the mode... | [
"def",
"names_to_path",
"(",
"self",
",",
"names",
",",
"opts",
",",
"allow_many",
"=",
"True",
",",
"fail_on_missing",
"=",
"False",
")",
":",
"path",
",",
"names_with_path",
"=",
"[",
"]",
",",
"[",
"]",
"for",
"pos",
",",
"name",
"in",
"enumerate",
... | [
1351,
4
] | [
1423,
58
] | python | en | ['en', 'error', 'th'] | False |
Query.setup_joins | (self, names, opts, alias, can_reuse=None, allow_many=True) |
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are starting from), 'alias' is the alias for
the table to start the joining from.
The 'can_reuse' defines the rever... |
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are starting from), 'alias' is the alias for
the table to start the joining from. | def setup_joins(self, names, opts, alias, can_reuse=None, allow_many=True):
"""
Compute the necessary table joins for the passage through the fields
given in 'names'. 'opts' is the Options class for the current model
(which gives the table we are starting from), 'alias' is the alias for
... | [
"def",
"setup_joins",
"(",
"self",
",",
"names",
",",
"opts",
",",
"alias",
",",
"can_reuse",
"=",
"None",
",",
"allow_many",
"=",
"True",
")",
":",
"joins",
"=",
"[",
"alias",
"]",
"# First, generate the path for the names",
"path",
",",
"final_field",
",",... | [
1425,
4
] | [
1471,
54
] | python | en | ['en', 'error', 'th'] | False |
Query.trim_joins | (self, targets, joins, path) |
The 'target' parameter is the final field being joined to, 'joins'
is the full list of join aliases. The 'path' contain the PathInfos
used to create the joins.
Returns the final target field and table alias and the new active
joins.
We will always trim any direct join ... |
The 'target' parameter is the final field being joined to, 'joins'
is the full list of join aliases. The 'path' contain the PathInfos
used to create the joins. | def trim_joins(self, targets, joins, path):
"""
The 'target' parameter is the final field being joined to, 'joins'
is the full list of join aliases. The 'path' contain the PathInfos
used to create the joins.
Returns the final target field and table alias and the new active
... | [
"def",
"trim_joins",
"(",
"self",
",",
"targets",
",",
"joins",
",",
"path",
")",
":",
"joins",
"=",
"joins",
"[",
":",
"]",
"for",
"pos",
",",
"info",
"in",
"enumerate",
"(",
"reversed",
"(",
"path",
")",
")",
":",
"if",
"len",
"(",
"joins",
")"... | [
1473,
4
] | [
1497,
40
] | python | en | ['en', 'error', 'th'] | False |
Query.split_exclude | (self, filter_expr, prefix, can_reuse, names_with_path) |
When doing an exclude against any kind of N-to-many relation, we need
to use a subquery. This method constructs the nested query, given the
original exclude filter (filter_expr) and the portion up to the first
N-to-many relation field.
As an example we could have original filte... |
When doing an exclude against any kind of N-to-many relation, we need
to use a subquery. This method constructs the nested query, given the
original exclude filter (filter_expr) and the portion up to the first
N-to-many relation field. | def split_exclude(self, filter_expr, prefix, can_reuse, names_with_path):
"""
When doing an exclude against any kind of N-to-many relation, we need
to use a subquery. This method constructs the nested query, given the
original exclude filter (filter_expr) and the portion up to the first
... | [
"def",
"split_exclude",
"(",
"self",
",",
"filter_expr",
",",
"prefix",
",",
"can_reuse",
",",
"names_with_path",
")",
":",
"# Generate the inner query.",
"query",
"=",
"Query",
"(",
"self",
".",
"model",
")",
"query",
".",
"add_filter",
"(",
"filter_expr",
")... | [
1499,
4
] | [
1561,
38
] | python | en | ['en', 'error', 'th'] | False |
Query.set_limits | (self, low=None, high=None) |
Adjusts the limits on the rows retrieved. We use low/high to set these,
as it makes it more Pythonic to read and write. When the SQL query is
created, they are converted to the appropriate offset and limit values.
Any limits passed in here are applied relative to the existing
c... |
Adjusts the limits on the rows retrieved. We use low/high to set these,
as it makes it more Pythonic to read and write. When the SQL query is
created, they are converted to the appropriate offset and limit values. | def set_limits(self, low=None, high=None):
"""
Adjusts the limits on the rows retrieved. We use low/high to set these,
as it makes it more Pythonic to read and write. When the SQL query is
created, they are converted to the appropriate offset and limit values.
Any limits passed ... | [
"def",
"set_limits",
"(",
"self",
",",
"low",
"=",
"None",
",",
"high",
"=",
"None",
")",
":",
"if",
"high",
"is",
"not",
"None",
":",
"if",
"self",
".",
"high_mark",
"is",
"not",
"None",
":",
"self",
".",
"high_mark",
"=",
"min",
"(",
"self",
".... | [
1570,
4
] | [
1589,
51
] | python | en | ['en', 'error', 'th'] | False |
Query.clear_limits | (self) |
Clears any existing limits.
|
Clears any existing limits.
| def clear_limits(self):
"""
Clears any existing limits.
"""
self.low_mark, self.high_mark = 0, None | [
"def",
"clear_limits",
"(",
"self",
")",
":",
"self",
".",
"low_mark",
",",
"self",
".",
"high_mark",
"=",
"0",
",",
"None"
] | [
1591,
4
] | [
1595,
47
] | python | en | ['en', 'error', 'th'] | False |
Query.can_filter | (self) |
Returns True if adding filters to this instance is still possible.
Typically, this means no limits or offsets have been put on the results.
|
Returns True if adding filters to this instance is still possible. | def can_filter(self):
"""
Returns True if adding filters to this instance is still possible.
Typically, this means no limits or offsets have been put on the results.
"""
return not self.low_mark and self.high_mark is None | [
"def",
"can_filter",
"(",
"self",
")",
":",
"return",
"not",
"self",
".",
"low_mark",
"and",
"self",
".",
"high_mark",
"is",
"None"
] | [
1597,
4
] | [
1603,
59
] | python | en | ['en', 'error', 'th'] | False |
Query.clear_select_clause | (self) |
Removes all fields from SELECT clause.
|
Removes all fields from SELECT clause.
| def clear_select_clause(self):
"""
Removes all fields from SELECT clause.
"""
self.select = []
self.default_cols = False
self.select_related = False
self.set_extra_mask(())
self.set_aggregate_mask(()) | [
"def",
"clear_select_clause",
"(",
"self",
")",
":",
"self",
".",
"select",
"=",
"[",
"]",
"self",
".",
"default_cols",
"=",
"False",
"self",
".",
"select_related",
"=",
"False",
"self",
".",
"set_extra_mask",
"(",
"(",
")",
")",
"self",
".",
"set_aggreg... | [
1605,
4
] | [
1613,
35
] | python | en | ['en', 'error', 'th'] | False |
Query.clear_select_fields | (self) |
Clears the list of fields to select (but not extra_select columns).
Some queryset types completely replace any existing list of select
columns.
|
Clears the list of fields to select (but not extra_select columns).
Some queryset types completely replace any existing list of select
columns.
| def clear_select_fields(self):
"""
Clears the list of fields to select (but not extra_select columns).
Some queryset types completely replace any existing list of select
columns.
"""
self.select = [] | [
"def",
"clear_select_fields",
"(",
"self",
")",
":",
"self",
".",
"select",
"=",
"[",
"]"
] | [
1615,
4
] | [
1621,
24
] | python | en | ['en', 'error', 'th'] | False |
Query.add_distinct_fields | (self, *field_names) |
Adds and resolves the given fields to the query's "distinct on" clause.
|
Adds and resolves the given fields to the query's "distinct on" clause.
| def add_distinct_fields(self, *field_names):
"""
Adds and resolves the given fields to the query's "distinct on" clause.
"""
self.distinct_fields = field_names
self.distinct = True | [
"def",
"add_distinct_fields",
"(",
"self",
",",
"*",
"field_names",
")",
":",
"self",
".",
"distinct_fields",
"=",
"field_names",
"self",
".",
"distinct",
"=",
"True"
] | [
1623,
4
] | [
1628,
28
] | python | en | ['en', 'error', 'th'] | False |
Query.add_fields | (self, field_names, allow_m2m=True) |
Adds the given (model) fields to the select set. The field names are
added in the order specified.
|
Adds the given (model) fields to the select set. The field names are
added in the order specified.
| def add_fields(self, field_names, allow_m2m=True):
"""
Adds the given (model) fields to the select set. The field names are
added in the order specified.
"""
alias = self.get_initial_alias()
opts = self.get_meta()
try:
for name in field_names:
... | [
"def",
"add_fields",
"(",
"self",
",",
"field_names",
",",
"allow_m2m",
"=",
"True",
")",
":",
"alias",
"=",
"self",
".",
"get_initial_alias",
"(",
")",
"opts",
"=",
"self",
".",
"get_meta",
"(",
")",
"try",
":",
"for",
"name",
"in",
"field_names",
":"... | [
1630,
4
] | [
1659,
38
] | python | en | ['en', 'error', 'th'] | False |
Query.add_ordering | (self, *ordering) |
Adds items from the 'ordering' sequence to the query's "order by"
clause. These items are either field names (not column names) --
possibly with a direction prefix ('-' or '?') -- or ordinals,
corresponding to column positions in the 'select' list.
If 'ordering' is empty, all o... |
Adds items from the 'ordering' sequence to the query's "order by"
clause. These items are either field names (not column names) --
possibly with a direction prefix ('-' or '?') -- or ordinals,
corresponding to column positions in the 'select' list. | def add_ordering(self, *ordering):
"""
Adds items from the 'ordering' sequence to the query's "order by"
clause. These items are either field names (not column names) --
possibly with a direction prefix ('-' or '?') -- or ordinals,
corresponding to column positions in the 'select... | [
"def",
"add_ordering",
"(",
"self",
",",
"*",
"ordering",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"item",
"in",
"ordering",
":",
"if",
"not",
"ORDER_PATTERN",
".",
"match",
"(",
"item",
")",
":",
"errors",
".",
"append",
"(",
"item",
")",
"if",
"... | [
1661,
4
] | [
1679,
41
] | python | en | ['en', 'error', 'th'] | False |
Query.clear_ordering | (self, force_empty) |
Removes any ordering settings. If 'force_empty' is True, there will be
no ordering in the resulting query (not even the model's default).
|
Removes any ordering settings. If 'force_empty' is True, there will be
no ordering in the resulting query (not even the model's default).
| def clear_ordering(self, force_empty):
"""
Removes any ordering settings. If 'force_empty' is True, there will be
no ordering in the resulting query (not even the model's default).
"""
self.order_by = []
self.extra_order_by = ()
if force_empty:
self.de... | [
"def",
"clear_ordering",
"(",
"self",
",",
"force_empty",
")",
":",
"self",
".",
"order_by",
"=",
"[",
"]",
"self",
".",
"extra_order_by",
"=",
"(",
")",
"if",
"force_empty",
":",
"self",
".",
"default_ordering",
"=",
"False"
] | [
1681,
4
] | [
1689,
41
] | python | en | ['en', 'error', 'th'] | False |
Query.set_group_by | (self) |
Expands the GROUP BY clause required by the query.
This will usually be the set of all non-aggregate fields in the
return data. If the database backend supports grouping by the
primary key, and the query would be equivalent, the optimization
will be made automatically.
|
Expands the GROUP BY clause required by the query. | def set_group_by(self):
"""
Expands the GROUP BY clause required by the query.
This will usually be the set of all non-aggregate fields in the
return data. If the database backend supports grouping by the
primary key, and the query would be equivalent, the optimization
w... | [
"def",
"set_group_by",
"(",
"self",
")",
":",
"self",
".",
"group_by",
"=",
"[",
"]",
"for",
"col",
",",
"_",
"in",
"self",
".",
"select",
":",
"self",
".",
"group_by",
".",
"append",
"(",
"col",
")"
] | [
1691,
4
] | [
1703,
37
] | python | en | ['en', 'error', 'th'] | False |
Query.add_count_column | (self) |
Converts the query to do count(...) or count(distinct(pk)) in order to
get its size.
|
Converts the query to do count(...) or count(distinct(pk)) in order to
get its size.
| def add_count_column(self):
"""
Converts the query to do count(...) or count(distinct(pk)) in order to
get its size.
"""
if not self.distinct:
if not self.select:
count = self.aggregates_module.Count('*', is_summary=True)
else:
... | [
"def",
"add_count_column",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"distinct",
":",
"if",
"not",
"self",
".",
"select",
":",
"count",
"=",
"self",
".",
"aggregates_module",
".",
"Count",
"(",
"'*'",
",",
"is_summary",
"=",
"True",
")",
"else",... | [
1705,
4
] | [
1738,
28
] | python | en | ['en', 'error', 'th'] | False |
Query.add_select_related | (self, fields) |
Sets up the select_related data structure so that we only select
certain related models (as opposed to all models, when
self.select_related=True).
|
Sets up the select_related data structure so that we only select
certain related models (as opposed to all models, when
self.select_related=True).
| def add_select_related(self, fields):
"""
Sets up the select_related data structure so that we only select
certain related models (as opposed to all models, when
self.select_related=True).
"""
if isinstance(self.select_related, bool):
field_dict = {}
e... | [
"def",
"add_select_related",
"(",
"self",
",",
"fields",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"select_related",
",",
"bool",
")",
":",
"field_dict",
"=",
"{",
"}",
"else",
":",
"field_dict",
"=",
"self",
".",
"select_related",
"for",
"field",
... | [
1740,
4
] | [
1755,
37
] | python | en | ['en', 'error', 'th'] | False |
Query.add_extra | (self, select, select_params, where, params, tables, order_by) |
Adds data to the various extra_* attributes for user-created additions
to the query.
|
Adds data to the various extra_* attributes for user-created additions
to the query.
| def add_extra(self, select, select_params, where, params, tables, order_by):
"""
Adds data to the various extra_* attributes for user-created additions
to the query.
"""
if select:
# We need to pair any placeholder markers in the 'select'
# dictionary with... | [
"def",
"add_extra",
"(",
"self",
",",
"select",
",",
"select_params",
",",
"where",
",",
"params",
",",
"tables",
",",
"order_by",
")",
":",
"if",
"select",
":",
"# We need to pair any placeholder markers in the 'select'",
"# dictionary with their parameters in 'select_pa... | [
1757,
4
] | [
1788,
42
] | python | en | ['en', 'error', 'th'] | False |
Query.clear_deferred_loading | (self) |
Remove any fields from the deferred loading set.
|
Remove any fields from the deferred loading set.
| def clear_deferred_loading(self):
"""
Remove any fields from the deferred loading set.
"""
self.deferred_loading = (set(), True) | [
"def",
"clear_deferred_loading",
"(",
"self",
")",
":",
"self",
".",
"deferred_loading",
"=",
"(",
"set",
"(",
")",
",",
"True",
")"
] | [
1790,
4
] | [
1794,
45
] | python | en | ['en', 'error', 'th'] | False |
Query.add_deferred_loading | (self, field_names) |
Add the given list of model field names to the set of fields to
exclude from loading from the database when automatic column selection
is done. The new field names are added to any existing field names that
are deferred (or removed from any existing field names that are marked
a... |
Add the given list of model field names to the set of fields to
exclude from loading from the database when automatic column selection
is done. The new field names are added to any existing field names that
are deferred (or removed from any existing field names that are marked
a... | def add_deferred_loading(self, field_names):
"""
Add the given list of model field names to the set of fields to
exclude from loading from the database when automatic column selection
is done. The new field names are added to any existing field names that
are deferred (or removed... | [
"def",
"add_deferred_loading",
"(",
"self",
",",
"field_names",
")",
":",
"# Fields on related models are stored in the literal double-underscore",
"# format, so that we can use a set datastructure. We do the foo__bar",
"# splitting and handling when computing the SQL column names (as part of",
... | [
1796,
4
] | [
1814,
75
] | python | en | ['en', 'error', 'th'] | False |
Query.add_immediate_loading | (self, field_names) |
Add the given list of model field names to the set of fields to
retrieve when the SQL is executed ("immediate loading" fields). The
field names replace any existing immediate loading field names. If
there are field names already specified for deferred loading, those
names are re... |
Add the given list of model field names to the set of fields to
retrieve when the SQL is executed ("immediate loading" fields). The
field names replace any existing immediate loading field names. If
there are field names already specified for deferred loading, those
names are re... | def add_immediate_loading(self, field_names):
"""
Add the given list of model field names to the set of fields to
retrieve when the SQL is executed ("immediate loading" fields). The
field names replace any existing immediate loading field names. If
there are field names already s... | [
"def",
"add_immediate_loading",
"(",
"self",
",",
"field_names",
")",
":",
"existing",
",",
"defer",
"=",
"self",
".",
"deferred_loading",
"field_names",
"=",
"set",
"(",
"field_names",
")",
"if",
"'pk'",
"in",
"field_names",
":",
"field_names",
".",
"remove",... | [
1816,
4
] | [
1838,
54
] | python | en | ['en', 'error', 'th'] | False |
Query.get_loaded_field_names | (self) |
If any fields are marked to be deferred, returns a dictionary mapping
models to a set of names in those fields that will be loaded. If a
model is not in the returned dictionary, none of its fields are
deferred.
If no fields are marked for deferral, returns an empty dictionary.
... |
If any fields are marked to be deferred, returns a dictionary mapping
models to a set of names in those fields that will be loaded. If a
model is not in the returned dictionary, none of its fields are
deferred. | def get_loaded_field_names(self):
"""
If any fields are marked to be deferred, returns a dictionary mapping
models to a set of names in those fields that will be loaded. If a
model is not in the returned dictionary, none of its fields are
deferred.
If no fields are marke... | [
"def",
"get_loaded_field_names",
"(",
"self",
")",
":",
"# We cache this because we call this function multiple times",
"# (compiler.fill_related_selections, query.iterator)",
"try",
":",
"return",
"self",
".",
"_loaded_field_names_cache",
"except",
"AttributeError",
":",
"collecti... | [
1840,
4
] | [
1857,
29
] | python | en | ['en', 'error', 'th'] | False |
Query.get_loaded_field_names_cb | (self, target, model, fields) |
Callback used by get_deferred_field_names().
|
Callback used by get_deferred_field_names().
| def get_loaded_field_names_cb(self, target, model, fields):
"""
Callback used by get_deferred_field_names().
"""
target[model] = set(f.name for f in fields) | [
"def",
"get_loaded_field_names_cb",
"(",
"self",
",",
"target",
",",
"model",
",",
"fields",
")",
":",
"target",
"[",
"model",
"]",
"=",
"set",
"(",
"f",
".",
"name",
"for",
"f",
"in",
"fields",
")"
] | [
1859,
4
] | [
1863,
51
] | python | en | ['en', 'error', 'th'] | False |
Query.set_aggregate_mask | (self, names) | Set the mask of aggregates that will actually be returned by the SELECT | Set the mask of aggregates that will actually be returned by the SELECT | def set_aggregate_mask(self, names):
"Set the mask of aggregates that will actually be returned by the SELECT"
if names is None:
self.aggregate_select_mask = None
else:
self.aggregate_select_mask = set(names)
self._aggregate_select_cache = None | [
"def",
"set_aggregate_mask",
"(",
"self",
",",
"names",
")",
":",
"if",
"names",
"is",
"None",
":",
"self",
".",
"aggregate_select_mask",
"=",
"None",
"else",
":",
"self",
".",
"aggregate_select_mask",
"=",
"set",
"(",
"names",
")",
"self",
".",
"_aggregat... | [
1865,
4
] | [
1871,
43
] | python | en | ['en', 'en', 'en'] | True |
Query.set_extra_mask | (self, names) |
Set the mask of extra select items that will be returned by SELECT,
we don't actually remove them from the Query since they might be used
later
|
Set the mask of extra select items that will be returned by SELECT,
we don't actually remove them from the Query since they might be used
later
| def set_extra_mask(self, names):
"""
Set the mask of extra select items that will be returned by SELECT,
we don't actually remove them from the Query since they might be used
later
"""
if names is None:
self.extra_select_mask = None
else:
s... | [
"def",
"set_extra_mask",
"(",
"self",
",",
"names",
")",
":",
"if",
"names",
"is",
"None",
":",
"self",
".",
"extra_select_mask",
"=",
"None",
"else",
":",
"self",
".",
"extra_select_mask",
"=",
"set",
"(",
"names",
")",
"self",
".",
"_extra_select_cache",... | [
1877,
4
] | [
1887,
39
] | python | en | ['en', 'error', 'th'] | False |
Query.aggregate_select | (self) | The OrderedDict of aggregate columns that are not masked, and should
be used in the SELECT clause.
This result is cached for optimization purposes.
| The OrderedDict of aggregate columns that are not masked, and should
be used in the SELECT clause. | def aggregate_select(self):
"""The OrderedDict of aggregate columns that are not masked, and should
be used in the SELECT clause.
This result is cached for optimization purposes.
"""
if self._aggregate_select_cache is not None:
return self._aggregate_select_cache
... | [
"def",
"aggregate_select",
"(",
"self",
")",
":",
"if",
"self",
".",
"_aggregate_select_cache",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_aggregate_select_cache",
"elif",
"not",
"self",
".",
"_aggregates",
":",
"return",
"{",
"}",
"elif",
"self",
".... | [
1890,
4
] | [
1907,
34
] | python | en | ['en', 'en', 'en'] | True |
Query.trim_start | (self, names_with_path) |
Trims joins from the start of the join path. The candidates for trim
are the PathInfos in names_with_path structure that are m2m joins.
Also sets the select column so the start matches the join.
This method is meant to be used for generating the subquery joins &
cols in split_... |
Trims joins from the start of the join path. The candidates for trim
are the PathInfos in names_with_path structure that are m2m joins. | def trim_start(self, names_with_path):
"""
Trims joins from the start of the join path. The candidates for trim
are the PathInfos in names_with_path structure that are m2m joins.
Also sets the select column so the start matches the join.
This method is meant to be used for gene... | [
"def",
"trim_start",
"(",
"self",
",",
"names_with_path",
")",
":",
"all_paths",
"=",
"[",
"]",
"for",
"_",
",",
"paths",
"in",
"names_with_path",
":",
"all_paths",
".",
"extend",
"(",
"paths",
")",
"contains_louter",
"=",
"False",
"# Trim and operate only on ... | [
1924,
4
] | [
1982,
46
] | python | en | ['en', 'error', 'th'] | False |
Query.is_nullable | (self, field) |
A helper to check if the given field should be treated as nullable.
Some backends treat '' as null and Django treats such fields as
nullable for those backends. In such situations field.null can be
False even if we should treat the field as nullable.
|
A helper to check if the given field should be treated as nullable. | def is_nullable(self, field):
"""
A helper to check if the given field should be treated as nullable.
Some backends treat '' as null and Django treats such fields as
nullable for those backends. In such situations field.null can be
False even if we should treat the field as null... | [
"def",
"is_nullable",
"(",
"self",
",",
"field",
")",
":",
"# We need to use DEFAULT_DB_ALIAS here, as QuerySet does not have",
"# (nor should it have) knowledge of which connection is going to be",
"# used. The proper fix would be to defer all decisions where",
"# is_nullable() is needed to t... | [
1984,
4
] | [
2001,
29
] | python | en | ['en', 'error', 'th'] | False |
JoinPromoter.add_votes | (self, inner_votes) |
Add single vote per item to self.inner_votes. Parameter can be any
iterable.
|
Add single vote per item to self.inner_votes. Parameter can be any
iterable.
| def add_votes(self, inner_votes):
"""
Add single vote per item to self.inner_votes. Parameter can be any
iterable.
"""
for voted in inner_votes:
self.inner_votes[voted] = self.inner_votes.get(voted, 0) + 1 | [
"def",
"add_votes",
"(",
"self",
",",
"inner_votes",
")",
":",
"for",
"voted",
"in",
"inner_votes",
":",
"self",
".",
"inner_votes",
"[",
"voted",
"]",
"=",
"self",
".",
"inner_votes",
".",
"get",
"(",
"voted",
",",
"0",
")",
"+",
"1"
] | [
2070,
4
] | [
2076,
72
] | python | en | ['en', 'error', 'th'] | False |
JoinPromoter.update_join_types | (self, query) |
Change join types so that the generated query is as efficient as
possible, but still correct. So, change as many joins as possible
to INNER, but don't make OUTER joins INNER if that could remove
results from the query.
|
Change join types so that the generated query is as efficient as
possible, but still correct. So, change as many joins as possible
to INNER, but don't make OUTER joins INNER if that could remove
results from the query.
| def update_join_types(self, query):
"""
Change join types so that the generated query is as efficient as
possible, but still correct. So, change as many joins as possible
to INNER, but don't make OUTER joins INNER if that could remove
results from the query.
"""
t... | [
"def",
"update_join_types",
"(",
"self",
",",
"query",
")",
":",
"to_promote",
"=",
"set",
"(",
")",
"to_demote",
"=",
"set",
"(",
")",
"# The effective_connector is used so that NOT (a AND b) is treated",
"# similarly to (a OR b) for join promotion.",
"for",
"table",
","... | [
2078,
4
] | [
2132,
24
] | python | en | ['en', 'error', 'th'] | False |
clear_scheduled_invitation_emails | (email: str) | Unlike most scheduled emails, invitation emails don't have an
existing user object to key off of, so we filter by address here. | Unlike most scheduled emails, invitation emails don't have an
existing user object to key off of, so we filter by address here. | def clear_scheduled_invitation_emails(email: str) -> None:
"""Unlike most scheduled emails, invitation emails don't have an
existing user object to key off of, so we filter by address here."""
items = ScheduledEmail.objects.filter(
address__iexact=email, type=ScheduledEmail.INVITATION_REMINDER
)... | [
"def",
"clear_scheduled_invitation_emails",
"(",
"email",
":",
"str",
")",
"->",
"None",
":",
"items",
"=",
"ScheduledEmail",
".",
"objects",
".",
"filter",
"(",
"address__iexact",
"=",
"email",
",",
"type",
"=",
"ScheduledEmail",
".",
"INVITATION_REMINDER",
")"... | [
309,
0
] | [
315,
18
] | python | en | ['en', 'en', 'en'] | True |
send_custom_email | (users: List[UserProfile], options: Dict[str, Any]) |
Can be used directly with from a management shell with
send_custom_email(user_profile_list, dict(
markdown_template_path="/path/to/markdown/file.md",
subject="Email Subject",
from_name="Sender Name")
)
|
Can be used directly with from a management shell with
send_custom_email(user_profile_list, dict(
markdown_template_path="/path/to/markdown/file.md",
subject="Email Subject",
from_name="Sender Name")
)
| def send_custom_email(users: List[UserProfile], options: Dict[str, Any]) -> None:
"""
Can be used directly with from a management shell with
send_custom_email(user_profile_list, dict(
markdown_template_path="/path/to/markdown/file.md",
subject="Email Subject",
from_name="Sender Name"... | [
"def",
"send_custom_email",
"(",
"users",
":",
"List",
"[",
"UserProfile",
"]",
",",
"options",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"None",
":",
"with",
"open",
"(",
"options",
"[",
"\"markdown_template_path\"",
"]",
")",
"as",
"f",
":... | [
383,
0
] | [
445,
9
] | python | en | ['en', 'error', 'th'] | False |
unpack | (path, dest='.') | Unpack a wheel.
Wheel content will be unpacked to {dest}/{name}-{ver}, where {name}
is the package name and {ver} its version.
:param path: The path to the wheel.
:param dest: Destination directory (default to current directory).
| Unpack a wheel. | def unpack(path, dest='.'):
"""Unpack a wheel.
Wheel content will be unpacked to {dest}/{name}-{ver}, where {name}
is the package name and {ver} its version.
:param path: The path to the wheel.
:param dest: Destination directory (default to current directory).
"""
with WheelFile(path) as w... | [
"def",
"unpack",
"(",
"path",
",",
"dest",
"=",
"'.'",
")",
":",
"with",
"WheelFile",
"(",
"path",
")",
"as",
"wf",
":",
"namever",
"=",
"wf",
".",
"parsed_filename",
".",
"group",
"(",
"'namever'",
")",
"destination",
"=",
"os",
".",
"path",
".",
... | [
8,
0
] | [
24,
15
] | python | en | ['en', 'gd', 'en'] | True |
install_lib.get_exclusions | (self) |
Return a collections.Sized collections.Container of paths to be
excluded for single_version_externally_managed installations.
|
Return a collections.Sized collections.Container of paths to be
excluded for single_version_externally_managed installations.
| def get_exclusions(self):
"""
Return a collections.Sized collections.Container of paths to be
excluded for single_version_externally_managed installations.
"""
all_packages = (
pkg
for ns_pkg in self._get_SVEM_NSPs()
for pkg in self._all_packag... | [
"def",
"get_exclusions",
"(",
"self",
")",
":",
"all_packages",
"=",
"(",
"pkg",
"for",
"ns_pkg",
"in",
"self",
".",
"_get_SVEM_NSPs",
"(",
")",
"for",
"pkg",
"in",
"self",
".",
"_all_packages",
"(",
"ns_pkg",
")",
")",
"excl_specs",
"=",
"product",
"(",... | [
16,
4
] | [
28,
63
] | python | en | ['en', 'error', 'th'] | False |
install_lib._exclude_pkg_path | (self, pkg, exclusion_path) |
Given a package name and exclusion path within that package,
compute the full exclusion path.
|
Given a package name and exclusion path within that package,
compute the full exclusion path.
| def _exclude_pkg_path(self, pkg, exclusion_path):
"""
Given a package name and exclusion path within that package,
compute the full exclusion path.
"""
parts = pkg.split('.') + [exclusion_path]
return os.path.join(self.install_dir, *parts) | [
"def",
"_exclude_pkg_path",
"(",
"self",
",",
"pkg",
",",
"exclusion_path",
")",
":",
"parts",
"=",
"pkg",
".",
"split",
"(",
"'.'",
")",
"+",
"[",
"exclusion_path",
"]",
"return",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"install_dir",
",",
... | [
30,
4
] | [
36,
53
] | python | en | ['en', 'error', 'th'] | False |
install_lib._all_packages | (pkg_name) |
>>> list(install_lib._all_packages('foo.bar.baz'))
['foo.bar.baz', 'foo.bar', 'foo']
|
>>> list(install_lib._all_packages('foo.bar.baz'))
['foo.bar.baz', 'foo.bar', 'foo']
| def _all_packages(pkg_name):
"""
>>> list(install_lib._all_packages('foo.bar.baz'))
['foo.bar.baz', 'foo.bar', 'foo']
"""
while pkg_name:
yield pkg_name
pkg_name, sep, child = pkg_name.rpartition('.') | [
"def",
"_all_packages",
"(",
"pkg_name",
")",
":",
"while",
"pkg_name",
":",
"yield",
"pkg_name",
"pkg_name",
",",
"sep",
",",
"child",
"=",
"pkg_name",
".",
"rpartition",
"(",
"'.'",
")"
] | [
39,
4
] | [
46,
59
] | python | en | ['en', 'error', 'th'] | False |
install_lib._get_SVEM_NSPs | (self) |
Get namespace packages (list) but only for
single_version_externally_managed installations and empty otherwise.
|
Get namespace packages (list) but only for
single_version_externally_managed installations and empty otherwise.
| def _get_SVEM_NSPs(self):
"""
Get namespace packages (list) but only for
single_version_externally_managed installations and empty otherwise.
"""
# TODO: is it necessary to short-circuit here? i.e. what's the cost
# if get_finalized_command is called even when namespace_p... | [
"def",
"_get_SVEM_NSPs",
"(",
"self",
")",
":",
"# TODO: is it necessary to short-circuit here? i.e. what's the cost",
"# if get_finalized_command is called even when namespace_packages is",
"# False?",
"if",
"not",
"self",
".",
"distribution",
".",
"namespace_packages",
":",
"retu... | [
48,
4
] | [
62,
67
] | python | en | ['en', 'error', 'th'] | False |
install_lib._gen_exclusion_paths | () |
Generate file paths to be excluded for namespace packages (bytecode
cache files).
|
Generate file paths to be excluded for namespace packages (bytecode
cache files).
| def _gen_exclusion_paths():
"""
Generate file paths to be excluded for namespace packages (bytecode
cache files).
"""
# always exclude the package module itself
yield '__init__.py'
yield '__init__.pyc'
yield '__init__.pyo'
if not hasattr(sys, 'im... | [
"def",
"_gen_exclusion_paths",
"(",
")",
":",
"# always exclude the package module itself",
"yield",
"'__init__.py'",
"yield",
"'__init__.pyc'",
"yield",
"'__init__.pyo'",
"if",
"not",
"hasattr",
"(",
"sys",
",",
"'implementation'",
")",
":",
"return",
"base",
"=",
"o... | [
65,
4
] | [
84,
33
] | python | en | ['en', 'error', 'th'] | False |
Loader.get_template | (self, template_name, skip=None) |
Perform the caching that gives this loader its name. Often many of the
templates attempted will be missing, so memory use is of concern here.
To keep it in check, caching behavior is a little complicated when a
template is not found. See ticket #26306 for more details.
With tem... |
Perform the caching that gives this loader its name. Often many of the
templates attempted will be missing, so memory use is of concern here.
To keep it in check, caching behavior is a little complicated when a
template is not found. See ticket #26306 for more details. | def get_template(self, template_name, skip=None):
"""
Perform the caching that gives this loader its name. Often many of the
templates attempted will be missing, so memory use is of concern here.
To keep it in check, caching behavior is a little complicated when a
template is not... | [
"def",
"get_template",
"(",
"self",
",",
"template_name",
",",
"skip",
"=",
"None",
")",
":",
"key",
"=",
"self",
".",
"cache_key",
"(",
"template_name",
",",
"skip",
")",
"cached",
"=",
"self",
".",
"get_template_cache",
".",
"get",
"(",
"key",
")",
"... | [
23,
4
] | [
59,
23
] | python | en | ['en', 'error', 'th'] | False |
Loader.cache_key | (self, template_name, skip=None) |
Generate a cache key for the template name and skip.
If skip is provided, only origins that match template_name are included
in the cache key. This ensures each template is only parsed and cached
once if contained in different extend chains like:
x -> a -> a
y ... |
Generate a cache key for the template name and skip. | def cache_key(self, template_name, skip=None):
"""
Generate a cache key for the template name and skip.
If skip is provided, only origins that match template_name are included
in the cache key. This ensures each template is only parsed and cached
once if contained in different e... | [
"def",
"cache_key",
"(",
"self",
",",
"template_name",
",",
"skip",
"=",
"None",
")",
":",
"skip_prefix",
"=",
"''",
"if",
"skip",
":",
"matching",
"=",
"[",
"origin",
".",
"name",
"for",
"origin",
"in",
"skip",
"if",
"origin",
".",
"template_name",
"=... | [
65,
4
] | [
84,
74
] | python | en | ['en', 'error', 'th'] | False |
Loader.reset | (self) | Empty the template cache. | Empty the template cache. | def reset(self):
"Empty the template cache."
self.get_template_cache.clear() | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"get_template_cache",
".",
"clear",
"(",
")"
] | [
89,
4
] | [
91,
39
] | python | en | ['en', 'en', 'en'] | True |
MergeDict.copy | (self) | Returns a copy of this object. | Returns a copy of this object. | def copy(self):
"""Returns a copy of this object."""
return self.__copy__() | [
"def",
"copy",
"(",
"self",
")",
":",
"return",
"self",
".",
"__copy__",
"(",
")"
] | [
97,
4
] | [
99,
30
] | python | en | ['en', 'en', 'en'] | True |
MergeDict.__str__ | (self) |
Returns something like
"{'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}"
instead of the generic "<object meta-data>" inherited from object.
|
Returns something like | def __str__(self):
'''
Returns something like
"{'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}"
instead of the generic "<object meta-data>" inherited from object.
'''
return str(dict(self.items())) | [
"def",
"__str__",
"(",
"self",
")",
":",
"return",
"str",
"(",
"dict",
"(",
"self",
".",
"items",
"(",
")",
")",
")"
] | [
101,
4
] | [
109,
38
] | python | en | ['en', 'error', 'th'] | False |
MergeDict.__repr__ | (self) |
Returns something like
MergeDict({'key1': 'val1', 'key2': 'val2'}, {'key3': 'val3'})
instead of generic "<object meta-data>" inherited from object.
|
Returns something like | def __repr__(self):
'''
Returns something like
MergeDict({'key1': 'val1', 'key2': 'val2'}, {'key3': 'val3'})
instead of generic "<object meta-data>" inherited from object.
'''
dictreprs = ', '.join(repr(d) for d in self.dicts)
return '%s(%s)' % (self.__class... | [
"def",
"__repr__",
"(",
"self",
")",
":",
"dictreprs",
"=",
"', '",
".",
"join",
"(",
"repr",
"(",
"d",
")",
"for",
"d",
"in",
"self",
".",
"dicts",
")",
"return",
"'%s(%s)'",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"dictreprs",
"... | [
111,
4
] | [
120,
62
] | python | en | ['en', 'error', 'th'] | False |
SortedDict.copy | (self) | Returns a copy of this object. | Returns a copy of this object. | def copy(self):
"""Returns a copy of this object."""
# This way of initializing the copy means it works for subclasses, too.
return self.__class__(self) | [
"def",
"copy",
"(",
"self",
")",
":",
"# This way of initializing the copy means it works for subclasses, too.",
"return",
"self",
".",
"__class__",
"(",
"self",
")"
] | [
229,
4
] | [
232,
35
] | python | en | ['en', 'en', 'en'] | True |
SortedDict.__repr__ | (self) |
Replaces the normal dict.__repr__ with a version that returns the keys
in their sorted order.
|
Replaces the normal dict.__repr__ with a version that returns the keys
in their sorted order.
| def __repr__(self):
"""
Replaces the normal dict.__repr__ with a version that returns the keys
in their sorted order.
"""
return '{%s}' % ', '.join('%r: %r' % (k, v) for k, v in six.iteritems(self)) | [
"def",
"__repr__",
"(",
"self",
")",
":",
"return",
"'{%s}'",
"%",
"', '",
".",
"join",
"(",
"'%r: %r'",
"%",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"self",
")",
")"
] | [
234,
4
] | [
239,
84
] | python | en | ['en', 'error', 'th'] | False |
MultiValueDict.__getitem__ | (self, key) |
Returns the last data value for this key, or [] if it's an empty list;
raises KeyError if not found.
|
Returns the last data value for this key, or [] if it's an empty list;
raises KeyError if not found.
| def __getitem__(self, key):
"""
Returns the last data value for this key, or [] if it's an empty list;
raises KeyError if not found.
"""
try:
list_ = super(MultiValueDict, self).__getitem__(key)
except KeyError:
raise MultiValueDictKeyError(repr(ke... | [
"def",
"__getitem__",
"(",
"self",
",",
"key",
")",
":",
"try",
":",
"list_",
"=",
"super",
"(",
"MultiValueDict",
",",
"self",
")",
".",
"__getitem__",
"(",
"key",
")",
"except",
"KeyError",
":",
"raise",
"MultiValueDictKeyError",
"(",
"repr",
"(",
"key... | [
310,
4
] | [
322,
21
] | python | en | ['en', 'error', 'th'] | False |
MultiValueDict.get | (self, key, default=None) |
Returns the last data value for the passed key. If key doesn't exist
or value is an empty list, then default is returned.
|
Returns the last data value for the passed key. If key doesn't exist
or value is an empty list, then default is returned.
| def get(self, key, default=None):
"""
Returns the last data value for the passed key. If key doesn't exist
or value is an empty list, then default is returned.
"""
try:
val = self[key]
except KeyError:
return default
if val == []:
... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"val",
"=",
"self",
"[",
"key",
"]",
"except",
"KeyError",
":",
"return",
"default",
"if",
"val",
"==",
"[",
"]",
":",
"return",
"default",
"return",
"val"
] | [
354,
4
] | [
365,
18
] | python | en | ['en', 'error', 'th'] | False |
MultiValueDict.getlist | (self, key, default=None) |
Returns the list of values for the passed key. If key doesn't exist,
then a default value is returned.
|
Returns the list of values for the passed key. If key doesn't exist,
then a default value is returned.
| def getlist(self, key, default=None):
"""
Returns the list of values for the passed key. If key doesn't exist,
then a default value is returned.
"""
try:
return super(MultiValueDict, self).__getitem__(key)
except KeyError:
if default is None:
... | [
"def",
"getlist",
"(",
"self",
",",
"key",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"return",
"super",
"(",
"MultiValueDict",
",",
"self",
")",
".",
"__getitem__",
"(",
"key",
")",
"except",
"KeyError",
":",
"if",
"default",
"is",
"None",
"... | [
367,
4
] | [
377,
26
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.