-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V0.2.0支持保留原文的翻译,增加翻译错误处理,增加word和PowerPoint的支持
- Loading branch information
Showing
11 changed files
with
332 additions
and
73 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,29 @@ | ||
import os | ||
import json | ||
|
||
# 定义默认配置 | ||
default_config = { | ||
"save_original": False, #保留原文件值 | ||
"version": "0.2.0", | ||
"dev": False | ||
} | ||
|
||
# 定义配置文件的路径 | ||
config_path = './config.json' | ||
|
||
def load_config(): | ||
"""加载配置,如果config.json不存在则创建并使用默认配置。""" | ||
if not os.path.exists(config_path): | ||
# 如果不存在,创建config.json并写入默认配置 | ||
with open(config_path, 'w') as config_file: | ||
json.dump(default_config, config_file, indent=4) | ||
return default_config | ||
else: | ||
# 如果存在,加载config.json并更新默认配置 | ||
with open(config_path, 'r') as config_file: | ||
user_config = json.load(config_file) | ||
# 更新默认配置 | ||
return {**default_config, **user_config} | ||
|
||
# 直接加载配置供外部使用 | ||
config = load_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
Oops, something went wrong.