Skip to content

Commit

Permalink
用logging取代print
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Sep 14, 2023
1 parent 567c653 commit 5ba8ea2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions crazy_functions/批量Markdown翻译.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import glob, time, os, re
import glob, time, os, re, logging
from toolbox import update_ui, trimmed_format_exc, gen_time_str, disable_auto_promotion
from toolbox import CatchException, report_execption, get_log_folder
from toolbox import write_history_to_file, promote_file_to_downloadzone
Expand Down Expand Up @@ -34,7 +34,7 @@ def run_file_split(self, max_token_limit=1900):
self.sp_file_contents.append(segment)
self.sp_file_index.append(index)
self.sp_file_tag.append(self.file_paths[index] + f".part-{j}.md")
print('Segmentation: done')
logging.info('Segmentation: done')

def merge_result(self):
self.file_result = ["" for _ in range(len(self.file_paths))]
Expand Down Expand Up @@ -101,7 +101,7 @@ def 多文件翻译(file_manifest, project_folder, llm_kwargs, plugin_kwargs, ch
pfg.merge_result()
pfg.write_result(language)
except:
print(trimmed_format_exc())
logging.error(trimmed_format_exc())

# <-------- 整理结果,退出 ---------->
create_report_file_name = gen_time_str() + f"-chatgpt.md"
Expand All @@ -121,7 +121,7 @@ def get_files_from_everything(txt, preference=''):
proxies, = get_conf('proxies')
# 网络的远程文件
if preference == 'Github':
print('正在从github下载资源 ...')
logging.info('正在从github下载资源 ...')
if not txt.endswith('.md'):
# Make a request to the GitHub API to retrieve the repository information
url = txt.replace("https://github.com/", "https://api.github.com/repos/") + '/readme'
Expand Down

0 comments on commit 5ba8ea2

Please sign in to comment.