Skip to content

Commit

Permalink
Merge pull request #98 from xxnuo/main
Browse files Browse the repository at this point in the history
feat(cache folder): Change cache path to ~/.cache/babeldoc
  • Loading branch information
awwaawwa authored Feb 17, 2025
2 parents b0d5153 + 50d3035 commit cbf4d57
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
7 changes: 5 additions & 2 deletions babeldoc/document_il/midend/il_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
from pathlib import Path
from typing import List, Union

from tqdm import tqdm

Expand Down Expand Up @@ -178,7 +179,7 @@ class TranslateInput:
def __init__(
self,
unicode: str,
placeholders: [RichTextPlaceholder | FormulaPlaceholder],
placeholders: List[Union[RichTextPlaceholder, FormulaPlaceholder]],
base_style: PdfStyle = None,
):
self.unicode = unicode
Expand Down Expand Up @@ -487,7 +488,9 @@ def remove_placeholder(text: str):
PdfSameStyleCharacters,
) and text.replace(" ", "") == "".join(
x.char_unicode for x in placeholder.composition.pdf_character
).replace(" ", ""):
).replace(
" ", ""
):
comp = PdfParagraphComposition(
pdf_same_style_characters=placeholder.composition,
)
Expand Down
3 changes: 2 additions & 1 deletion babeldoc/document_il/translator/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
from peewee import SqliteDatabase
from peewee import TextField

from babeldoc.const import CACHE_FOLDER as cache_folder

# we don't init the database here
db = SqliteDatabase(None)

Expand Down Expand Up @@ -92,7 +94,6 @@ def set(self, original_text: str, translation: str):


def init_db(remove_exists=False):
cache_folder = Path.home() / ".cache" / "pdf2zh"
cache_folder.mkdir(parents=True, exist_ok=True)
# The current version does not support database migration, so add the version number to the file name.
cache_db_path = cache_folder / "cache.v1.db"
Expand Down

0 comments on commit cbf4d57

Please sign in to comment.