split folder into db and results

This commit is contained in:
relikd
2021-02-12 00:54:50 +01:00
parent a9d4085a4b
commit 1c27f17677
15 changed files with 24 additions and 17 deletions

View File

@@ -54,10 +54,10 @@ class InterruptDB(object):
@staticmethod
def load(dbname):
if not os.path.isfile(LPath.InterruptDB(dbname)):
if not os.path.isfile(LPath.db(dbname)):
return {}
ret = {}
with open(LPath.InterruptDB(dbname), 'r') as f:
with open(LPath.db(dbname), 'r') as f:
for line in f.readlines():
if line.startswith('#'):
continue
@@ -73,7 +73,7 @@ class InterruptDB(object):
@staticmethod
def write(name, score, irp, irpmax, keylen, nums, dbname='db_main'):
with open(LPath.InterruptDB(dbname), 'a') as f:
with open(LPath.db(dbname), 'a') as f:
nums = ','.join(map(str, nums))
f.write(f'{name}|{irpmax}|{score:.5f}|{irp}|{keylen}|{nums}\n')

View File

@@ -28,7 +28,7 @@ class InterruptIndices(object):
@staticmethod
def write(dbname='db_indices'):
with open(LPath.InterruptDB(dbname), 'w') as f:
with open(LPath.db(dbname), 'w') as f:
f.write('# file | total runes in file | interrupt | indices\n')
for name in FILES_ALL:
data = load_indices(LPath.page(name), 0)
@@ -42,7 +42,7 @@ class InterruptIndices(object):
@staticmethod
def load(dbname='db_indices'):
with open(LPath.InterruptDB(dbname), 'r') as f:
with open(LPath.db(dbname), 'r') as f:
ret = {}
for line in f.readlines():
if line.startswith('#'):

View File

@@ -27,13 +27,13 @@ class LPath(object):
return os.path.join(LP_ROOT_DIR, 'data', f'{fname}.{ext}')
@staticmethod
def tmp(fname, ext='txt'):
return os.path.join(LP_ROOT_DIR, 'tmp', f'{fname}.{ext}')
@staticmethod
def InterruptDB(fname):
return os.path.join(LP_ROOT_DIR, 'InterruptDB', fname + '.txt')
def db(fname):
return os.path.join(LP_ROOT_DIR, 'db', fname + '.txt')
@staticmethod
def results(fname):
return os.path.join(LP_ROOT_DIR, 'InterruptDB', fname)
return os.path.join(LP_ROOT_DIR, 'results', fname)
@staticmethod
def tmp(fname, ext='txt'):
return os.path.join(LP_ROOT_DIR, 'tmp', f'{fname}.{ext}')