first commit
This commit is contained in:
1
utils/__init__.py
Normal file
1
utils/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
# This file is intentionally left blank.
|
||||
31
utils/helpers.py
Normal file
31
utils/helpers.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from typing import Any, Dict
|
||||
import os
|
||||
import logging
|
||||
|
||||
def setup_logging() -> None:
|
||||
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
||||
|
||||
def save_translated_file(file_path: str, data: Any) -> str:
|
||||
base, ext = os.path.splitext(file_path)
|
||||
translated_file_path = f"{base}_translated{ext}"
|
||||
|
||||
# Assuming data is a DataFrame or similar structure
|
||||
data.to_excel(translated_file_path, index=False)
|
||||
|
||||
logging.info(f"Translated file saved as: {translated_file_path}")
|
||||
return translated_file_path
|
||||
|
||||
def read_excel_file(file_path: str) -> Dict[str, Any]:
|
||||
import pandas as pd
|
||||
|
||||
logging.info(f"Reading Excel file: {file_path}")
|
||||
return pd.read_excel(file_path, sheet_name=None)
|
||||
|
||||
def translate_text(text: str, target_language: str) -> str:
|
||||
# Placeholder for translation logic
|
||||
logging.info(f"Translating text: {text} to {target_language}")
|
||||
return text # Replace with actual translation logic
|
||||
|
||||
def handle_file_not_found(file_path: str) -> None:
|
||||
logging.error(f"File not found: {file_path}")
|
||||
raise FileNotFoundError(f"The file {file_path} does not exist.")
|
||||
Reference in New Issue
Block a user