def _getSound(playCmdSounds, prefs, prefName): noPlay = Sound.NoPlay() if not playCmdSounds: return noPlay soundPref = prefs.getPrefVar(prefName) if soundPref is None: sys.stderr.write("StatusBar cannot play %r; no such preference" % prefName) return noPlay elif not hasattr(soundPref, "play"): sys.stderr.write( "StatusBar cannot play %r; preference exists but is not a sound" % prefName) return noPlay return soundPref