From 5584624537159eed3e811df8ace4f42e9035951f Mon Sep 17 00:00:00 2001 From: Dastgir Date: Sun, 17 Jun 2018 16:47:00 +0100 Subject: Added Pet Evolution Lua to DB Converter --- tools/utils/common.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tools/utils/common.py') diff --git a/tools/utils/common.py b/tools/utils/common.py index 1a398d544..7b7811654 100644 --- a/tools/utils/common.py +++ b/tools/utils/common.py @@ -48,3 +48,18 @@ def LoadDBConsts(DBname, mode, serverpath): print('LoadDBConsts: invalid database name {}'.format(DBname)) exit(1) return consts + +def LoadDB(DBname, mode, serverpath): + filenames = [serverpath + 'db/{}/{}.conf'.format(mode, DBname)] + + if os.path.isfile(serverpath + 'db/{}2.conf'.format(DBname)): + filenames.append(serverpath + 'db/{}2.conf'.format(DBname)) + + consts = dict() + for filename in filenames: + with io.open(filename) as f: + config = libconf.load(f) + db = config[DBname] + return db + print('LoadDB: invalid database name {}'.format(DBname)) + exit(1) -- cgit v1.2.3-60-g2f50