partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | BaseSchema._deserialize | Deserialize ``data`` based on the schema defined by ``fields_dict``.
:param dict data: The data to deserialize.
:param dict fields_dict: Mapping of field names to :class:`Field` objects.
:param ErrorStore error_store: Structure to store errors.
:param bool many: Set to `True` if ``data`... | src/marshmallow/schema.py | def _deserialize(
self, data, fields_dict, error_store, many=False, partial=False,
unknown=RAISE, dict_class=dict, index_errors=True, index=None,
):
"""Deserialize ``data`` based on the schema defined by ``fields_dict``.
:param dict data: The data to deserialize.
:param dict... | def _deserialize(
self, data, fields_dict, error_store, many=False, partial=False,
unknown=RAISE, dict_class=dict, index_errors=True, index=None,
):
"""Deserialize ``data`` based on the schema defined by ``fields_dict``.
:param dict data: The data to deserialize.
:param dict... | [
"Deserialize",
"data",
"based",
"on",
"the",
"schema",
"defined",
"by",
"fields_dict",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L579-L682 | [
"def",
"_deserialize",
"(",
"self",
",",
"data",
",",
"fields_dict",
",",
"error_store",
",",
"many",
"=",
"False",
",",
"partial",
"=",
"False",
",",
"unknown",
"=",
"RAISE",
",",
"dict_class",
"=",
"dict",
",",
"index_errors",
"=",
"True",
",",
"index"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema.load | Deserialize a data structure to an object defined by this Schema's fields.
:param dict data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
value for `self.many` is used.
:param bool|tuple partial: Whether to ignore missing f... | src/marshmallow/schema.py | def load(self, data, many=None, partial=None, unknown=None):
"""Deserialize a data structure to an object defined by this Schema's fields.
:param dict data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
value for `self.many`... | def load(self, data, many=None, partial=None, unknown=None):
"""Deserialize a data structure to an object defined by this Schema's fields.
:param dict data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
value for `self.many`... | [
"Deserialize",
"a",
"data",
"structure",
"to",
"an",
"object",
"defined",
"by",
"this",
"Schema",
"s",
"fields",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L684-L709 | [
"def",
"load",
"(",
"self",
",",
"data",
",",
"many",
"=",
"None",
",",
"partial",
"=",
"None",
",",
"unknown",
"=",
"None",
")",
":",
"return",
"self",
".",
"_do_load",
"(",
"data",
",",
"many",
",",
"partial",
"=",
"partial",
",",
"unknown",
"=",... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema.loads | Same as :meth:`load`, except it takes a JSON string as input.
:param str json_data: A JSON string of the data to deserialize.
:param bool many: Whether to deserialize `obj` as a collection. If `None`, the
value for `self.many` is used.
:param bool|tuple partial: Whether to ignore mi... | src/marshmallow/schema.py | def loads(
self, json_data, many=None, partial=None, unknown=None,
**kwargs
):
"""Same as :meth:`load`, except it takes a JSON string as input.
:param str json_data: A JSON string of the data to deserialize.
:param bool many: Whether to deserialize `obj` as a collection. If ... | def loads(
self, json_data, many=None, partial=None, unknown=None,
**kwargs
):
"""Same as :meth:`load`, except it takes a JSON string as input.
:param str json_data: A JSON string of the data to deserialize.
:param bool many: Whether to deserialize `obj` as a collection. If ... | [
"Same",
"as",
":",
"meth",
":",
"load",
"except",
"it",
"takes",
"a",
"JSON",
"string",
"as",
"input",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L711-L737 | [
"def",
"loads",
"(",
"self",
",",
"json_data",
",",
"many",
"=",
"None",
",",
"partial",
"=",
"None",
",",
"unknown",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"opts",
".",
"render_module",
".",
"loads",
"(",
"json_d... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema.validate | Validate `data` against the schema, returning a dictionary of
validation errors.
:param dict data: The data to validate.
:param bool many: Whether to validate `data` as a collection. If `None`, the
value for `self.many` is used.
:param bool|tuple partial: Whether to ignore m... | src/marshmallow/schema.py | def validate(self, data, many=None, partial=None):
"""Validate `data` against the schema, returning a dictionary of
validation errors.
:param dict data: The data to validate.
:param bool many: Whether to validate `data` as a collection. If `None`, the
value for `self.many` i... | def validate(self, data, many=None, partial=None):
"""Validate `data` against the schema, returning a dictionary of
validation errors.
:param dict data: The data to validate.
:param bool many: Whether to validate `data` as a collection. If `None`, the
value for `self.many` i... | [
"Validate",
"data",
"against",
"the",
"schema",
"returning",
"a",
"dictionary",
"of",
"validation",
"errors",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L752-L772 | [
"def",
"validate",
"(",
"self",
",",
"data",
",",
"many",
"=",
"None",
",",
"partial",
"=",
"None",
")",
":",
"try",
":",
"self",
".",
"_do_load",
"(",
"data",
",",
"many",
",",
"partial",
"=",
"partial",
",",
"postprocess",
"=",
"False",
")",
"exc... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema._do_load | Deserialize `data`, returning the deserialized result.
:param data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
value for `self.many` is used.
:param bool|tuple partial: Whether to validate required fields. If its value is... | src/marshmallow/schema.py | def _do_load(
self, data, many=None, partial=None, unknown=None,
postprocess=True,
):
"""Deserialize `data`, returning the deserialized result.
:param data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
v... | def _do_load(
self, data, many=None, partial=None, unknown=None,
postprocess=True,
):
"""Deserialize `data`, returning the deserialized result.
:param data: The data to deserialize.
:param bool many: Whether to deserialize `data` as a collection. If `None`, the
v... | [
"Deserialize",
"data",
"returning",
"the",
"deserialized",
"result",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L776-L870 | [
"def",
"_do_load",
"(",
"self",
",",
"data",
",",
"many",
"=",
"None",
",",
"partial",
"=",
"None",
",",
"unknown",
"=",
"None",
",",
"postprocess",
"=",
"True",
",",
")",
":",
"error_store",
"=",
"ErrorStore",
"(",
")",
"errors",
"=",
"{",
"}",
"m... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema._normalize_nested_options | Apply then flatten nested schema options | src/marshmallow/schema.py | def _normalize_nested_options(self):
"""Apply then flatten nested schema options"""
if self.only is not None:
# Apply the only option to nested fields.
self.__apply_nested_option('only', self.only, 'intersection')
# Remove the child field names from the only option.
... | def _normalize_nested_options(self):
"""Apply then flatten nested schema options"""
if self.only is not None:
# Apply the only option to nested fields.
self.__apply_nested_option('only', self.only, 'intersection')
# Remove the child field names from the only option.
... | [
"Apply",
"then",
"flatten",
"nested",
"schema",
"options"
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L872-L894 | [
"def",
"_normalize_nested_options",
"(",
"self",
")",
":",
"if",
"self",
".",
"only",
"is",
"not",
"None",
":",
"# Apply the only option to nested fields.",
"self",
".",
"__apply_nested_option",
"(",
"'only'",
",",
"self",
".",
"only",
",",
"'intersection'",
")",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema.__apply_nested_option | Apply nested options to nested fields | src/marshmallow/schema.py | def __apply_nested_option(self, option_name, field_names, set_operation):
"""Apply nested options to nested fields"""
# Split nested field names on the first dot.
nested_fields = [name.split('.', 1) for name in field_names if '.' in name]
# Partition the nested field names by parent fiel... | def __apply_nested_option(self, option_name, field_names, set_operation):
"""Apply nested options to nested fields"""
# Split nested field names on the first dot.
nested_fields = [name.split('.', 1) for name in field_names if '.' in name]
# Partition the nested field names by parent fiel... | [
"Apply",
"nested",
"options",
"to",
"nested",
"fields"
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L896-L913 | [
"def",
"__apply_nested_option",
"(",
"self",
",",
"option_name",
",",
"field_names",
",",
"set_operation",
")",
":",
"# Split nested field names on the first dot.",
"nested_fields",
"=",
"[",
"name",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"for",
"name",
"in",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema._init_fields | Update fields based on schema options. | src/marshmallow/schema.py | def _init_fields(self):
"""Update fields based on schema options."""
if self.opts.fields:
available_field_names = self.set_class(self.opts.fields)
else:
available_field_names = self.set_class(self.declared_fields.keys())
if self.opts.additional:
... | def _init_fields(self):
"""Update fields based on schema options."""
if self.opts.fields:
available_field_names = self.set_class(self.opts.fields)
else:
available_field_names = self.set_class(self.declared_fields.keys())
if self.opts.additional:
... | [
"Update",
"fields",
"based",
"on",
"schema",
"options",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L915-L977 | [
"def",
"_init_fields",
"(",
"self",
")",
":",
"if",
"self",
".",
"opts",
".",
"fields",
":",
"available_field_names",
"=",
"self",
".",
"set_class",
"(",
"self",
".",
"opts",
".",
"fields",
")",
"else",
":",
"available_field_names",
"=",
"self",
".",
"se... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | BaseSchema._bind_field | Bind field to the schema, setting any necessary attributes on the
field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was
specified in ``class Meta``. | src/marshmallow/schema.py | def _bind_field(self, field_name, field_obj):
"""Bind field to the schema, setting any necessary attributes on the
field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was
specified in ``class Meta``.
"""
try:
if field_nam... | def _bind_field(self, field_name, field_obj):
"""Bind field to the schema, setting any necessary attributes on the
field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was
specified in ``class Meta``.
"""
try:
if field_nam... | [
"Bind",
"field",
"to",
"the",
"schema",
"setting",
"any",
"necessary",
"attributes",
"on",
"the",
"field",
"(",
"e",
".",
"g",
".",
"parent",
"and",
"name",
")",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/schema.py#L986-L1008 | [
"def",
"_bind_field",
"(",
"self",
",",
"field_name",
",",
"field_obj",
")",
":",
"try",
":",
"if",
"field_name",
"in",
"self",
".",
"load_only",
":",
"field_obj",
".",
"load_only",
"=",
"True",
"if",
"field_name",
"in",
"self",
".",
"dump_only",
":",
"f... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | validates_schema | Register a schema-level validator.
By default, receives a single object at a time, regardless of whether ``many=True``
is passed to the `Schema`. If ``pass_many=True``, the raw data (which may be a collection)
and the value for ``many`` is passed.
If ``pass_original=True``, the original data (before u... | src/marshmallow/decorators.py | def validates_schema(
fn=None,
pass_many=False,
pass_original=False,
skip_on_field_errors=True,
):
"""Register a schema-level validator.
By default, receives a single object at a time, regardless of whether ``many=True``
is passed to the `Schema`. If ``pass_many=True``, the raw data (which ... | def validates_schema(
fn=None,
pass_many=False,
pass_original=False,
skip_on_field_errors=True,
):
"""Register a schema-level validator.
By default, receives a single object at a time, regardless of whether ``many=True``
is passed to the `Schema`. If ``pass_many=True``, the raw data (which ... | [
"Register",
"a",
"schema",
"-",
"level",
"validator",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/decorators.py#L72-L98 | [
"def",
"validates_schema",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
",",
"pass_original",
"=",
"False",
",",
"skip_on_field_errors",
"=",
"True",
",",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"VALIDATES_SCHEMA",
",",
"pass_many",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | post_dump | Register a method to invoke after serializing an object. The method
receives the serialized object and returns the processed object.
By default, receives a single object at a time, transparently handling the ``many``
argument passed to the Schema. If ``pass_many=True``, the raw data
(which may be a col... | src/marshmallow/decorators.py | def post_dump(fn=None, pass_many=False, pass_original=False):
"""Register a method to invoke after serializing an object. The method
receives the serialized object and returns the processed object.
By default, receives a single object at a time, transparently handling the ``many``
argument passed to th... | def post_dump(fn=None, pass_many=False, pass_original=False):
"""Register a method to invoke after serializing an object. The method
receives the serialized object and returns the processed object.
By default, receives a single object at a time, transparently handling the ``many``
argument passed to th... | [
"Register",
"a",
"method",
"to",
"invoke",
"after",
"serializing",
"an",
"object",
".",
"The",
"method",
"receives",
"the",
"serialized",
"object",
"and",
"returns",
"the",
"processed",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/decorators.py#L112-L123 | [
"def",
"post_dump",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
",",
"pass_original",
"=",
"False",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"POST_DUMP",
",",
"pass_many",
")",
",",
"pass_original",
"=",
"pass_original",
")"
] | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | post_load | Register a method to invoke after deserializing an object. The method
receives the deserialized data and returns the processed data.
By default, receives a single datum at a time, transparently handling the ``many``
argument passed to the Schema. If ``pass_many=True``, the raw data
(which may be a coll... | src/marshmallow/decorators.py | def post_load(fn=None, pass_many=False, pass_original=False):
"""Register a method to invoke after deserializing an object. The method
receives the deserialized data and returns the processed data.
By default, receives a single datum at a time, transparently handling the ``many``
argument passed to the... | def post_load(fn=None, pass_many=False, pass_original=False):
"""Register a method to invoke after deserializing an object. The method
receives the deserialized data and returns the processed data.
By default, receives a single datum at a time, transparently handling the ``many``
argument passed to the... | [
"Register",
"a",
"method",
"to",
"invoke",
"after",
"deserializing",
"an",
"object",
".",
"The",
"method",
"receives",
"the",
"deserialized",
"data",
"and",
"returns",
"the",
"processed",
"data",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/decorators.py#L137-L148 | [
"def",
"post_load",
"(",
"fn",
"=",
"None",
",",
"pass_many",
"=",
"False",
",",
"pass_original",
"=",
"False",
")",
":",
"return",
"set_hook",
"(",
"fn",
",",
"(",
"POST_LOAD",
",",
"pass_many",
")",
",",
"pass_original",
"=",
"pass_original",
")"
] | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | set_hook | Mark decorated function as a hook to be picked up later.
.. note::
Currently only works with functions and instance methods. Class and
static methods are not supported.
:return: Decorated function if supplied, else this decorator with its args
bound. | src/marshmallow/decorators.py | def set_hook(fn, key, **kwargs):
"""Mark decorated function as a hook to be picked up later.
.. note::
Currently only works with functions and instance methods. Class and
static methods are not supported.
:return: Decorated function if supplied, else this decorator with its args
bo... | def set_hook(fn, key, **kwargs):
"""Mark decorated function as a hook to be picked up later.
.. note::
Currently only works with functions and instance methods. Class and
static methods are not supported.
:return: Decorated function if supplied, else this decorator with its args
bo... | [
"Mark",
"decorated",
"function",
"as",
"a",
"hook",
"to",
"be",
"picked",
"up",
"later",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/decorators.py#L151-L175 | [
"def",
"set_hook",
"(",
"fn",
",",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"# Allow using this as either a decorator or a decorator factory.",
"if",
"fn",
"is",
"None",
":",
"return",
"functools",
".",
"partial",
"(",
"set_hook",
",",
"key",
"=",
"key",
",",... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | OneOf.options | Return a generator over the (value, label) pairs, where value
is a string associated with each choice. This convenience method
is useful to populate, for instance, a form select field.
:param valuegetter: Can be a callable or a string. In the former case, it must
be a one-argument c... | src/marshmallow/validate.py | def options(self, valuegetter=text_type):
"""Return a generator over the (value, label) pairs, where value
is a string associated with each choice. This convenience method
is useful to populate, for instance, a form select field.
:param valuegetter: Can be a callable or a string. In the... | def options(self, valuegetter=text_type):
"""Return a generator over the (value, label) pairs, where value
is a string associated with each choice. This convenience method
is useful to populate, for instance, a form select field.
:param valuegetter: Can be a callable or a string. In the... | [
"Return",
"a",
"generator",
"over",
"the",
"(",
"value",
"label",
")",
"pairs",
"where",
"value",
"is",
"a",
"string",
"associated",
"with",
"each",
"choice",
".",
"This",
"convenience",
"method",
"is",
"useful",
"to",
"populate",
"for",
"instance",
"a",
"... | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/validate.py#L441-L455 | [
"def",
"options",
"(",
"self",
",",
"valuegetter",
"=",
"text_type",
")",
":",
"valuegetter",
"=",
"valuegetter",
"if",
"callable",
"(",
"valuegetter",
")",
"else",
"attrgetter",
"(",
"valuegetter",
")",
"pairs",
"=",
"zip_longest",
"(",
"self",
".",
"choice... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | merge_errors | Deeply merge two error messages.
The format of ``errors1`` and ``errors2`` matches the ``message``
parameter of :exc:`marshmallow.exceptions.ValidationError`. | src/marshmallow/error_store.py | def merge_errors(errors1, errors2):
"""Deeply merge two error messages.
The format of ``errors1`` and ``errors2`` matches the ``message``
parameter of :exc:`marshmallow.exceptions.ValidationError`.
"""
if not errors1:
return errors2
if not errors2:
return errors1
if isinstan... | def merge_errors(errors1, errors2):
"""Deeply merge two error messages.
The format of ``errors1`` and ``errors2`` matches the ``message``
parameter of :exc:`marshmallow.exceptions.ValidationError`.
"""
if not errors1:
return errors2
if not errors2:
return errors1
if isinstan... | [
"Deeply",
"merge",
"two",
"error",
"messages",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/error_store.py#L35-L79 | [
"def",
"merge_errors",
"(",
"errors1",
",",
"errors2",
")",
":",
"if",
"not",
"errors1",
":",
"return",
"errors2",
"if",
"not",
"errors2",
":",
"return",
"errors1",
"if",
"isinstance",
"(",
"errors1",
",",
"list",
")",
":",
"if",
"isinstance",
"(",
"erro... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | register | Add a class to the registry of serializer classes. When a class is
registered, an entry for both its classname and its full, module-qualified
path are added to the registry.
Example: ::
class MyClass:
pass
register('MyClass', MyClass)
# Registry:
# {
# ... | src/marshmallow/class_registry.py | def register(classname, cls):
"""Add a class to the registry of serializer classes. When a class is
registered, an entry for both its classname and its full, module-qualified
path are added to the registry.
Example: ::
class MyClass:
pass
register('MyClass', MyClass)
... | def register(classname, cls):
"""Add a class to the registry of serializer classes. When a class is
registered, an entry for both its classname and its full, module-qualified
path are added to the registry.
Example: ::
class MyClass:
pass
register('MyClass', MyClass)
... | [
"Add",
"a",
"class",
"to",
"the",
"registry",
"of",
"serializer",
"classes",
".",
"When",
"a",
"class",
"is",
"registered",
"an",
"entry",
"for",
"both",
"its",
"classname",
"and",
"its",
"full",
"module",
"-",
"qualified",
"path",
"are",
"added",
"to",
... | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/class_registry.py#L22-L60 | [
"def",
"register",
"(",
"classname",
",",
"cls",
")",
":",
"# Module where the class is located",
"module",
"=",
"cls",
".",
"__module__",
"# Full module path to the class",
"# e.g. user.schemas.UserSchema",
"fullpath",
"=",
"'.'",
".",
"join",
"(",
"[",
"module",
","... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | get_class | Retrieve a class from the registry.
:raises: marshmallow.exceptions.RegistryError if the class cannot be found
or if there are multiple entries for the given class name. | src/marshmallow/class_registry.py | def get_class(classname, all=False):
"""Retrieve a class from the registry.
:raises: marshmallow.exceptions.RegistryError if the class cannot be found
or if there are multiple entries for the given class name.
"""
try:
classes = _registry[classname]
except KeyError:
raise Re... | def get_class(classname, all=False):
"""Retrieve a class from the registry.
:raises: marshmallow.exceptions.RegistryError if the class cannot be found
or if there are multiple entries for the given class name.
"""
try:
classes = _registry[classname]
except KeyError:
raise Re... | [
"Retrieve",
"a",
"class",
"from",
"the",
"registry",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/class_registry.py#L62-L80 | [
"def",
"get_class",
"(",
"classname",
",",
"all",
"=",
"False",
")",
":",
"try",
":",
"classes",
"=",
"_registry",
"[",
"classname",
"]",
"except",
"KeyError",
":",
"raise",
"RegistryError",
"(",
"'Class with name {!r} was not found. You may need '",
"'to import the... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field.get_value | Return the value for a given key from an object.
:param object obj: The object to get the value from
:param str attr: The attribute/key in `obj` to get the value from.
:param callable accessor: A callable used to retrieve the value of `attr` from
the object `obj`. Defaults to `marsh... | src/marshmallow/fields.py | def get_value(self, obj, attr, accessor=None, default=missing_):
"""Return the value for a given key from an object.
:param object obj: The object to get the value from
:param str attr: The attribute/key in `obj` to get the value from.
:param callable accessor: A callable used to retrie... | def get_value(self, obj, attr, accessor=None, default=missing_):
"""Return the value for a given key from an object.
:param object obj: The object to get the value from
:param str attr: The attribute/key in `obj` to get the value from.
:param callable accessor: A callable used to retrie... | [
"Return",
"the",
"value",
"for",
"a",
"given",
"key",
"from",
"an",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L204-L217 | [
"def",
"get_value",
"(",
"self",
",",
"obj",
",",
"attr",
",",
"accessor",
"=",
"None",
",",
"default",
"=",
"missing_",
")",
":",
"# NOTE: Use getattr instead of direct attribute access here so that",
"# subclasses aren't required to define `attribute` member",
"attribute",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field._validate | Perform validation on ``value``. Raise a :exc:`ValidationError` if validation
does not succeed. | src/marshmallow/fields.py | def _validate(self, value):
"""Perform validation on ``value``. Raise a :exc:`ValidationError` if validation
does not succeed.
"""
errors = []
kwargs = {}
for validator in self.validators:
try:
r = validator(value)
if not isinst... | def _validate(self, value):
"""Perform validation on ``value``. Raise a :exc:`ValidationError` if validation
does not succeed.
"""
errors = []
kwargs = {}
for validator in self.validators:
try:
r = validator(value)
if not isinst... | [
"Perform",
"validation",
"on",
"value",
".",
"Raise",
"a",
":",
"exc",
":",
"ValidationError",
"if",
"validation",
"does",
"not",
"succeed",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L219-L237 | [
"def",
"_validate",
"(",
"self",
",",
"value",
")",
":",
"errors",
"=",
"[",
"]",
"kwargs",
"=",
"{",
"}",
"for",
"validator",
"in",
"self",
".",
"validators",
":",
"try",
":",
"r",
"=",
"validator",
"(",
"value",
")",
"if",
"not",
"isinstance",
"(... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field._validate_missing | Validate missing values. Raise a :exc:`ValidationError` if
`value` should be considered missing. | src/marshmallow/fields.py | def _validate_missing(self, value):
"""Validate missing values. Raise a :exc:`ValidationError` if
`value` should be considered missing.
"""
if value is missing_:
if hasattr(self, 'required') and self.required:
self.fail('required')
if value is None:
... | def _validate_missing(self, value):
"""Validate missing values. Raise a :exc:`ValidationError` if
`value` should be considered missing.
"""
if value is missing_:
if hasattr(self, 'required') and self.required:
self.fail('required')
if value is None:
... | [
"Validate",
"missing",
"values",
".",
"Raise",
"a",
":",
"exc",
":",
"ValidationError",
"if",
"value",
"should",
"be",
"considered",
"missing",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L253-L262 | [
"def",
"_validate_missing",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"missing_",
":",
"if",
"hasattr",
"(",
"self",
",",
"'required'",
")",
"and",
"self",
".",
"required",
":",
"self",
".",
"fail",
"(",
"'required'",
")",
"if",
"value"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field.serialize | Pulls the value for the given key from the object, applies the
field's formatting and returns the result.
:param str attr: The attribute or key to get from the object.
:param str obj: The object to pull the key from.
:param callable accessor: Function used to pull values from ``obj``.
... | src/marshmallow/fields.py | def serialize(self, attr, obj, accessor=None, **kwargs):
"""Pulls the value for the given key from the object, applies the
field's formatting and returns the result.
:param str attr: The attribute or key to get from the object.
:param str obj: The object to pull the key from.
:p... | def serialize(self, attr, obj, accessor=None, **kwargs):
"""Pulls the value for the given key from the object, applies the
field's formatting and returns the result.
:param str attr: The attribute or key to get from the object.
:param str obj: The object to pull the key from.
:p... | [
"Pulls",
"the",
"value",
"for",
"the",
"given",
"key",
"from",
"the",
"object",
"applies",
"the",
"field",
"s",
"formatting",
"and",
"returns",
"the",
"result",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L264-L283 | [
"def",
"serialize",
"(",
"self",
",",
"attr",
",",
"obj",
",",
"accessor",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"_CHECK_ATTRIBUTE",
":",
"value",
"=",
"self",
".",
"get_value",
"(",
"obj",
",",
"attr",
",",
"accessor",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field.deserialize | Deserialize ``value``.
:param value: The value to be deserialized.
:param str attr: The attribute/key in `data` to be deserialized.
:param dict data: The raw input data passed to the `Schema.load`.
:param dict kwargs': Field-specific keyword arguments.
:raise ValidationError: If... | src/marshmallow/fields.py | def deserialize(self, value, attr=None, data=None, **kwargs):
"""Deserialize ``value``.
:param value: The value to be deserialized.
:param str attr: The attribute/key in `data` to be deserialized.
:param dict data: The raw input data passed to the `Schema.load`.
:param dict kwar... | def deserialize(self, value, attr=None, data=None, **kwargs):
"""Deserialize ``value``.
:param value: The value to be deserialized.
:param str attr: The attribute/key in `data` to be deserialized.
:param dict data: The raw input data passed to the `Schema.load`.
:param dict kwar... | [
"Deserialize",
"value",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L285-L305 | [
"def",
"deserialize",
"(",
"self",
",",
"value",
",",
"attr",
"=",
"None",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# Validate required fields, deserialize, then validate",
"# deserialized value",
"self",
".",
"_validate_missing",
"(",
"value"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field._bind_to_schema | Update field with values from its parent schema. Called by
:meth:`_bind_field<marshmallow.Schema._bind_field>`.
:param str field_name: Field name set in schema.
:param Schema schema: Parent schema. | src/marshmallow/fields.py | def _bind_to_schema(self, field_name, schema):
"""Update field with values from its parent schema. Called by
:meth:`_bind_field<marshmallow.Schema._bind_field>`.
:param str field_name: Field name set in schema.
:param Schema schema: Parent schema.
"""
self.parent = s... | def _bind_to_schema(self, field_name, schema):
"""Update field with values from its parent schema. Called by
:meth:`_bind_field<marshmallow.Schema._bind_field>`.
:param str field_name: Field name set in schema.
:param Schema schema: Parent schema.
"""
self.parent = s... | [
"Update",
"field",
"with",
"values",
"from",
"its",
"parent",
"schema",
".",
"Called",
"by",
":",
"meth",
":",
"_bind_field<marshmallow",
".",
"Schema",
".",
"_bind_field",
">",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L309-L317 | [
"def",
"_bind_to_schema",
"(",
"self",
",",
"field_name",
",",
"schema",
")",
":",
"self",
".",
"parent",
"=",
"self",
".",
"parent",
"or",
"schema",
"self",
".",
"name",
"=",
"self",
".",
"name",
"or",
"field_name"
] | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Field.root | Reference to the `Schema` that this field belongs to even if it is buried in a `List`.
Return `None` for unbound fields. | src/marshmallow/fields.py | def root(self):
"""Reference to the `Schema` that this field belongs to even if it is buried in a `List`.
Return `None` for unbound fields.
"""
ret = self
while hasattr(ret, 'parent') and ret.parent:
ret = ret.parent
return ret if isinstance(ret, SchemaABC) el... | def root(self):
"""Reference to the `Schema` that this field belongs to even if it is buried in a `List`.
Return `None` for unbound fields.
"""
ret = self
while hasattr(ret, 'parent') and ret.parent:
ret = ret.parent
return ret if isinstance(ret, SchemaABC) el... | [
"Reference",
"to",
"the",
"Schema",
"that",
"this",
"field",
"belongs",
"to",
"even",
"if",
"it",
"is",
"buried",
"in",
"a",
"List",
".",
"Return",
"None",
"for",
"unbound",
"fields",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L366-L373 | [
"def",
"root",
"(",
"self",
")",
":",
"ret",
"=",
"self",
"while",
"hasattr",
"(",
"ret",
",",
"'parent'",
")",
"and",
"ret",
".",
"parent",
":",
"ret",
"=",
"ret",
".",
"parent",
"return",
"ret",
"if",
"isinstance",
"(",
"ret",
",",
"SchemaABC",
"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Nested.schema | The nested Schema object.
.. versionchanged:: 1.0.0
Renamed from `serializer` to `schema` | src/marshmallow/fields.py | def schema(self):
"""The nested Schema object.
.. versionchanged:: 1.0.0
Renamed from `serializer` to `schema`
"""
if not self.__schema:
# Inherit context from parent.
context = getattr(self.parent, 'context', {})
if isinstance(self.nested... | def schema(self):
"""The nested Schema object.
.. versionchanged:: 1.0.0
Renamed from `serializer` to `schema`
"""
if not self.__schema:
# Inherit context from parent.
context = getattr(self.parent, 'context', {})
if isinstance(self.nested... | [
"The",
"nested",
"Schema",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L435-L467 | [
"def",
"schema",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"__schema",
":",
"# Inherit context from parent.",
"context",
"=",
"getattr",
"(",
"self",
".",
"parent",
",",
"'context'",
",",
"{",
"}",
")",
"if",
"isinstance",
"(",
"self",
".",
"neste... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Nested._deserialize | Same as :meth:`Field._deserialize` with additional ``partial`` argument.
:param bool|tuple partial: For nested schemas, the ``partial``
parameter passed to `Schema.load`.
.. versionchanged:: 3.0.0
Add ``partial`` parameter | src/marshmallow/fields.py | def _deserialize(self, value, attr, data, partial=None, **kwargs):
"""Same as :meth:`Field._deserialize` with additional ``partial`` argument.
:param bool|tuple partial: For nested schemas, the ``partial``
parameter passed to `Schema.load`.
.. versionchanged:: 3.0.0
Add... | def _deserialize(self, value, attr, data, partial=None, **kwargs):
"""Same as :meth:`Field._deserialize` with additional ``partial`` argument.
:param bool|tuple partial: For nested schemas, the ``partial``
parameter passed to `Schema.load`.
.. versionchanged:: 3.0.0
Add... | [
"Same",
"as",
":",
"meth",
":",
"Field",
".",
"_deserialize",
"with",
"additional",
"partial",
"argument",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L499-L509 | [
"def",
"_deserialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"data",
",",
"partial",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_test_collection",
"(",
"value",
")",
"return",
"self",
".",
"_load",
"(",
"value",
",",
"data",... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | UUID._validated | Format the value or raise a :exc:`ValidationError` if an error occurs. | src/marshmallow/fields.py | def _validated(self, value):
"""Format the value or raise a :exc:`ValidationError` if an error occurs."""
if value is None:
return None
if isinstance(value, uuid.UUID):
return value
try:
if isinstance(value, bytes) and len(value) == 16:
... | def _validated(self, value):
"""Format the value or raise a :exc:`ValidationError` if an error occurs."""
if value is None:
return None
if isinstance(value, uuid.UUID):
return value
try:
if isinstance(value, bytes) and len(value) == 16:
... | [
"Format",
"the",
"value",
"or",
"raise",
"a",
":",
"exc",
":",
"ValidationError",
"if",
"an",
"error",
"occurs",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L728-L740 | [
"def",
"_validated",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"if",
"isinstance",
"(",
"value",
",",
"uuid",
".",
"UUID",
")",
":",
"return",
"value",
"try",
":",
"if",
"isinstance",
"(",
"value",
",",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Number._format_num | Return the number value for value, given this field's `num_type`. | src/marshmallow/fields.py | def _format_num(self, value):
"""Return the number value for value, given this field's `num_type`."""
# (value is True or value is False) is ~5x faster than isinstance(value, bool)
if value is True or value is False:
raise TypeError('value must be a Number, not a boolean.')
r... | def _format_num(self, value):
"""Return the number value for value, given this field's `num_type`."""
# (value is True or value is False) is ~5x faster than isinstance(value, bool)
if value is True or value is False:
raise TypeError('value must be a Number, not a boolean.')
r... | [
"Return",
"the",
"number",
"value",
"for",
"value",
"given",
"this",
"field",
"s",
"num_type",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L767-L772 | [
"def",
"_format_num",
"(",
"self",
",",
"value",
")",
":",
"# (value is True or value is False) is ~5x faster than isinstance(value, bool)",
"if",
"value",
"is",
"True",
"or",
"value",
"is",
"False",
":",
"raise",
"TypeError",
"(",
"'value must be a Number, not a boolean.'"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Number._validated | Format the value or raise a :exc:`ValidationError` if an error occurs. | src/marshmallow/fields.py | def _validated(self, value):
"""Format the value or raise a :exc:`ValidationError` if an error occurs."""
if value is None:
return None
try:
return self._format_num(value)
except (TypeError, ValueError):
self.fail('invalid', input=value)
except... | def _validated(self, value):
"""Format the value or raise a :exc:`ValidationError` if an error occurs."""
if value is None:
return None
try:
return self._format_num(value)
except (TypeError, ValueError):
self.fail('invalid', input=value)
except... | [
"Format",
"the",
"value",
"or",
"raise",
"a",
":",
"exc",
":",
"ValidationError",
"if",
"an",
"error",
"occurs",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L774-L783 | [
"def",
"_validated",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"None",
"try",
":",
"return",
"self",
".",
"_format_num",
"(",
"value",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"self",
".",
"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Number._serialize | Return a string if `self.as_string=True`, otherwise return this field's `num_type`. | src/marshmallow/fields.py | def _serialize(self, value, attr, obj, **kwargs):
"""Return a string if `self.as_string=True`, otherwise return this field's `num_type`."""
ret = self._validated(value)
return (
self._to_string(ret)
if (self.as_string and ret not in (None, missing_))
else ret
... | def _serialize(self, value, attr, obj, **kwargs):
"""Return a string if `self.as_string=True`, otherwise return this field's `num_type`."""
ret = self._validated(value)
return (
self._to_string(ret)
if (self.as_string and ret not in (None, missing_))
else ret
... | [
"Return",
"a",
"string",
"if",
"self",
".",
"as_string",
"=",
"True",
"otherwise",
"return",
"this",
"field",
"s",
"num_type",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L788-L795 | [
"def",
"_serialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"obj",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"self",
".",
"_validated",
"(",
"value",
")",
"return",
"(",
"self",
".",
"_to_string",
"(",
"ret",
")",
"if",
"(",
"self",
".... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | Time._deserialize | Deserialize an ISO8601-formatted time to a :class:`datetime.time` object. | src/marshmallow/fields.py | def _deserialize(self, value, attr, data, **kwargs):
"""Deserialize an ISO8601-formatted time to a :class:`datetime.time` object."""
if not value: # falsy values are invalid
self.fail('invalid')
try:
return utils.from_iso_time(value)
except (AttributeError, TypeE... | def _deserialize(self, value, attr, data, **kwargs):
"""Deserialize an ISO8601-formatted time to a :class:`datetime.time` object."""
if not value: # falsy values are invalid
self.fail('invalid')
try:
return utils.from_iso_time(value)
except (AttributeError, TypeE... | [
"Deserialize",
"an",
"ISO8601",
"-",
"formatted",
"time",
"to",
"a",
":",
"class",
":",
"datetime",
".",
"time",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/fields.py#L1143-L1150 | [
"def",
"_deserialize",
"(",
"self",
",",
"value",
",",
"attr",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"value",
":",
"# falsy values are invalid",
"self",
".",
"fail",
"(",
"'invalid'",
")",
"try",
":",
"return",
"utils",
".",
"fro... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | is_instance_or_subclass | Return True if ``val`` is either a subclass or instance of ``class_``. | src/marshmallow/utils.py | def is_instance_or_subclass(val, class_):
"""Return True if ``val`` is either a subclass or instance of ``class_``."""
try:
return issubclass(val, class_)
except TypeError:
return isinstance(val, class_) | def is_instance_or_subclass(val, class_):
"""Return True if ``val`` is either a subclass or instance of ``class_``."""
try:
return issubclass(val, class_)
except TypeError:
return isinstance(val, class_) | [
"Return",
"True",
"if",
"val",
"is",
"either",
"a",
"subclass",
"or",
"instance",
"of",
"class_",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L72-L77 | [
"def",
"is_instance_or_subclass",
"(",
"val",
",",
"class_",
")",
":",
"try",
":",
"return",
"issubclass",
"(",
"val",
",",
"class_",
")",
"except",
"TypeError",
":",
"return",
"isinstance",
"(",
"val",
",",
"class_",
")"
] | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | pprint | Pretty-printing function that can pretty-print OrderedDicts
like regular dictionaries. Useful for printing the output of
:meth:`marshmallow.Schema.dump`. | src/marshmallow/utils.py | def pprint(obj, *args, **kwargs):
"""Pretty-printing function that can pretty-print OrderedDicts
like regular dictionaries. Useful for printing the output of
:meth:`marshmallow.Schema.dump`.
"""
if isinstance(obj, collections.OrderedDict):
print(json.dumps(obj, *args, **kwargs))
else:
... | def pprint(obj, *args, **kwargs):
"""Pretty-printing function that can pretty-print OrderedDicts
like regular dictionaries. Useful for printing the output of
:meth:`marshmallow.Schema.dump`.
"""
if isinstance(obj, collections.OrderedDict):
print(json.dumps(obj, *args, **kwargs))
else:
... | [
"Pretty",
"-",
"printing",
"function",
"that",
"can",
"pretty",
"-",
"print",
"OrderedDicts",
"like",
"regular",
"dictionaries",
".",
"Useful",
"for",
"printing",
"the",
"output",
"of",
":",
"meth",
":",
"marshmallow",
".",
"Schema",
".",
"dump",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L86-L94 | [
"def",
"pprint",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"obj",
",",
"collections",
".",
"OrderedDict",
")",
":",
"print",
"(",
"json",
".",
"dumps",
"(",
"obj",
",",
"*",
"args",
",",
"*",
"*",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | local_rfcformat | Return the RFC822-formatted representation of a timezone-aware datetime
with the UTC offset. | src/marshmallow/utils.py | def local_rfcformat(dt):
"""Return the RFC822-formatted representation of a timezone-aware datetime
with the UTC offset.
"""
weekday = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][dt.weekday()]
month = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov'... | def local_rfcformat(dt):
"""Return the RFC822-formatted representation of a timezone-aware datetime
with the UTC offset.
"""
weekday = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'][dt.weekday()]
month = [
'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov'... | [
"Return",
"the",
"RFC822",
"-",
"formatted",
"representation",
"of",
"a",
"timezone",
"-",
"aware",
"datetime",
"with",
"the",
"UTC",
"offset",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L151-L164 | [
"def",
"local_rfcformat",
"(",
"dt",
")",
":",
"weekday",
"=",
"[",
"'Mon'",
",",
"'Tue'",
",",
"'Wed'",
",",
"'Thu'",
",",
"'Fri'",
",",
"'Sat'",
",",
"'Sun'",
"]",
"[",
"dt",
".",
"weekday",
"(",
")",
"]",
"month",
"=",
"[",
"'Jan'",
",",
"'Feb... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | rfcformat | Return the RFC822-formatted representation of a datetime object.
:param datetime dt: The datetime.
:param bool localtime: If ``True``, return the date relative to the local
timezone instead of UTC, displaying the proper offset,
e.g. "Sun, 10 Nov 2013 08:23:45 -0600" | src/marshmallow/utils.py | def rfcformat(dt, localtime=False):
"""Return the RFC822-formatted representation of a datetime object.
:param datetime dt: The datetime.
:param bool localtime: If ``True``, return the date relative to the local
timezone instead of UTC, displaying the proper offset,
e.g. "Sun, 10 Nov 2013 0... | def rfcformat(dt, localtime=False):
"""Return the RFC822-formatted representation of a datetime object.
:param datetime dt: The datetime.
:param bool localtime: If ``True``, return the date relative to the local
timezone instead of UTC, displaying the proper offset,
e.g. "Sun, 10 Nov 2013 0... | [
"Return",
"the",
"RFC822",
"-",
"formatted",
"representation",
"of",
"a",
"datetime",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L167-L178 | [
"def",
"rfcformat",
"(",
"dt",
",",
"localtime",
"=",
"False",
")",
":",
"if",
"not",
"localtime",
":",
"return",
"formatdate",
"(",
"timegm",
"(",
"dt",
".",
"utctimetuple",
"(",
")",
")",
")",
"else",
":",
"return",
"local_rfcformat",
"(",
"dt",
")"
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | isoformat | Return the ISO8601-formatted UTC representation of a datetime object. | src/marshmallow/utils.py | def isoformat(dt, localtime=False, *args, **kwargs):
"""Return the ISO8601-formatted UTC representation of a datetime object."""
if localtime and dt.tzinfo is not None:
localized = dt
else:
if dt.tzinfo is None:
localized = UTC.localize(dt)
else:
localized = d... | def isoformat(dt, localtime=False, *args, **kwargs):
"""Return the ISO8601-formatted UTC representation of a datetime object."""
if localtime and dt.tzinfo is not None:
localized = dt
else:
if dt.tzinfo is None:
localized = UTC.localize(dt)
else:
localized = d... | [
"Return",
"the",
"ISO8601",
"-",
"formatted",
"UTC",
"representation",
"of",
"a",
"datetime",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L199-L208 | [
"def",
"isoformat",
"(",
"dt",
",",
"localtime",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"localtime",
"and",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
":",
"localized",
"=",
"dt",
"else",
":",
"if",
"dt",
".",
"tz... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | from_rfc | Parse a RFC822-formatted datetime string and return a datetime object.
Use dateutil's parser if possible.
https://stackoverflow.com/questions/885015/how-to-parse-a-rfc-2822-date-time-into-a-python-datetime | src/marshmallow/utils.py | def from_rfc(datestring, use_dateutil=True):
"""Parse a RFC822-formatted datetime string and return a datetime object.
Use dateutil's parser if possible.
https://stackoverflow.com/questions/885015/how-to-parse-a-rfc-2822-date-time-into-a-python-datetime
"""
# Use dateutil's parser if possible
... | def from_rfc(datestring, use_dateutil=True):
"""Parse a RFC822-formatted datetime string and return a datetime object.
Use dateutil's parser if possible.
https://stackoverflow.com/questions/885015/how-to-parse-a-rfc-2822-date-time-into-a-python-datetime
"""
# Use dateutil's parser if possible
... | [
"Parse",
"a",
"RFC822",
"-",
"formatted",
"datetime",
"string",
"and",
"return",
"a",
"datetime",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L211-L224 | [
"def",
"from_rfc",
"(",
"datestring",
",",
"use_dateutil",
"=",
"True",
")",
":",
"# Use dateutil's parser if possible",
"if",
"dateutil_available",
"and",
"use_dateutil",
":",
"return",
"parser",
".",
"parse",
"(",
"datestring",
")",
"else",
":",
"parsed",
"=",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | from_iso_datetime | Parse an ISO8601-formatted datetime string and return a datetime object.
Use dateutil's parser if possible and return a timezone-aware datetime. | src/marshmallow/utils.py | def from_iso_datetime(datetimestring, use_dateutil=True):
"""Parse an ISO8601-formatted datetime string and return a datetime object.
Use dateutil's parser if possible and return a timezone-aware datetime.
"""
if not _iso8601_datetime_re.match(datetimestring):
raise ValueError('Not a valid ISO8... | def from_iso_datetime(datetimestring, use_dateutil=True):
"""Parse an ISO8601-formatted datetime string and return a datetime object.
Use dateutil's parser if possible and return a timezone-aware datetime.
"""
if not _iso8601_datetime_re.match(datetimestring):
raise ValueError('Not a valid ISO8... | [
"Parse",
"an",
"ISO8601",
"-",
"formatted",
"datetime",
"string",
"and",
"return",
"a",
"datetime",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L227-L239 | [
"def",
"from_iso_datetime",
"(",
"datetimestring",
",",
"use_dateutil",
"=",
"True",
")",
":",
"if",
"not",
"_iso8601_datetime_re",
".",
"match",
"(",
"datetimestring",
")",
":",
"raise",
"ValueError",
"(",
"'Not a valid ISO8601-formatted datetime string'",
")",
"# Us... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | from_iso_time | Parse an ISO8601-formatted datetime string and return a datetime.time
object. | src/marshmallow/utils.py | def from_iso_time(timestring, use_dateutil=True):
"""Parse an ISO8601-formatted datetime string and return a datetime.time
object.
"""
if not _iso8601_time_re.match(timestring):
raise ValueError('Not a valid ISO8601-formatted time string')
if dateutil_available and use_dateutil:
retu... | def from_iso_time(timestring, use_dateutil=True):
"""Parse an ISO8601-formatted datetime string and return a datetime.time
object.
"""
if not _iso8601_time_re.match(timestring):
raise ValueError('Not a valid ISO8601-formatted time string')
if dateutil_available and use_dateutil:
retu... | [
"Parse",
"an",
"ISO8601",
"-",
"formatted",
"datetime",
"string",
"and",
"return",
"a",
"datetime",
".",
"time",
"object",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L242-L255 | [
"def",
"from_iso_time",
"(",
"timestring",
",",
"use_dateutil",
"=",
"True",
")",
":",
"if",
"not",
"_iso8601_time_re",
".",
"match",
"(",
"timestring",
")",
":",
"raise",
"ValueError",
"(",
"'Not a valid ISO8601-formatted time string'",
")",
"if",
"dateutil_availab... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | set_value | Set a value in a dict. If `key` contains a '.', it is assumed
be a path (i.e. dot-delimited string) to the value's location.
::
>>> d = {}
>>> set_value(d, 'foo.bar', 42)
>>> d
{'foo': {'bar': 42}} | src/marshmallow/utils.py | def set_value(dct, key, value):
"""Set a value in a dict. If `key` contains a '.', it is assumed
be a path (i.e. dot-delimited string) to the value's location.
::
>>> d = {}
>>> set_value(d, 'foo.bar', 42)
>>> d
{'foo': {'bar': 42}}
"""
if '.' in key:
head, ... | def set_value(dct, key, value):
"""Set a value in a dict. If `key` contains a '.', it is assumed
be a path (i.e. dot-delimited string) to the value's location.
::
>>> d = {}
>>> set_value(d, 'foo.bar', 42)
>>> d
{'foo': {'bar': 42}}
"""
if '.' in key:
head, ... | [
"Set",
"a",
"value",
"in",
"a",
"dict",
".",
"If",
"key",
"contains",
"a",
".",
"it",
"is",
"assumed",
"be",
"a",
"path",
"(",
"i",
".",
"e",
".",
"dot",
"-",
"delimited",
"string",
")",
"to",
"the",
"value",
"s",
"location",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L323-L344 | [
"def",
"set_value",
"(",
"dct",
",",
"key",
",",
"value",
")",
":",
"if",
"'.'",
"in",
"key",
":",
"head",
",",
"rest",
"=",
"key",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"target",
"=",
"dct",
".",
"setdefault",
"(",
"head",
",",
"{",
"}",
... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | get_func_args | Given a callable, return a tuple of argument names. Handles
`functools.partial` objects and class-based callables.
.. versionchanged:: 3.0.0a1
Do not return bound arguments, eg. ``self``. | src/marshmallow/utils.py | def get_func_args(func):
"""Given a callable, return a tuple of argument names. Handles
`functools.partial` objects and class-based callables.
.. versionchanged:: 3.0.0a1
Do not return bound arguments, eg. ``self``.
"""
if isinstance(func, functools.partial):
return _signature(func.... | def get_func_args(func):
"""Given a callable, return a tuple of argument names. Handles
`functools.partial` objects and class-based callables.
.. versionchanged:: 3.0.0a1
Do not return bound arguments, eg. ``self``.
"""
if isinstance(func, functools.partial):
return _signature(func.... | [
"Given",
"a",
"callable",
"return",
"a",
"tuple",
"of",
"argument",
"names",
".",
"Handles",
"functools",
".",
"partial",
"objects",
"and",
"class",
"-",
"based",
"callables",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L365-L377 | [
"def",
"get_func_args",
"(",
"func",
")",
":",
"if",
"isinstance",
"(",
"func",
",",
"functools",
".",
"partial",
")",
":",
"return",
"_signature",
"(",
"func",
".",
"func",
")",
"if",
"inspect",
".",
"isfunction",
"(",
"func",
")",
"or",
"inspect",
".... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | resolve_field_instance | Return a Schema instance from a Schema class or instance.
:param type|Schema cls_or_instance: Marshmallow Schema class or instance. | src/marshmallow/utils.py | def resolve_field_instance(cls_or_instance):
"""Return a Schema instance from a Schema class or instance.
:param type|Schema cls_or_instance: Marshmallow Schema class or instance.
"""
if isinstance(cls_or_instance, type):
if not issubclass(cls_or_instance, FieldABC):
raise FieldInst... | def resolve_field_instance(cls_or_instance):
"""Return a Schema instance from a Schema class or instance.
:param type|Schema cls_or_instance: Marshmallow Schema class or instance.
"""
if isinstance(cls_or_instance, type):
if not issubclass(cls_or_instance, FieldABC):
raise FieldInst... | [
"Return",
"a",
"Schema",
"instance",
"from",
"a",
"Schema",
"class",
"or",
"instance",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L380-L392 | [
"def",
"resolve_field_instance",
"(",
"cls_or_instance",
")",
":",
"if",
"isinstance",
"(",
"cls_or_instance",
",",
"type",
")",
":",
"if",
"not",
"issubclass",
"(",
"cls_or_instance",
",",
"FieldABC",
")",
":",
"raise",
"FieldInstanceResolutionError",
"return",
"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | UTC.localize | Convert naive time to local time | src/marshmallow/utils.py | def localize(self, dt, is_dst=False):
"""Convert naive time to local time"""
if dt.tzinfo is not None:
raise ValueError('Not naive datetime (tzinfo is already set)')
return dt.replace(tzinfo=self) | def localize(self, dt, is_dst=False):
"""Convert naive time to local time"""
if dt.tzinfo is not None:
raise ValueError('Not naive datetime (tzinfo is already set)')
return dt.replace(tzinfo=self) | [
"Convert",
"naive",
"time",
"to",
"local",
"time"
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L127-L131 | [
"def",
"localize",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"False",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"not",
"None",
":",
"raise",
"ValueError",
"(",
"'Not naive datetime (tzinfo is already set)'",
")",
"return",
"dt",
".",
"replace",
"(",
"tz... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | UTC.normalize | Correct the timezone information on the given datetime | src/marshmallow/utils.py | def normalize(self, dt, is_dst=False):
"""Correct the timezone information on the given datetime"""
if dt.tzinfo is self:
return dt
if dt.tzinfo is None:
raise ValueError('Naive time - no tzinfo set')
return dt.astimezone(self) | def normalize(self, dt, is_dst=False):
"""Correct the timezone information on the given datetime"""
if dt.tzinfo is self:
return dt
if dt.tzinfo is None:
raise ValueError('Naive time - no tzinfo set')
return dt.astimezone(self) | [
"Correct",
"the",
"timezone",
"information",
"on",
"the",
"given",
"datetime"
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/src/marshmallow/utils.py#L133-L139 | [
"def",
"normalize",
"(",
"self",
",",
"dt",
",",
"is_dst",
"=",
"False",
")",
":",
"if",
"dt",
".",
"tzinfo",
"is",
"self",
":",
"return",
"dt",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"'Naive time - no tzinfo set'",
"... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | check_auth | Check if a username/password combination is valid. | examples/peewee_example.py | def check_auth(email, password):
"""Check if a username/password combination is valid.
"""
try:
user = User.get(User.email == email)
except User.DoesNotExist:
return False
return password == user.password | def check_auth(email, password):
"""Check if a username/password combination is valid.
"""
try:
user = User.get(User.email == email)
except User.DoesNotExist:
return False
return password == user.password | [
"Check",
"if",
"a",
"username",
"/",
"password",
"combination",
"is",
"valid",
"."
] | marshmallow-code/marshmallow | python | https://github.com/marshmallow-code/marshmallow/blob/a6b6c4151f1fbf16f3774d4052ca2bddf6903750/examples/peewee_example.py#L100-L107 | [
"def",
"check_auth",
"(",
"email",
",",
"password",
")",
":",
"try",
":",
"user",
"=",
"User",
".",
"get",
"(",
"User",
".",
"email",
"==",
"email",
")",
"except",
"User",
".",
"DoesNotExist",
":",
"return",
"False",
"return",
"password",
"==",
"user",... | a6b6c4151f1fbf16f3774d4052ca2bddf6903750 |
train | AuthenticationBackend._stash_user | Now, be aware, the following is quite ugly, let me explain:
Even if the user credentials match, the authentication can fail because
Django's default ModelBackend calls user_can_authenticate(), which
checks `is_active`. Now, earlier versions of allauth did not do this
and simply returned... | allauth/account/auth_backends.py | def _stash_user(cls, user):
"""Now, be aware, the following is quite ugly, let me explain:
Even if the user credentials match, the authentication can fail because
Django's default ModelBackend calls user_can_authenticate(), which
checks `is_active`. Now, earlier versions of allauth did ... | def _stash_user(cls, user):
"""Now, be aware, the following is quite ugly, let me explain:
Even if the user credentials match, the authentication can fail because
Django's default ModelBackend calls user_can_authenticate(), which
checks `is_active`. Now, earlier versions of allauth did ... | [
"Now",
"be",
"aware",
"the",
"following",
"is",
"quite",
"ugly",
"let",
"me",
"explain",
":"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/auth_backends.py#L68-L93 | [
"def",
"_stash_user",
"(",
"cls",
",",
"user",
")",
":",
"global",
"_stash",
"ret",
"=",
"getattr",
"(",
"_stash",
",",
"'user'",
",",
"None",
")",
"_stash",
".",
"user",
"=",
"user",
"return",
"ret"
] | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | BitbucketOAuth2Adapter.get_email | Fetches email address from email API endpoint | allauth/socialaccount/providers/bitbucket_oauth2/views.py | def get_email(self, token):
"""Fetches email address from email API endpoint"""
resp = requests.get(self.emails_url,
params={'access_token': token.token})
emails = resp.json().get('values', [])
email = ''
try:
email = emails[0].get('email')... | def get_email(self, token):
"""Fetches email address from email API endpoint"""
resp = requests.get(self.emails_url,
params={'access_token': token.token})
emails = resp.json().get('values', [])
email = ''
try:
email = emails[0].get('email')... | [
"Fetches",
"email",
"address",
"from",
"email",
"API",
"endpoint"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/bitbucket_oauth2/views.py#L29-L42 | [
"def",
"get_email",
"(",
"self",
",",
"token",
")",
":",
"resp",
"=",
"requests",
".",
"get",
"(",
"self",
".",
"emails_url",
",",
"params",
"=",
"{",
"'access_token'",
":",
"token",
".",
"token",
"}",
")",
"emails",
"=",
"resp",
".",
"json",
"(",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.is_email_verified | Checks whether or not the email address is already verified
beyond allauth scope, for example, by having accepted an
invitation before signing up. | allauth/account/adapter.py | def is_email_verified(self, request, email):
"""
Checks whether or not the email address is already verified
beyond allauth scope, for example, by having accepted an
invitation before signing up.
"""
ret = False
verified_email = request.session.get('account_verifi... | def is_email_verified(self, request, email):
"""
Checks whether or not the email address is already verified
beyond allauth scope, for example, by having accepted an
invitation before signing up.
"""
ret = False
verified_email = request.session.get('account_verifi... | [
"Checks",
"whether",
"or",
"not",
"the",
"email",
"address",
"is",
"already",
"verified",
"beyond",
"allauth",
"scope",
"for",
"example",
"by",
"having",
"accepted",
"an",
"invitation",
"before",
"signing",
"up",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L71-L81 | [
"def",
"is_email_verified",
"(",
"self",
",",
"request",
",",
"email",
")",
":",
"ret",
"=",
"False",
"verified_email",
"=",
"request",
".",
"session",
".",
"get",
"(",
"'account_verified_email'",
")",
"if",
"verified_email",
":",
"ret",
"=",
"verified_email",... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.get_login_redirect_url | Returns the default URL to redirect to after logging in. Note
that URLs passed explicitly (e.g. by passing along a `next`
GET parameter) take precedence over the value returned here. | allauth/account/adapter.py | def get_login_redirect_url(self, request):
"""
Returns the default URL to redirect to after logging in. Note
that URLs passed explicitly (e.g. by passing along a `next`
GET parameter) take precedence over the value returned here.
"""
assert request.user.is_authenticated
... | def get_login_redirect_url(self, request):
"""
Returns the default URL to redirect to after logging in. Note
that URLs passed explicitly (e.g. by passing along a `next`
GET parameter) take precedence over the value returned here.
"""
assert request.user.is_authenticated
... | [
"Returns",
"the",
"default",
"URL",
"to",
"redirect",
"to",
"after",
"logging",
"in",
".",
"Note",
"that",
"URLs",
"passed",
"explicitly",
"(",
"e",
".",
"g",
".",
"by",
"passing",
"along",
"a",
"next",
"GET",
"parameter",
")",
"take",
"precedence",
"ove... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L139-L153 | [
"def",
"get_login_redirect_url",
"(",
"self",
",",
"request",
")",
":",
"assert",
"request",
".",
"user",
".",
"is_authenticated",
"url",
"=",
"getattr",
"(",
"settings",
",",
"\"LOGIN_REDIRECT_URLNAME\"",
",",
"None",
")",
"if",
"url",
":",
"warnings",
".",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.get_email_confirmation_redirect_url | The URL to return to after successful e-mail confirmation. | allauth/account/adapter.py | def get_email_confirmation_redirect_url(self, request):
"""
The URL to return to after successful e-mail confirmation.
"""
if request.user.is_authenticated:
if app_settings.EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL:
return \
app_settin... | def get_email_confirmation_redirect_url(self, request):
"""
The URL to return to after successful e-mail confirmation.
"""
if request.user.is_authenticated:
if app_settings.EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL:
return \
app_settin... | [
"The",
"URL",
"to",
"return",
"to",
"after",
"successful",
"e",
"-",
"mail",
"confirmation",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L164-L175 | [
"def",
"get_email_confirmation_redirect_url",
"(",
"self",
",",
"request",
")",
":",
"if",
"request",
".",
"user",
".",
"is_authenticated",
":",
"if",
"app_settings",
".",
"EMAIL_CONFIRMATION_AUTHENTICATED_REDIRECT_URL",
":",
"return",
"app_settings",
".",
"EMAIL_CONFIR... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.populate_username | Fills in a valid username, if required and missing. If the
username is already present it is assumed to be valid
(unique). | allauth/account/adapter.py | def populate_username(self, request, user):
"""
Fills in a valid username, if required and missing. If the
username is already present it is assumed to be valid
(unique).
"""
from .utils import user_username, user_email, user_field
first_name = user_field(user, '... | def populate_username(self, request, user):
"""
Fills in a valid username, if required and missing. If the
username is already present it is assumed to be valid
(unique).
"""
from .utils import user_username, user_email, user_field
first_name = user_field(user, '... | [
"Fills",
"in",
"a",
"valid",
"username",
"if",
"required",
"and",
"missing",
".",
"If",
"the",
"username",
"is",
"already",
"present",
"it",
"is",
"assumed",
"to",
"be",
"valid",
"(",
"unique",
")",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L193-L212 | [
"def",
"populate_username",
"(",
"self",
",",
"request",
",",
"user",
")",
":",
"from",
".",
"utils",
"import",
"user_username",
",",
"user_email",
",",
"user_field",
"first_name",
"=",
"user_field",
"(",
"user",
",",
"'first_name'",
")",
"last_name",
"=",
"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.save_user | Saves a new `User` instance using information provided in the
signup form. | allauth/account/adapter.py | def save_user(self, request, user, form, commit=True):
"""
Saves a new `User` instance using information provided in the
signup form.
"""
from .utils import user_username, user_email, user_field
data = form.cleaned_data
first_name = data.get('first_name')
... | def save_user(self, request, user, form, commit=True):
"""
Saves a new `User` instance using information provided in the
signup form.
"""
from .utils import user_username, user_email, user_field
data = form.cleaned_data
first_name = data.get('first_name')
... | [
"Saves",
"a",
"new",
"User",
"instance",
"using",
"information",
"provided",
"in",
"the",
"signup",
"form",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L217-L244 | [
"def",
"save_user",
"(",
"self",
",",
"request",
",",
"user",
",",
"form",
",",
"commit",
"=",
"True",
")",
":",
"from",
".",
"utils",
"import",
"user_username",
",",
"user_email",
",",
"user_field",
"data",
"=",
"form",
".",
"cleaned_data",
"first_name",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.clean_username | Validates the username. You can hook into this if you want to
(dynamically) restrict what usernames can be chosen. | allauth/account/adapter.py | def clean_username(self, username, shallow=False):
"""
Validates the username. You can hook into this if you want to
(dynamically) restrict what usernames can be chosen.
"""
for validator in app_settings.USERNAME_VALIDATORS:
validator(username)
# TODO: Add re... | def clean_username(self, username, shallow=False):
"""
Validates the username. You can hook into this if you want to
(dynamically) restrict what usernames can be chosen.
"""
for validator in app_settings.USERNAME_VALIDATORS:
validator(username)
# TODO: Add re... | [
"Validates",
"the",
"username",
".",
"You",
"can",
"hook",
"into",
"this",
"if",
"you",
"want",
"to",
"(",
"dynamically",
")",
"restrict",
"what",
"usernames",
"can",
"be",
"chosen",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L246-L278 | [
"def",
"clean_username",
"(",
"self",
",",
"username",
",",
"shallow",
"=",
"False",
")",
":",
"for",
"validator",
"in",
"app_settings",
".",
"USERNAME_VALIDATORS",
":",
"validator",
"(",
"username",
")",
"# TODO: Add regexp support to USERNAME_BLACKLIST",
"username_b... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.clean_password | Validates a password. You can hook into this if you want to
restric the allowed password choices. | allauth/account/adapter.py | def clean_password(self, password, user=None):
"""
Validates a password. You can hook into this if you want to
restric the allowed password choices.
"""
min_length = app_settings.PASSWORD_MIN_LENGTH
if min_length and len(password) < min_length:
raise forms.Val... | def clean_password(self, password, user=None):
"""
Validates a password. You can hook into this if you want to
restric the allowed password choices.
"""
min_length = app_settings.PASSWORD_MIN_LENGTH
if min_length and len(password) < min_length:
raise forms.Val... | [
"Validates",
"a",
"password",
".",
"You",
"can",
"hook",
"into",
"this",
"if",
"you",
"want",
"to",
"restric",
"the",
"allowed",
"password",
"choices",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L287-L297 | [
"def",
"clean_password",
"(",
"self",
",",
"password",
",",
"user",
"=",
"None",
")",
":",
"min_length",
"=",
"app_settings",
".",
"PASSWORD_MIN_LENGTH",
"if",
"min_length",
"and",
"len",
"(",
"password",
")",
"<",
"min_length",
":",
"raise",
"forms",
".",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.add_message | Wrapper of `django.contrib.messages.add_message`, that reads
the message text from a template. | allauth/account/adapter.py | def add_message(self, request, level, message_template,
message_context=None, extra_tags=''):
"""
Wrapper of `django.contrib.messages.add_message`, that reads
the message text from a template.
"""
if 'django.contrib.messages' in settings.INSTALLED_APPS:
... | def add_message(self, request, level, message_template,
message_context=None, extra_tags=''):
"""
Wrapper of `django.contrib.messages.add_message`, that reads
the message text from a template.
"""
if 'django.contrib.messages' in settings.INSTALLED_APPS:
... | [
"Wrapper",
"of",
"django",
".",
"contrib",
".",
"messages",
".",
"add_message",
"that",
"reads",
"the",
"message",
"text",
"from",
"a",
"template",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L304-L320 | [
"def",
"add_message",
"(",
"self",
",",
"request",
",",
"level",
",",
"message_template",
",",
"message_context",
"=",
"None",
",",
"extra_tags",
"=",
"''",
")",
":",
"if",
"'django.contrib.messages'",
"in",
"settings",
".",
"INSTALLED_APPS",
":",
"try",
":",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.confirm_email | Marks the email address as confirmed on the db | allauth/account/adapter.py | def confirm_email(self, request, email_address):
"""
Marks the email address as confirmed on the db
"""
email_address.verified = True
email_address.set_as_primary(conditional=True)
email_address.save() | def confirm_email(self, request, email_address):
"""
Marks the email address as confirmed on the db
"""
email_address.verified = True
email_address.set_as_primary(conditional=True)
email_address.save() | [
"Marks",
"the",
"email",
"address",
"as",
"confirmed",
"on",
"the",
"db"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L396-L402 | [
"def",
"confirm_email",
"(",
"self",
",",
"request",
",",
"email_address",
")",
":",
"email_address",
".",
"verified",
"=",
"True",
"email_address",
".",
"set_as_primary",
"(",
"conditional",
"=",
"True",
")",
"email_address",
".",
"save",
"(",
")"
] | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.get_email_confirmation_url | Constructs the email confirmation (activation) url.
Note that if you have architected your system such that email
confirmations are sent outside of the request context `request`
can be `None` here. | allauth/account/adapter.py | def get_email_confirmation_url(self, request, emailconfirmation):
"""Constructs the email confirmation (activation) url.
Note that if you have architected your system such that email
confirmations are sent outside of the request context `request`
can be `None` here.
"""
... | def get_email_confirmation_url(self, request, emailconfirmation):
"""Constructs the email confirmation (activation) url.
Note that if you have architected your system such that email
confirmations are sent outside of the request context `request`
can be `None` here.
"""
... | [
"Constructs",
"the",
"email",
"confirmation",
"(",
"activation",
")",
"url",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L418-L431 | [
"def",
"get_email_confirmation_url",
"(",
"self",
",",
"request",
",",
"emailconfirmation",
")",
":",
"url",
"=",
"reverse",
"(",
"\"account_confirm_email\"",
",",
"args",
"=",
"[",
"emailconfirmation",
".",
"key",
"]",
")",
"ret",
"=",
"build_absolute_uri",
"("... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultAccountAdapter.authenticate | Only authenticates, does not actually login. See `login` | allauth/account/adapter.py | def authenticate(self, request, **credentials):
"""Only authenticates, does not actually login. See `login`"""
from allauth.account.auth_backends import AuthenticationBackend
self.pre_authenticate(request, **credentials)
AuthenticationBackend.unstash_authenticated_user()
user = ... | def authenticate(self, request, **credentials):
"""Only authenticates, does not actually login. See `login`"""
from allauth.account.auth_backends import AuthenticationBackend
self.pre_authenticate(request, **credentials)
AuthenticationBackend.unstash_authenticated_user()
user = ... | [
"Only",
"authenticates",
"does",
"not",
"actually",
"login",
".",
"See",
"login"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/adapter.py#L483-L498 | [
"def",
"authenticate",
"(",
"self",
",",
"request",
",",
"*",
"*",
"credentials",
")",
":",
"from",
"allauth",
".",
"account",
".",
"auth_backends",
"import",
"AuthenticationBackend",
"self",
".",
"pre_authenticate",
"(",
"request",
",",
"*",
"*",
"credentials... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | MailChimpProvider.extract_common_fields | Extract fields from a metadata query. | allauth/socialaccount/providers/mailchimp/provider.py | def extract_common_fields(self, data):
"""Extract fields from a metadata query."""
return dict(
dc=data.get('dc'),
role=data.get('role'),
account_name=data.get('accountname'),
user_id=data.get('user_id'),
login=data.get('login'),
lo... | def extract_common_fields(self, data):
"""Extract fields from a metadata query."""
return dict(
dc=data.get('dc'),
role=data.get('role'),
account_name=data.get('accountname'),
user_id=data.get('user_id'),
login=data.get('login'),
lo... | [
"Extract",
"fields",
"from",
"a",
"metadata",
"query",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/mailchimp/provider.py#L35-L45 | [
"def",
"extract_common_fields",
"(",
"self",
",",
"data",
")",
":",
"return",
"dict",
"(",
"dc",
"=",
"data",
".",
"get",
"(",
"'dc'",
")",
",",
"role",
"=",
"data",
".",
"get",
"(",
"'role'",
")",
",",
"account_name",
"=",
"data",
".",
"get",
"(",... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | LinkedInAPI.to_dict | Convert XML structure to dict recursively, repeated keys
entries are returned as in list containers. | allauth/socialaccount/providers/linkedin/views.py | def to_dict(self, xml):
"""
Convert XML structure to dict recursively, repeated keys
entries are returned as in list containers.
"""
children = list(xml)
if not children:
return xml.text
else:
out = {}
for node in list(xml):
... | def to_dict(self, xml):
"""
Convert XML structure to dict recursively, repeated keys
entries are returned as in list containers.
"""
children = list(xml)
if not children:
return xml.text
else:
out = {}
for node in list(xml):
... | [
"Convert",
"XML",
"structure",
"to",
"dict",
"recursively",
"repeated",
"keys",
"entries",
"are",
"returned",
"as",
"in",
"list",
"containers",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/linkedin/views.py#L32-L49 | [
"def",
"to_dict",
"(",
"self",
",",
"xml",
")",
":",
"children",
"=",
"list",
"(",
"xml",
")",
"if",
"not",
"children",
":",
"return",
"xml",
".",
"text",
"else",
":",
"out",
"=",
"{",
"}",
"for",
"node",
"in",
"list",
"(",
"xml",
")",
":",
"if... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | provider_login_url | {% provider_login_url "facebook" next=bla %}
{% provider_login_url "openid" openid="http://me.yahoo.com" next=bla %} | allauth/socialaccount/templatetags/socialaccount.py | def provider_login_url(parser, token):
"""
{% provider_login_url "facebook" next=bla %}
{% provider_login_url "openid" openid="http://me.yahoo.com" next=bla %}
"""
bits = token.split_contents()
provider_id = bits[1]
params = token_kwargs(bits[2:], parser, support_legacy=False)
return Pro... | def provider_login_url(parser, token):
"""
{% provider_login_url "facebook" next=bla %}
{% provider_login_url "openid" openid="http://me.yahoo.com" next=bla %}
"""
bits = token.split_contents()
provider_id = bits[1]
params = token_kwargs(bits[2:], parser, support_legacy=False)
return Pro... | [
"{",
"%",
"provider_login_url",
"facebook",
"next",
"=",
"bla",
"%",
"}",
"{",
"%",
"provider_login_url",
"openid",
"openid",
"=",
"http",
":",
"//",
"me",
".",
"yahoo",
".",
"com",
"next",
"=",
"bla",
"%",
"}"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/templatetags/socialaccount.py#L43-L51 | [
"def",
"provider_login_url",
"(",
"parser",
",",
"token",
")",
":",
"bits",
"=",
"token",
".",
"split_contents",
"(",
")",
"provider_id",
"=",
"bits",
"[",
"1",
"]",
"params",
"=",
"token_kwargs",
"(",
"bits",
"[",
"2",
":",
"]",
",",
"parser",
",",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | get_social_accounts | {% get_social_accounts user as accounts %}
Then:
{{accounts.twitter}} -- a list of connected Twitter accounts
{{accounts.twitter.0}} -- the first Twitter account
{% if accounts %} -- if there is at least one social account | allauth/socialaccount/templatetags/socialaccount.py | def get_social_accounts(user):
"""
{% get_social_accounts user as accounts %}
Then:
{{accounts.twitter}} -- a list of connected Twitter accounts
{{accounts.twitter.0}} -- the first Twitter account
{% if accounts %} -- if there is at least one social account
"""
accounts = {}... | def get_social_accounts(user):
"""
{% get_social_accounts user as accounts %}
Then:
{{accounts.twitter}} -- a list of connected Twitter accounts
{{accounts.twitter.0}} -- the first Twitter account
{% if accounts %} -- if there is at least one social account
"""
accounts = {}... | [
"{",
"%",
"get_social_accounts",
"user",
"as",
"accounts",
"%",
"}"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/templatetags/socialaccount.py#L68-L81 | [
"def",
"get_social_accounts",
"(",
"user",
")",
":",
"accounts",
"=",
"{",
"}",
"for",
"account",
"in",
"user",
".",
"socialaccount_set",
".",
"all",
"(",
")",
".",
"iterator",
"(",
")",
":",
"providers",
"=",
"accounts",
".",
"setdefault",
"(",
"account... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultSocialAccountAdapter.save_user | Saves a newly signed up social login. In case of auto-signup,
the signup form is not available. | allauth/socialaccount/adapter.py | def save_user(self, request, sociallogin, form=None):
"""
Saves a newly signed up social login. In case of auto-signup,
the signup form is not available.
"""
u = sociallogin.user
u.set_unusable_password()
if form:
get_account_adapter().save_user(reques... | def save_user(self, request, sociallogin, form=None):
"""
Saves a newly signed up social login. In case of auto-signup,
the signup form is not available.
"""
u = sociallogin.user
u.set_unusable_password()
if form:
get_account_adapter().save_user(reques... | [
"Saves",
"a",
"newly",
"signed",
"up",
"social",
"login",
".",
"In",
"case",
"of",
"auto",
"-",
"signup",
"the",
"signup",
"form",
"is",
"not",
"available",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/adapter.py#L71-L83 | [
"def",
"save_user",
"(",
"self",
",",
"request",
",",
"sociallogin",
",",
"form",
"=",
"None",
")",
":",
"u",
"=",
"sociallogin",
".",
"user",
"u",
".",
"set_unusable_password",
"(",
")",
"if",
"form",
":",
"get_account_adapter",
"(",
")",
".",
"save_use... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultSocialAccountAdapter.populate_user | Hook that can be used to further populate the user instance.
For convenience, we populate several common fields.
Note that the user instance being populated represents a
suggested User instance that represents the social user that is
in the process of being logged in.
The User... | allauth/socialaccount/adapter.py | def populate_user(self,
request,
sociallogin,
data):
"""
Hook that can be used to further populate the user instance.
For convenience, we populate several common fields.
Note that the user instance being populated repres... | def populate_user(self,
request,
sociallogin,
data):
"""
Hook that can be used to further populate the user instance.
For convenience, we populate several common fields.
Note that the user instance being populated repres... | [
"Hook",
"that",
"can",
"be",
"used",
"to",
"further",
"populate",
"the",
"user",
"instance",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/adapter.py#L85-L113 | [
"def",
"populate_user",
"(",
"self",
",",
"request",
",",
"sociallogin",
",",
"data",
")",
":",
"username",
"=",
"data",
".",
"get",
"(",
"'username'",
")",
"first_name",
"=",
"data",
".",
"get",
"(",
"'first_name'",
")",
"last_name",
"=",
"data",
".",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultSocialAccountAdapter.get_connect_redirect_url | Returns the default URL to redirect to after successfully
connecting a social account. | allauth/socialaccount/adapter.py | def get_connect_redirect_url(self, request, socialaccount):
"""
Returns the default URL to redirect to after successfully
connecting a social account.
"""
assert request.user.is_authenticated
url = reverse('socialaccount_connections')
return url | def get_connect_redirect_url(self, request, socialaccount):
"""
Returns the default URL to redirect to after successfully
connecting a social account.
"""
assert request.user.is_authenticated
url = reverse('socialaccount_connections')
return url | [
"Returns",
"the",
"default",
"URL",
"to",
"redirect",
"to",
"after",
"successfully",
"connecting",
"a",
"social",
"account",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/adapter.py#L115-L122 | [
"def",
"get_connect_redirect_url",
"(",
"self",
",",
"request",
",",
"socialaccount",
")",
":",
"assert",
"request",
".",
"user",
".",
"is_authenticated",
"url",
"=",
"reverse",
"(",
"'socialaccount_connections'",
")",
"return",
"url"
] | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DefaultSocialAccountAdapter.validate_disconnect | Validate whether or not the socialaccount account can be
safely disconnected. | allauth/socialaccount/adapter.py | def validate_disconnect(self, account, accounts):
"""
Validate whether or not the socialaccount account can be
safely disconnected.
"""
if len(accounts) == 1:
# No usable password would render the local account unusable
if not account.user.has_usable_passw... | def validate_disconnect(self, account, accounts):
"""
Validate whether or not the socialaccount account can be
safely disconnected.
"""
if len(accounts) == 1:
# No usable password would render the local account unusable
if not account.user.has_usable_passw... | [
"Validate",
"whether",
"or",
"not",
"the",
"socialaccount",
"account",
"can",
"be",
"safely",
"disconnected",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/adapter.py#L124-L140 | [
"def",
"validate_disconnect",
"(",
"self",
",",
"account",
",",
"accounts",
")",
":",
"if",
"len",
"(",
"accounts",
")",
"==",
"1",
":",
"# No usable password would render the local account unusable",
"if",
"not",
"account",
".",
"user",
".",
"has_usable_password",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | serialize_instance | Since Django 1.6 items added to the session are no longer pickled,
but JSON encoded by default. We are storing partially complete models
in the session (user, account, token, ...). We cannot use standard
Django serialization, as these are models are not "complete" yet.
Serialization will start complaini... | allauth/utils.py | def serialize_instance(instance):
"""
Since Django 1.6 items added to the session are no longer pickled,
but JSON encoded by default. We are storing partially complete models
in the session (user, account, token, ...). We cannot use standard
Django serialization, as these are models are not "complet... | def serialize_instance(instance):
"""
Since Django 1.6 items added to the session are no longer pickled,
but JSON encoded by default. We are storing partially complete models
in the session (user, account, token, ...). We cannot use standard
Django serialization, as these are models are not "complet... | [
"Since",
"Django",
"1",
".",
"6",
"items",
"added",
"to",
"the",
"session",
"are",
"no",
"longer",
"pickled",
"but",
"JSON",
"encoded",
"by",
"default",
".",
"We",
"are",
"storing",
"partially",
"complete",
"models",
"in",
"the",
"session",
"(",
"user",
... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/utils.py#L167-L196 | [
"def",
"serialize_instance",
"(",
"instance",
")",
":",
"data",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"instance",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"startswith",
"(",
"'_'",
")",
"or",
"callable",
"(",
"v",
")",
"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | set_form_field_order | This function is a verbatim copy of django.forms.Form.order_fields() to
support field ordering below Django 1.9.
field_order is a list of field names specifying the order. Append fields
not included in the list in the default order for backward compatibility
with subclasses not overriding field_order. ... | allauth/utils.py | def set_form_field_order(form, field_order):
"""
This function is a verbatim copy of django.forms.Form.order_fields() to
support field ordering below Django 1.9.
field_order is a list of field names specifying the order. Append fields
not included in the list in the default order for backward compa... | def set_form_field_order(form, field_order):
"""
This function is a verbatim copy of django.forms.Form.order_fields() to
support field ordering below Django 1.9.
field_order is a list of field names specifying the order. Append fields
not included in the list in the default order for backward compa... | [
"This",
"function",
"is",
"a",
"verbatim",
"copy",
"of",
"django",
".",
"forms",
".",
"Form",
".",
"order_fields",
"()",
"to",
"support",
"field",
"ordering",
"below",
"Django",
"1",
".",
"9",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/utils.py#L235-L256 | [
"def",
"set_form_field_order",
"(",
"form",
",",
"field_order",
")",
":",
"if",
"field_order",
"is",
"None",
":",
"return",
"fields",
"=",
"OrderedDict",
"(",
")",
"for",
"key",
"in",
"field_order",
":",
"try",
":",
"fields",
"[",
"key",
"]",
"=",
"form"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | build_absolute_uri | request.build_absolute_uri() helper
Like request.build_absolute_uri, but gracefully handling
the case where request is None. | allauth/utils.py | def build_absolute_uri(request, location, protocol=None):
"""request.build_absolute_uri() helper
Like request.build_absolute_uri, but gracefully handling
the case where request is None.
"""
from .account import app_settings as account_settings
if request is None:
site = Site.objects.ge... | def build_absolute_uri(request, location, protocol=None):
"""request.build_absolute_uri() helper
Like request.build_absolute_uri, but gracefully handling
the case where request is None.
"""
from .account import app_settings as account_settings
if request is None:
site = Site.objects.ge... | [
"request",
".",
"build_absolute_uri",
"()",
"helper"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/utils.py#L259-L291 | [
"def",
"build_absolute_uri",
"(",
"request",
",",
"location",
",",
"protocol",
"=",
"None",
")",
":",
"from",
".",
"account",
"import",
"app_settings",
"as",
"account_settings",
"if",
"request",
"is",
"None",
":",
"site",
"=",
"Site",
".",
"objects",
".",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | _base_signup_form_class | Currently, we inherit from the custom form, if any. This is all
not very elegant, though it serves a purpose:
- There are two signup forms: one for local accounts, and one for
social accounts
- Both share a common base (BaseSignupForm)
- Given the above, how to put in a custom signup form? Which... | allauth/account/forms.py | def _base_signup_form_class():
"""
Currently, we inherit from the custom form, if any. This is all
not very elegant, though it serves a purpose:
- There are two signup forms: one for local accounts, and one for
social accounts
- Both share a common base (BaseSignupForm)
- Given the above... | def _base_signup_form_class():
"""
Currently, we inherit from the custom form, if any. This is all
not very elegant, though it serves a purpose:
- There are two signup forms: one for local accounts, and one for
social accounts
- Both share a common base (BaseSignupForm)
- Given the above... | [
"Currently",
"we",
"inherit",
"from",
"the",
"custom",
"form",
"if",
"any",
".",
"This",
"is",
"all",
"not",
"very",
"elegant",
"though",
"it",
"serves",
"a",
"purpose",
":"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/forms.py#L219-L258 | [
"def",
"_base_signup_form_class",
"(",
")",
":",
"if",
"not",
"app_settings",
".",
"SIGNUP_FORM_CLASS",
":",
"return",
"_DummyCustomSignupForm",
"try",
":",
"fc_module",
",",
"fc_classname",
"=",
"app_settings",
".",
"SIGNUP_FORM_CLASS",
".",
"rsplit",
"(",
"'.'",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | LoginForm.user_credentials | Provides the credentials required to authenticate the user for
login. | allauth/account/forms.py | def user_credentials(self):
"""
Provides the credentials required to authenticate the user for
login.
"""
credentials = {}
login = self.cleaned_data["login"]
if app_settings.AUTHENTICATION_METHOD == AuthenticationMethod.EMAIL:
credentials["email"] = lo... | def user_credentials(self):
"""
Provides the credentials required to authenticate the user for
login.
"""
credentials = {}
login = self.cleaned_data["login"]
if app_settings.AUTHENTICATION_METHOD == AuthenticationMethod.EMAIL:
credentials["email"] = lo... | [
"Provides",
"the",
"credentials",
"required",
"to",
"authenticate",
"the",
"user",
"for",
"login",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/forms.py#L142-L160 | [
"def",
"user_credentials",
"(",
"self",
")",
":",
"credentials",
"=",
"{",
"}",
"login",
"=",
"self",
".",
"cleaned_data",
"[",
"\"login\"",
"]",
"if",
"app_settings",
".",
"AUTHENTICATION_METHOD",
"==",
"AuthenticationMethod",
".",
"EMAIL",
":",
"credentials",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | _build_locale_table | Parses the FacebookLocales.xml file and builds a dict relating every
available language ('en, 'es, 'zh', ...) with a list of available regions
for that language ('en' -> 'US', 'EN') and an (arbitrary) default region. | allauth/socialaccount/providers/facebook/locale.py | def _build_locale_table(filename_or_file):
"""
Parses the FacebookLocales.xml file and builds a dict relating every
available language ('en, 'es, 'zh', ...) with a list of available regions
for that language ('en' -> 'US', 'EN') and an (arbitrary) default region.
"""
# Require the XML parser mod... | def _build_locale_table(filename_or_file):
"""
Parses the FacebookLocales.xml file and builds a dict relating every
available language ('en, 'es, 'zh', ...) with a list of available regions
for that language ('en' -> 'US', 'EN') and an (arbitrary) default region.
"""
# Require the XML parser mod... | [
"Parses",
"the",
"FacebookLocales",
".",
"xml",
"file",
"and",
"builds",
"a",
"dict",
"relating",
"every",
"available",
"language",
"(",
"en",
"es",
"zh",
"...",
")",
"with",
"a",
"list",
"of",
"available",
"regions",
"for",
"that",
"language",
"(",
"en",
... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/facebook/locale.py#L9-L37 | [
"def",
"_build_locale_table",
"(",
"filename_or_file",
")",
":",
"# Require the XML parser module only if we want the default mapping",
"from",
"xml",
".",
"dom",
".",
"minidom",
"import",
"parse",
"dom",
"=",
"parse",
"(",
"filename_or_file",
")",
"reps",
"=",
"dom",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | get_default_locale_callable | Wrapper function so that the default mapping is only built when needed | allauth/socialaccount/providers/facebook/locale.py | def get_default_locale_callable():
"""
Wrapper function so that the default mapping is only built when needed
"""
exec_dir = os.path.dirname(os.path.realpath(__file__))
xml_path = os.path.join(exec_dir, 'data', 'FacebookLocales.xml')
fb_locales = _build_locale_table(xml_path)
def default_l... | def get_default_locale_callable():
"""
Wrapper function so that the default mapping is only built when needed
"""
exec_dir = os.path.dirname(os.path.realpath(__file__))
xml_path = os.path.join(exec_dir, 'data', 'FacebookLocales.xml')
fb_locales = _build_locale_table(xml_path)
def default_l... | [
"Wrapper",
"function",
"so",
"that",
"the",
"default",
"mapping",
"is",
"only",
"built",
"when",
"needed"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/facebook/locale.py#L40-L70 | [
"def",
"get_default_locale_callable",
"(",
")",
":",
"exec_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"xml_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"exec_dir",
",",
"'data'"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | AppSettings.EMAIL_REQUIRED | The user is required to hand over an e-mail address when signing up | allauth/socialaccount/app_settings.py | def EMAIL_REQUIRED(self):
"""
The user is required to hand over an e-mail address when signing up
"""
from allauth.account import app_settings as account_settings
return self._setting("EMAIL_REQUIRED", account_settings.EMAIL_REQUIRED) | def EMAIL_REQUIRED(self):
"""
The user is required to hand over an e-mail address when signing up
"""
from allauth.account import app_settings as account_settings
return self._setting("EMAIL_REQUIRED", account_settings.EMAIL_REQUIRED) | [
"The",
"user",
"is",
"required",
"to",
"hand",
"over",
"an",
"e",
"-",
"mail",
"address",
"when",
"signing",
"up"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/app_settings.py#L40-L45 | [
"def",
"EMAIL_REQUIRED",
"(",
"self",
")",
":",
"from",
"allauth",
".",
"account",
"import",
"app_settings",
"as",
"account_settings",
"return",
"self",
".",
"_setting",
"(",
"\"EMAIL_REQUIRED\"",
",",
"account_settings",
".",
"EMAIL_REQUIRED",
")"
] | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | AppSettings.EMAIL_VERIFICATION | See e-mail verification method | allauth/socialaccount/app_settings.py | def EMAIL_VERIFICATION(self):
"""
See e-mail verification method
"""
from allauth.account import app_settings as account_settings
return self._setting("EMAIL_VERIFICATION",
account_settings.EMAIL_VERIFICATION) | def EMAIL_VERIFICATION(self):
"""
See e-mail verification method
"""
from allauth.account import app_settings as account_settings
return self._setting("EMAIL_VERIFICATION",
account_settings.EMAIL_VERIFICATION) | [
"See",
"e",
"-",
"mail",
"verification",
"method"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/app_settings.py#L48-L54 | [
"def",
"EMAIL_VERIFICATION",
"(",
"self",
")",
":",
"from",
"allauth",
".",
"account",
"import",
"app_settings",
"as",
"account_settings",
"return",
"self",
".",
"_setting",
"(",
"\"EMAIL_VERIFICATION\"",
",",
"account_settings",
".",
"EMAIL_VERIFICATION",
")"
] | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DataportenAccount.to_str | Returns string representation of a social account. Includes the name
of the user. | allauth/socialaccount/providers/dataporten/provider.py | def to_str(self):
'''
Returns string representation of a social account. Includes the name
of the user.
'''
dflt = super(DataportenAccount, self).to_str()
return '%s (%s)' % (
self.account.extra_data.get('name', ''),
dflt,
) | def to_str(self):
'''
Returns string representation of a social account. Includes the name
of the user.
'''
dflt = super(DataportenAccount, self).to_str()
return '%s (%s)' % (
self.account.extra_data.get('name', ''),
dflt,
) | [
"Returns",
"string",
"representation",
"of",
"a",
"social",
"account",
".",
"Includes",
"the",
"name",
"of",
"the",
"user",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/dataporten/provider.py#L15-L24 | [
"def",
"to_str",
"(",
"self",
")",
":",
"dflt",
"=",
"super",
"(",
"DataportenAccount",
",",
"self",
")",
".",
"to_str",
"(",
")",
"return",
"'%s (%s)'",
"%",
"(",
"self",
".",
"account",
".",
"extra_data",
".",
"get",
"(",
"'name'",
",",
"''",
")",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DataportenProvider.extract_common_fields | This function extracts information from the /userinfo endpoint which
will be consumed by allauth.socialaccount.adapter.populate_user().
Look there to find which key-value pairs that should be saved in the
returned dict.
Typical return dict:
{
"userid": "76a7a061-3c55... | allauth/socialaccount/providers/dataporten/provider.py | def extract_common_fields(self, data):
'''
This function extracts information from the /userinfo endpoint which
will be consumed by allauth.socialaccount.adapter.populate_user().
Look there to find which key-value pairs that should be saved in the
returned dict.
Typical ... | def extract_common_fields(self, data):
'''
This function extracts information from the /userinfo endpoint which
will be consumed by allauth.socialaccount.adapter.populate_user().
Look there to find which key-value pairs that should be saved in the
returned dict.
Typical ... | [
"This",
"function",
"extracts",
"information",
"from",
"the",
"/",
"userinfo",
"endpoint",
"which",
"will",
"be",
"consumed",
"by",
"allauth",
".",
"socialaccount",
".",
"adapter",
".",
"populate_user",
"()",
".",
"Look",
"there",
"to",
"find",
"which",
"key",... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/dataporten/provider.py#L60-L91 | [
"def",
"extract_common_fields",
"(",
"self",
",",
"data",
")",
":",
"# Make shallow copy to prevent possible mutability issues",
"data",
"=",
"dict",
"(",
"data",
")",
"# If a Feide username is available, use it. If not, use the \"username\"",
"# of the email-address",
"for",
"us... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | verified_email_required | Even when email verification is not mandatory during signup, there
may be circumstances during which you really want to prevent
unverified users to proceed. This decorator ensures the user is
authenticated and has a verified email address. If the former is
not the case then the behavior is identical to ... | allauth/account/decorators.py | def verified_email_required(function=None,
login_url=None,
redirect_field_name=REDIRECT_FIELD_NAME):
"""
Even when email verification is not mandatory during signup, there
may be circumstances during which you really want to prevent
unverified user... | def verified_email_required(function=None,
login_url=None,
redirect_field_name=REDIRECT_FIELD_NAME):
"""
Even when email verification is not mandatory during signup, there
may be circumstances during which you really want to prevent
unverified user... | [
"Even",
"when",
"email",
"verification",
"is",
"not",
"mandatory",
"during",
"signup",
"there",
"may",
"be",
"circumstances",
"during",
"which",
"you",
"really",
"want",
"to",
"prevent",
"unverified",
"users",
"to",
"proceed",
".",
"This",
"decorator",
"ensures"... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/decorators.py#L9-L37 | [
"def",
"verified_email_required",
"(",
"function",
"=",
"None",
",",
"login_url",
"=",
"None",
",",
"redirect_field_name",
"=",
"REDIRECT_FIELD_NAME",
")",
":",
"def",
"decorator",
"(",
"view_func",
")",
":",
"@",
"login_required",
"(",
"redirect_field_name",
"=",... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuth2Client._strip_empty_keys | Added because the Dropbox OAuth2 flow doesn't
work when scope is passed in, which is empty. | allauth/socialaccount/providers/oauth2/client.py | def _strip_empty_keys(self, params):
"""Added because the Dropbox OAuth2 flow doesn't
work when scope is passed in, which is empty.
"""
keys = [k for k, v in params.items() if v == '']
for key in keys:
del params[key] | def _strip_empty_keys(self, params):
"""Added because the Dropbox OAuth2 flow doesn't
work when scope is passed in, which is empty.
"""
keys = [k for k, v in params.items() if v == '']
for key in keys:
del params[key] | [
"Added",
"because",
"the",
"Dropbox",
"OAuth2",
"flow",
"doesn",
"t",
"work",
"when",
"scope",
"is",
"passed",
"in",
"which",
"is",
"empty",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth2/client.py#L88-L94 | [
"def",
"_strip_empty_keys",
"(",
"self",
",",
"params",
")",
":",
"keys",
"=",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"params",
".",
"items",
"(",
")",
"if",
"v",
"==",
"''",
"]",
"for",
"key",
"in",
"keys",
":",
"del",
"params",
"[",
"key",
"]"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | int_to_base36 | Django on py2 raises ValueError on large values. | allauth/compat.py | def int_to_base36(i):
"""
Django on py2 raises ValueError on large values.
"""
if six.PY2:
char_set = '0123456789abcdefghijklmnopqrstuvwxyz'
if i < 0:
raise ValueError("Negative base36 conversion input.")
if not isinstance(i, six.integer_types):
raise Type... | def int_to_base36(i):
"""
Django on py2 raises ValueError on large values.
"""
if six.PY2:
char_set = '0123456789abcdefghijklmnopqrstuvwxyz'
if i < 0:
raise ValueError("Negative base36 conversion input.")
if not isinstance(i, six.integer_types):
raise Type... | [
"Django",
"on",
"py2",
"raises",
"ValueError",
"on",
"large",
"values",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/compat.py#L41-L60 | [
"def",
"int_to_base36",
"(",
"i",
")",
":",
"if",
"six",
".",
"PY2",
":",
"char_set",
"=",
"'0123456789abcdefghijklmnopqrstuvwxyz'",
"if",
"i",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"Negative base36 conversion input.\"",
")",
"if",
"not",
"isinstance",
"(... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | SocialLogin.save | Saves a new account. Note that while the account is new,
the user may be an existing one (when connecting accounts) | allauth/socialaccount/models.py | def save(self, request, connect=False):
"""
Saves a new account. Note that while the account is new,
the user may be an existing one (when connecting accounts)
"""
assert not self.is_existing
user = self.user
user.save()
self.account.user = user
se... | def save(self, request, connect=False):
"""
Saves a new account. Note that while the account is new,
the user may be an existing one (when connecting accounts)
"""
assert not self.is_existing
user = self.user
user.save()
self.account.user = user
se... | [
"Saves",
"a",
"new",
"account",
".",
"Note",
"that",
"while",
"the",
"account",
"is",
"new",
"the",
"user",
"may",
"be",
"an",
"existing",
"one",
"(",
"when",
"connecting",
"accounts",
")"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/models.py#L228-L245 | [
"def",
"save",
"(",
"self",
",",
"request",
",",
"connect",
"=",
"False",
")",
":",
"assert",
"not",
"self",
".",
"is_existing",
"user",
"=",
"self",
".",
"user",
"user",
".",
"save",
"(",
")",
"self",
".",
"account",
".",
"user",
"=",
"user",
"sel... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | SocialLogin.lookup | Lookup existing account, if any. | allauth/socialaccount/models.py | def lookup(self):
"""
Lookup existing account, if any.
"""
assert not self.is_existing
try:
a = SocialAccount.objects.get(provider=self.account.provider,
uid=self.account.uid)
# Update account
a.extra_d... | def lookup(self):
"""
Lookup existing account, if any.
"""
assert not self.is_existing
try:
a = SocialAccount.objects.get(provider=self.account.provider,
uid=self.account.uid)
# Update account
a.extra_d... | [
"Lookup",
"existing",
"account",
"if",
"any",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/models.py#L254-L285 | [
"def",
"lookup",
"(",
"self",
")",
":",
"assert",
"not",
"self",
".",
"is_existing",
"try",
":",
"a",
"=",
"SocialAccount",
".",
"objects",
".",
"get",
"(",
"provider",
"=",
"self",
".",
"account",
".",
"provider",
",",
"uid",
"=",
"self",
".",
"acco... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | Provider.sociallogin_from_response | Instantiates and populates a `SocialLogin` model based on the data
retrieved in `response`. The method does NOT save the model to the
DB.
Data for `SocialLogin` will be extracted from `response` with the
help of the `.extract_uid()`, `.extract_extra_data()`,
`.extract_common_fie... | allauth/socialaccount/providers/base.py | def sociallogin_from_response(self, request, response):
"""
Instantiates and populates a `SocialLogin` model based on the data
retrieved in `response`. The method does NOT save the model to the
DB.
Data for `SocialLogin` will be extracted from `response` with the
help of... | def sociallogin_from_response(self, request, response):
"""
Instantiates and populates a `SocialLogin` model based on the data
retrieved in `response`. The method does NOT save the model to the
DB.
Data for `SocialLogin` will be extracted from `response` with the
help of... | [
"Instantiates",
"and",
"populates",
"a",
"SocialLogin",
"model",
"based",
"on",
"the",
"data",
"retrieved",
"in",
"response",
".",
"The",
"method",
"does",
"NOT",
"save",
"the",
"model",
"to",
"the",
"DB",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/base.py#L65-L99 | [
"def",
"sociallogin_from_response",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"# NOTE: Avoid loading models at top due to registry boot...",
"from",
"allauth",
".",
"socialaccount",
".",
"models",
"import",
"SocialLogin",
",",
"SocialAccount",
"adapter",
"="... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | EventbriteProvider.extract_common_fields | Extract fields from a basic user query. | allauth/socialaccount/providers/eventbrite/provider.py | def extract_common_fields(self, data):
"""Extract fields from a basic user query."""
email = None
for curr_email in data.get("emails", []):
email = email or curr_email.get("email")
if curr_email.get("verified", False) and \
curr_email.get("primary", Fa... | def extract_common_fields(self, data):
"""Extract fields from a basic user query."""
email = None
for curr_email in data.get("emails", []):
email = email or curr_email.get("email")
if curr_email.get("verified", False) and \
curr_email.get("primary", Fa... | [
"Extract",
"fields",
"from",
"a",
"basic",
"user",
"query",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/eventbrite/provider.py#L32-L48 | [
"def",
"extract_common_fields",
"(",
"self",
",",
"data",
")",
":",
"email",
"=",
"None",
"for",
"curr_email",
"in",
"data",
".",
"get",
"(",
"\"emails\"",
",",
"[",
"]",
")",
":",
"email",
"=",
"email",
"or",
"curr_email",
".",
"get",
"(",
"\"email\""... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | DataportenAdapter.complete_login | Arguments:
request - The get request to the callback URL
/accounts/dataporten/login/callback.
app - The corresponding SocialApp model instance
token - A token object with access token given in token.token
Returns:
Should return a dict with ... | allauth/socialaccount/providers/dataporten/views.py | def complete_login(self, request, app, token, **kwargs):
'''
Arguments:
request - The get request to the callback URL
/accounts/dataporten/login/callback.
app - The corresponding SocialApp model instance
token - A token object with access token... | def complete_login(self, request, app, token, **kwargs):
'''
Arguments:
request - The get request to the callback URL
/accounts/dataporten/login/callback.
app - The corresponding SocialApp model instance
token - A token object with access token... | [
"Arguments",
":",
"request",
"-",
"The",
"get",
"request",
"to",
"the",
"callback",
"URL",
"/",
"accounts",
"/",
"dataporten",
"/",
"login",
"/",
"callback",
".",
"app",
"-",
"The",
"corresponding",
"SocialApp",
"model",
"instance",
"token",
"-",
"A",
"tok... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/dataporten/views.py#L20-L60 | [
"def",
"complete_login",
"(",
"self",
",",
"request",
",",
"app",
",",
"token",
",",
"*",
"*",
"kwargs",
")",
":",
"# The athentication header",
"headers",
"=",
"{",
"'Authorization'",
":",
"'Bearer '",
"+",
"token",
".",
"token",
"}",
"# Userinfo endpoint, fo... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuthCallbackView.dispatch | View to handle final steps of OAuth based authentication where the user
gets redirected back to from the service provider | allauth/socialaccount/providers/oauth/views.py | def dispatch(self, request):
"""
View to handle final steps of OAuth based authentication where the user
gets redirected back to from the service provider
"""
login_done_url = reverse(self.adapter.provider_id + "_callback")
client = self._get_client(request, login_done_ur... | def dispatch(self, request):
"""
View to handle final steps of OAuth based authentication where the user
gets redirected back to from the service provider
"""
login_done_url = reverse(self.adapter.provider_id + "_callback")
client = self._get_client(request, login_done_ur... | [
"View",
"to",
"handle",
"final",
"steps",
"of",
"OAuth",
"based",
"authentication",
"where",
"the",
"user",
"gets",
"redirected",
"back",
"to",
"from",
"the",
"service",
"provider"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/views.py#L78-L115 | [
"def",
"dispatch",
"(",
"self",
",",
"request",
")",
":",
"login_done_url",
"=",
"reverse",
"(",
"self",
".",
"adapter",
".",
"provider_id",
"+",
"\"_callback\"",
")",
"client",
"=",
"self",
".",
"_get_client",
"(",
"request",
",",
"login_done_url",
")",
"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | ConfirmEmailView.login_on_confirm | Simply logging in the user may become a security issue. If you
do not take proper care (e.g. don't purge used email
confirmations), a malicious person that got hold of the link
will be able to login over and over again and the user is
unable to do anything about it. Even restoring their ... | allauth/account/views.py | def login_on_confirm(self, confirmation):
"""
Simply logging in the user may become a security issue. If you
do not take proper care (e.g. don't purge used email
confirmations), a malicious person that got hold of the link
will be able to login over and over again and the user is... | def login_on_confirm(self, confirmation):
"""
Simply logging in the user may become a security issue. If you
do not take proper care (e.g. don't purge used email
confirmations), a malicious person that got hold of the link
will be able to login over and over again and the user is... | [
"Simply",
"logging",
"in",
"the",
"user",
"may",
"become",
"a",
"security",
"issue",
".",
"If",
"you",
"do",
"not",
"take",
"proper",
"care",
"(",
"e",
".",
"g",
".",
"don",
"t",
"purge",
"used",
"email",
"confirmations",
")",
"a",
"malicious",
"person... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/views.py#L302-L338 | [
"def",
"login_on_confirm",
"(",
"self",
",",
"confirmation",
")",
":",
"user_pk",
"=",
"None",
"user_pk_str",
"=",
"get_adapter",
"(",
"self",
".",
"request",
")",
".",
"unstash_user",
"(",
"self",
".",
"request",
")",
"if",
"user_pk_str",
":",
"user_pk",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | extract_from_dict | Navigate `data`, a multidimensional array (list or dictionary), and returns
the object at `path`. | allauth/socialaccount/providers/orcid/provider.py | def extract_from_dict(data, path):
"""
Navigate `data`, a multidimensional array (list or dictionary), and returns
the object at `path`.
"""
value = data
try:
for key in path:
value = value[key]
return value
except (KeyError, IndexError, TypeError):
return... | def extract_from_dict(data, path):
"""
Navigate `data`, a multidimensional array (list or dictionary), and returns
the object at `path`.
"""
value = data
try:
for key in path:
value = value[key]
return value
except (KeyError, IndexError, TypeError):
return... | [
"Navigate",
"data",
"a",
"multidimensional",
"array",
"(",
"list",
"or",
"dictionary",
")",
"and",
"returns",
"the",
"object",
"at",
"path",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/orcid/provider.py#L44-L55 | [
"def",
"extract_from_dict",
"(",
"data",
",",
"path",
")",
":",
"value",
"=",
"data",
"try",
":",
"for",
"key",
"in",
"path",
":",
"value",
"=",
"value",
"[",
"key",
"]",
"return",
"value",
"except",
"(",
"KeyError",
",",
"IndexError",
",",
"TypeError"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | _extract_email | {'elements': [{'handle': 'urn:li:emailAddress:319371470',
'handle~': {'emailAddress': 'raymond.penners@intenct.nl'}}]} | allauth/socialaccount/providers/linkedin_oauth2/provider.py | def _extract_email(data):
"""
{'elements': [{'handle': 'urn:li:emailAddress:319371470',
'handle~': {'emailAddress': 'raymond.penners@intenct.nl'}}]}
"""
ret = ''
elements = data.get('elements', [])
if len(elements) > 0:
ret = elements[0].get('handle~', {}).get('emailAddres... | def _extract_email(data):
"""
{'elements': [{'handle': 'urn:li:emailAddress:319371470',
'handle~': {'emailAddress': 'raymond.penners@intenct.nl'}}]}
"""
ret = ''
elements = data.get('elements', [])
if len(elements) > 0:
ret = elements[0].get('handle~', {}).get('emailAddres... | [
"{",
"elements",
":",
"[",
"{",
"handle",
":",
"urn",
":",
"li",
":",
"emailAddress",
":",
"319371470",
"handle~",
":",
"{",
"emailAddress",
":",
"raymond",
".",
"penners"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/linkedin_oauth2/provider.py#L31-L40 | [
"def",
"_extract_email",
"(",
"data",
")",
":",
"ret",
"=",
"''",
"elements",
"=",
"data",
".",
"get",
"(",
"'elements'",
",",
"[",
"]",
")",
"if",
"len",
"(",
"elements",
")",
">",
"0",
":",
"ret",
"=",
"elements",
"[",
"0",
"]",
".",
"get",
"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuthClient._get_request_token | Obtain a temporary request token to authorize an access token and to
sign the request to obtain the access token | allauth/socialaccount/providers/oauth/client.py | def _get_request_token(self):
"""
Obtain a temporary request token to authorize an access token and to
sign the request to obtain the access token
"""
if self.request_token is None:
get_params = {}
if self.parameters:
get_params.update(self... | def _get_request_token(self):
"""
Obtain a temporary request token to authorize an access token and to
sign the request to obtain the access token
"""
if self.request_token is None:
get_params = {}
if self.parameters:
get_params.update(self... | [
"Obtain",
"a",
"temporary",
"request",
"token",
"to",
"authorize",
"an",
"access",
"token",
"and",
"to",
"sign",
"the",
"request",
"to",
"obtain",
"the",
"access",
"token"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L61-L84 | [
"def",
"_get_request_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"request_token",
"is",
"None",
":",
"get_params",
"=",
"{",
"}",
"if",
"self",
".",
"parameters",
":",
"get_params",
".",
"update",
"(",
"self",
".",
"parameters",
")",
"get_params",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuthClient.get_access_token | Obtain the access token to access private resources at the API
endpoint. | allauth/socialaccount/providers/oauth/client.py | def get_access_token(self):
"""
Obtain the access token to access private resources at the API
endpoint.
"""
if self.access_token is None:
request_token = self._get_rt_from_session()
oauth = OAuth1(
self.consumer_key,
client... | def get_access_token(self):
"""
Obtain the access token to access private resources at the API
endpoint.
"""
if self.access_token is None:
request_token = self._get_rt_from_session()
oauth = OAuth1(
self.consumer_key,
client... | [
"Obtain",
"the",
"access",
"token",
"to",
"access",
"private",
"resources",
"at",
"the",
"API",
"endpoint",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L86-L116 | [
"def",
"get_access_token",
"(",
"self",
")",
":",
"if",
"self",
".",
"access_token",
"is",
"None",
":",
"request_token",
"=",
"self",
".",
"_get_rt_from_session",
"(",
")",
"oauth",
"=",
"OAuth1",
"(",
"self",
".",
"consumer_key",
",",
"client_secret",
"=",
... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuthClient.get_redirect | Returns a ``HttpResponseRedirect`` object to redirect the user
to the URL the OAuth provider handles authorization. | allauth/socialaccount/providers/oauth/client.py | def get_redirect(self, authorization_url, extra_params):
"""
Returns a ``HttpResponseRedirect`` object to redirect the user
to the URL the OAuth provider handles authorization.
"""
request_token = self._get_request_token()
params = {'oauth_token': request_token['oauth_tok... | def get_redirect(self, authorization_url, extra_params):
"""
Returns a ``HttpResponseRedirect`` object to redirect the user
to the URL the OAuth provider handles authorization.
"""
request_token = self._get_request_token()
params = {'oauth_token': request_token['oauth_tok... | [
"Returns",
"a",
"HttpResponseRedirect",
"object",
"to",
"redirect",
"the",
"user",
"to",
"the",
"URL",
"the",
"OAuth",
"provider",
"handles",
"authorization",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L140-L151 | [
"def",
"get_redirect",
"(",
"self",
",",
"authorization_url",
",",
"extra_params",
")",
":",
"request_token",
"=",
"self",
".",
"_get_request_token",
"(",
")",
"params",
"=",
"{",
"'oauth_token'",
":",
"request_token",
"[",
"'oauth_token'",
"]",
",",
"'oauth_cal... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuth._get_at_from_session | Get the saved access token for private resources from the session. | allauth/socialaccount/providers/oauth/client.py | def _get_at_from_session(self):
"""
Get the saved access token for private resources from the session.
"""
try:
return self.request.session['oauth_%s_access_token'
% get_token_prefix(
self.req... | def _get_at_from_session(self):
"""
Get the saved access token for private resources from the session.
"""
try:
return self.request.session['oauth_%s_access_token'
% get_token_prefix(
self.req... | [
"Get",
"the",
"saved",
"access",
"token",
"for",
"private",
"resources",
"from",
"the",
"session",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L167-L178 | [
"def",
"_get_at_from_session",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"request",
".",
"session",
"[",
"'oauth_%s_access_token'",
"%",
"get_token_prefix",
"(",
"self",
".",
"request_token_url",
")",
"]",
"except",
"KeyError",
":",
"raise",
"O... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | OAuth.query | Request a API endpoint at ``url`` with ``params`` being either the
POST or GET data. | allauth/socialaccount/providers/oauth/client.py | def query(self, url, method="GET", params=dict(), headers=dict()):
"""
Request a API endpoint at ``url`` with ``params`` being either the
POST or GET data.
"""
access_token = self._get_at_from_session()
oauth = OAuth1(
self.consumer_key,
client_sec... | def query(self, url, method="GET", params=dict(), headers=dict()):
"""
Request a API endpoint at ``url`` with ``params`` being either the
POST or GET data.
"""
access_token = self._get_at_from_session()
oauth = OAuth1(
self.consumer_key,
client_sec... | [
"Request",
"a",
"API",
"endpoint",
"at",
"url",
"with",
"params",
"being",
"either",
"the",
"POST",
"or",
"GET",
"data",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/socialaccount/providers/oauth/client.py#L180-L200 | [
"def",
"query",
"(",
"self",
",",
"url",
",",
"method",
"=",
"\"GET\"",
",",
"params",
"=",
"dict",
"(",
")",
",",
"headers",
"=",
"dict",
"(",
")",
")",
":",
"access_token",
"=",
"self",
".",
"_get_at_from_session",
"(",
")",
"oauth",
"=",
"OAuth1",... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | get_next_redirect_url | Returns the next URL to redirect to, if it was explicitly passed
via the request. | allauth/account/utils.py | def get_next_redirect_url(request, redirect_field_name="next"):
"""
Returns the next URL to redirect to, if it was explicitly passed
via the request.
"""
redirect_to = get_request_param(request, redirect_field_name)
if not get_adapter(request).is_safe_url(redirect_to):
redirect_to = None... | def get_next_redirect_url(request, redirect_field_name="next"):
"""
Returns the next URL to redirect to, if it was explicitly passed
via the request.
"""
redirect_to = get_request_param(request, redirect_field_name)
if not get_adapter(request).is_safe_url(redirect_to):
redirect_to = None... | [
"Returns",
"the",
"next",
"URL",
"to",
"redirect",
"to",
"if",
"it",
"was",
"explicitly",
"passed",
"via",
"the",
"request",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L28-L36 | [
"def",
"get_next_redirect_url",
"(",
"request",
",",
"redirect_field_name",
"=",
"\"next\"",
")",
":",
"redirect_to",
"=",
"get_request_param",
"(",
"request",
",",
"redirect_field_name",
")",
"if",
"not",
"get_adapter",
"(",
"request",
")",
".",
"is_safe_url",
"(... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | user_field | Gets or sets (optional) user model fields. No-op if fields do not exist. | allauth/account/utils.py | def user_field(user, field, *args):
"""
Gets or sets (optional) user model fields. No-op if fields do not exist.
"""
if not field:
return
User = get_user_model()
try:
field_meta = User._meta.get_field(field)
max_length = field_meta.max_length
except FieldDoesNotExist:... | def user_field(user, field, *args):
"""
Gets or sets (optional) user model fields. No-op if fields do not exist.
"""
if not field:
return
User = get_user_model()
try:
field_meta = User._meta.get_field(field)
max_length = field_meta.max_length
except FieldDoesNotExist:... | [
"Gets",
"or",
"sets",
"(",
"optional",
")",
"user",
"model",
"fields",
".",
"No",
"-",
"op",
"if",
"fields",
"do",
"not",
"exist",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L80-L102 | [
"def",
"user_field",
"(",
"user",
",",
"field",
",",
"*",
"args",
")",
":",
"if",
"not",
"field",
":",
"return",
"User",
"=",
"get_user_model",
"(",
")",
"try",
":",
"field_meta",
"=",
"User",
".",
"_meta",
".",
"get_field",
"(",
"field",
")",
"max_l... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | perform_login | Keyword arguments:
signup -- Indicates whether or not sending the
email is essential (during signup), or if it can be skipped (e.g. in
case email verification is optional and we are only logging in). | allauth/account/utils.py | def perform_login(request, user, email_verification,
redirect_url=None, signal_kwargs=None,
signup=False):
"""
Keyword arguments:
signup -- Indicates whether or not sending the
email is essential (during signup), or if it can be skipped (e.g. in
case email verifi... | def perform_login(request, user, email_verification,
redirect_url=None, signal_kwargs=None,
signup=False):
"""
Keyword arguments:
signup -- Indicates whether or not sending the
email is essential (during signup), or if it can be skipped (e.g. in
case email verifi... | [
"Keyword",
"arguments",
":"
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L115-L166 | [
"def",
"perform_login",
"(",
"request",
",",
"user",
",",
"email_verification",
",",
"redirect_url",
"=",
"None",
",",
"signal_kwargs",
"=",
"None",
",",
"signup",
"=",
"False",
")",
":",
"# Local users are stopped due to form validation checking",
"# is_active, yet, ad... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | cleanup_email_addresses | Takes a list of EmailAddress instances and cleans it up, making
sure only valid ones remain, without multiple primaries etc.
Order is important: e.g. if multiple primary e-mail addresses
exist, the first one encountered will be kept as primary. | allauth/account/utils.py | def cleanup_email_addresses(request, addresses):
"""
Takes a list of EmailAddress instances and cleans it up, making
sure only valid ones remain, without multiple primaries etc.
Order is important: e.g. if multiple primary e-mail addresses
exist, the first one encountered will be kept as primary.
... | def cleanup_email_addresses(request, addresses):
"""
Takes a list of EmailAddress instances and cleans it up, making
sure only valid ones remain, without multiple primaries etc.
Order is important: e.g. if multiple primary e-mail addresses
exist, the first one encountered will be kept as primary.
... | [
"Takes",
"a",
"list",
"of",
"EmailAddress",
"instances",
"and",
"cleans",
"it",
"up",
"making",
"sure",
"only",
"valid",
"ones",
"remain",
"without",
"multiple",
"primaries",
"etc",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L184-L241 | [
"def",
"cleanup_email_addresses",
"(",
"request",
",",
"addresses",
")",
":",
"from",
".",
"models",
"import",
"EmailAddress",
"adapter",
"=",
"get_adapter",
"(",
"request",
")",
"# Let's group by `email`",
"e2a",
"=",
"OrderedDict",
"(",
")",
"# maps email to Email... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | setup_user_email | Creates proper EmailAddress for the user that was just signed
up. Only sets up, doesn't do any other handling such as sending
out email confirmation mails etc. | allauth/account/utils.py | def setup_user_email(request, user, addresses):
"""
Creates proper EmailAddress for the user that was just signed
up. Only sets up, doesn't do any other handling such as sending
out email confirmation mails etc.
"""
from .models import EmailAddress
assert not EmailAddress.objects.filter(use... | def setup_user_email(request, user, addresses):
"""
Creates proper EmailAddress for the user that was just signed
up. Only sets up, doesn't do any other handling such as sending
out email confirmation mails etc.
"""
from .models import EmailAddress
assert not EmailAddress.objects.filter(use... | [
"Creates",
"proper",
"EmailAddress",
"for",
"the",
"user",
"that",
"was",
"just",
"signed",
"up",
".",
"Only",
"sets",
"up",
"doesn",
"t",
"do",
"any",
"other",
"handling",
"such",
"as",
"sending",
"out",
"email",
"confirmation",
"mails",
"etc",
"."
] | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L244-L278 | [
"def",
"setup_user_email",
"(",
"request",
",",
"user",
",",
"addresses",
")",
":",
"from",
".",
"models",
"import",
"EmailAddress",
"assert",
"not",
"EmailAddress",
".",
"objects",
".",
"filter",
"(",
"user",
"=",
"user",
")",
".",
"exists",
"(",
")",
"... | f70cb3d622f992f15fe9b57098e0b328445b664e |
train | send_email_confirmation | E-mail verification mails are sent:
a) Explicitly: when a user signs up
b) Implicitly: when a user attempts to log in using an unverified
e-mail while EMAIL_VERIFICATION is mandatory.
Especially in case of b), we want to limit the number of mails
sent (consider a user retrying a few times), which i... | allauth/account/utils.py | def send_email_confirmation(request, user, signup=False):
"""
E-mail verification mails are sent:
a) Explicitly: when a user signs up
b) Implicitly: when a user attempts to log in using an unverified
e-mail while EMAIL_VERIFICATION is mandatory.
Especially in case of b), we want to limit the nu... | def send_email_confirmation(request, user, signup=False):
"""
E-mail verification mails are sent:
a) Explicitly: when a user signs up
b) Implicitly: when a user attempts to log in using an unverified
e-mail while EMAIL_VERIFICATION is mandatory.
Especially in case of b), we want to limit the nu... | [
"E",
"-",
"mail",
"verification",
"mails",
"are",
"sent",
":",
"a",
")",
"Explicitly",
":",
"when",
"a",
"user",
"signs",
"up",
"b",
")",
"Implicitly",
":",
"when",
"a",
"user",
"attempts",
"to",
"log",
"in",
"using",
"an",
"unverified",
"e",
"-",
"m... | pennersr/django-allauth | python | https://github.com/pennersr/django-allauth/blob/f70cb3d622f992f15fe9b57098e0b328445b664e/allauth/account/utils.py#L281-L332 | [
"def",
"send_email_confirmation",
"(",
"request",
",",
"user",
",",
"signup",
"=",
"False",
")",
":",
"from",
".",
"models",
"import",
"EmailAddress",
",",
"EmailConfirmation",
"cooldown_period",
"=",
"timedelta",
"(",
"seconds",
"=",
"app_settings",
".",
"EMAIL... | f70cb3d622f992f15fe9b57098e0b328445b664e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.