Skip to content

Commit

Permalink
fix windows breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
areibman committed Sep 24, 2024
1 parent bf29142 commit d9d6790
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "spellcaster"
version = "0.0.6"
version = "0.0.7"
authors = [
{ name="Alex Reibman", email="[email protected]" }
]
Expand Down
13 changes: 11 additions & 2 deletions spellcaster/grammar.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import json
from pydantic import BaseModel
from rich.console import Console
Expand Down Expand Up @@ -198,8 +199,16 @@ def display_results(response: Grammar, path: str, repo_link: str = ""):
"""Display the grammar check results using Rich."""
# Replace local file path with GitHub URL
if repo_link:
path = repo_link.rstrip('/') + '/blob/main/' + \
'/'.join(response.file_path.split("samples/")[1].split('/')[2:])
# Use os.path.split to handle path separators correctly
parts = os.path.normpath(response.file_path).split(os.path.sep)
if "samples" in parts:
index = parts.index("samples")
relative_path = os.path.sep.join(parts[index+1:])
path = f"{repo_link.rstrip('/')}/blob/main/{relative_path}"
else:
# Fallback if 'samples' is not in the path
path = f"{repo_link.rstrip('/')}/blob/main/{os.path.basename(response.file_path)}"

# Create a console for file output
console = Console(record=True)

Expand Down

0 comments on commit d9d6790

Please sign in to comment.