Refactored cpl-query Iterable & Enumerable #129
This commit is contained in:
@@ -5,15 +5,13 @@ from cpl_query.exceptions import IndexOutOfRangeException
|
||||
|
||||
|
||||
class SequenceValues:
|
||||
def __init__(self, data, _t: type):
|
||||
if data is None:
|
||||
data = []
|
||||
|
||||
def __init__(self, data: list, _t: type):
|
||||
if len(data) > 0:
|
||||
def type_check(_t: type, _l: list):
|
||||
return all(isinstance(x, _t) for x in _l)
|
||||
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__'):
|
||||
@@ -30,7 +28,7 @@ class SequenceValues:
|
||||
|
||||
def __iter__(self):
|
||||
i = 0
|
||||
while i < len(self):
|
||||
while i < self._len():
|
||||
yield next(self._cycle)
|
||||
i += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user