summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gbp/rpm/linkedlist.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/gbp/rpm/linkedlist.py b/gbp/rpm/linkedlist.py
index c622f603..ac121316 100644
--- a/gbp/rpm/linkedlist.py
+++ b/gbp/rpm/linkedlist.py
@@ -12,8 +12,8 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+# along with this program; if not, please see
+# <http://www.gnu.org/licenses/>
"""Simple implementation of a doubly linked list"""
import collections
@@ -59,12 +59,11 @@ class LinkedListNode(object):
data = ""
self._data = data
-
def delete(self):
"""Delete node"""
if self.prev:
- self.prev.next = self.__next__
- if self.__next__:
+ self.prev.next = self.next
+ if self.next:
self.next.prev = self.prev
self._data = None
@@ -78,11 +77,14 @@ class LinkedListIterator(collections.abc.Iterator):
def __next__(self):
ret = self._next
if ret:
- self._next = ret.__next__
+ self._next = ret.next
else:
raise StopIteration
return ret
+ def next(self):
+ return self.__next__()
+
class LinkedList(collections.abc.Iterable):
"""Doubly linked list"""
@@ -171,8 +173,8 @@ class LinkedList(collections.abc.Iterable):
>>> [str(data) for data in list]
['foo', 'baz', 'bar']
"""
- new = LinkedListNode(data, prev_node=node, next_node=node.__next__)
- if node.__next__:
+ new = LinkedListNode(data, prev_node=node, next_node=node.next)
+ if node.next:
node.next.prev = new
else:
self._last = new
@@ -205,10 +207,11 @@ class LinkedList(collections.abc.Iterable):
"""
ret = node.prev
if node is self._first:
- ret = self._first = self._first.__next__
+ ret = self._first = self._first.next
if node is self._last:
self._last = self._last.prev
node.delete()
return ret
# vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·:
+