The AutoCoder Toolkit helps you find and fix errors, perform code-quality refactoring, and translate code between different programming languages (while finding substitute packages and imports as it goes).
Clone the repo then install the dependencies via poetry
:
poetry install
Import the necessary functions from the module and get to toolkitting!:
from auto_coder_toolkit import (
refactor_code,
update_code,
fix_errors,
translate_code,
find_imports,
is_external_import,
find_alternative_imports,
process_directory,
)
Translate code from one language to another using the translate_code
function:
translated_code = translate_code(source_language, target_language, code)
source_language
: The source programming language (e.g., "Python")target_language
: The target programming language (e.g., "JavaScript")code
: The code to be translated
Find all import statements in a file using the find_imports
function:
import_statements = find_imports(file_path, source_language)
file_path
: The path to the file containing the codesource_language
: The source programming language (e.g., "Python")
Check if an import statement is for an external package or a reference to another file in the project using the is_external_import
function:
is_external = is_external_import(import_statement, source_language)
import_statement
: The import statement to checksource_language
: The source programming language (e.g., "Python")
Find alternative imports in the target language for a list of source language imports using the find_alternative_imports
function:
alternative_imports = find_alternative_imports(source_imports, source_language, target_language, browser_compatible=False)
source_imports
: A list of import statements in the source languagesource_language
: The source programming language (e.g., "Python")target_language
: The target programming language (e.g., "JavaScript")browser_compatible
(optional): Set toTrue
to find browser-compatible alternatives for JavaScript or TypeScript. Default isFalse
.
Contributions are welcome! If you have suggestions for improvements or bug fixes, please open an issue or submit a pull request.
This project is licensed under the MIT License.