SHARE
TWEET

Untitled

a guest Mar 22nd, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/python3
  2. import os
  3. os.environ['LANG'] = 'C'
  4. import json
  5. import subprocess
  6.  
  7. pkgstats = json.load(open('pkgstats.json'))
  8. packages = subprocess.check_output('pacman -Slq archlinuxcn'.split(' ')).decode('utf-8').split('\n')
  9. packages = [i for i in packages if i != '']
  10.  
  11. packagers = {}
  12. output = subprocess.check_output(['pacman', '-Si'] + packages).decode('utf-8').split('\n')
  13. for line in output:
  14.     if line.startswith('Name            :'):
  15.         pkgname = ''.join(line.split(':')[1:]).strip(' ')
  16.     elif line.startswith('Packager        :'):
  17.         packager = ''.join(line.split(':')[1:]).strip(' ').lower()
  18.         packagers[pkgname] = packager
  19.  
  20. for i in pkgstats['data']:
  21.     pkgstats[i['pkgname']] = i['count']
  22.  
  23. result = {}
  24. for i in packages:
  25.     packager = packagers[i]
  26.     if not packager in result:
  27.         result[packager] = []
  28.     if i in pkgstats:
  29.         if pkgstats[i] < 11:
  30.             result[packager].append((i, pkgstats[i]))
  31.     else:
  32.         result[packager].append((i, 0))
  33.  
  34. for packager, packages in sorted(result.items()):
  35.     if len(result[packager]) == 0:
  36.         continue
  37.     print('`%s`' % packager)
  38.     print()
  39.     for i in packages:
  40.         print('- [ ]', i[0], i[1])
  41.     print()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top