aboutsummaryrefslogtreecommitdiff
path: root/utils/aur/check-aur-dependencies.py
diff options
context:
space:
mode:
authorEyan Au <[email protected]>2021-12-01 15:02:19 +0800
committerGitHub <[email protected]>2021-12-01 15:02:19 +0800
commit520c429e5baaa7aad0212984294cc658862bd689 (patch)
tree4e96fc461df9eee1993e773000579509a2ed25d8 /utils/aur/check-aur-dependencies.py
parent4f3f1031166162311c2d2b97f77d076e41ac3f33 (diff)
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 <[email protected]>
Diffstat (limited to 'utils/aur/check-aur-dependencies.py')
-rwxr-xr-xutils/aur/check-aur-dependencies.py16
1 files changed, 9 insertions, 7 deletions
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<DEPS>([^)]|\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<DEPS>([^)]|\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<DEPS>([^)]|\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)]