new stream util + non valued arg -> True/False

This commit is contained in:
klemek
2020-04-29 12:24:52 +02:00
parent b6d063e1e5
commit 8caa7efb94
2 changed files with 19 additions and 3 deletions
+17 -2
View File
@@ -1,7 +1,7 @@
import re
import sys
import os.path as path
from typing import List, Optional, Union, Tuple
from typing import List, Optional, Union, Tuple, BinaryIO
from Levenshtein import distance
@@ -111,7 +111,10 @@ def read_argument(args: List[str], *names: str, valued: bool = False, delete: bo
if delete:
del args[i + 1]
return v
return None
if valued:
return None
else:
return False
def split_arguments(args: Union[List[str], Tuple[str]], separator: str) -> List[List[str]]:
@@ -208,4 +211,16 @@ def safe_index(src: Union[str, list], pattern, start: int = 0):
except ValueError:
return None
# endregion
# region stream utils
def read_stream(stream: BinaryIO) -> bytes:
output_data = bytearray()
for line in stream:
output_data += line
return output_data
# endregion