30 lines
772 B
Python
30 lines
772 B
Python
|
|
|
|
from pathlib import Path
|
|
from db import CalDB
|
|
import configparser
|
|
|
|
class Env:
|
|
|
|
def __init__(self):
|
|
# Config directory
|
|
self.confdir=Path.home() / ".config" / "tropical"
|
|
if not self.confdir.is_dir():
|
|
self.confdir.mkdir()
|
|
# Config file
|
|
self.confFile=self.confdir / "config.ini"
|
|
self.config=configparser.ConfigParser()
|
|
if not self.confFile.is_file():
|
|
self.initConfig()
|
|
else:
|
|
self.config.read(self.confFile)
|
|
# Database
|
|
self.dbFile=self.confdir / "sqlite3.db"
|
|
self.db=CalDB(str(self.dbFile))
|
|
|
|
def initConfig(self):
|
|
self.config["global"]={"new":True}
|
|
with open(self.confFile,"w") as f:
|
|
self.config.write(f)
|
|
|
|
|