diff --git a/cli/commands/analyze.py b/cli/commands/analyze.py index 2ec16c4..76f4e01 100644 --- a/cli/commands/analyze.py +++ b/cli/commands/analyze.py @@ -1,6 +1,6 @@ from InquirerPy import inquirer -from cli.utils.get_translation import get_translation +from utils.get_translation import get_translation from spice.analyze import analyze_file diff --git a/cli/commands/export/export.py b/cli/commands/export/export.py index 7af48a3..c8e6ff6 100644 --- a/cli/commands/export/export.py +++ b/cli/commands/export/export.py @@ -5,7 +5,7 @@ from rich.console import Console from rich.table import Table -from cli.utils.get_translation import get_translation +from utils.get_translation import get_translation def export_results(results, format_type, output_file, messages): """ diff --git a/cli/commands/hello.py b/cli/commands/hello.py index f58f7a9..f50fcea 100644 --- a/cli/commands/hello.py +++ b/cli/commands/hello.py @@ -1,6 +1,6 @@ from rich import print # this add colors to the printed text -from cli.utils.get_translation import get_translation +from utils.get_translation import get_translation def hello_command(LANG_FILE): diff --git a/cli/commands/version.py b/cli/commands/version.py index 2e9111e..71ee7fa 100644 --- a/cli/commands/version.py +++ b/cli/commands/version.py @@ -1,7 +1,7 @@ import os from rich import print # this add colors to the printed text -from cli.utils.get_translation import get_translation +from utils.get_translation import get_translation def version_command(LANG_FILE, CURRENT_DIR): diff --git a/spice/analyze.py b/spice/analyze.py index 3c4eaa6..9545c49 100644 --- a/spice/analyze.py +++ b/spice/analyze.py @@ -46,7 +46,7 @@ def analyze_file(file_path: str, selected_stats=None): # only put the code through the lexer and proceed with tokenization if needed if any(stat in selected_stats for stat in ["function_count"]): # get the lexer for the code's language - from spice.utils.get_lexer import get_lexer_for_file + from utils.get_lexer import get_lexer_for_file LexerClass = get_lexer_for_file(file_path) # tokenize the code via lexer diff --git a/spice/utils/__init__.py b/spice/utils/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/cli/utils/__init__.py b/utils/__init__.py similarity index 100% rename from cli/utils/__init__.py rename to utils/__init__.py diff --git a/utils/get_lang.py b/utils/get_lang.py new file mode 100644 index 0000000..83e5fbc --- /dev/null +++ b/utils/get_lang.py @@ -0,0 +1,22 @@ +import os + + +# this will read the file extension and return the correct langague +def get_lexer_for_file(file_path): + _, ext = os.path.splitext(file_path) + + if ext == ".rb": + return "ruby" + + elif ext == ".py": + from lexers.python.pythonlexer import PythonLexer + return "python" + + elif ext == ".js": + return "javascript" + + elif ext == ".go": + return "go" + + else: + raise ValueError(f"Unsupported file extension: {ext}") \ No newline at end of file diff --git a/spice/utils/get_lexer.py b/utils/get_lexer.py similarity index 100% rename from spice/utils/get_lexer.py rename to utils/get_lexer.py diff --git a/cli/utils/get_translation.py b/utils/get_translation.py similarity index 100% rename from cli/utils/get_translation.py rename to utils/get_translation.py