-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
177 lines (122 loc) · 6.35 KB
/
Copy pathmain.py
File metadata and controls
177 lines (122 loc) · 6.35 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
from utils.build_html import build_html
from utils.check_image import compare_images
from utils.utils import pathfinder, hex_to_rgb
from utils.menu import show_menu_base, show_menu_inputfolder, show_menu_outputfolder, show_menu_color
from pathlib import Path
def main():
# Init vars
invalidChoice = False
menuChoice = ""
inputFolder = {"aFolder": Path(__file__).parent / "images" / "a",
"bFolder": Path(__file__).parent / "images" / "b",
"emptyString": False}
outputFolder = {"outputFolder": Path(__file__).parent / "output", "emptyString": False}
hexColor = "#ff0000"
while True:
show_menu_base(invalidChoice, menuChoice)
menuChoice = input("Make a choice: ")
if (menuChoice == "1"): menuChoice1(inputFolder)
elif (menuChoice == "2"): menuChoice2(outputFolder)
elif (menuChoice == "3"): hexColor = menuChoice3(hexColor)
elif (menuChoice.lower() == "s") or menuChoice == "4":
print("\n\nStart...\n\n")
diff, broken, notExists, diffSize, aFolder, bFolder, outputFolder = (
compare_images(inputFolder["aFolder"], inputFolder["bFolder"], outputFolder, hexColor))
build_html(diff, broken, notExists, diffSize, aFolder, bFolder, outputFolder["outputFolder"])
elif (menuChoice.lower() == "q") or menuChoice == "5": break
else: invalidChoice = True
def menuChoice1(inputFolder):
# Init vars
inputChoice = ""
invalidChoice = False
pathInput = ""
folderCount = 0
# Def path A and B. emptyString = True -> show def path message
while True:
show_menu_inputfolder(invalidChoice, inputChoice, pathInput, inputFolder, folderCount) # Show cool "ui"
inputChoice = input("Make a choice: ")
invalidChoice = False # Reset invalid input flag for new user selection
folderCount = 0 # Reset counter for folder validation in current input
if inputChoice == "1": # HARD. Change input folder
pathInput = input("\nThere should be only 2 folders in the specified directory"
"\nWrite path to input folder: ")
# Def Path: Path("images") / "a". Without folder cleaning. Returns True when ""
inputFolder["aFolder"], inputFolder["emptyString"] = (
pathfinder(pathInput, Path("images") / "a", False, 1))
# Def Path: Path("images") / "b"
inputFolder["bFolder"], inputFolder["emptyString"] = (
pathfinder(pathInput, Path("images") / "b", False, 1))
if inputFolder["emptyString"] == True: continue # Def Path
elif inputFolder["aFolder"] == pathInput: continue # is not a path to folder
for iFolder in inputFolder["aFolder"].iterdir(): # Check amount of folders in directory (iFolder = input folder)
if folderCount == 3: break # Returns 2 iFolders + warning
if iFolder.is_dir():
folderCount += 1
if folderCount == 1: inputFolder["aFolder"] = iFolder
elif folderCount == 2: inputFolder["bFolder"] = iFolder
else: break # Go to "if folderCount == 3", when its actually 3
else: continue
if folderCount == 1: # Not enough folders -> set def folders
inputFolder["aFolder"] = Path(__file__).parent / "images" / "a"
inputFolder["bFolder"] = Path(__file__).parent / "images" / "b"
elif inputChoice == "2":
pathInput = input("Write path to input A folder: ")
# Def Path: Path("images") / "a". Without folder cleaning. Returns False when ""
inputFolder["aFolder"], inputFolder["emptyString"] =(
pathfinder(pathInput, Path("images") / "a",
False, 2))
elif inputChoice == "3":
# Def Path: Path("images") / "b". Without folder cleaning. Returns False when ""
pathInput = input("Write path to input B folder: ")
inputFolder["bFolder"], inputFolder["emptyString"] =(
pathfinder(pathInput, Path("images") / "b",
False, 2))
elif inputChoice == "4":continue # Show current paths
elif inputChoice == "test":
# Def Path: Path("testing") / "test" / "a". Without folder cleaning
inputFolder["aFolder"] = (
pathfinder(pathInput, Path("testing") / "test" / "a", False, 3))
# Def Path: Path("testing") / "test" / "b"
inputFolder["bFolder"] = (
pathfinder(pathInput, Path("testing") / "test" / "b", False, 3))
elif inputChoice == "task":
# Def Path: Path("testing") / "task" / "a". Without folder cleaning
inputFolder["aFolder"] = (
pathfinder(pathInput, Path("testing") / "task" / "a", False, 3))
# Def Path: Path("testing") / "task" / "b"
inputFolder["bFolder"] = (
pathfinder(pathInput, Path("testing") / "task" / "b", False, 3))
elif inputChoice == "q" or inputChoice == "5":break # Go back
else: invalidChoice = True # Invalid Choice message
def menuChoice2(outputFolder):
# Init vars
outputChoice = ""
invalidChoice = False
while True:
show_menu_outputfolder(invalidChoice, outputChoice, outputFolder)
outputChoice = input("Make a choice: ")
invalidChoice = False
if outputChoice == "1":
pathInput = input("Write path to output folder: ")
outputFolder["outputFolder"], outputFolder["emptyString"] = (
pathfinder(pathInput, Path("images") / "b",
False, 1))
elif outputChoice == "2": continue
elif outputChoice == "3" or outputChoice == "q": break
else: invalidChoice = True
def menuChoice3(hexColor):
# Init vars
colorChoice = ""
invalidChoice = False
while True:
show_menu_color(invalidChoice, colorChoice, hexColor)
colorChoice = input("Make a choice: ")
invalidChoice = False
if colorChoice == "1":
hexColor = hex_to_rgb(input("Write color: "))
elif colorChoice == "2": continue
elif colorChoice == "3" or colorChoice == "q":
return hexColor
else: invalidChoice = True
if (__name__) == "__main__":
main()