Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _extend(self, args, kwargs, name, method):
if len(args) > 1:
raise TypeError(
"{} takes at most 1 positional argument"
" ({} given)".format(name, len(args))
)
if args:
arg = args[0]
if isinstance(args[0], (MultiDict, MultiDictProxy)) and not kwargs:
items = arg._impl._items
else:
if hasattr(arg, "items"):
arg = arg.items()
if kwargs:
arg = list(arg)
arg.extend(list(kwargs.items()))
items = []
for item in arg:
if not len(item) == 2:
raise TypeError(
"{} takes either dict or list of (key, value) "
"tuples".format(name)
)
items.append((self._title(item[0]), self._key(item[0]), item[1]))
raise TypeError(
"ctor requires MultiDict or MultiDictProxy instance"
", not {}".format(type(arg))
)
self._impl = arg._impl
def __reduce__(self):
raise TypeError("can't pickle {} objects".format(self.__class__.__name__))
def copy(self):
"""Return a copy of itself."""
return MultiDict(self.items())
class CIMultiDictProxy(MultiDictProxy):
"""Read-only proxy for CIMultiDict instance."""
def __init__(self, arg):
if not isinstance(arg, (CIMultiDict, CIMultiDictProxy)):
raise TypeError(
"ctor requires CIMultiDict or CIMultiDictProxy instance"
", not {}".format(type(arg))
)
self._impl = arg._impl
def _title(self, key):
return key.title()
def copy(self):
"""Return a copy of itself."""