aboutsummaryrefslogtreecommitdiff
path: root/utils/aur/check-aur-dependencies.py
diff options
context:
space:
mode:
authorEyan Au <[email protected]>2021-11-24 18:40:52 +0800
committerGitHub <[email protected]>2021-11-24 18:40:52 +0800
commit61ee9bde0befeef86b873a1164c30f86bbbcd41e (patch)
treeb647a021bcf4344c324b9ab1d6ffb90dc0b35c8a /utils/aur/check-aur-dependencies.py
parent88b74518c2fd51b744959c5e3fee959791cb0d15 (diff)
pref(script): use heapq to sort and add minor changes in check-aur-dependencies.py (#22)
Signed-off-by: 67au <[email protected]>
Diffstat (limited to 'utils/aur/check-aur-dependencies.py')
-rwxr-xr-xutils/aur/check-aur-dependencies.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/utils/aur/check-aur-dependencies.py b/utils/aur/check-aur-dependencies.py
index 6749f69..f3e9e31 100755
--- a/utils/aur/check-aur-dependencies.py
+++ b/utils/aur/check-aur-dependencies.py
@@ -18,6 +18,7 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
import asyncio
+import heapq
import logging
import re
from pathlib import Path
@@ -34,7 +35,7 @@ async def check_pkg(session: aiohttp.ClientSession, num: int, pkg: str) -> Tuple
async def main() -> int:
- parser = argparse.ArgumentParser(description='check-aur.py')
+ parser = argparse.ArgumentParser(description='check-aur-dependencies.py')
parser.add_argument('paths', metavar='sub_path', type=str, nargs='*', help='sub-path for repo root')
args = parser.parse_args()
@@ -60,13 +61,13 @@ async def main() -> int:
for task in asyncio.as_completed(tasks):
n, r = await task
if r:
- yay_dep_nums.append(n)
+ heapq.heappush(yay_dep_nums, n)
yaydeps_dir = repo_dir.parent.joinpath('.yaydeps')
if len(yay_dep_nums) > 0:
async with aiofiles.open(yaydeps_dir.joinpath(repo_dir.stem), 'w', encoding='utf-8') as f:
- await f.write('\n'.join([*(deps[n] for n in sorted(yay_dep_nums)), '']))
+ await f.write('\n'.join([*(deps[heapq.heappop(yay_dep_nums)] for _ in range(len(yay_dep_nums))), '']))
return 0
@@ -74,5 +75,4 @@ async def main() -> int:
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(levelname)s - %(funcName)s - %(lineno)d - %(message)s')
- loop = asyncio.get_event_loop()
- exit(loop.run_until_complete(main()))
+ exit(asyncio.run(main()))