code cleanup

This commit is contained in:
nlitkowski 2019-06-10 00:41:31 +02:00
parent 945ad8ce12
commit 078768815f

View File

@ -100,18 +100,16 @@ class House:
def find_trash_file(self): def find_trash_file(self):
# trash_files_list = []
from os.path import sep # culture and os invariant separator from os.path import sep # culture and os invariant separator
file_names = [(join(f"Images{sep}TestImages", f)) file_names = [(join(f"Images{sep}TestImages", f))
for f in listdir(f"Images{sep}TestImages") for f in listdir(f"Images{sep}TestImages")
if isfile(join(f"Images{sep}TestImages", f))] if isfile(join(f"Images{sep}TestImages", f))]
# #filter names
# for f in file_names:
# if trash[2] in f:
# trash_files_list.append(f)
file_name = file_names[rd.randint(0,len(file_names)) - 1] file_name = file_names[rd.randint(0,len(file_names)) - 1]
from Logic.TrashRecognition.ImageClassification import classify_file from Logic.TrashRecognition.ImageClassification import classify_file
if file_name in recognized_trash: if file_name in recognized_trash:
rt = recognized_trash[file_name] rt = recognized_trash[file_name]
return (file_name, rt[0], rt[1]) return (file_name, rt[0], rt[1])
@ -119,16 +117,6 @@ class House:
classification = classify_file(file_dir=file_name) classification = classify_file(file_dir=file_name)
recognized_trash[file_name] = (classification[1], classification[2]) recognized_trash[file_name] = (classification[1], classification[2])
return classification return classification
# trash_files_list = []
# # filter names
# for f in trash_files:
# if trash[2] in f[1]:
# trash_files_list.append(f[0])
# f = rd.randint(0,len(trash_files_list))
# return trash_files_list[f-1]
def generate_trash(self): def generate_trash(self):
self.empty = False self.empty = False
@ -136,19 +124,6 @@ class House:
classification = self.find_trash_file() classification = self.find_trash_file()
self.trash = self.trash_dict[classification[1]] self.trash = self.trash_dict[classification[1]]
self.trash_file = classification[0] self.trash_file = classification[0]
# num = rd.randint(1, 4)
# if num == 1:
# self.trash = self.paper
# self.trash_file = self.find_trash_file(self.trash)
# elif num == 2:
# self.trash = self.glass
# self.trash_file = self.find_trash_file(self.trash)
# elif num == 3:
# self.trash = self.metal
# self.trash_file = self.find_trash_file(self.trash)
# elif num == 4:
# self.trash = self.plastic
# self.trash_file = self.find_trash_file(self.trash)
def get_day_of_week(self, d: int): def get_day_of_week(self, d: int):
for day in self.DAYS: for day in self.DAYS: