-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
376 lines (351 loc) · 14.8 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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
"""
LEGO Block Creator
Copyright (C) 2016-2024 @willtheorangeguy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
#pylint: disable=invalid-name, global-variable-undefined, too-many-branches, too-many-statements, consider-using-in
def lego_cmd():
"""Offline inventory tracking of LEGO parts and sets through an easy to use CLI."""
# Prompt
INPUTmain = input("LEGO CMD: ")
# Functions to Answer Commands
# Piece Commands
if INPUTmain == "newpiece": # the 'newpiece' command
global INPUTnewpiece # create global var
global INPUTnewpiececount # create global var
global INPUTnewpiececolour # create global var
INPUTnewpiece = str(
input("Name the piece you would like to add: ")
) # ask for name
INPUTnewpiececolour = str(
input(
'What is the piece colour \
(make sure this colour is in the colour database, \
otherwise add using "newcolour")? '
)
) # ask for colour
INPUTnewpiececount = int(
input("How many of that would you like to add? ")
) # ask for qty
print(
"A new piece has been created named:",
'"' + INPUTnewpiece + '",',
"in the colour:",
'"' + INPUTnewpiececolour + '",',
"in the quantity of:",
INPUTnewpiececount,
) # check with user to make sure input ok
elif INPUTmain == "newcolour": # the 'newcolour' command
global INPUTnewcolour # create global var
INPUTnewcolour = str(
input("Name the colour you would like to add: ")
) # ask for colour name
print(
"A new colour had been created named:", '"' + INPUTnewcolour + '".'
) # check with user to make sure input ok
elif INPUTmain == "newcolor": # the 'newcolor' command
INPUTnewcolour = str(
input("Name the color you would like to add: ")
) # ask for colour name
print(
"A new color had been created named:", '"' + INPUTnewcolour + '".'
) # check with user to make sure input ok
elif INPUTmain == "addpiece": # the 'addpiece' command
global INPUTpiecename # create global var
global INPUTpiececolour # create global var
global INPUTpiececount # create global var
INPUTpiecename = str(
input("What is the name of the piece that you would like to add to? ")
) # ask for piece name
INPUTpiececolour = str(
input("What is the piece colour? ")
) # ask for piece colour
INPUTpiececount = int(
input("How many of that piece do you want to add? ")
) # ask for piece qty
print(
INPUTpiececount,
"pieces have been added to:",
'"' + INPUTpiecename + '",',
"in the colour of:",
'"' + INPUTpiececolour + '".',
) # check with user to make sure input ok
elif INPUTmain == "removepiece": # the 'removepiece' command
INPUTpiecename = str(
input("What is the name of the piece that you would like to remove? ")
) # ask for piece name
INPUTpiececolour = str(
input("What is the piece colour? ")
) # ask for piece colour
INPUTpiececount = int(
input("How many of that piece do you want to remove? ")
) # ask for piece qty
print(
INPUTpiececount,
"pieces have been removed from:",
'"' + INPUTpiecename + '",',
"in the colour of:",
'"' + INPUTpiececolour + '".',
) # check with user to make sure input ok
elif INPUTmain == "sortparts-all": # the 'sortparts-all' command
PIECESall = {
"piecename": "piecenames",
"piececolour": "piecescolour",
"piececount": "numofpieces",
} # create dictionary of pieces requested
print(
"Here are all the pieces in the database:", PIECESall
) # return specified results
elif INPUTmain == "sortparts-name": # the 'sortparts-name' command
global INPUTsearch # create global var
INPUTsearch = str(
input("Please enter a brick name: ")
) # search bar to sort by name
PIECESbyname = {
"piecename": "piecenamescontainingINPUTsearch",
"piececolour": "piecescolour",
"piececount": "numofpieces",
} # create dictionary of pieces requested
print(
"The following results were found for this search keyword:",
'"' + INPUTsearch + '", \n',
PIECESbyname,
) # return specified results
elif INPUTmain == "sortparts-colour": # the 'sortparts-colour' command
INPUTsearch = str(
input("Please enter a brick colour: ")
) # search bar to sort by colour
PIECESbycolour = {
"piecename": "piecenames",
"piececolour": "piecescolourcontainingINPUTsearch",
"piececount": "numofpieces",
} # create dictionary of pieces requested
print(
"The following results were found for this colour:",
'"' + INPUTsearch + '", \n',
PIECESbycolour,
) # return specified results
elif INPUTmain == "sortparts-color": # the 'sortparts-color' command
INPUTsearch = str(
input("Please enter a brick color: ")
) # search bar to sort by colour
PIECESbycolour = {
"piecename": "piecenames",
"piececolour": "piecescolourcontainingINPUTsearch",
"piececount": "numofpieces",
} # create dictionary of pieces requested
print(
"The following results were found for this color:",
'"' + INPUTsearch + '", \n',
PIECESbycolour,
) # return specified results
# Set commands
elif INPUTmain == "newset": # the 'newset' command
global INPUTnewset # create global var
global INPUTnewsetnum # create global var
global INPUTnewsettheme # create global var
global INPUTnewsetpiececount # create global var
global INPUTnewsetcount # create global var
INPUTnewset = str(input("Name the set you would like to add: ")) # ask set name
INPUTnewsetnum = str(
input("What is the set number for the set you would like to add? ")
) # ask set number
INPUTnewsettheme = str(
input(
'What is the theme for the set you would like to add? \
(make sure this theme is in the database, \
otherwise add using "newtheme") '
)
) # ask set theme
INPUTnewsetpiececount = str(
input("How many pieces are there in this set? ")
) # ask set piece count
INPUTnewsetcount = int(
input("How many of this set would you like to add? ")
) # ask number of sets to add
print(
"A new set has been created named:",
'"' + INPUTnewset + '",',
"with the set number:",
'"' + INPUTnewsetnum + '",',
"in the theme:",
'"' + INPUTnewsettheme + '",',
"with the piece count of:",
INPUTnewsetpiececount + ",",
"in the quantity of:",
INPUTnewsetcount,
) # check with user to make sure input ok
elif INPUTmain == "newtheme": # the 'newtheme' command
global INPUTnewtheme # create global var
INPUTnewtheme = str(
input("Name the theme you would like to add: ")
) # ask for theme name
print(
"A new theme had been created named:", '"' + INPUTnewtheme + '"'
) # check with user to make sure input ok
elif INPUTmain == "addset": # the 'addset' command
global INPUTsetnum # create global var
global INPUTsetcount # create global var
INPUTsetnum = str(
input("What is the set number of the set that you would like to add? ")
) # ask for set number
INPUTsetcount = int(
input("How many of that set do you want to add? ")
) # ask for set qty
print(
INPUTsetcount,
"sets have been added to set number:",
'"' + INPUTsetnum + '"',
) # check with user to make sure input ok
elif INPUTmain == "removeset": # the 'removeset' command
INPUTsetnum = str(
input("What is the set number of the set that you would like to remove? ")
) # ask for set number
INPUTsetcount = int(
input("How many of that set do you want to remove? ")
) # ask for set qty
print(
INPUTsetcount,
"sets have been removed from set number:",
'"' + INPUTsetnum + '"',
) # check with user to make sure input ok
elif INPUTmain == "sortsets-all": # the 'sortsets-all' command
SETSall = {
"setname": "setnames",
"setnum": "setnums",
"settheme": "setthemes",
"setpiececount": "numofpieces",
"setcount": "numofsets",
} # create dictionary of sets requested
print(
"Here are all the sets in the database:", SETSall
) # return specified results
elif INPUTmain == "sortsets-name": # the 'sortsets-name' command
INPUTsearch = str(
input("Please enter a set name (NOT number): ")
) # search bar to sort by name
SETSbyname = {
"setname": "setnamescontainingINPUTsearch",
"setnum": "setnums",
"settheme": "setthemes",
"setpiececount": "numofpieces",
"setcount": "numofsets",
} # create dictionary of pieces requested
print(
"The following results were found for this search keyword:",
'"' + INPUTsearch + '", \n',
SETSbyname,
) # return specified results
elif INPUTmain == "sortsets-number": # the 'sortsets-number' command
INPUTsearch = str(
input("Please enter a set number (NOT name): ")
) # search bar to sort by name
SETSbynum = {
"setname": "setnames",
"setnum": "setnumscontainingINPUTsearch",
"settheme": "setthemes",
"setpiececount": "numofpieces",
"setcount": "numofsets",
} # create dictionary of pieces requested
print(
"The following results were found for this search keyword:",
'"' + INPUTsearch + '", \n',
SETSbynum,
) # return specified results
elif INPUTmain == "sortsets-theme": # the 'sortsets-theme' command
INPUTsearch = str(
input("Please enter a set theme: ")
) # search bar to sort by name
SETSbytheme = {
"setname": "setnames",
"setnum": "setnums",
"settheme": "setthemescontainingINPUTsearch",
"setpiececount": "numofpieces",
"setcount": "numofsets",
} # create dictionary of pieces requested
print(
"The following results were found for this search keyword:",
'"' + INPUTsearch + '", \n',
SETSbytheme,
) # return specified results
# Other commands
elif INPUTmain == "help": # the 'help' command
print(
"You have entered the help area! Here is a list of commands for your reference:"
)
print("newpiece - creates a new piece in the database.")
print("newcolour/newcolor - creates a new colour in the database.")
print("addpiece - adds a quantity of your selected piece to the database.")
print(
"removepiece - \
removes a quantity of your selected piece from the database."
)
print(
"sortparts-all - \
prints all pieces and their respective colours and quantities to the screen."
)
print(
"sortparts-name - \
prints all pieces related to the search query entered, \
as well as their respective colours and quantities to the screen."
)
print(
"sortparts-colour/sortparts-color - \
prints all pieces in that colour, \
as well as their respective names and quantities."
)
print("newset - creates a new set in the database.")
print("newtheme - creates a new theme in the database. ")
print("addset - adds a quantity of your selected set to the database.")
print(
"removeset - \
removes a quantity of your selected set from the database."
)
print(
"sortsets-all - \
prints all sets and their respective set numbers, \
themes, piece count and quantity to the screen."
)
print(
"sortsets-name - \
prints all the sets related to the set name entered, \
as well as their respective set numbers, \
themes, piece count and quantity to the screen."
)
print(
"sortsets-number - \
prints all the sets related to the set number entered, \
as well as their respective set names, \
themes, piece count and quantity to the screen."
)
print(
"sortsets-theme - \
prints all the sets related to the set theme entered, \
as well as their respective set names, \
numbers, piece count and quantity to the screen."
)
print(
'copyright/license"- \
prints license and copyright information \
and opens the license in default text editor.'
)
print("help - prints this help text")
elif INPUTmain == "copyright" or INPUTmain == "license": # the 'copyright command'
print(
"Copyright (C) 2018-2023 Dog Face Development Co. \
\nUse is subject to the terms and conditions outlined in the LICENSE.md document."
) # copyright info
else:
print(
'Sorry, try again! \nType "help" for a list of commands.'
) # helpful error message
if __name__ == "__main__":
lego_cmd()