Path.parts
Path.parts(...)Description
Documentation for Path.parts.
Real-World Examples
Practical code examples showing how Path.parts is used in real projects.
"""Parse a GitHub URL into owner, repo, and path."""
# Remove the protocol part if present
gh_url = gh_url.replace("https://", "").replace("http://", "")
# Split by '/' and take the last two parts
parts = gh_url.split("/")
if len(parts) < 2:
raise ValueError("Invalid GitHub URL")
owner = parts[-2]
repo = parts[-1]
return owner, repo
def _get_file_name_from_zip_name(self, zip_name: str) -> str:
zip_name = zip_name.split("/")
root_dir = zip_name[0]
return "-".join(root_dir.split("-")[1:-1]) + "/" + "/".join(zip_name[1:])
async def _raise_for_status(
self, owner: str, repo: str, response: aiohttp.ClientResponse
):
if response.status == 404:
raise GitHubNotFoundError(owner, repo)
elif response.status in (429, 403):
raise GitHubRateLimitError(owner, repo)
elif response.status != 200:
# Skip already processed repos
if full_name in seen_repos:
continue
seen_repos.add(full_name)
parts = full_name.split("/", 1)
if len(parts) != 2:
continue
owner, name = parts
file_path = item.get("path", "")
# Get repo details (stars, default branch, pushed_at)
try:
repo_info = self._get_repo_info(owner, name)
stars = repo_info.get("stargazers_count", 0)
default_branch = repo_info.get("default_branch", "main")
pushed_at = repo_info.get("pushed_at", "")
except Exception:
stars = 0
default_branch = "main"
pushed_at = ""
# Get last commit date for the specific file
try: