-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
114 lines (86 loc) · 4.75 KB
/
main.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
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import tkinter as tk
import gui
from project import project
from compare import comparison
# venv\Scripts\pyinstaller.exe --onefile main.py
try:
if __name__ == "__main__":
# start GUI
root = tk.Tk()
app = gui.user_interface(root)
root.mainloop()
# format data_array from gui to project_data[X][Y], X project, Y data (0=name, 1=folder path)
if "" in app.data_array_projects:
raise Exception("All projects need a valid name and folder path")
if len(app.data_array_projects) >= 4:
app.data_array_projects = list(filter(lambda x: x != "", app.data_array_projects))
project_data = []
project_data = [app.data_array_projects[i:i+2] for i in range(0, len(app.data_array_projects), 2)]
else:
raise Exception("Program needs at least 2 projects, each with a valid name and a folder path")
# create excel file, get desktop path and some info
comp = comparison()
comp.get_file_pathes()
comp.get_info_for_script()
comp.local_changes_On = app.local_changes_On
comp.summary_differnces_On = app.summary_differences_On
print("Information gathered from GUI")
# get filter info from GUI
comp.filters_On = app.filters_on
comp.filter_index = app.filter_index
# read all projects
project_list = []
number_of_projects = int(len(project_data))
for index_in_project_list in range(number_of_projects):
# create new project
project_name = project_data[index_in_project_list][0]
project_folder_path = project_data[index_in_project_list][1]
column_in_excel = index_in_project_list + 2 #column 1=parameters, therefore first project[0] in column = 2
new_project = project(project_name,project_folder_path,column_in_excel)
# get file pathes of standardTemplate and StandardTemplatesChanges
new_project.get_path_of_templates()
# fill parameter_list with data from templates
new_project.get_param_from_standardtemplate()
# clean standardtempletes from duplicates
new_project.delete_duplicates()
# overwrite parameter from standardtemplateschanges to standardtemplate
new_project.write_changes_to_standard_template()
# get the local changes
new_project.get_local_changes(ignored_folders=comp.Ignored_folders,ignored_param=comp.ignored_parameters)
# add project to projectlist
project_list.append(new_project)
# write project list to compare class
comp.project_list = project_list
print("Parameter gathered")
# write first project to excel
comp.write_first_project_to_mainfile()
# add more projects to excel sheet
if number_of_projects > 1:
for index_in_project_list in range(1,number_of_projects):
comp.add_next_project_to_mainfile(index_in_project_list=index_in_project_list)
comp.compare_parameters_in_file(file_path=comp.path_file_comparison, compare_column_in_excel=2, column_in_excel=comp.project_list[index_in_project_list].column_in_excel)
# Add 2 columns between A and B and split GVL to make it easier to filter in excel
comp.format_parameter_column(file_path= comp.path_file_comparison)
comp.format_sheet(file_path=comp.path_file_comparison)
print("Parameter Comparison done")
# create excel files for local changes of each project if selected
if comp.local_changes_On:
for index_in_project_list in range(number_of_projects):
comp.write_local_changes_to_excel(index_in_project_list=index_in_project_list)
print("Local Parameter changes collected")
# create the filtered file if selected
if comp.filters_On:
comp.get_filters()
comp.copy_comparison_with_filter()
comp.format_sheet(file_path=comp.path_file_filtered_comparion)
print("Filtered Parameter Comparison done")
# create summary of differences if selected, not working for now
if comp.summary_differnces_On:
comp.create_list_with_differences(number_of_projects=number_of_projects)
comp.format_sheet(file_path=comp.path_file_differences)
print("Summary of Differences")
# Tell user script is done
print("Program Done")
except Exception as e:
print(f"Error: {e}")
input("Press Enter to exit the programme.")