本文整理匯總了Python中configuration.Config類的典型用法代碼示例。如果您正苦於以下問題:Python Config類的具體用法?Python Config怎麽用?Python Config使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Config類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SetAllSoundFxObjectVolumes
def SetAllSoundFxObjectVolumes(
self, volume=None
): # MFH - single function to go through all sound objects (and iterate through all sound lists) and set object volume to the given volume
# MFH TODO - set every sound object's volume here...
if volume is None:
self.sfxVolume = Config.get("audio", "SFX_volume")
self.crowdVolume = Config.get("audio", "crowd_volume")
volume = self.sfxVolume
self.starDingSound.setVolume(volume)
self.bassDrumSound.setVolume(volume)
self.T1DrumSound.setVolume(volume)
self.T2DrumSound.setVolume(volume)
self.T3DrumSound.setVolume(volume)
self.CDrumSound.setVolume(volume)
for s in self.acceptSounds:
s.setVolume(volume)
for s in self.cancelSounds:
s.setVolume(volume)
self.rockSound.setVolume(volume)
self.starDeActivateSound.setVolume(volume)
self.starActivateSound.setVolume(volume)
self.battleUsedSound.setVolume(volume)
self.rescueSound.setVolume(volume)
self.coOpFailSound.setVolume(volume)
self.crowdSound.setVolume(self.crowdVolume)
self.starReadySound.setVolume(volume)
self.clapSound.setVolume(volume)
self.failSound.setVolume(volume)
self.starSound.setVolume(volume)
self.startSound.setVolume(volume)
self.selectSound1.setVolume(volume)
self.selectSound2.setVolume(volume)
self.selectSound3.setVolume(volume)
示例2: test2
def test2(self):
c = Config()
c.from_dict({
'static_files': {
'root':'/path/to/root/',
'filter':'*.jpg'
},
'users':{
'id_property':'email',
'data_dir':'/data/system/userdata/'
},
})
self.assertDictEqual(c['users'], {
'id_property':'email',
'data_dir':'/data/system/userdata/'
})
self.assertDictEqual(c['static_files'], {
'root':'/path/to/root/',
'filter':'*.jpg'
})
示例3: ConfigDialog
class ConfigDialog(QtGui.QDialog):
def __init__(self, parent=None):
"""Initializes the Dialog"""
self.logger = logging.getLogger('pymetadatamanager.configuration_dialog')
QtGui.QWidget.__init__(self, parent)
self.ui = Ui_ConfigDialog()
self.ui.setupUi(self)
self.config = Config()
self.ui.lineEdit_tv_dirs.setText(",".join(self.config.tv_dirs))
self.ui.lineEdit_movie_dirs.setText(",".join(self.config.movie_dirs))
self.ui.checkBox_prefer_local.setChecked(self.config.prefer_local)
self.ui.lineEdit_mediainfo_path.setText(self.config.mediainfo_path)
self.ui.pushButton_tv_browse.clicked.connect(self.tv_browser)
self.ui.pushButton_movie_browse.clicked.connect(self.movie_browser)
self.ui.pushButton_mediainfo_browse.clicked.connect(self.mediainfo_browser)
self.ui.buttonBox.accepted.connect(self.save_values)
def tv_browser(self):
old_filename = self.ui.lineEdit_tv_dirs.text()
filename = QtGui.QFileDialog.getExistingDirectory(self, "TV Directory", \
old_filename)
if not filename == '':
self.ui.lineEdit_tv_dirs.setText(filename)
else:
self.ui.lineEdit_tv_dirs.setText(old_filename)
def movie_browser(self):
old_filename = self.ui.lineEdit_movie_dirs.text()
filename = QtGui.QFileDialog.getExistingDirectory(self, "Movie Directory", \
old_filename)
if not filename == '':
self.ui.lineEdit_movie_dirs.setText(filename)
else:
self.ui.lineEdit_movie_dirs.setText(old_filename)
def mediainfo_browser(self):
old_path = self.ui.lineEdit_mediainfo_path.text()
path = QtGui.QFileDialog.getOpenFileName(self, \
"MediaInfo Path", \
os.path.expanduser("~"))
if not path == '':
self.ui.lineEdit_mediainfo_path.setText(path)
else:
self.ui.lineEdit_mediainfo_path.setText(old_path)
def save_values(self):
del self.config.tv_dirs[:]
for dir in str(self.ui.lineEdit_tv_dirs.text()).split(","):
self.config.tv_dirs.append(dir)
del self.config.movie_dirs[:]
for dir in str(self.ui.lineEdit_movie_dirs.text()).split(","):
self.config.movie_dirs.append(dir)
self.config.mediainfo_path = self.ui.lineEdit_mediainfo_path.text()
if self.ui.checkBox_prefer_local.isChecked():
self.config.prefer_local = 1
else:
self.config.prefer_local = 0
self.config.write_config_file()
示例4: init
def init(engine):
# define configuration keys for all available mods
for m in getAvailableMods(engine):
Config.define("mods", "mod_" + m, bool, False, text = m, options = {False: _("Off"), True: _("On")})
# init all active mods
for m in getActiveMods(engine):
activateMod(engine, m)
示例5: on_mainWindow_delete_event
def on_mainWindow_delete_event(self, widget, event):
# leave edit mode and persist configs to database
commands.leave_edit_mode(self)
# persist config to config file
Config.persist()
# close Database
if DB.close() == True:
return False
else:
return True
示例6: Wrapper
class Wrapper(object):
def __init__(self, config=None, file=None):
if config:
self.config = config
elif file:
self.config = Config(file)
def disabled(self):
self.config.disable()
def output(self, line):
print self.config.format(line)
示例7: loadControls
def loadControls():
global controllerDict
controllers = []
allcontrollers = VFS.listdir(controlpath)
default = ["defaultd.ini", "defaultg.ini", "defaultm.ini"]
for name in allcontrollers:
if name.lower().endswith(".ini") and len(name) > 4:
if name in default:
continue
controllers.append(name[0:len(name)-4])
i = len(controllers)
controllerDict = dict([(str(controllers[n]),controllers[n]) for n in range(0, i)])
controllerDict["defaultg"] = _("Default Guitar")
controllerDict["defaultd"] = _("Default Drum")
defMic = None
if Microphone.supported:
controllerDict["defaultm"] = _("Default Microphone")
defMic = "defaultm"
tsControl = _("Controller %d")
tsControlTip = _("Select the controller for slot %d")
i = 1
Config.define("game", "control0", str, "defaultg", text = tsControl % 1, options = controllerDict, tipText = tsControlTip % 1)
controllerDict[_("None")] = None
Config.define("game", "control1", str, "defaultd", text = tsControl % 2, options = controllerDict, tipText = tsControlTip % 2)
Config.define("game", "control2", str, defMic, text = tsControl % 3, options = controllerDict, tipText = tsControlTip % 3)
Config.define("game", "control3", str, None, text = tsControl % 4, options = controllerDict, tipText = tsControlTip % 4)
示例8: test6
def test6(self):
s = Config()
s.from_dict({
'root':'/path/to/root/',
'filter':'*.jpg'
})
c = Config()
c['static_files'] = s
self.assertDictEqual(c.get('static_files'), {
'root':'/path/to/root/',
'filter':'*.jpg'
})
示例9: setPriority
def setPriority(self, pid = None, priority = 2):
""" Set The Priority of a Windows Process. Priority is a value between 0-5 where
2 is normal priority. Default sets the priority of the current
python process but can take any valid process ID. """
import win32api, win32process, win32con
priorityClasses = [win32process.IDLE_PRIORITY_CLASS,
win32process.BELOW_NORMAL_PRIORITY_CLASS,
win32process.NORMAL_PRIORITY_CLASS,
win32process.ABOVE_NORMAL_PRIORITY_CLASS,
win32process.HIGH_PRIORITY_CLASS,
win32process.REALTIME_PRIORITY_CLASS]
threadPriorities = [win32process.THREAD_PRIORITY_IDLE,
#win32process.THREAD_PRIORITY_ABOVE_IDLE,
#win32process.THREAD_PRIORITY_LOWEST,
win32process.THREAD_PRIORITY_BELOW_NORMAL,
win32process.THREAD_PRIORITY_NORMAL,
win32process.THREAD_PRIORITY_ABOVE_NORMAL,
win32process.THREAD_PRIORITY_HIGHEST,
win32process.THREAD_PRIORITY_TIME_CRITICAL]
pid = win32api.GetCurrentProcessId()
tid = win32api.GetCurrentThread()
handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid)
win32process.SetPriorityClass(handle, priorityClasses[priority])
win32process.SetThreadPriority(tid, threadPriorities[priority])
if Config.get('performance', 'restrict_to_first_processor'):
win32process.SetProcessAffinityMask(handle, 1)
示例10: _get_hot_slice_by_threads
def _get_hot_slice_by_threads(rlbb, nav_slice):
ops_and_scores = rlbb.with_scores[nav_slice] if rlbb else []
ops = [Comment(id=id) for (id, score) in ops_and_scores]
max_from_thread = 3
# Got the OPs, now I need to bulk fetch the top replies.
pipeline = redis.pipeline()
for comment in ops:
pipeline.get(comment.redis_score.key)
for comment in ops:
pipeline.zrevrange(comment.popular_replies.key, 0, max_from_thread - 1, withscores=True)
results = pipeline.execute()
op_scores, pop_reply_lists = results[:len(ops)], results[len(ops):]
ids = []
if ops_and_scores:
# Lowest score sets the threshold, but replies get a "boost" factor
cutoff = ops_and_scores[-1][1] / Config.get('reply_boost', 1)
for op, op_score, pop_replies in zip(ops, op_scores, pop_reply_lists):
items = [(int(id), float(score or 0)) for (id,score) in [(op.id, op_score)] + pop_replies]
items.sort(key=lambda (id, score): -score)
ids += [id for (id, score) in items if score >= cutoff][:max_from_thread]
return ids
示例11: build_default
def build_default(deployment_home, cwd, CommandClasses):
"""
Create a runtime from the command line arguments and configuration on
disk.
If you want something more custom, e.g. in testing, you can build
it yourself ;)
"""
if len(CommandClasses):
arg_parser = CommandClasses[0].build_arg_parser()
else:
arg_parser = Runtime.__create_placeholder_arg_parser()
Runtime.add_default_arguments(arg_parser)
runtime = Runtime()
for CommandClass in CommandClasses:
CommandClass.register_services(runtime)
for ServiceClass in runtime.each_service_class():
add_default_arguments_method = getattr(ServiceClass, 'add_default_arguments', None)
if add_default_arguments_method and callable(add_default_arguments_method):
ServiceClass.add_default_arguments(arg_parser)
options = arg_parser.parse_args()
if not hasattr(options, 'deployment_home'):
options.deployment_home = deployment_home
config = Config()
config.set_options(options)
config.set_cwd(cwd)
if hasattr(CommandClass, 'DOTFILE_NAME'):
config.set_dotfile_name(CommandClass.DOTFILE_NAME)
try:
config.read()
except Exception as e:
if not hasattr(CommandClass, 'is_config_required') or CommandClass.is_config_required():
exc_info = sys.exc_info()
raise e, None, exc_info[2]
log = Log()
log.set_options(options)
runtime.set_options(options)
runtime.set_config(config)
runtime.set_log(log)
runtime.set_cwd(cwd)
return runtime
示例12: setUp
def setUp(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
self.e = GameEngine(config)
self.e.loadImgDrawing(self, "svg", "mfhlogo.png")
while not self.svg:
self.e.run()
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)
示例13: activateMod
def activateMod(engine, modName):
modPath = _getModPath(engine)
m = os.path.join(modPath, modName)
t = os.path.join(m, "theme.ini")
if os.path.isdir(m):
engine.resource.addDataPath(m)
if os.path.isfile(t):
theme = Config.load(t)
Theme.open(theme)
示例14: testLoading
def testLoading(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
e = GameEngine(config)
infoFile = e.resource.fileName("tutorials", "bangbang", "song.ini")
guitarFile = e.resource.fileName("tutorials", "bangbang", "guitar.ogg")
songFile = e.resource.fileName("tutorials", "bangbang", "song.ogg")
noteFile = e.resource.fileName("tutorials", "bangbang", "notes.mid")
song = Song(e, infoFile, guitarFile, songFile, None, noteFile)
assert int(song.bpm) == 120
示例15: __init__
def __init__(self, dataPath = os.path.join("..", "data")):
self.resultQueue = Queue()
self.dataPaths = [dataPath]
self.loaderSemaphore = BoundedSemaphore(value = 1)
self.loaders = []
#myfingershurt: the following should be global, and only done at startup. Not every damn time a file is loaded.
self.songPath = []
self.baseLibrary = Config.get("setlist", "base_library")
#evilynux - Support for songs in ~/.fretsonfire/songs (GNU/Linux and MacOS X)
if self.baseLibrary == "None" and os.name == "posix":
path = os.path.expanduser("~/." + Version.PROGRAM_UNIXSTYLE_NAME)
if os.path.isdir(path):
self.baseLibrary = path
Config.set("setlist", "base_library", path)
if self.baseLibrary and os.path.isdir(self.baseLibrary):
self.songPath = [self.baseLibrary]
self.logLoadings = Config.get("game", "log_loadings")