add sorting code, saving to file
parent
e21628b608
commit
bcfd61a7cf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,31 @@
|
||||
# Sort items
|
||||
import pickle
|
||||
|
||||
def write(bins):
|
||||
file = open("bins.txt","w+b")
|
||||
pickle.dump(bins, file)
|
||||
file.close()
|
||||
|
||||
def sort(input):
|
||||
file = open("bins.txt","a+b")
|
||||
file.close()
|
||||
file = open("bins.txt", "rb")
|
||||
bins = pickle.load(file)
|
||||
|
||||
|
||||
if len(bins) == 0:
|
||||
bins = ['Unknown']
|
||||
file.close()
|
||||
write(bins)
|
||||
#file.write(str(bins))
|
||||
if bins.count(input) == 0:
|
||||
bins.append(input)
|
||||
bin = bins.index(input)
|
||||
print(str(bins))
|
||||
print(bin)
|
||||
write(bins)
|
||||
return bin
|
||||
|
||||
def clear():
|
||||
write(["Unknown"])
|
||||
write(["Unknown"])
|
Loading…
Reference in New Issue