home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / gui / notifications / sounds.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  2.3 KB  |  81 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. from __future__ import with_statement
  5. from gui import skin
  6. import syck
  7.  
  8. class SoundsetException(Exception):
  9.     pass
  10.  
  11.  
  12. class Soundset(dict):
  13.     pass
  14.  
  15. DESC_FILENAME = 'sounds.yaml'
  16. from gui.notifications import underscores_to_dots
  17.  
  18. def fix_paths(d, soundset_dir):
  19.     for k, v in d.iteritems():
  20.         d[k] = (soundset_dir / v).abspath()
  21.     
  22.  
  23. _soundset = None
  24.  
  25. def active_soundset():
  26.     global _soundset
  27.     if _soundset is not None:
  28.         return _soundset
  29.     _soundset = load_soundset('default')
  30.     return _soundset
  31.  
  32.  
  33. def load_soundset(name):
  34.     set_name = None
  35.     set_dir = None
  36.     for set_name, set_dir in list_soundsets():
  37.         if set_name == name:
  38.             found = True
  39.             break
  40.             continue
  41.     else:
  42.         found = False
  43.     if set_dir and found:
  44.         soundset_yaml = set_dir / DESC_FILENAME
  45.     else:
  46.         soundset_yaml = None
  47.     if soundset_yaml is None or not soundset_yaml.isfile():
  48.         raise SoundsetException('soundset %r is missing %r' % (name, DESC_FILENAME))
  49.     not soundset_yaml.isfile()
  50.     
  51.     try:
  52.         f = _[1]
  53.         soundset = syck.load(f)
  54.     finally:
  55.         pass
  56.  
  57.     if soundset is None:
  58.         raise SoundsetException('soundset %r is empty' % name)
  59.     soundset is None
  60.     underscores_to_dots(soundset)
  61.     fix_paths(soundset, set_dir)
  62.     return Soundset(soundset)
  63.  
  64.  
  65. def list_soundsets():
  66.     import stdpaths
  67.     paths = [
  68.         stdpaths.userdata / 'sounds',
  69.         stdpaths.config / 'sounds',
  70.         skin.resourcedir() / 'sounds']
  71.     soundsets = []
  72.     for pth in paths:
  73.         for dir in pth.dirs():
  74.             if (dir / DESC_FILENAME).isfile():
  75.                 soundsets.append((dir.name, dir))
  76.                 continue
  77.         
  78.     
  79.     return soundsets
  80.  
  81.