This repository has been archived by the owner on Feb 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(config): ✨ add config file to storage api key
- Loading branch information
1 parent
1fd45d4
commit a3ecd95
Showing
7 changed files
with
59 additions
and
13 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,7 +1,7 @@ | ||
{ | ||
"conventionalCommits.scopes": [ | ||
"requester", | ||
"ui", | ||
"download" | ||
"download", | ||
"config" | ||
] | ||
} |
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,22 +1,17 @@ | ||
import os | ||
import shutil | ||
|
||
from utils.constant import PATH | ||
from utils.factory import Factory | ||
from utils.window.main import Main | ||
|
||
|
||
def main(): | ||
# 清理临时文件夹 | ||
if os.path.isdir(PATH.TEMP_DIR_PATH): | ||
shutil.rmtree(PATH.TEMP_DIR_PATH) | ||
os.mkdir(PATH.TEMP_DIR_PATH) | ||
if not os.path.isdir(PATH.TEMP_DIR_PATH): | ||
os.mkdir(PATH.TEMP_DIR_PATH) | ||
|
||
factory = Factory() | ||
Main(factory).main() | ||
|
||
shutil.rmtree(PATH.TEMP_DIR_PATH) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
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,19 @@ | ||
import os | ||
import yaml | ||
|
||
from utils.constant import CONFIG | ||
|
||
|
||
class Config(dict): | ||
def __init__(self): | ||
if os.path.isfile(CONFIG.FILE_PATH): | ||
with open(CONFIG.FILE_PATH, encoding='utf-8') as f: | ||
super().__init__(yaml.safe_load(f)) | ||
else: | ||
super().__init__(CONFIG.DEFAULT) | ||
self.save() | ||
|
||
def save(self): | ||
"""Save data""" | ||
with open(CONFIG.FILE_PATH, 'w', encoding='utf-8') as f: | ||
yaml.dump(self.copy(), f) |
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
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