mirror of
https://github.com/yihong0618/bilingual_book_maker.git
synced 2025-06-06 11:35:49 +00:00
fix: Fix parameter mismatch in EPUBBookLoaderHelper.translate_with_backoff
- Fix TypeError when calling translate_with_backoff with multiple arguments - Add proper parameter handling in the decorated method - Add jitter=None to prevent extra parameters from backoff decorator - Improve code readability and error handling
This commit is contained in:
parent
9261d92e20
commit
0b5e5f4d08
@ -1,7 +1,7 @@
|
|||||||
import re
|
import re
|
||||||
from copy import copy
|
|
||||||
import backoff
|
import backoff
|
||||||
import logging
|
import logging
|
||||||
|
from copy import copy
|
||||||
|
|
||||||
logging.basicConfig(level=logging.WARNING)
|
logging.basicConfig(level=logging.WARNING)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@ -37,9 +37,10 @@ class EPUBBookLoaderHelper:
|
|||||||
Exception,
|
Exception,
|
||||||
on_backoff=lambda details: logger.warning(f"retry backoff: {details}"),
|
on_backoff=lambda details: logger.warning(f"retry backoff: {details}"),
|
||||||
on_giveup=lambda details: logger.warning(f"retry abort: {details}"),
|
on_giveup=lambda details: logger.warning(f"retry abort: {details}"),
|
||||||
|
jitter=None
|
||||||
)
|
)
|
||||||
def translate_with_backoff(self, **kwargs):
|
def translate_with_backoff(self, text, context_flag=False):
|
||||||
return self.translate_model.translate(**kwargs)
|
return self.translate_model.translate(text, context_flag)
|
||||||
|
|
||||||
def deal_new(self, p, wait_p_list, single_translate=False):
|
def deal_new(self, p, wait_p_list, single_translate=False):
|
||||||
self.deal_old(wait_p_list, single_translate, self.context_flag)
|
self.deal_old(wait_p_list, single_translate, self.context_flag)
|
||||||
@ -128,4 +129,4 @@ def not_trans(s):
|
|||||||
is_text_digit_and_space(s),
|
is_text_digit_and_space(s),
|
||||||
is_text_isbn(s),
|
is_text_isbn(s),
|
||||||
]
|
]
|
||||||
)
|
)
|
Loading…
x
Reference in New Issue
Block a user