lib Ordner hinzugefügt
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -71,7 +71,7 @@ dist/
|
|||||||
downloads/
|
downloads/
|
||||||
eggs/
|
eggs/
|
||||||
.eggs/
|
.eggs/
|
||||||
lib/
|
# lib/
|
||||||
lib64/
|
lib64/
|
||||||
parts/
|
parts/
|
||||||
sdist/
|
sdist/
|
||||||
|
|||||||
39
lib/ConfigLoader.py
Normal file
39
lib/ConfigLoader.py
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
# This Python file uses the following encoding: utf-8
|
||||||
|
import toml
|
||||||
|
from platformdirs import user_config_dir
|
||||||
|
from pathlib import Path
|
||||||
|
from PySide6.QtCore import QObject, Slot
|
||||||
|
|
||||||
|
|
||||||
|
class ConfigLoader(QObject):
|
||||||
|
__config = None
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__()
|
||||||
|
self.config_dir = user_config_dir() + '/pyqcrm' #user_config_dir = Funktion platformdirs
|
||||||
|
config_dir = Path(self.config_dir)
|
||||||
|
|
||||||
|
config_dir.mkdir(0o750, True, True)
|
||||||
|
self.__configLoad()
|
||||||
|
|
||||||
|
@Slot(str)
|
||||||
|
def createUser(self, username):
|
||||||
|
print(username)
|
||||||
|
|
||||||
|
def __configLoad(self):
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open (self.config_dir + '/pyqcrm.toml', 'r') as f:
|
||||||
|
self.__config = toml.load(f)
|
||||||
|
except FileNotFoundError:
|
||||||
|
print("Konnte die Konfiguration nicht laden.")
|
||||||
|
|
||||||
|
|
||||||
|
def getConfig(self):
|
||||||
|
|
||||||
|
return self.__config
|
||||||
|
|
||||||
|
def createConfig(self):
|
||||||
|
|
||||||
|
with open(self.config_dir + '/pyqcrm.toml', "w") as datei:
|
||||||
|
datei.write("[pyqcrm]")
|
||||||
1
lib/__init__.py
Normal file
1
lib/__init__.py
Normal file
@@ -0,0 +1 @@
|
|||||||
|
from .ConfigLoader import ConfigLoader
|
||||||
Reference in New Issue
Block a user