new arg util + code cleaning

This commit is contained in:
klemek
2020-04-28 16:38:06 +02:00
parent 462ec21a53
commit 208a10c61e
2 changed files with 46 additions and 18 deletions
+11 -1
View File
@@ -114,6 +114,16 @@ def read_argument(args: List[str], *names: str, valued: bool = False, delete: bo
return None
def split_arguments(args: List[str], separator: str) -> List[List[str]]:
output = [[]]
for argument in args:
if argument == separator:
output += [[]]
else:
output[-1] += [argument]
return [block for block in output if len(block) > 0]
# endregion
# region lang utils
@@ -134,7 +144,7 @@ def find_nearest(word: str, wlist: List[str], threshold: int = 5) -> Optional[st
# endregion
# region text formatting utils
# region format utils
def justify_text(src: str, n_lines: int) -> Optional[str]:
spaces_indexes = find_all(src, " ")