Program creates .OWNBASE file if not exists and fills it

This commit is contained in:
BarsTiger
2021-08-21 11:26:35 +03:00
parent 66d18b0560
commit 13d0fb5c39

View File

@@ -252,9 +252,11 @@ def checkbelow(belowthis, dictionary):
yesbelow[key] = dictionary[key]
return yesbelow
showown = "All"
basename = 'default.database'
backname = str(os.path.splitext(basename)[0]) + ".databack"
showown = "All"
ownname = str(os.path.splitext(basename)[0]) + ".ownbase"
if not os.path.isfile(basename):
basewrite = open(basename, 'w+')
@@ -296,8 +298,16 @@ shops = set(shops)
shops = list(shops)
shops = sorted(shops)
if not os.path.isfile(ownname):
ownwrite = open(ownname, 'w+')
empty = {}
for item in buyitems:
empty[item] = False
json.dump(empty, ownwrite, indent=3, ensure_ascii=False)
ownwrite.close()
def openbase():
global baseread, database, buyitems, typesofitems, shops, bytype, byshop, byprice, backname
global baseread, database, buyitems, typesofitems, shops, bytype, byshop, byprice, backname, ownname
if not os.path.isfile(basename):
basewrite = open(basename, 'w+')
empty = {}
@@ -338,6 +348,15 @@ def openbase():
shops = list(shops)
shops = sorted(shops)
backname = str(os.path.splitext(basename)[0]) + ".databack"
ownname = str(os.path.splitext(basename)[0]) + ".ownbase"
if not os.path.isfile(ownname):
ownwrite = open(ownname, 'w+')
empty = {}
for item in buyitems:
empty[item] = False
json.dump(empty, ownwrite, indent=3, ensure_ascii=False)
ownwrite.close()
printlogo()