Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
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
13 changes: 6 additions & 7 deletions scripts/gh-download.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def download_directory(repository: Repository, sha: str, server_path: str) -> No
contents = repository.get_dir_contents(server_path, ref=sha)

for content in contents:
print("Processing %s" % content.path)
print(f"Processing {content.path}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function download_directory refactored with the following changes:

if content.type == "dir":
os.makedirs(content.path)
download_directory(repository, sha, content.path)
Expand All @@ -59,11 +59,10 @@ def download_directory(repository: Repository, sha: str, server_path: str) -> No
file_content = repository.get_contents(path, ref=sha)
if not isinstance(file_content, ContentFile):
raise ValueError("Expected ContentFile")
file_out = open(content.path, "w+")
if file_content.content:
file_data = base64.b64decode(file_content.content)
file_out.write(file_data.decode("utf-8"))
file_out.close()
with open(content.path, "w+") as file_out:
if file_content.content:
file_data = base64.b64decode(file_content.content)
file_out.write(file_data.decode("utf-8"))
except (GithubException, IOError, ValueError) as exc:
print("Error processing %s: %s", content.path, exc)

Expand All @@ -82,7 +81,7 @@ def main(argv):
try:
opts, _ = getopt.getopt(argv, "r:b:f:", ["repo=", "branch=", "folder="])
except getopt.GetoptError as err:
print(str(err))
print(err)
Comment on lines -85 to +84
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function main refactored with the following changes:

usage()
sys.exit(2)
repo: Optional[str] = None
Expand Down