forked from Le0Michine/FusionGridfinityGenerator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: persist command panel status in a config on hard drive
- Loading branch information
1 parent
4d3b215
commit 0fa92f4
Showing
4 changed files
with
63 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
__pycache__ | ||
/.vscode | ||
.env | ||
.env | ||
commandConfig |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import configparser | ||
import os | ||
|
||
CONFIG_FILE_NAME = 'config.ini' | ||
|
||
def getDefaultConfig(): | ||
config = configparser.ConfigParser() | ||
config['UI'] = {'IS_PROMOTED': 'yes'} | ||
return config | ||
|
||
def readConfig(path: str): | ||
CONFIG_FILE_PATH = os.path.join(path, CONFIG_FILE_NAME) | ||
config = configparser.ConfigParser() | ||
try: | ||
if os.path.exists(CONFIG_FILE_PATH): | ||
config.read(CONFIG_FILE_PATH) | ||
return config | ||
return getDefaultConfig() | ||
except: | ||
return getDefaultConfig() | ||
|
||
def writeConfig(config: configparser.ConfigParser, path: str): | ||
try: | ||
CONFIG_FILE_PATH = os.path.join(path, CONFIG_FILE_NAME) | ||
if not os.path.exists(path): | ||
os.mkdir(path) | ||
with open(CONFIG_FILE_PATH, 'w') as configfile: | ||
config.write(configfile) | ||
return True | ||
except: | ||
return False | ||
|