Skip to content

Commit 74c80eb

Browse files
committed
refactor: 🚚 move warning filter to __init_.py
To make sure the warning is filtered.
1 parent 06361ff commit 74c80eb

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/stas_ln_translator/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
import sys
22
import asyncio
33
import importlib.metadata
4+
import warnings
45

56
import asyncclick as click
7+
from bs4 import XMLParsedAsHTMLWarning
68
from ebooklib import epub
79

810
from stas_ln_translator import config, translator, process
911

12+
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
13+
1014

1115
# Call back for validating file need to have '.epub' file extension
1216
def validate_epub_file(ctx, param, value):

src/stas_ln_translator/translator.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import asyncio
2-
import warnings
32

4-
from bs4 import BeautifulSoup, XMLParsedAsHTMLWarning
3+
from bs4 import BeautifulSoup
54
import httpx
65
from tqdm.asyncio import tqdm_asyncio
76
from ebooklib import epub
87

98
from stas_ln_translator import config, process, connection
109

11-
warnings.filterwarnings("ignore", category=XMLParsedAsHTMLWarning)
12-
1310

1411
async def translate_epub(book: epub.EpubBook) -> dict[str, BeautifulSoup]:
1512
documents = process.get_all_documents_in_epub(book)

0 commit comments

Comments
 (0)