url_check.py 文件源码

python
阅读 16 收藏 0 点赞 0 评论 0

项目:msys2-helpers 作者: lazka 项目源码 文件源码
def main(args):
    sources = {}
    repo_path = os.path.abspath(args.path)

    repo_packages = PacmanPackage.get_all_packages()
    repo_package_names = set(p.pkgname for p in repo_packages)

    for package in iter_packages(repo_path):
        # only check packages which are in the repo, all others are many
        # times broken in other ways.
        if not args.all and package.pkgname not in repo_package_names:
            continue
        for source in package.sources:
            url = source_get_url(source)
            if url:
                sources.setdefault(url, set()).add(package.pkgbuild_path)

    print("Checking URLs...")
    work_items = sources.items()
    pool = ThreadPool(50)
    pool_iter = pool.imap_unordered(_check_url, work_items)
    broken = []
    with progress(len(work_items)) as update:
        for i, (url, pkgbuilds, error) in enumerate(pool_iter):
            update(i + 1)
            if error:
                broken.append((url, pkgbuilds, error))
    pool.close()
    pool.join()

    for url, pkgbuilds, error in broken:
        print("\n%s\n   %s\n   %s" % (
            url, " ".join(error.splitlines()), ", ".join(pkgbuilds)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号