mirror of
https://github.com/Starlio-app/StarlioX
synced 2024-11-22 08:46:22 +03:00
добавление конфига и иконки
This commit is contained in:
parent
88866d62bd
commit
46da3771f7
2 changed files with 41 additions and 0 deletions
41
config.py
Normal file
41
config.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
import configparser
|
||||
import os
|
||||
|
||||
|
||||
class Config:
|
||||
|
||||
def create_config(self, path):
|
||||
if not os.path.exists(path):
|
||||
config = configparser.ConfigParser()
|
||||
config.add_section("Settings")
|
||||
|
||||
config.set("Settings", "autorun", "False")
|
||||
with open(path, "w") as file:
|
||||
config.write(file)
|
||||
else:
|
||||
return print("The file exists")
|
||||
|
||||
def get_config(self, path):
|
||||
if not os.path.exists(path):
|
||||
self.create_config(path)
|
||||
|
||||
config = configparser.ConfigParser()
|
||||
config.read(path)
|
||||
return config
|
||||
|
||||
def get_setting(self, path, section, setting):
|
||||
config = self.get_config(path)
|
||||
value = config.get(section, setting)
|
||||
return value
|
||||
|
||||
def update_setting(self, path, section, setting, value):
|
||||
config = self.get_config(path)
|
||||
config.set(section, setting, value)
|
||||
with open(path, "w") as file:
|
||||
config.write(file)
|
||||
|
||||
def delete_setting(self, path, section, setting):
|
||||
config = self.get_config(path)
|
||||
config.remove_option(section, setting)
|
||||
with open(path, "w") as file:
|
||||
config.write(file)
|
BIN
nasa.ico
Normal file
BIN
nasa.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
Loading…
Add table
Reference in a new issue