This repository contains various Python utilities to help with different tasks. Below is a description of the utilities available in this repository.
This script translates the names of files and directories within a specified directory to English using the Google Translate API.
translate_name(name, translator, fast_translation=False): Translates a given name to English if it contains non-English characters.translate_directory(path, translator): Translates all file and directory names in the specified path.
Run the script with the directory path as an argument.
<directory_path>: Path of the directory to translate.
python py_translate_dir.py /path/to/directoryThis script implements an HTTP server that serves the contents of a specified directory and supports directory traversal. It also includes functionality to translate file and directory names using Google Translate.
DirectoryHandler(http.server.SimpleHTTPRequestHandler): Handles HTTP requests and provides directory listing with optional translation of file and directory names.
pretranslate_directory(path, translator): Pre-translates all file and directory names in the specified path and caches the translations.signal_handler(signal, frame): Handles shutdown signals to gracefully stop the server.
Run the script with optional arguments to specify the port, directory, and translation options.
--port, -p: Port number to serve on (default: 8000)--directory, -d: Directory to serve (default: current directory)--translate, -t: Translate file and directory names (default: False)--pretranslate, -pt: Pre-translate all file and directory names (default: False)--quicktranslate, -qt: Enable quick translation mode (default: False)
python py_http_dir_traversal.py --port 8080 --directory /path/to/serve --translateA batch script to set up a Python virtual environment and install the required dependencies.
setup.bat-
Clone the repository:
git clone <repository_url> cd py_utils
-
Run the setup script to create a virtual environment and install dependencies:
setup.bat
- Python 3.x
googletranslibrary
This project is licensed under the MIT License.