Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions frontend/src/lib/parsing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ export const SUPPORTED_EXTENSIONS = [
".md",
".py",
".json",
".js",
".ts",
".tsx",
".jsx",
".go",
".rs",
".java",
".c",
".cpp",
".h",
".hpp",
".html",
".css",
".yaml",
".yml",
".toml",
".xml",
".sql",
".sh",
".bash",
];

export function hasSupportedExtension(name: string): boolean {
Expand Down
30 changes: 29 additions & 1 deletion src/norefund/core/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,35 @@

logger = logging.getLogger(__name__)

SUPPORTED_EXTENSIONS = {".pdf", ".pptx", ".docx", ".txt", ".md", ".py", ".json"}
SUPPORTED_EXTENSIONS = {
".pdf",
".pptx",
".docx",
".txt",
".md",
".py",
".json",
".js",
".ts",
".tsx",
".jsx",
".go",
".rs",
".java",
".c",
".cpp",
".h",
".hpp",
".html",
".css",
".yaml",
".yml",
".toml",
".xml",
".sql",
".sh",
".bash",
}


def extract_text(path: Path) -> str:
Expand Down
6 changes: 3 additions & 3 deletions src/norefund/core/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

from __future__ import annotations

from .parsing import SUPPORTED_EXTENSIONS, extract_text

import threading
from collections.abc import Callable
from dataclasses import dataclass
Expand All @@ -23,8 +25,6 @@
from norefund.logging_config import get_logger

_LOG = get_logger(__name__)
_SUPPORTED = {".txt", ".md", ".pdf", ".pptx", ".docx", ".py", ".json"}


@dataclass
class AnalysisResult:
Expand Down Expand Up @@ -137,7 +137,7 @@ def analyze_folder(
)
break

if not (f.is_file() and f.suffix.lower() in _SUPPORTED):
if not (f.is_file() and f.suffix.lower() in SUPPORTED_EXTENSIONS):
continue

# analyze_file already catches all exceptions internally
Expand Down
3 changes: 3 additions & 0 deletions tests/test_desktop_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ def test_pick_files_filters_to_supported_extensions():
(pattern,) = kwargs["file_types"]
assert "*.pdf" in pattern
assert "*.docx" in pattern
assert "*.java" in pattern
assert "*.js;" in pattern
assert "*.cpp" in pattern


def test_pick_files_returns_empty_list_when_dialog_is_cancelled():
Expand Down
34 changes: 29 additions & 5 deletions tests/test_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,35 @@
from norefund.core.parsing import SUPPORTED_EXTENSIONS, extract_text


def test_supported_extensions_present():
assert ".pdf" in SUPPORTED_EXTENSIONS
assert ".pptx" in SUPPORTED_EXTENSIONS
assert ".docx" in SUPPORTED_EXTENSIONS
assert ".txt" in SUPPORTED_EXTENSIONS
def test_supported_code_extensions_present():
expected = {
".pdf",
".pptx",
".docx",
".txt",
".js",
".ts",
".tsx",
".jsx",
".go",
".rs",
".java",
".c",
".cpp",
".h",
".hpp",
".html",
".css",
".yaml",
".yml",
".toml",
".xml",
".sql",
".sh",
".bash",
}

assert expected <= SUPPORTED_EXTENSIONS


def test_extract_text_txt(tmp_path: Path):
Expand Down
Loading