Archived
1
0
Fork 0
This repository has been archived on 2024-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
akari-bot/config/__init__.py
yzhh 582824e2ab Did you write a lot of code again?
Yes, but actually no
2021-07-16 23:50:25 +08:00

27 lines
632 B
Python

import traceback
from configparser import ConfigParser
from os.path import abspath
config_filename = 'config.cfg'
config_path = abspath('./config/' + config_filename)
class CFG:
def config(self, q):
cp = ConfigParser()
cp.read(config_path)
try:
section = cp.sections()[0]
value = cp.get(section, q)
except Exception:
return False
if value.upper() == 'TRUE':
return True
if value.upper() == 'FALSE':
return False
return value
Config = CFG().config
CachePath = Config('cache_path')
DBPath = Config('db_path')