-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
28 additions
and
12 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,15 +1,31 @@ | ||
__all__ = ['config'] | ||
|
||
import configparser | ||
from pathlib import Path | ||
import os | ||
|
||
default_dict = { | ||
'db_type': 'sqlite', | ||
'auto_open_browser': 'yes', | ||
} | ||
|
||
_project_dir = Path(__file__).parent | ||
_config_file_path = _project_dir / 'config.conf' | ||
|
||
|
||
def check_config_file_exists(): | ||
if not os.path.exists(_config_file_path): | ||
from shutil import copyfile | ||
print("【步骤遗漏!】还没有复制配置文件哦...") | ||
copyfile(_project_dir / "config_sample.conf", _config_file_path) | ||
print( | ||
f'但我已经帮你复制好了:\n{_project_dir / "config_sample.conf"} -> {_config_file_path}' | ||
) | ||
print("继续往下走吧~") | ||
|
||
|
||
check_config_file_exists() | ||
|
||
config = configparser.ConfigParser(default_dict) | ||
# print(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'config.conf')) | ||
config.read(os.path.join( | ||
os.path.dirname(os.path.abspath(__file__)), | ||
'config.conf'), encoding='utf-8') | ||
config.read(_config_file_path, encoding='utf-8') |
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