def __load(self): config = None path = os.path.join(sys.path[0], "..", "resources", "ddpg.conf") if not os.path.exists(path): path = os.path.join(sys.path[0], "resources", "ddpg.conf") with open(path, "r", encoding='utf-8') as f: config = libconf.load(f) return config
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)) 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)
def LoadDBConsts(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] if DBname == 'item_db': for i, v in enumerate(db): consts[db[i].Id] = db[i].AegisName elif DBname == 'mob_db': for i, v in enumerate(db): consts[db[i].Id] = db[i].SpriteName elif DBname == 'skill_db': for i, v in enumerate(db): consts[db[i].Id] = db[i].Name else: print('LoadDBConsts: invalid database name {}'.format(DBname)) exit(1) return consts