parse-timelogs-for-upload/settings.py

31 lines
699 B
Python
Raw Normal View History

2021-05-02 22:27:51 +00:00
#!/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'
2021-05-03 00:30:14 +00:00
write()
2021-05-02 22:27:51 +00:00
config.read('settings.ini')
2021-05-03 00:30:14 +00:00
def write():
with open('settings.ini', 'w') as configfile:
config.write(configfile)
2021-05-02 22:27:51 +00:00
def pomodoro_logfile():
return config['pomodoro']['logfile']
2021-05-03 00:30:14 +00:00
def pomodoro_latest_recorded(value = None):
2021-05-02 22:27:51 +00:00
if value:
2021-05-03 00:30:14 +00:00
pomodoro.set('latest_recorded', value)
write()
2021-05-02 22:27:51 +00:00
else:
2021-05-03 00:30:14 +00:00
return pomodoro.get('latest_recorded', None)