mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
d81046013e
commit
5ff7bfe564
@ -31,10 +31,9 @@ class OrderedSet(collections.MutableSet):
|
|||||||
every entry has an index that can be looked up.
|
every entry has an index that can be looked up.
|
||||||
"""
|
"""
|
||||||
def __init__(self, iterable=None):
|
def __init__(self, iterable=None):
|
||||||
if iterable is None:
|
|
||||||
self.items = []
|
self.items = []
|
||||||
self.map = {}
|
self.map = {}
|
||||||
else:
|
if iterable is not None:
|
||||||
for item in iterable:
|
for item in iterable:
|
||||||
idx = self.map.get(item)
|
idx = self.map.get(item)
|
||||||
if idx is None:
|
if idx is None:
|
||||||
@ -131,9 +130,6 @@ class OrderedSet(collections.MutableSet):
|
|||||||
if isinstance(other, OrderedSet):
|
if isinstance(other, OrderedSet):
|
||||||
return len(self) == len(other) and self.items == other.items
|
return len(self) == len(other) and self.items == other.items
|
||||||
try:
|
try:
|
||||||
other_as_set = set(other)
|
return type(other)(self.map) == other
|
||||||
except TypeError:
|
except TypeError:
|
||||||
# If `other` can't be converted into a set, it's not equal.
|
|
||||||
return False
|
return False
|
||||||
else:
|
|
||||||
return set(self) == other_as_set
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user