You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
951 B
32 lines
951 B
import configparser
|
|
import re
|
|
import os.path as osp
|
|
|
|
# https://stackoverflow.com/a/11866695
|
|
ROOT = osp.dirname(__file__)
|
|
CONFIG_PATH = osp.join(ROOT, "config.ini")
|
|
|
|
|
|
class AdbConfig(configparser.ConfigParser):
|
|
def __init__(self):
|
|
super().__init__(interpolation=configparser.ExtendedInterpolation())
|
|
|
|
def getlist(self, section, option, fallback=None):
|
|
data = self.get(section, option, fallback=fallback)
|
|
if data == fallback:
|
|
return data
|
|
return list(filter(bool, re.split(" *, *", data)))
|
|
|
|
def getpath(self, section, option, fallback=None):
|
|
data = self.get(section, option, fallback=fallback)
|
|
if data == fallback:
|
|
return data
|
|
return osp.expandvars(data)
|
|
|
|
def getpaths(self, section, option, fallback=None):
|
|
data = self.getlist(section, option, fallback)
|
|
return list(map(osp.expandvars, data))
|
|
|
|
|
|
config = AdbConfig()
|
|
config.read(CONFIG_PATH)
|