home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / gst-python / 0.10 / examples / gstfile.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  2.3 KB  |  64 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import sys
  6. import gobject
  7. gobject.threads_init()
  8. import pygst
  9. pygst.require('0.10')
  10. from gst.extend.discoverer import Discoverer
  11.  
  12. class GstFile:
  13.     '''
  14.     Analyses one or more files and prints out the multimedia information of
  15.     each file.
  16.     '''
  17.     
  18.     def __init__(self, files):
  19.         self.files = files
  20.         self.mainloop = gobject.MainLoop()
  21.         self.current = None
  22.  
  23.     
  24.     def run(self):
  25.         gobject.idle_add(self._discover_one)
  26.         self.mainloop.run()
  27.  
  28.     
  29.     def _discovered(self, discoverer, ismedia):
  30.         discoverer.print_info()
  31.         self.current = None
  32.         if len(self.files):
  33.             print '\n'
  34.         
  35.         gobject.idle_add(self._discover_one)
  36.  
  37.     
  38.     def _discover_one(self):
  39.         if not len(self.files):
  40.             gobject.idle_add(self.mainloop.quit)
  41.             return False
  42.         filename = self.files.pop(0)
  43.         if not os.path.isfile(filename):
  44.             gobject.idle_add(self._discover_one)
  45.             return False
  46.         print 'Running on', filename
  47.         self.current = Discoverer(filename)
  48.         self.current.connect('discovered', self._discovered)
  49.         self.current.discover()
  50.         return False
  51.  
  52.  
  53.  
  54. def main(args):
  55.     if len(args) < 2:
  56.         print 'usage: %s files...' % args[0]
  57.         return 2
  58.     gstfile = GstFile(args[1:])
  59.     gstfile.run()
  60.  
  61. if __name__ == '__main__':
  62.     sys.exit(main(sys.argv))
  63.  
  64.