测试gitnore
This commit is contained in:
@@ -25,9 +25,6 @@ class OrderedSet:
|
||||
def __iter__(self):
|
||||
return iter(self.dict)
|
||||
|
||||
def __reversed__(self):
|
||||
return reversed(self.dict)
|
||||
|
||||
def __contains__(self, item):
|
||||
return item in self.dict
|
||||
|
||||
@@ -37,10 +34,6 @@ class OrderedSet:
|
||||
def __len__(self):
|
||||
return len(self.dict)
|
||||
|
||||
def __repr__(self):
|
||||
data = repr(list(self.dict)) if self.dict else ""
|
||||
return f"{self.__class__.__qualname__}({data})"
|
||||
|
||||
|
||||
class MultiValueDictKeyError(KeyError):
|
||||
pass
|
||||
@@ -65,10 +58,9 @@ class MultiValueDict(dict):
|
||||
>>> d.setlist('lastname', ['Holovaty', 'Willison'])
|
||||
|
||||
This class exists to solve the irritating problem raised by cgi.parse_qs,
|
||||
which returns a list for every key, even though most web forms submit
|
||||
which returns a list for every key, even though most Web forms submit
|
||||
single name-value pairs.
|
||||
"""
|
||||
|
||||
def __init__(self, key_to_list_mapping=()):
|
||||
super().__init__(key_to_list_mapping)
|
||||
|
||||
@@ -93,22 +85,24 @@ class MultiValueDict(dict):
|
||||
super().__setitem__(key, [value])
|
||||
|
||||
def __copy__(self):
|
||||
return self.__class__([(k, v[:]) for k, v in self.lists()])
|
||||
return self.__class__([
|
||||
(k, v[:])
|
||||
for k, v in self.lists()
|
||||
])
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
result = self.__class__()
|
||||
memo[id(self)] = result
|
||||
for key, value in dict.items(self):
|
||||
dict.__setitem__(
|
||||
result, copy.deepcopy(key, memo), copy.deepcopy(value, memo)
|
||||
)
|
||||
dict.__setitem__(result, copy.deepcopy(key, memo),
|
||||
copy.deepcopy(value, memo))
|
||||
return result
|
||||
|
||||
def __getstate__(self):
|
||||
return {**self.__dict__, "_data": {k: self._getlist(k) for k in self}}
|
||||
return {**self.__dict__, '_data': {k: self._getlist(k) for k in self}}
|
||||
|
||||
def __setstate__(self, obj_dict):
|
||||
data = obj_dict.pop("_data", {})
|
||||
data = obj_dict.pop('_data', {})
|
||||
for k, v in data.items():
|
||||
self.setlist(k, v)
|
||||
self.__dict__.update(obj_dict)
|
||||
@@ -230,7 +224,7 @@ class ImmutableList(tuple):
|
||||
AttributeError: You cannot mutate this.
|
||||
"""
|
||||
|
||||
def __new__(cls, *args, warning="ImmutableList object is immutable.", **kwargs):
|
||||
def __new__(cls, *args, warning='ImmutableList object is immutable.', **kwargs):
|
||||
self = tuple.__new__(cls, *args, **kwargs)
|
||||
self.warning = warning
|
||||
return self
|
||||
@@ -263,7 +257,6 @@ class DictWrapper(dict):
|
||||
Used by the SQL construction code to ensure that values are correctly
|
||||
quoted before being used.
|
||||
"""
|
||||
|
||||
def __init__(self, data, func, prefix):
|
||||
super().__init__(data)
|
||||
self.func = func
|
||||
@@ -277,7 +270,7 @@ class DictWrapper(dict):
|
||||
"""
|
||||
use_func = key.startswith(self.prefix)
|
||||
if use_func:
|
||||
key = key[len(self.prefix) :]
|
||||
key = key[len(self.prefix):]
|
||||
value = super().__getitem__(key)
|
||||
if use_func:
|
||||
return self.func(value)
|
||||
@@ -288,13 +281,11 @@ def _destruct_iterable_mapping_values(data):
|
||||
for i, elem in enumerate(data):
|
||||
if len(elem) != 2:
|
||||
raise ValueError(
|
||||
"dictionary update sequence element #{} has "
|
||||
"length {}; 2 is required.".format(i, len(elem))
|
||||
'dictionary update sequence element #{} has '
|
||||
'length {}; 2 is required.'.format(i, len(elem))
|
||||
)
|
||||
if not isinstance(elem[0], str):
|
||||
raise ValueError(
|
||||
"Element key %r invalid, only strings are allowed" % elem[0]
|
||||
)
|
||||
raise ValueError('Element key %r invalid, only strings are allowed' % elem[0])
|
||||
yield tuple(elem)
|
||||
|
||||
|
||||
@@ -330,7 +321,9 @@ class CaseInsensitiveMapping(Mapping):
|
||||
def __eq__(self, other):
|
||||
return isinstance(other, Mapping) and {
|
||||
k.lower(): v for k, v in self.items()
|
||||
} == {k.lower(): v for k, v in other.items()}
|
||||
} == {
|
||||
k.lower(): v for k, v in other.items()
|
||||
}
|
||||
|
||||
def __iter__(self):
|
||||
return (original_key for original_key, value in self._store.values())
|
||||
|
||||
Reference in New Issue
Block a user