Minor changes
This commit is contained in:
parent
79ce6bc894
commit
8e93823945
2 changed files with 34 additions and 3 deletions
30
tropical/env.py
Normal file
30
tropical/env.py
Normal file
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
import qt.mainwindow as QtCalanus
|
import qt.mainwindow as QtCalanus
|
||||||
from calstate import CalState
|
from calstate import CalState
|
||||||
from db import CalDB
|
from env import Env
|
||||||
|
|
||||||
__VERSION__ = "0.1"
|
__VERSION__ = "0.1"
|
||||||
|
|
||||||
|
@ -13,7 +13,8 @@ __VERSION__ = "0.1"
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
calState=CalState()
|
env=Env()
|
||||||
QtCalanus.StartApplication(__VERSION__,calState)
|
# calState=CalState()
|
||||||
|
# QtCalanus.StartApplication(__VERSION__,calState)
|
||||||
#print(db.keyExists("calendars",1))
|
#print(db.keyExists("calendars",1))
|
||||||
#db=CalDB("sqlite.db")
|
#db=CalDB("sqlite.db")
|
||||||
|
|
Loading…
Add table
Reference in a new issue