added more tests for converter.py
This commit is contained in:
1 parent
d4f53e49d9
commit
cd9f10c030
5 files changed
+157
-13
No files matched your search
@@ -47,6 +47,9 @@ def convert_file(path: str, overwrite: bool = False) -> None:
|
||||
path (str): The path to the HTML file to be converted.
|
||||
overwrite (bool, optional): Whether to overwrite the original file. Defaults to False.
|
||||
"""
|
||||
if not (os.path.exists(path) and os.path.isfile(path)):
|
||||
raise FileNotFoundError
|
||||
|
||||
with open(path, "r") as file:
|
||||
soup = bs4.BeautifulSoup(file, "html.parser")
|
||||
|
||||
@@ -75,6 +78,9 @@ def convert_dir(path: str, overwrite: bool = False) -> None:
|
||||
path (str): The path to the directory containing the HTML files to be converted.
|
||||
overwrite (bool, optional): Whether to overwrite the original files. Defaults to False.
|
||||
"""
|
||||
if not (os.path.exists(path) and os.path.isdir(path)):
|
||||
raise FileNotFoundError
|
||||
|
||||
for filepath in glob(f"{path}/**/*.html", recursive=True):
|
||||
convert_file(filepath, overwrite)
|
||||
|
||||
|
||||
Reference in new issue
Block a user