home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / python2.6 / dist-packages / GnomeCodecInstall / Main.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  4.0 KB  |  107 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import sys
  5. import gtk
  6. import gettext
  7. from gettext import gettext as _
  8. import re
  9. (INSTALL_PLUGINS_SUCCESS, INSTALL_PLUGINS_NOT_FOUND, INSTALL_PLUGINS_ERROR, INSTALL_PLUGINS_PARTIAL_SUCCESS, INSTALL_PLUGINS_USER_ABORT) = range(5)
  10.  
  11. class Request(object):
  12.     
  13.     def __init__(self, major, minor, app, descr, kind, caps = None, feature = None):
  14.         self.major = major
  15.         self.minor = minor
  16.         self.application = app
  17.         self.description = descr
  18.         self.gstkind = kind
  19.         self.caps = caps
  20.         self.feature = feature
  21.  
  22.  
  23.  
  24. def parse_arguments(args):
  25.     regex = re.compile('^gstreamer\\|([0-9])+\\.([0-9]+)\\|(.+)\\|(.+)\\|([a-z]+)-(.*)[|]?')
  26.     requests = []
  27.     gst_init = False
  28.     major = 0
  29.     minor = 0
  30.     for arg in args:
  31.         match = regex.search(arg)
  32.         if not match:
  33.             continue
  34.         
  35.         
  36.         try:
  37.             r_major = int(match.group(1))
  38.             r_minor = int(match.group(2))
  39.             if not gst_init:
  40.                 import pygst
  41.                 pygst.require('%d.%d' % (r_major, r_minor))
  42.                 import gst
  43.                 gst_init = True
  44.                 major = r_major
  45.                 minor = r_minor
  46.             elif r_major != major or r_minor != minor:
  47.                 return None
  48.         except ValueError:
  49.             continue
  50.  
  51.         if match.group(5) == 'decoder' or match.group(5) == 'encoder':
  52.             
  53.             try:
  54.                 requests.append(Request(major, minor, match.group(3), match.group(4), match.group(5), caps = gst.Caps(match.group(6))))
  55.             except TypeError:
  56.                 continue
  57.             except:
  58.                 None<EXCEPTION MATCH>TypeError
  59.             
  60.  
  61.         None<EXCEPTION MATCH>TypeError
  62.         if match.group(5) == 'urisource' and match.group(5) == 'urisink' or match.group(5) == 'element':
  63.             requests.append(Request(major, minor, match.group(3), match.group(4), match.group(5), feature = match.group(6)))
  64.             continue
  65.     
  66.     return requests
  67.  
  68.  
  69. def main(args):
  70.     gettext.textdomain('gnome-codec-install')
  71.     gettext.bindtextdomain('gnome-codec-install')
  72.     requests = parse_arguments(args)
  73.     
  74.     try:
  75.         icon = gtk.icon_theme_get_default().load_icon('gnome-codec-install', 32, 0)
  76.     except:
  77.         icon = None
  78.  
  79.     if icon:
  80.         gtk.window_set_default_icon(icon)
  81.     
  82.     if requests == None or len(requests) == 0:
  83.         sys.stderr.write("invalid commandline '%s'\n" % args)
  84.         dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _('Invalid commandline'))
  85.         dlg.format_secondary_text(_('The parameters passed to the application had an invalid format. Please file a bug!\n\nThe parameters were:\n%s') % '\n'.join(map(str, args)))
  86.         dlg.set_title(_('Invalid commandline'))
  87.         dlg.run()
  88.         dlg.destroy()
  89.         exit(INSTALL_PLUGINS_ERROR)
  90.     else:
  91.         dlg = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_QUESTION, gtk.BUTTONS_CANCEL, _('Search for suitable plugin?'))
  92.         dlg.format_secondary_text(_('The required software to play this file is not installed. You need to install suitable plugins to play media files. Do you want to search for a plugin that supports the selected file?\n\nThe search will also include software which is not officially supported.'))
  93.         btn = dlg.add_button(_('_Search'), gtk.RESPONSE_YES)
  94.         btn.grab_focus()
  95.         dlg.set_title(_('Search for suitable plugin?'))
  96.         res = dlg.run()
  97.         dlg.destroy()
  98.         while gtk.events_pending():
  99.             gtk.main_iteration()
  100.         if res != gtk.RESPONSE_YES:
  101.             exit(INSTALL_PLUGINS_USER_ABORT)
  102.         
  103.         import MainWindow
  104.         window = MainWindow.MainWindow(requests)
  105.         exit(window.main())
  106.  
  107.