diff options
Diffstat (limited to 'test/src/file.py')
-rw-r--r-- | test/src/file.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/src/file.py b/test/src/file.py new file mode 100644 index 0000000..e1e6ed8 --- /dev/null +++ b/test/src/file.py @@ -0,0 +1,21 @@ +import configparser +import os + +BASEDIR = os.path.normpath(os.path.join(os.path.dirname(__file__), os.pardir)) + +_config = configparser.ConfigParser() +_config.read(os.path.join(BASEDIR, 'config.ini')) +config = _config['FILE'] + + +def save(key, value): + with open(config['KEYSTORE'], "a") as keystore: + keystore.write("{} = {}\n".format(key, value)) + + +def fetch(key): + with open(config['KEYSTORE'], "r") as keystore: + for line in keystore: + if(line.startswith(key + " = ")): + val = line[line.index("=")+2:] + return val.strip() |