diff --git a/func.py b/func.py index d8f4ef1..0bfa27f 100644 --- a/func.py +++ b/func.py @@ -12,6 +12,7 @@ class database(): else: self.connection = sql.connect(filepath) self.crsr = self.connection.cursor() + def add_index(self,vallist): # compile the options into a command for the SQLite database colstring=",".join(self.collist) @@ -226,7 +227,7 @@ class filestable(database): f.close() return str(md5_hash.hexdigest()) - def search_index(self,args): + def search_index(self,args,quiet=False): #print(args) #### ## WARNING!!!!!! UGLY CODE INCOMING!!!!!! @@ -306,20 +307,29 @@ class filestable(database): print("\tCategory:",temp_list[4]) print("\tTags:\t ",temp_list[5]) n+=1 - eingabe=input("Enter number 0-{}: ".format(n-1)) - if int(eingabe) < n: - for i in selection[int(eingabe)]: - res.append(i) - print("\n\nFinal match:") + eingabe=input("Enter number(s) (0-{}; '*' for all entries): ".format(n-1)) + if not eingabe: + return ["."] + num_list=[] + if re.match('[*]',eingabe): + for i in range(0,n): + num_list.append(i) else: - print(type(eingabe)) + num_list=eingabe.split(' ') + nminus=0 + for i in num_list: + if int(i) >= n: + print("The number {} is too big!".format(i)) + nminus+=1 + continue + res.append(selection[int(i)]) + if not quiet: + print("\n\nFinal match{}:".format("es" if len(num_list)-nminus > 1 else "")) else: if selection[0] == ".": print("No matching entry found!") return ["."] - tempres=selection[0] - for i in tempres: - res.append(i) + res=selection print("\nMatch found!") return res return 1 \ No newline at end of file diff --git a/main.py b/main.py index b43c69b..0ad9bff 100755 --- a/main.py +++ b/main.py @@ -40,21 +40,23 @@ def check(args): repair(path_list) def delete(args): - selection=search(args) - if selection[0] != ".": - try: - category=selection[4] - filename=selection[0] - os.remove("{}/{}".format(category,filename)) - except Exception: - print("Couldn't delete file!") - return 1 - tb.delete_index(selection) + selection=search(args,True) + for sel in selection: + if sel[0] != ".": + try: + category=sel[4] + filename=sel[0] + os.remove("{}/{}/{}".format(ROOT_DIR,category,filename)) + except Exception as e: + print(e) + print("Couldn't delete a file!") + return 1 + tb.delete_index(sel) def help(): print("SYNTAX:\n\t'image-index