nvchecker/scripts/maintained_in_aur
Felix Yan 30fe6e6d49
Use f-string for better readability
Since we are targeting 3.7+, it should be safe to use them now.
2020-09-03 00:51:46 +08:00

23 lines
651 B
Python
Executable File

#!/usr/bin/env python3
# MIT licensed
# Copyright (c) 2013-2017 lilydjwg <lilydjwg@gmail.com>, et al.
'''show a list of packages maintained by someone in AUR'''
import sys
import json
import urllib.request
def main(user):
url = f'https://aur.archlinux.org/rpc.php?type=msearch&arg={user}'
res = urllib.request.urlopen(url)
if res.status != 200:
sys.exit(f'Error: {res.status} {res.reason}')
d = res.read().decode('utf-8')
d = json.loads(d)
print('\n'.join(sorted(pkg['Name'] for pkg in d['results'])))
if __name__ == '__main__':
main(sys.argv[1]) if len(sys.argv) == 2 else \
sys.exit('whose packages do you want to see?')