home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 June / maximum-cd-2009-06.iso / DiscContents / digsby_setup.exe / lib / gui / notifications / sounds.pyo (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2009-02-26  |  2.3 KB  |  82 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  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.     
  30.     _soundset = load_soundset('default')
  31.     return _soundset
  32.  
  33.  
  34. def load_soundset(name):
  35.     set_name = None
  36.     set_dir = None
  37.     for set_name, set_dir in list_soundsets():
  38.         if set_name == name:
  39.             found = True
  40.             break
  41.             continue
  42.     else:
  43.         found = False
  44.     if set_dir and found:
  45.         soundset_yaml = set_dir / DESC_FILENAME
  46.     else:
  47.         soundset_yaml = None
  48.     if soundset_yaml is None or not soundset_yaml.exists():
  49.         raise SoundsetException('soundset %r is missing %r' % (name, DESC_FILENAME))
  50.     
  51.     
  52.     try:
  53.         f = _[2]
  54.         soundset = syck.load(f)
  55.     finally:
  56.         pass
  57.  
  58.     if soundset is None:
  59.         raise SoundsetException('soundset %r is empty' % name)
  60.     
  61.     underscores_to_dots(soundset)
  62.     fix_paths(soundset, set_dir)
  63.     return Soundset(soundset)
  64.  
  65.  
  66. def list_soundsets():
  67.     import stdpaths
  68.     paths = [
  69.         stdpaths.userdata / 'sounds',
  70.         stdpaths.config / 'sounds',
  71.         skin.resourcedir() / 'sounds']
  72.     soundsets = []
  73.     for pth in paths:
  74.         for dir in pth.dirs():
  75.             if (dir / DESC_FILENAME).exists():
  76.                 soundsets.append((dir.name, dir))
  77.                 continue
  78.         
  79.     
  80.     return soundsets
  81.  
  82.