From 95491de0c6c5377107a8a7eb6ce4b665e7e0f1d2 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Wed, 23 Jan 2019 09:41:47 +0200 Subject: Add: read config file --- effitool | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'effitool') diff --git a/effitool b/effitool index 071cc7f..6a42885 100755 --- a/effitool +++ b/effitool @@ -16,8 +16,31 @@ # along with this program. If not, see . +import configparser +import os +import sys + + +CONFIG_FILENAME = os.path.expanduser('~/.config/effitool/credentials.conf') + + +class Config: + + def __init__(self): + self._cp = configparser.ConfigParser() + + def read(self, filename): + with open(filename) as f: + self._cp.read_file(f) + + def dump(self, f): + self._cp.write(f) + + def main(): - print('hello from effitool') + config = Config() + config.read(CONFIG_FILENAME) + config.dump(sys.stdout) if __name__ == '__main__': -- cgit v1.2.1