From 6180d04bc553e818833da29fbbd64abd9d4c6726 Mon Sep 17 00:00:00 2001 From: mlncn Date: Sun, 2 May 2021 18:27:51 -0400 Subject: [PATCH] Proof of concept settings system --- settings.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 settings.py diff --git a/settings.py b/settings.py new file mode 100644 index 0000000..c51e3e9 --- /dev/null +++ b/settings.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python3 + +import configparser +import os + +config = configparser.ConfigParser() +config['pomodoro'] = {} +pomodoro = config['pomodoro'] + +if not os.path.isfile('settings.ini'): + # Set some essential initial values. + pomodoro['logfile'] = '~/Projects/agaric/python/pomodoroprompt/logs/2021.csv' + with open('settings.ini', 'w') as configfile: + config.write(configfile) + +config.read('settings.ini') + +def pomodoro_logfile(): + return config['pomodoro']['logfile'] + +def pomodoro_latest_start(value = None): + if value: + pomodoro.set('latest_start', value) + else: + return pomodoro.get('latest_start', None)