TeamspeakStats/tsstats/config.py

22 lines
613 B
Python
Raw Normal View History

from os.path import abspath
from tsstats.exceptions import InvalidConfig
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser
def parse_config(config_path):
config = ConfigParser()
config.read(config_path)
2016-05-09 13:25:48 -04:00
if not config.has_section('General') or not \
(config.has_option('General', 'logfile') and
config.has_option('General', 'outputfile')):
raise InvalidConfig
2016-05-09 13:29:24 -04:00
log_path = abspath(config.get('General', 'logfile'))
output_path = abspath(config.get('General', 'outputfile'))
return log_path, output_path