-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.py
More file actions
99 lines (90 loc) · 2.48 KB
/
setup.py
File metadata and controls
99 lines (90 loc) · 2.48 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import argparse
import json
def parse_arguments():
parser = argparse.ArgumentParser(description="Setup for Project Time Tracker")
parser.add_argument(
"-l",
"--excel_location",
type=str,
default=".",
help="Directory to save the Excel file ex.: 'C:/Users/username/Desktop'",
)
parser.add_argument(
"-p1",
"--project1",
type=str,
default="Others",
help="Name of the first quick project",
)
parser.add_argument(
"-p2",
"--project2",
type=str,
default="RnD",
help="Name of the second quick project",
)
parser.add_argument(
"-p3",
"--project3",
type=str,
default="products",
help="Name of the second quick project",
)
parser.add_argument(
"-p4",
"--project4",
type=str,
default="projects",
help="Name of the second quick project",
)
parser.add_argument(
"-no",
"--normalize_hours",
type=float,
default=7.5,
help="Number of hours to normalize to every day (default 7.5)",
)
parser.add_argument(
"-w",
"--language",
type=int,
default=0,
choices=[0, 1],
help="Language selection (0 - English, 1 - Czech)",
)
parser.add_argument(
"-n",
"--name",
type=str,
default="projectLog",
help="Name the sheet file 'Hours Loggging Sheet Name'",
)
return parser.parse_args()
def save_configuration(args):
config = {
"excel_location": args.excel_location,
"default_projects": [
args.project1,
args.project2,
args.project3,
args.project4,
],
"normalize_hours": args.normalize_hours,
"language": args.language,
"name": args.name,
}
with open("config.json", "w") as config_file:
json.dump(config, config_file)
def main():
args = parse_arguments()
save_configuration(args)
print("\n")
print(f"Excel file named '{args.name}' set to location: '{args.excel_location}'")
print(f"Default projects: '{args.project1}', '{args.project2}'")
print(f"Hours will be normalized to: '{args.normalize_hours}' hours")
print(f"Language: '{args.language}' (0 - English, 1 - Czech))")
print("\n")
print("Setup completed. Configuration saved.")
print("To run the program, run main.py")
if __name__ == "__main__":
main()