Fix creating broken mine.json
This commit is contained in:
parent
963dd8ed5c
commit
7fa2ff0827
@ -1,19 +1,18 @@
|
||||
import json
|
||||
from os.path import isfile
|
||||
from os import system as sys
|
||||
|
||||
# Money
|
||||
# {username: balance, ...}
|
||||
class money():
|
||||
# {username: [balance, OpenKey], ...}
|
||||
class users():
|
||||
def read():
|
||||
if not isfile("money.json"):
|
||||
sys('echo "{}" > money.json')
|
||||
with open('money.json', 'r') as openfile:
|
||||
if not isfile("users.json"):
|
||||
sys('echo "{}" > users.json')
|
||||
with open('users.json', 'r') as openfile:
|
||||
data = json.load(openfile)
|
||||
return data
|
||||
def write(data):
|
||||
js = json.dumps(data, indent=4)
|
||||
with open("money.json", "w") as outfile:
|
||||
with open("users.json", "w") as outfile:
|
||||
outfile.write(js)
|
||||
|
||||
# Mining + Registrations
|
||||
@ -22,7 +21,8 @@ class money():
|
||||
class mine():
|
||||
def read():
|
||||
if not isfile("mine.json"):
|
||||
sys('echo "[]" > mine.json')
|
||||
#sys('echo "[]" > mine.json')
|
||||
mine.write([])
|
||||
with open('mine.json', 'r') as openfile:
|
||||
data = json.load(openfile)
|
||||
return data
|
||||
@ -46,16 +46,16 @@ class pay():
|
||||
with open("pay.json", "w") as outfile:
|
||||
outfile.write(js)
|
||||
|
||||
# Keys
|
||||
# {"user32532": "762eagdfgtars5e34", ...}
|
||||
class keys():
|
||||
# Ways
|
||||
# [bore.pub:5423, bore.pub:2239, ...]
|
||||
class ways():
|
||||
def read():
|
||||
if not isfile("keys.json"):
|
||||
sys('echo "{}" > keys.json')
|
||||
with open('keys.json', 'r') as openfile:
|
||||
if not isfile("ways.json"):
|
||||
sys('echo "[]" > ways.json')
|
||||
with open('ways.json', 'r') as openfile:
|
||||
data = json.load(openfile)
|
||||
return data
|
||||
def write(data):
|
||||
js = json.dumps(data, indent=4)
|
||||
with open("keys.json", "w") as outfile:
|
||||
with open("ways.json", "w") as outfile:
|
||||
outfile.write(js)
|
||||
|
Loading…
Reference in New Issue
Block a user