Skip to content

Commit

Permalink
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pyro/PapyrusProject.py
Original file line number Diff line number Diff line change
@@ -503,7 +503,7 @@ def _get_remote_path(self, node: etree.ElementBase) -> str:
url_path = os.sep.join(url_path_parts)
elif parsed_url.netloc == 'github.com':
url_path_parts = parsed_url.path.split('/')[1:]
url_path_parts.pop(3) # pop 'master'
url_path_parts.pop(3) # pop 'master' (or any other branch)
url_path_parts.pop(2) # pop 'tree'
url_path = os.sep.join(url_path_parts)
else:
12 changes: 9 additions & 3 deletions pyro/Remotes.py
Original file line number Diff line number Diff line change
@@ -47,10 +47,16 @@ def get_contents(self, url: str, output_path: str) -> Generator:
if parsed_url.netloc == 'api.github.com':
request_url = url
_, owner, repo = url_path.split('/')[:3]
else:
url_path = url_path.replace('tree/master', 'contents')
elif parsed_url.netloc == 'github.com':
url_path_parts = parsed_url.path.split('/')[1:]
url_path_parts.pop(3) # pop 'master' (or any other branch)
url_path_parts.pop(2) # pop 'tree'
url_path_parts.insert(2, 'contents')
url_path = '/'.join(url_path_parts)
request_url = f'https://api.github.com/repos/{url_path}'
owner, repo = url_path.split('/')[:2]
owner, repo = url_path_parts[0], url_path_parts[1]
else:
raise NotImplementedError

request = Request(request_url)
request.add_header('Authorization', f'token {self.access_token}')

0 comments on commit 24ece4d

Please sign in to comment.