def createChain(size=None, signed=None, value=None, fields=None): chain = fields if chain: for i, field in enumerate(chain): if i: field.__offset = chain[i - 1].nextOffset else: chain = [] args = (size, signed, value) def count(): for x in args: if StaticUtils.isIterable(x): return len(x) raise ValueError() for index in range(count()): params = tuple(v[index] if StaticUtils.isIterable(v) else v for v in args) chain.append( Field(params[0], previousField=chain[index - 1] if index else None, signed=params[1], value=params[2])) return chain
def count(): for x in args: if StaticUtils.isIterable(x): return len(x) raise ValueError()