Skip to content

Commit

Permalink
整理: ファイルを操作するユーティリティを file_utility へ分離 (#1379)
Browse files Browse the repository at this point in the history
refactor: ファイルに関するユーティリティを別モジュールへ分離
  • Loading branch information
tarepan authored Jun 2, 2024
1 parent c38458e commit 03c6c64
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion voicevox_engine/app/routers/morphing.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
synthesis_morphing_parameter as _synthesis_morphing_parameter,
)
from voicevox_engine.tts_pipeline.tts_engine import TTSEngineManager
from voicevox_engine.utility.path_utility import delete_file
from voicevox_engine.utility.file_utility import delete_file

# キャッシュを有効化
# モジュール側でlru_cacheを指定するとキャッシュを制御しにくいため、HTTPサーバ側で指定する
Expand Down
2 changes: 1 addition & 1 deletion voicevox_engine/app/routers/tts_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
TalkSingInvalidInputError,
TTSEngineManager,
)
from voicevox_engine.utility.path_utility import delete_file
from voicevox_engine.utility.file_utility import delete_file


class ParseKanaBadRequest(BaseModel):
Expand Down
12 changes: 12 additions & 0 deletions voicevox_engine/utility/file_utility.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""ファイル操作に関するユーティリティ"""

import os
import traceback


def delete_file(file_path: str) -> None:
"""指定されたファイルを削除する。"""
try:
os.remove(file_path)
except OSError:
traceback.print_exc()
10 changes: 0 additions & 10 deletions voicevox_engine/utility/path_utility.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import os
import sys
import traceback
from pathlib import Path

from platformdirs import user_data_dir
Expand Down Expand Up @@ -57,11 +55,3 @@ def get_save_dir() -> Path:
else:
app_name = "voicevox-engine"
return Path(user_data_dir(app_name))


def delete_file(file_path: str) -> None:
"""指定されたファイルを削除する。"""
try:
os.remove(file_path)
except OSError:
traceback.print_exc()

0 comments on commit 03c6c64

Please sign in to comment.