Fix creating broken mine.json

main
justuser31 1 year ago
parent 963dd8ed5c
commit 7fa2ff0827

@ -1,19 +1,18 @@
import json import json
from os.path import isfile from os.path import isfile
from os import system as sys
# Money # Money
# {username: balance, ...} # {username: [balance, OpenKey], ...}
class money(): class users():
def read(): def read():
if not isfile("money.json"): if not isfile("users.json"):
sys('echo "{}" > money.json') sys('echo "{}" > users.json')
with open('money.json', 'r') as openfile: with open('users.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data
def write(data): def write(data):
js = json.dumps(data, indent=4) js = json.dumps(data, indent=4)
with open("money.json", "w") as outfile: with open("users.json", "w") as outfile:
outfile.write(js) outfile.write(js)
# Mining + Registrations # Mining + Registrations
@ -22,7 +21,8 @@ class money():
class mine(): class mine():
def read(): def read():
if not isfile("mine.json"): if not isfile("mine.json"):
sys('echo "[]" > mine.json') #sys('echo "[]" > mine.json')
mine.write([])
with open('mine.json', 'r') as openfile: with open('mine.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data
@ -46,16 +46,16 @@ class pay():
with open("pay.json", "w") as outfile: with open("pay.json", "w") as outfile:
outfile.write(js) outfile.write(js)
# Keys # Ways
# {"user32532": "762eagdfgtars5e34", ...} # [bore.pub:5423, bore.pub:2239, ...]
class keys(): class ways():
def read(): def read():
if not isfile("keys.json"): if not isfile("ways.json"):
sys('echo "{}" > keys.json') sys('echo "[]" > ways.json')
with open('keys.json', 'r') as openfile: with open('ways.json', 'r') as openfile:
data = json.load(openfile) data = json.load(openfile)
return data return data
def write(data): def write(data):
js = json.dumps(data, indent=4) js = json.dumps(data, indent=4)
with open("keys.json", "w") as outfile: with open("ways.json", "w") as outfile:
outfile.write(js) outfile.write(js)

Loading…
Cancel
Save