2016-05-08 15:32:37 -04:00
|
|
|
try:
|
|
|
|
from configparser import ConfigParser
|
|
|
|
except ImportError:
|
|
|
|
from ConfigParser import ConfigParser
|
|
|
|
|
2016-05-21 16:59:32 -04:00
|
|
|
import logging
|
|
|
|
|
|
|
|
logger = logging.getLogger('tsstats')
|
|
|
|
|
2016-05-08 15:32:37 -04:00
|
|
|
|
|
|
|
def parse_config(config_path):
|
2016-05-21 16:59:32 -04:00
|
|
|
logger.debug('reading config')
|
2016-05-08 15:32:37 -04:00
|
|
|
config = ConfigParser()
|
|
|
|
config.read(config_path)
|
2016-05-21 16:59:32 -04:00
|
|
|
# use dict(ConfigParser.items) to get an easy-to-use interface
|
|
|
|
# compatible with py2 and py3
|
|
|
|
config_items = dict(config.items('General'))
|
|
|
|
if 'debug' in config_items:
|
|
|
|
config_items['debug'] = config.getboolean('General', 'debug')
|
|
|
|
logger.debug('raw config: %s', config_items)
|
|
|
|
return (
|
|
|
|
config_items.get('idmap'),
|
|
|
|
config_items.get('log'),
|
|
|
|
config_items.get('output'),
|
|
|
|
config_items.get('debug', False)
|
|
|
|
)
|