Byaidu 1 年之前
父節點
當前提交
6d3f695a51
共有 4 個文件被更改,包括 4 次插入6 次删除
  1. 1 1
      pdf2zh/__init__.py
  2. 2 0
      pdf2zh/converter.py
  3. 0 5
      requirements.txt
  4. 1 0
      setup.py

+ 1 - 1
pdf2zh/__init__.py

@@ -1,2 +1,2 @@
-__version__ = "1.0.2"
+__version__ = "1.0.3"
 __author__ = "Byaidu"

+ 2 - 0
pdf2zh/converter.py

@@ -18,6 +18,7 @@ import concurrent.futures
 import mtranslate as translator
 import unicodedata
 import tqdm.auto
+from tenacity import retry
 from pdf2zh import cache
 def remove_control_characters(s):
     return "".join(ch for ch in s if unicodedata.category(ch)[0]!="C")
@@ -444,6 +445,7 @@ class TextConverter(PDFConverter[AnyIO]):
             if cache.is_cached(hash_key):
                 print('Cache is found')
             cache.create_cache(hash_key)
+            @retry
             def worker(s): # 多线程翻译
                 if re.search('[A-Za-z]',s):
                     hash_key_paragraph = cache.deterministic_hash(s)

+ 0 - 5
requirements.txt

@@ -1,5 +0,0 @@
-"charset-normalizer >= 2.0.0",
-"cryptography >= 36.0.0",
-"mtranslate"
-"pymupdf"
-"tqdm"

+ 1 - 0
setup.py

@@ -23,6 +23,7 @@ setup(
         "mtranslate",
         "pymupdf",
         "tqdm",
+        "tenacity",
     ],
     classifiers=[
         "Programming Language :: Python :: 3",