#!/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/log/2021.csv' # This path must be absolute, for some reason using ~ for home isn t wor:: pomodoro['logpath'] = '/home/mlncn/Projects/agaric/python/pomodoroprompt/log/' write() config.read('settings.ini') def write(): with open('settings.ini', 'w') as configfile: config.write(configfile) def pomodoro_logfile(): return config['pomodoro']['logfile'] def pomodoro_logpath(): return config['pomodoro']['logpath'] def pomodoro_latest_recorded(timestamp = None): if timestamp: config.set('pomodoro', 'latest_recorded', str(timestamp)) write() else: return pomodoro.get('latest_recorded', None)