-
Notifications
You must be signed in to change notification settings - Fork 1
/
helper_functions.py
59 lines (50 loc) · 2.1 KB
/
helper_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def get_build_folder(temp_filename: str):
build_folder = temp_filename[:temp_filename.rfind('/')]
return build_folder
def get_build_number(temp_filename: str):
build_folder = get_build_folder(temp_filename)
build_number = build_folder[:build_folder.find('_')]
build_number = build_number[(build_number.rfind('/') + 1):]
return build_number
def get_build_folder_name(temp_filename: str):
build_folder = get_build_folder(temp_filename)
build_folder_name = build_folder[:build_folder.rfind('/')]
build_folder_name = build_folder_name[build_folder_name.rfind('/') + 1:]
return build_folder_name
def printProgressBar(iteration,
total,
prefix='',
suffix='',
decimals=1,
length=40,
fill='█',
printEnd="\r"):
"""
Call in a loop to create terminal progress bar
@params:
iteration - Required : current iteration (Int)
total - Required : total iterations (Int)
prefix - Optional : prefix string (Str)
suffix - Optional : suffix string (Str)
decimals - Optional : positive number of decimals in percent complete (Int)
length - Optional : character length of bar (Int)
fill - Optional : bar fill character (Str)
printEnd - Optional : end character (e.g. "\r", "\r\n") (Str)
"""
percent = ("{0:." + str(decimals) + "f}").format(
100 * (iteration / float(total)))
filledLength = int(length * iteration // total)
bar = fill * filledLength + '-' * (length - filledLength)
print('\r%s |%s| %s%% %s' % (prefix, bar, percent, suffix), end=printEnd)
# Print New Line on Complete
if iteration == total:
print('\n')
def get_description_dict():
desc_dict = {}
desc_filename = 'descriptions.txt'
with open(desc_filename) as desc_file:
for line in desc_file:
split_line = line.split('-', 1)
(key, value) = split_line
desc_dict[key] = value
return desc_dict