home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-debian / examples / deb822 / grep-maintainer < prev   
Encoding:
Text File  |  2008-08-09  |  867 b   |  30 lines

  1. #!/usr/bin/python
  2.  
  3. # grep-maintainer
  4. # Copyright (C) 2007 Stefano Zacchiroli <zack@debian.org>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # (at your option) any later version.
  10.  
  11. """Dumb maintainer-based grep for the dpkg status file."""
  12.  
  13. import re
  14. import sys
  15. from debian_bundle import deb822
  16.  
  17. try:
  18.     maint_RE = re.compile(sys.argv[1])
  19. except IndexError:
  20.     print >>sys.stderr, "Usage: grep-maintainer REGEXP"
  21.     sys.exit(1)
  22. except re.error, e:
  23.     print >>sys.stderr, "Error in the regexp: %s" % (e,)
  24.     sys.exit(1)
  25.  
  26. for pkg in deb822.Packages.iter_paragraphs(file('/var/lib/dpkg/status')):
  27.     if pkg.has_key('Maintainer') and maint_RE.search(pkg['maintainer']):
  28.         print pkg['package']
  29.  
  30.