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