home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / examples / dpkg-extract.py < prev    next >
Encoding:
Python Source  |  2009-03-30  |  562 b   |  26 lines

  1. #!/usr/bin/python
  2. """Emulate dpkg --extract package.deb outdir"""
  3. import os
  4. import sys
  5.  
  6. import apt_inst
  7.  
  8.  
  9. def main():
  10.     """Main function."""
  11.     if len(sys.argv) < 3:
  12.         print >> sys.stderr, "Usage:", __file__, "package.deb outdir"
  13.         sys.exit(1)
  14.     if not os.path.exists(sys.argv[2]):
  15.         print >> sys.stderr, "The directory %s does not exist" % sys.argv[2]
  16.         sys.exit(1)
  17.  
  18.     fobj = open(sys.argv[1])
  19.     try:
  20.         apt_inst.debExtractArchive(fobj, sys.argv[2])
  21.     finally:
  22.         fobj.close()
  23.  
  24. if __name__ == "__main__":
  25.     main()
  26.