Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
hleft committed Mar 11, 2023
1 parent 21478d9 commit 4eecaa6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
10 changes: 7 additions & 3 deletions book_maker/loader/epub_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ def deal_old(wait_p_list):

send_num = self.accumulated_num
if send_num > 1:
print("------------------------------------------------------")
print(f"dealing {item.file_name} ...")
print("------------------------------------------------------")
count = 0
wait_p_list = []
for i in range(0, len(p_list)):
Expand Down Expand Up @@ -182,9 +185,10 @@ def deal_old(wait_p_list):
pbar.close()
except (KeyboardInterrupt, Exception) as e:
print(e)
print("you can resume it next time")
self._save_progress()
self._save_temp_book()
if self.accumulated_num == 1:
print("you can resume it next time")
self._save_progress()
self._save_temp_book()
sys.exit(0)

def load_state(self):
Expand Down
5 changes: 3 additions & 2 deletions book_maker/translator/chatgptapi_translator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import time
import re

import openai
from os import environ
Expand Down Expand Up @@ -48,7 +49,7 @@ def get_translation(self, text):

def translate(self, text):
# todo: Determine whether to print according to the cli option
print(text)
print(re.sub("\n{3,}", "\n\n", text))

try:
t_text = self.get_translation(text)
Expand All @@ -64,7 +65,7 @@ def translate(self, text):
t_text = self.get_translation(text)

# todo: Determine whether to print according to the cli option
print(t_text.strip())
print(re.sub("\n{3,}", "\n\n", t_text))
return t_text

def translate_list(self, plist):
Expand Down

0 comments on commit 4eecaa6

Please sign in to comment.