diff options
| author | Loïc Guégan <loic.guegan@mailbox.org> | 2024-09-16 14:32:43 +0200 |
|---|---|---|
| committer | Loïc Guégan <loic.guegan@mailbox.org> | 2024-09-16 14:32:43 +0200 |
| commit | 8e9382394524e1b8b6d233f4cba6575b7fecce21 (patch) | |
| tree | f5c5382b0b01a95c08341e35c3f6ed6bd23a70d3 /tropical | |
| parent | 79ce6bc894120527729bb282773a77a3c9cbaa2b (diff) | |
Minor changes
Diffstat (limited to 'tropical')
| -rw-r--r-- | tropical/env.py | 30 | ||||
| -rwxr-xr-x | tropical/tropical.py | 7 |
2 files changed, 34 insertions, 3 deletions
diff --git a/tropical/env.py b/tropical/env.py new file mode 100644 index 0000000..3c2bc3b --- /dev/null +++ b/tropical/env.py @@ -0,0 +1,30 @@ + + +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) + + diff --git a/tropical/tropical.py b/tropical/tropical.py index bb1e7e2..1adb66b 100755 --- a/tropical/tropical.py +++ b/tropical/tropical.py @@ -4,7 +4,7 @@ import qt.mainwindow as QtCalanus from calstate import CalState -from db import CalDB +from env import Env __VERSION__ = "0.1" @@ -13,7 +13,8 @@ __VERSION__ = "0.1" if __name__ == '__main__': - calState=CalState() - QtCalanus.StartApplication(__VERSION__,calState) + env=Env() +# calState=CalState() + # QtCalanus.StartApplication(__VERSION__,calState) #print(db.keyExists("calendars",1)) #db=CalDB("sqlite.db") |
