move files into a package structure

This commit is contained in:
2022-02-06 16:02:54 +01:00
parent 8bb4ca0563
commit 5428553a1e
28 changed files with 23 additions and 26 deletions

View File

@@ -0,0 +1,45 @@
import os
import sys
from pathlib import Path
from os.path import join
from configparser import ConfigParser
from raven.settings.settings import Settings
class SettingsStore():
def __init__(self):
pass
@staticmethod
def _session_file() -> str:
if sys.platform == 'win32' or sys.platform == 'cygwin':
return join(Path.home(), "AppData", "Local", "ravenlog", "session.ini")
else:
return join(Path.home(), ".local", "share", "ravenlog", "session.ini")
@staticmethod
def load() -> Settings:
session = SettingsStore._load_session()
return Settings(session)
@staticmethod
def _load_session() -> ConfigParser:
session_file = SettingsStore._session_file()
session = ConfigParser()
# apply default settings
session.add_section('general')
session.set('general', 'font_size', '12')
session.set('general', 'highlight_search_term', 'True')
session.set('general', 'open_tab_on_save_as_file', 'True')
session.read(session_file)
return session
@staticmethod
def save(settings: Settings):
session_file = SettingsStore._session_file()
dir = os.path.dirname(session_file)
os.makedirs(dir, exist_ok=True)
with open(session_file, 'w+') as fp:
settings.session.write(fp)