Skip to content
Merged
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
17 changes: 8 additions & 9 deletions tableqa/metadata/parsers/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,14 @@ def _read_source(self, source: str | Path) -> str:
"""Read content from source."""
if isinstance(source, Path):
return source.read_text(encoding="utf-8")
if isinstance(source, str):
# Check if it looks like a file path (not too long and no newlines)
if len(source) < 4096 and "\n" not in source:
path = Path(source)
try:
if path.exists() and path.is_file():
return path.read_text(encoding="utf-8")
except (OSError, ValueError):
pass
# Check if it looks like a file path (not too long and no newlines)
if isinstance(source, str) and len(source) < 4096 and "\n" not in source:
path = Path(source)
try:
if path.exists() and path.is_file():
return path.read_text(encoding="utf-8")
except (OSError, ValueError):
pass
# Treat as string content
return str(source)

Expand Down
Loading