Remove unused code (and golf)
This commit is contained in:
parent
912ad34ab7
commit
90e06f8182
|
@ -11,41 +11,20 @@ class CountedIOList:
|
|||
self.length = len(i)
|
||||
|
||||
def counted(i):
|
||||
if isinstance(i, CountedIOList): return i
|
||||
return CountedIOList(i)
|
||||
|
||||
def withbyte(i, b):
|
||||
if i is None:
|
||||
return b
|
||||
elif isinstance(i, list):
|
||||
i.append(b)
|
||||
return i
|
||||
else:
|
||||
return [i, b]
|
||||
return i if isinstance(i, CountedIOList) else CountedIOList(i)
|
||||
|
||||
_len = len
|
||||
|
||||
def join(*iolists):
|
||||
if _len(iolists) == 0:
|
||||
return None
|
||||
if _len(iolists) == 1:
|
||||
return iolists[0]
|
||||
return list(iolists)
|
||||
|
||||
def len(i):
|
||||
if i is None:
|
||||
return 0
|
||||
if isinstance(i, int):
|
||||
return 1
|
||||
if isinstance(i, _bytes):
|
||||
return _len(i)
|
||||
if i is None: return 0
|
||||
if isinstance(i, int): return 1
|
||||
if isinstance(i, _bytes): return _len(i)
|
||||
if isinstance(i, list):
|
||||
acc = 0
|
||||
for j in i:
|
||||
acc = acc + len(j)
|
||||
return acc
|
||||
if isinstance(i, CountedIOList):
|
||||
return i.length
|
||||
if isinstance(i, CountedIOList): return i.length
|
||||
raise ValueError('invalid iolist: ' + repr(i) + ' ' + repr(type(i)))
|
||||
|
||||
_bytes = bytes
|
||||
|
@ -53,8 +32,7 @@ _bytes = bytes
|
|||
def bytes(i):
|
||||
buffer = bytearray(len(i))
|
||||
def fill(i, offset):
|
||||
while isinstance(i, CountedIOList):
|
||||
i = i.value
|
||||
while isinstance(i, CountedIOList): i = i.value
|
||||
if i is None:
|
||||
return offset
|
||||
if isinstance(i, int):
|
||||
|
|
Loading…
Reference in New Issue