Skip to content

Commit 5cf4a76

Browse files
authored
Merge pull request #131 from spicecode-cli/structural-changes
Structural changes
2 parents 0e9d580 + 7f49f36 commit 5cf4a76

File tree

10 files changed

+27
-5
lines changed

10 files changed

+27
-5
lines changed

β€Žcli/commands/analyze.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from InquirerPy import inquirer
22

3-
from cli.utils.get_translation import get_translation
3+
from utils.get_translation import get_translation
44
from spice.analyze import analyze_file
55

66

β€Žcli/commands/export/export.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from rich.console import Console
66
from rich.table import Table
77

8-
from cli.utils.get_translation import get_translation
8+
from utils.get_translation import get_translation
99

1010
def export_results(results, format_type, output_file, messages):
1111
"""

β€Žcli/commands/hello.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from rich import print # this add colors to the printed text
22

3-
from cli.utils.get_translation import get_translation
3+
from utils.get_translation import get_translation
44

55

66
def hello_command(LANG_FILE):

β€Žcli/commands/version.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
from rich import print # this add colors to the printed text
33

4-
from cli.utils.get_translation import get_translation
4+
from utils.get_translation import get_translation
55

66

77
def version_command(LANG_FILE, CURRENT_DIR):

β€Žspice/analyze.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def analyze_file(file_path: str, selected_stats=None):
4646
# only put the code through the lexer and proceed with tokenization if needed
4747
if any(stat in selected_stats for stat in ["function_count"]):
4848
# get the lexer for the code's language
49-
from spice.utils.get_lexer import get_lexer_for_file
49+
from utils.get_lexer import get_lexer_for_file
5050
LexerClass = get_lexer_for_file(file_path)
5151

5252
# tokenize the code via lexer

β€Žspice/utils/__init__.pyβ€Ž

Whitespace-only changes.

β€Žutils/get_lang.pyβ€Ž

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import os
2+
3+
4+
# this will read the file extension and return the correct langague
5+
def get_lexer_for_file(file_path):
6+
_, ext = os.path.splitext(file_path)
7+
8+
if ext == ".rb":
9+
return "ruby"
10+
11+
elif ext == ".py":
12+
from lexers.python.pythonlexer import PythonLexer
13+
return "python"
14+
15+
elif ext == ".js":
16+
return "javascript"
17+
18+
elif ext == ".go":
19+
return "go"
20+
21+
else:
22+
raise ValueError(f"Unsupported file extension: {ext}")

0 commit comments

Comments
Β (0)