From d5e5bfe69d7c55a0eef6f0a26a251a62ede0eedb Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Mon, 5 Dec 2022 14:15:01 +0100 Subject: [PATCH] Removed old file #134 --- src/cpl_query/base/sequence.py | 3 -- src/cpl_query/base/sequence_values.py | 47 --------------------------- 2 files changed, 50 deletions(-) delete mode 100644 src/cpl_query/base/sequence_values.py diff --git a/src/cpl_query/base/sequence.py b/src/cpl_query/base/sequence.py index ecb6cc5d..15f7fc4a 100644 --- a/src/cpl_query/base/sequence.py +++ b/src/cpl_query/base/sequence.py @@ -1,7 +1,4 @@ from abc import ABC, abstractmethod -from itertools import islice - -from cpl_query.base.sequence_values import SequenceValues class Sequence(list): diff --git a/src/cpl_query/base/sequence_values.py b/src/cpl_query/base/sequence_values.py deleted file mode 100644 index 6298a685..00000000 --- a/src/cpl_query/base/sequence_values.py +++ /dev/null @@ -1,47 +0,0 @@ -import io -import itertools - -from cpl_query.exceptions import IndexOutOfRangeException - - -class SequenceValues: - def __init__(self, data: list, _t: type): - if len(data) > 0: - def type_check(_t: type, _l: list): - return all([_t == any or isinstance(x, _t) for x in _l]) - - if not type_check(_t, data): - print([type(x) for x in data]) - raise Exception(f'Unexpected type\nExpected type: {_t}') - - if not hasattr(data, '__iter__'): - raise TypeError(f'{type(self).__name__} must be instantiated with an iterable object') - - self._new_cycle = lambda: itertools.cycle(data) - self._len = lambda: len(data) - - self._index = 0 - self._cycle = self._new_cycle() - - def __len__(self): - return self._len() - - def __iter__(self): - i = 0 - while i < self._len(): - yield next(self._cycle) - i += 1 - - def __next__(self): - if self._index >= len(self): - raise IndexOutOfRangeException() - self._index += 1 - - return self.next() - - def next(self): - return next(self._cycle) - - def reset(self): - self._index = 0 - self._cycle = self._new_cycle()