Refactored cpl-query Iterable & Enumerable #129

This commit is contained in:
2022-12-01 21:09:39 +01:00
parent e8ae635c88
commit f0f79e7e3b
19 changed files with 390 additions and 916 deletions

View File

@@ -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