From 7d11790d353f10ac6bc855c1c621e0bd1274fd6a Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 20 Feb 2014 20:45:30 +0100 Subject: [PATCH] Make it possible to use NeighborList without items --- qutebrowser/utils/types.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/qutebrowser/utils/types.py b/qutebrowser/utils/types.py index 328515d8b..6837f04af 100644 --- a/qutebrowser/utils/types.py +++ b/qutebrowser/utils/types.py @@ -37,7 +37,7 @@ class NeighborList: WRAP = 1 RAISE = 2 - def __init__(self, items, default=_UNSET, mode=BLOCK): + def __init__(self, items=None, default=_UNSET, mode=RAISE): """Constructor. Args: @@ -49,7 +49,10 @@ class NeighborList: RAISE: Raise an IndexError. """ - self._items = items + if items is None: + self._items = [] + else: + self._items = items self._default = default if default is not _UNSET: self.idx = self._items.index(default) @@ -74,6 +77,8 @@ class NeighborList: """ # FIXME - zooming somehow wraps... + if not self._items: + raise IndexError("No items found!") try: if self.idx + offset > 0: new = self._items[self.idx + offset]