Skip to content

Instantly share code, notes, and snippets.

@Moult
Forked from ekohl/maintainer-needed.py
Created December 6, 2012 09:47
Show Gist options
  • Save Moult/4223307 to your computer and use it in GitHub Desktop.
Save Moult/4223307 to your computer and use it in GitHub Desktop.
#!/usr/bin/python
from bs4 import BeautifulSoup
import portage
import urllib2
url = 'http://www.gentoo.org/proj/en/qa/treecleaners/maintainer-needed.xml'
# Build a to remove set
f = urllib2.urlopen(url)
soup = BeautifulSoup(f.read())
table = soup.find('table', {'class': 'ntable'})
toremove = set(row.findChild('a').text for row in table.findChildren('tr')[1:])
f.close()
# Build an installed set
vartree = portage.db[portage.root]['vartree']
installed = set(vartree.dbapi.cp_all())
# Print installed, but to be removed
packages = sorted(toremove.intersection(installed))
if packages:
print "The following %d installed package(s) need a maintainer" % len(packages)
for package in packages:
print "-", package
exit(1)
else:
print "All installed packages have a maintainer :)"
exit(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment