From 520c429e5baaa7aad0212984294cc658862bd689 Mon Sep 17 00:00:00 2001 From: Eyan Au Date: Wed, 1 Dec 2021 15:02:19 +0800 Subject: fix(script): Fix checking depends and add minor changes (#25) * fix(script): Fix checking depends and add minor changes * fix(script): Fix NoneType in checking depends * Close #24 Signed-off-by: 67au --- utils/aur/check-aur-dependencies.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'utils/aur/check-aur-dependencies.py') diff --git a/utils/aur/check-aur-dependencies.py b/utils/aur/check-aur-dependencies.py index f3e9e31..38b6436 100755 --- a/utils/aur/check-aur-dependencies.py +++ b/utils/aur/check-aur-dependencies.py @@ -22,13 +22,12 @@ import heapq import logging import re from pathlib import Path -from typing import Tuple import aiofiles import aiohttp -async def check_pkg(session: aiohttp.ClientSession, num: int, pkg: str) -> Tuple[int, bool]: +async def check_pkg(session: aiohttp.ClientSession, num: int, pkg: str) -> tuple[int, bool]: logging.info(f'Checking {pkg}') ret = await session.head(f'https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h={pkg}') return num, ret.status == 200 @@ -48,12 +47,15 @@ async def main() -> int: async with aiofiles.open(pkgbuild_file, 'r', encoding='utf-8') as f: pkgbuild_text = await f.read() - deps_match = re.search(r"makedepends=\((?P([^)]|\n)+)\)", pkgbuild_text, re.M) - if not deps_match: - logging.error("Can't found `makedepends' keyword, if you think this is mistake, please report issue") - return 2 + runtime_deps_match = re.search(r"depends=\((?P([^)]|\n)*)\)", pkgbuild_text, re.M) + if not runtime_deps_match: + logging.warning("Can't found 'depends' keyword, if you think this is mistake, please report issue") - deps = deps_match.group('DEPS').split() + make_deps_match = re.search(r"makedepends=\((?P([^)]|\n)*)\)", pkgbuild_text, re.M) + if not make_deps_match: + logging.warning("Can't found `makedepends' keyword, if you think this is mistake, please report issue") + + deps = [dep.strip('\'') for m in {runtime_deps_match, make_deps_match} if m for dep in m.group('DEPS').split()] async with aiohttp.ClientSession(timeout=aiohttp.ClientTimeout(10)) as session: tasks = [asyncio.create_task(check_pkg(session, n, pkg)) for n, pkg in enumerate(deps)] -- cgit v1.3.1