#!/bin/python3 import sys,os,re from func import * from config import * def add(): args=[] for i in ["Filepath","Category","Title","Source","Tags","Content"]: eingabe = input("Enter {}: ".format(i)) if i in ["Filepath"] and not eingabe: print("{} has to not be empty!".format(i)) return 1 if i in ["Category"] and not eingabe: print("{} set to 'default'".format(i)) eingabe="default" args.append(eingabe) tb.add_index(args[0],args[1],args[2],args[3],args[4],args[5]) def check(args): success=0 if not args: hash_list,path_list=tb.check_index() if hash_list: print("{} file{} faulty!".format(len(hash_list),"s are" if len(hash_list) > 1 else " is")) success=-1 if path_list: print("{} file{} missing!".format(int(len(path_list)/2),"s are" if int(len(path_list)/2) > 1 else " is")) success=-1 if success >= 0: print("Everything is good!") if hash_list: eingabe=input("Do you want to remove the faulty files? [y/N]: ") if re.match('[yY]',eingabe): print("Removing faulty files...") repair(hash_list) if path_list: eingabe=input("Do you want to remove the orphaned entries? [Y/n]: ") if not re.match('[nN]',eingabe): print("Removing orphaned entries...") repair(path_list) def delete(args): 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