From cea63c5e46eebb33bb4c8d321e3bb7e987de5551 Mon Sep 17 00:00:00 2001 From: BarsTiger Date: Sat, 21 Aug 2021 13:41:09 +0300 Subject: [PATCH] Added one-at-time ownoption edit --- GTAwhatToBuy/GTAwhatToBuy.py | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/GTAwhatToBuy/GTAwhatToBuy.py b/GTAwhatToBuy/GTAwhatToBuy.py index fe8de43..57f378d 100644 --- a/GTAwhatToBuy/GTAwhatToBuy.py +++ b/GTAwhatToBuy/GTAwhatToBuy.py @@ -470,8 +470,32 @@ while True: softcls() elif doing == menulist["ownoptions"][0]: - print("Which item you would like to change?") - whattodonow = input("1 - Print all items\n2 - Search item\nType here: ") + print("Select type of editor") + typeofedit = input("1 - Edit all items\n2 - Edit one at a time\nType here: ") + if typeofedit == "2": + print() + print("Which item you would like to change?") + whattodonow = input("1 - Print all items\n2 - Search item\nType here: ") + if whattodonow == "1": + for item in buyitems: + print(item) + print() + elif whattodonow == "2": + whichtocontain = input("Start typing name here: ") + containthis = [] + for item in buyitems: + if whichtocontain.lower() in item.lower(): + containthis.append(item) + for item in containthis: + print(item) + itemtoedit = input("Type here name of item: ") + print(itemtoedit + " is now " + str(database[itemtoedit][3])) + isowneditem = bool(input("Do you own this item? (1 - Yes, 0 - No): ") == "1") + database[itemtoedit][3] = isowneditem + + basewrite = open(basename, 'w+') + json.dump(database, basewrite, indent=3, ensure_ascii=False) + basewrite.close() input("To go back to menu press Enter...") softcls()