Skip to content

Commit

Permalink
‣ Fix local path repository logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
eli64s committed Sep 13, 2023
1 parent b013707 commit 3849ad1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 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 = "poetry.core.masonry.api"

[tool.poetry]
name = "readmeai"
version = "0.3.015"
version = "0.3.016"
description = "🚀 Generate awesome README.md files from the terminal, powered by OpenAI's GPT language model APIs 💫"
authors = ["Eli <0x.eli.64s@gmail.com>"]
license = "MIT"
Expand Down
12 changes: 8 additions & 4 deletions readmeai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,20 @@ def get_github_file_link(file: str, user_repo_name: str) -> str:
return f"https://github.com/{user_repo_name}/blob/main/{file}"


def get_user_repository_name(url) -> str:
"""Extract username and repository name from a GitHub URL."""
def get_user_repository_name(url_or_path) -> str:
"""Extract username and repository name from a GitHub URL or local path."""

if os.path.exists(url_or_path):
return os.path.basename(url_or_path)

pattern = r"https?://github.com/([^/]+)/([^/]+)"
match = re.match(pattern, url)
match = re.match(pattern, url_or_path)

if match:
username, reponame = match.groups()
return f"{username}/{reponame}"
else:
raise ("Error: invalid remote repository URL.")
raise ValueError("Error: invalid remote repository URL or local path.")


def adjust_max_tokens(max_tokens: int, prompt: str, target: str = "Hello!") -> int:
Expand Down

0 comments on commit 3849ad1

Please sign in to comment.