From 0823f1131022d1bdf89a083dbe060fe110ea6cd6 Mon Sep 17 00:00:00 2001 From: Lee Skillen Date: Wed, 31 Jan 2018 16:36:16 +0000 Subject: Fix pep8 complaints --- uritemplate/orderedset.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'uritemplate') diff --git a/uritemplate/orderedset.py b/uritemplate/orderedset.py index 94f4733..7a9d33e 100644 --- a/uritemplate/orderedset.py +++ b/uritemplate/orderedset.py @@ -1,25 +1,28 @@ -# From: https://github.com/ActiveState/code/blob/master/recipes/Python/576696_OrderedSet_with_Weakrefs/ +# From: https://github.com/ActiveState/code/blob/master/recipes/Python/576696_OrderedSet_with_Weakrefs/ # noqa import collections from weakref import proxy + class Link(object): __slots__ = 'prev', 'next', 'key', '__weakref__' + class OrderedSet(collections.MutableSet): 'Set the remembers the order elements were added' # Big-O running times for all methods are the same as for regular sets. - # The internal self.__map dictionary maps keys to links in a doubly linked list. - # The circular doubly linked list starts and ends with a sentinel element. - # The sentinel element never gets deleted (this simplifies the algorithm). - # The prev/next links are weakref proxies (to prevent circular references). - # Individual links are kept alive by the hard reference in self.__map. - # Those hard references disappear when a key is deleted from an OrderedSet. + # The internal self.__map dictionary maps keys to links in a doubly linked + # list. The circular doubly linked list starts and ends with a sentinel + # element. The sentinel element never gets deleted (this simplifies the + # algorithm). The prev/next links are weakref proxies (to prevent circular + # references). Individual links are kept alive by the hard reference in + # self.__map. Those hard references disappear when a key is deleted from + # an OrderedSet. def __init__(self, iterable=None): - self.__root = root = Link() # sentinel node for doubly linked list + self.__root = root = Link() # sentinel node for doubly linked list root.prev = root.next = root - self.__map = {} # key --> link + self.__map = {} # key --> link if iterable is not None: self |= iterable -- cgit v1.2.3