Skip to content

Commit

Permalink
style: format code with Ruff Formatter (#2)
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 958ed9e according to the output
from Ruff Formatter.

Details: None

Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com>
  • Loading branch information
deepsource-autofix[bot] authored Sep 11, 2024
1 parent 958ed9e commit 987b2de
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 10 deletions.
5 changes: 3 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
os.getenv("CREATE_ORG", str(options["CONFIG"]["CREATE_ORG"])).lower() == "true"
)
REMOVE_INEXIST_REPO = (
os.getenv("REMOVE_INEXIST_REPO", str(options["CONFIG"]["REMOVE_INEXIST_REPO"]))
.lower()
os.getenv(
"REMOVE_INEXIST_REPO", str(options["CONFIG"]["REMOVE_INEXIST_REPO"])
).lower()
== "true"
)
REMOVE_EXISTING_REPO = (
Expand Down
4 changes: 3 additions & 1 deletion utils/giteaOrg.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ def create_gitea_org(org_name):
if response.status_code == 201:
logging.info(f"Organization created: {org_name}")
else:
logging.warning(f"Organization creation failed: {org_name}: {response.status_code} {response.content}")
logging.warning(
f"Organization creation failed: {org_name}: {response.status_code} {response.content}"
)
14 changes: 10 additions & 4 deletions utils/giteaRepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ def fetch_gitea_repos():
repos = []
page = 1
per_page = 50
headers = {'Authorization': f'token {config.GITEA_PAT}'}
headers = {"Authorization": f"token {config.GITEA_PAT}"}

logging.info("\nFetching Gitea repositories...")
while True:
url = f"{config.GITEA_HOST}/api/v1/user/repos?page={page}&limit={per_page}"
response = requests.get(url, headers=headers)
if response.status_code != 200:
logging.warning(f"Failed to fetch Gitea repositories: {response.status_code} {response.content}")
logging.warning(
f"Failed to fetch Gitea repositories: {response.status_code} {response.content}"
)
break
page_repos = response.json()
if not page_repos:
Expand All @@ -39,7 +41,9 @@ def remove_inexist_repo(github_repos, gitea_repos):
if response.status_code == 204:
logging.info(f"Removed removed: {repo['full_name']}")
else:
logging.warning(f"Repository removal failed: {repo['full_name']}: {response.status_code} {response.content}")
logging.warning(
f"Repository removal failed: {repo['full_name']}: {response.status_code} {response.content}"
)


def check_gitea_repo_exists(repo_name):
Expand All @@ -54,4 +58,6 @@ def remove_gitea_repo(repo_name):
if response.status_code == 204:
logging.info(f"Repository removed: {repo_name}")
else:
logging.warning(f"Repository removal failed: {repo_name}: {response.status_code} {response.content}")
logging.warning(
f"Repository removal failed: {repo_name}: {response.status_code} {response.content}"
)
6 changes: 4 additions & 2 deletions utils/githubRepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ def fetch_github_repos():
repos.extend(
fetch_request(
"https://api.github.com/user/starred?per_page={per_page}",
headers, "GitHub repositories"
headers,
"GitHub repositories",
)
)

Expand All @@ -46,7 +47,8 @@ def fetch_github_repos():
repos.extend(
fetch_request(
f"https://api.github.com/user/repos?per_page={{per_page}}&affiliation={affiliation_param}",
headers, "GitHub repositories"
headers,
"GitHub repositories",
)
)

Expand Down
4 changes: 3 additions & 1 deletion utils/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ def mirror_to_gitea(repo):
logging.info(f"\tSuccess: {target_repo_name}")
break
else:
logging.warning(f"\tFailed: {target_repo_name}: {response.status_code} {response.content}")
logging.warning(
f"\tFailed: {target_repo_name}: {response.status_code} {response.content}"
)
if attempt < 2:
logging.info(f"\tRetrying: {target_repo_name}")
time.sleep(5)

0 comments on commit 987b2de

Please sign in to comment.