代码拉取完成,页面将自动刷新
同步操作将从 OpenCloudOS/dev-tools 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import requests
import argparse
def get_gitee_organization_repos(organization, access_token):
url = f"https://gitee.com/api/v5/orgs/{organization}/repos"
headers = {"Authorization": f"token {access_token}"}
params = {"page": 1, "per_page": 100}
repos = []
while True:
print("Getting repo infomation:", params)
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
data = response.json()
if not data:
break
repos.extend(data)
params["page"] += 1
return repos
def get_gitee_organization_repo_info(organization, access_token):
repos = get_gitee_organization_repos(organization, access_token)
repo_info = {}
for repo in repos:
if repo["private"]:
repo_info[repo["name"]] = "private"
elif repo["public"]:
repo_info[repo["name"]] = "public"
elif repo["internal"]:
repo_info[repo["name"]] = "internal"
return repo_info
def write_repo_info(repo_info, file_name, with_visibility):
print(repo_info)
with open(file_name, "w") as file:
for pkgs, visibility in repo_info.items():
if with_visibility:
file.write(f"{pkgs}\t{visibility}\n")
else:
file.write(f"{pkgs}\n")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Get all repo name in Gitee group.')
parser.add_argument('token', type=str, help='The access token for the Gitee group, if the user does not have permission, some repos will be invisible.')
parser.add_argument('--with_visibility', default=True, type=bool, help='Whether the output file with repository visibility, default True.')
parser.add_argument('--organization', default="opencloudos-stream", type=str, help='The organization name.')
parser.add_argument('--output_file', default="repo_info_list", type=str, help='The repo name list file.')
args = parser.parse_args()
repo_info = get_gitee_organization_repo_info(args.organization, args.token)
write_repo_info(repo_info, args.output_file, args.with_visibility)
print(f"已将 {args.organization} 组织内的所有软件包名写入文件:{args.output_file}")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。