annotation tools for making the iterations publication (Manetta & Jara) - https://iterations.space/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
667 B
38 lines
667 B
import json
|
|
|
|
# different useful functions
|
|
|
|
# line = '-----------'
|
|
|
|
# def write_to_file(filename, string):
|
|
# path = './'+filename
|
|
# f = open(path,'a+')
|
|
# f.write(string)
|
|
# f.write('\n')
|
|
# if 'mark' in filename:
|
|
# f.write(line)
|
|
# f.write('\n')
|
|
# f.close()
|
|
|
|
def load_db(filename):
|
|
try:
|
|
open(filename,'r')
|
|
except:
|
|
open(filename,'w+')
|
|
f = open(filename,'r').read()
|
|
if f == '':
|
|
f = '{}'
|
|
db = json.loads(f)
|
|
# find last_id used in db
|
|
keys = [int(x) for x in db.keys()]
|
|
keys.sort()
|
|
if len(keys) == 0:
|
|
x = 0
|
|
else:
|
|
x = int(keys[-1])
|
|
return db, x
|
|
|
|
def write_db(filename, db):
|
|
f = open(filename, 'w')
|
|
f.write(json.dumps(db, indent=4))
|
|
f.close()
|