home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / lib / python2.5 / site-packages / pygst.py < prev    next >
Encoding:
Python Source  |  2007-03-20  |  2.0 KB  |  63 lines

  1. # -*- Mode: Python; py-indent-offset: 4 -*-
  2. # pygst - Python bindings for the GStreamer multimedia framework.
  3. # Copyright (C) 1998-2002  James Henstridge
  4. #           (C) 2005 Edward Hervey
  5. #
  6. #   pygst.py: pygst version selection code.
  7. #
  8. # This program is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 2 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # This program is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program; if not, write to the Free Software
  20. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. # USA
  22.  
  23. # This allows parallel installation of gst-python
  24. #
  25. # In order to have backward compatibility
  26.  
  27. import sys
  28.  
  29. __all__ = ['require']
  30.  
  31. _pygst_dir = '/usr/lib/python2.5/site-packages/gst-0.10'
  32.  
  33. _pygst_version = '0.10'
  34.  
  35. _pygst_required_version = None
  36.  
  37. class RequiredVersionError(ValueError, AssertionError):
  38.     # AssertionError is subclassed for compatibility reasons.
  39.     pass
  40.  
  41.  
  42. def require(version):
  43.     global _pygst_required_version
  44.  
  45.     if _pygst_required_version != None:
  46.         if _pygst_required_version != version:
  47.             raise RequiredVersionError, "a different version of gst was already required"
  48.         else:
  49.             return
  50.  
  51.     if sys.modules.has_key('gst'):
  52.         raise RequiredVersionError, "pygst.require() must be called before importing gst"
  53.  
  54.     if version != _pygst_version:
  55.         raise RequiredVersionError, "Only version '%s' is available" % _pygst_version
  56.  
  57.     # move the pygst path to the front
  58.     while _pygst_dir in sys.path:
  59.         sys.path.remove(_pygst_dir)
  60.     sys.path.insert(0, _pygst_dir)
  61.     
  62.     _pygst_required_version = version
  63.