本文整理匯總了Python中configuration.Config.set方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.set方法的具體用法?Python Config.set怎麽用?Python Config.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類configuration.Config
的用法示例。
在下文中一共展示了Config.set方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test5
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def test5(self):
s = Config()
s.from_dict({
'root':'/path/to/root/',
'filter':'*.jpg'
})
c = Config()
c.set('static_files', s)
self.assertDictEqual(c.get('static_files'), {
'root':'/path/to/root/',
'filter':'*.jpg'
})
示例2: __init__
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
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")
示例3: deleteControl
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def deleteControl(control):
VFS.unlink(_makeControllerIniName(control))
defaultUsed = -1
for i in range(4):
get = Config.get("game", "control%d" % i)
if get == control:
if i == 0:
Config.set("game", "control%d" % i, "defaultg")
defaultUsed = 0
else:
Config.set("game", "control%d" % i, None)
if get == "defaultg" and defaultUsed > -1:
Config.set("game", "control%d" % i, None)
loadControls()
示例4: test3
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def test3(self):
c = Config()
c.set('test','value')
self.assertEqual(c.get('test'), 'value')
示例5: __init__
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def __init__(self):
self.logClassInits = Config.get("game", "log_class_inits")
if self.logClassInits == 1:
Log.debug("Controls class init (Player.py)...")
self.controls = []
self.controls.append(Config.get("game", "control0"))
self.controls.append(Config.get("game", "control1"))
self.controls.append(Config.get("game", "control2"))
self.controls.append(Config.get("game", "control3"))
self.config = []
self.controlList = []
self.maxplayers = 0
self.guitars = 0
self.drums = 0
self.mics = 0
self.overlap = []
self.p2Nav = Config.get("game", "p2_menu_nav")
self.drumNav = Config.get("game", "drum_navigation")
self.keyCheckerMode = Config.get("game","key_checker_mode")
if VFS.isfile(_makeControllerIniName(self.controls[0])):
self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[0])), type = 1))
if VFS.isfile(_makeControllerIniName(self.controls[1])) and self.controls[1] != "None":
self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[1])), type = 1))
else:
self.config.append(None)
Config.set("game", "control1", None)
self.controls[1] = "None"
if VFS.isfile(_makeControllerIniName(self.controls[2])) and self.controls[2] != "None":
self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[2])), type = 1))
else:
self.config.append(None)
Config.set("game", "control2", None)
self.controls[2] = "None"
if VFS.isfile(_makeControllerIniName(self.controls[3])) and self.controls[3] != "None":
self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName(self.controls[3])), type = 1))
else:
self.config.append(None)
Config.set("game", "control3", None)
self.controls[3] = "None"
else:
confM = None
if Microphone.supported:
confM = Config.load(VFS.resolveRead(_makeControllerIniName("defaultm")), type = 1)
self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName("defaultg")), type = 1))
self.config.append(Config.load(VFS.resolveRead(_makeControllerIniName("defaultd")), type = 1))
self.config.append(confM)
self.config.append(None)
Config.set("game", "control0", "defaultg")
Config.set("game", "control1", "defaultd")
self.controls = ["defaultg", "defaultd"]
if confM is not None:
Config.set("game", "control2", "defaultm")
self.controls.append("defaultm")
else:
Config.set("game", "control2", None)
self.controls.append("None")
Config.set("game", "control3", None)
self.controls.append("None")
self.type = []
self.analogKill = []
self.analogSP = []
self.analogSPThresh = []
self.analogSPSense = []
self.analogDrum = [] #FIXME: Analog Drum
self.analogSlide = []
self.analogFX = [] #FIXME: Analog FX
self.twoChord = []
self.micDevice = [] #stump
self.micTapSensitivity = []
self.micPassthroughVolume = []
self.flags = 0
for i in self.config:
if i:
type = i.get("controller", "type")
if type == 5:
self.mics += 1
elif type > 1:
self.guitars += 1
else:
self.drums += 1
self.type.append(type)
self.analogKill.append(i.get("controller", "analog_kill"))
self.analogSP.append(i.get("controller", "analog_sp"))
self.analogSPThresh.append(i.get("controller", "analog_sp_threshold"))
self.analogSPSense.append(i.get("controller", "analog_sp_sensitivity"))
self.analogDrum.append(i.get("controller", "analog_drum")) #FIXME: Analog Drum
self.analogSlide.append(i.get("controller", "analog_slide"))
self.analogFX.append(i.get("controller", "analog_fx")) #FIXME: Analog FX
self.micDevice.append(i.get("controller", "mic_device")) #stump
self.micTapSensitivity.append(i.get("controller", "mic_tap_sensitivity"))
self.micPassthroughVolume.append(i.get("controller", "mic_passthrough_volume"))
self.twoChord.append(i.get("controller", "two_chord_max"))
self.controlList.append(i.get("controller", "name"))
#.........這裏部分代碼省略.........
示例6: renameControl
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def renameControl(control, newname):
VFS.rename(_makeControllerIniName(control), _makeControllerIniName(newname))
for i in range(4):
if Config.get("game", "control%d" % i) == control:
Config.set("game", "control%d" % i, newname)
loadControls()
示例7: __init__
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def __init__(self, resource, svg):
self.logClassInits = Config.get("game", "log_class_inits")
if self.logClassInits == 1:
Log.debug("Data class init (Data.py)...")
self.logLoadings = Config.get("game", "log_loadings")
self.logImageNotFound = Config.get("log", "log_image_not_found")
self.resource = resource
self.svg = svg
self.sfxVolume = Config.get("audio", "SFX_volume")
self.crowdVolume = Config.get("audio", "crowd_volume")
# Get theme
themename = Config.get("coffee", "themename")
self.themeLabel = themename
self.themeCoOp = False
self.players = None
self.players = Player.loadPlayers()
# myfingershurt: check for existence of theme path
themepath = os.path.join(Version.dataPath(), "themes")
self.themepath = themepath
self.path = Version.dataPath()
if not self.checkImgDrawing(os.path.join("themes", themename, "notes", "notes.png")):
# myfingershurt: here need to ensure an existing theme is selected
themes = []
defaultTheme = None # myfingershurt
allthemes = os.listdir(themepath)
for name in allthemes:
if self.checkImgDrawing(os.path.join("themes", name, "notes", "notes.png")):
themes.append(name)
if name == "MegaLight V4": # myfingershurt
defaultTheme = name # myfingershurt
if defaultTheme != "MegaLight V4": # myfingershurt
defaultTheme = themes[0] # myfingershurt
# not a valid theme if notes.png isn't there! Force default theme:
Config.set("coffee", "themename", defaultTheme)
# re-init Data with new default
themename = defaultTheme
self.themeLabel = themename
if not os.path.exists(os.path.join(Version.dataPath(), "themes", themename, "vocals")):
self.vocalPath = "vocals"
else:
self.vocalPath = os.path.join("themes", themename, "vocals")
self.theme = 2
self.themeCoOp = True
self.fontScreenBottom = (
0.75
) # from our current viewport's constant 3:4 aspect ratio (which is always stretched to fill the video resolution)
self.loadPartImages()
# myfingershurt: multi-OS compatibility file access fixes using os.path.join()
# load font customization images
# Worldrave - Use new defined Star3 and star4. Using star1 and star2 as a fallback.
# MFH - no more custom glyphs, these are wasting memory.
# MFH - but we do need these star1-4 images anyway. Leaving them loaded here in the Data object.
self.loadImgDrawing(self, "star1", os.path.join("themes", themename, "star1.png"), textureSize=(128, 128))
self.loadImgDrawing(self, "star2", os.path.join("themes", themename, "star2.png"), textureSize=(128, 128))
# MFH - let's not rely on errors here if we don't have to...
if not self.loadImgDrawing(
self, "star3", os.path.join("themes", themename, "star3.png"), textureSize=(128, 128)
):
self.star3 = self.star1
if not self.loadImgDrawing(
self, "star4", os.path.join("themes", themename, "star4.png"), textureSize=(128, 128)
):
self.star4 = self.star2
if self.loadImgDrawing(
self, "starPerfect", os.path.join("themes", themename, "starperfect.png"), textureSize=(128, 128)
):
self.perfectStars = True
self.maskStars = False
else:
self.starPerfect = self.star2
self.fcStars = False
self.starFC = self.star2
self.maskStars = True
self.perfectStars = False
if self.perfectStars:
if self.loadImgDrawing(
self, "starFC", os.path.join("themes", themename, "starfc.png"), textureSize=(128, 128)
):
self.fcStars = True
else:
self.starFC = self.starPerfect
self.fcStars = False
#.........這裏部分代碼省略.........
示例8: getAvailableLanguages
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
from util.Unicode import unicodify
Config.define("game", "language", str, "")
def getAvailableLanguages():
return [os.path.basename(l).capitalize().replace(".mo", "").replace("_", " ") for l in glob.glob(os.path.join(Version.dataPath(), "translations", "*.mo"))]
def dummyTranslator(string):
return unicodify(string)
language = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini").get("game", "language")
_ = dummyTranslator
if language:
try:
trFile = os.path.join(Version.dataPath(), "translations", "%s.mo" % language.lower().replace(" ", "_"))
catalog = gettext.GNUTranslations(open(trFile, "rb"))
def translate(m):
return catalog.ugettext(m)
_ = translate
except Exception, x:
Log.warn("Unable to select language '%s': %s" % (language, x))
language = None
Config.set("game", "language", "")
# Define the config key again now that we have some options for it
langOptions = {"": "English"}
for lang in getAvailableLanguages():
langOptions[lang] = _(lang)
Config.define("game", "language", str, "", _("Language"), langOptions, tipText = _("Change the game language!"))
示例9: __init__
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
def __init__(self, engine):
self.engine = engine
self.logClassInits = Config.get("game", "log_class_inits")
if self.logClassInits == 1:
Log.debug("MainMenu class init (MainMenu.py)...")
self.time = 0.0
self.nextLayer = None
self.visibility = 0.0
self.active = False
self.showStartupMessages = False
self.gfxVersionTag = Config.get("game", "gfx_version_tag")
self.chosenNeck = Config.get("game", "default_neck")
exists = 0
if engine.loadImgDrawing(self, "ok", os.path.join("necks",self.chosenNeck+".png")):
exists = 1
elif engine.loadImgDrawing(self, "ok", os.path.join("necks","Neck_"+self.chosenNeck+".png")):
exists = 1
#MFH - fallback logic now supports a couple valid default neck filenames
#MFH - check for Neck_1
if exists == 0:
if engine.loadImgDrawing(self, "ok", os.path.join("necks","Neck_1.png")):
Config.set("game", "default_neck", "1")
Log.warn("Default chosen neck not valid; fallback Neck_1.png forced.")
exists = 1
#MFH - check for defaultneck
if exists == 0:
if engine.loadImgDrawing(self, "ok", os.path.join("necks","defaultneck.png")):
Log.warn("Default chosen neck not valid; fallback defaultneck.png forced.")
Config.set("game", "default_neck", "defaultneck")
exists = 1
else:
Log.error("Default chosen neck not valid; fallbacks Neck_1.png and defaultneck.png also not valid!")
#Get theme
self.theme = self.engine.data.theme
self.themeCoOp = self.engine.data.themeCoOp
self.themename = self.engine.data.themeLabel
self.useSoloMenu = self.engine.theme.use_solo_submenu
allowMic = True
self.menux = self.engine.theme.menuPos[0]
self.menuy = self.engine.theme.menuPos[1]
self.rbmenu = self.engine.theme.menuRB
#MFH
self.main_menu_scale = self.engine.theme.main_menu_scaleVar
self.main_menu_vspacing = self.engine.theme.main_menu_vspacingVar
if not self.engine.loadImgDrawing(self, "background", os.path.join("themes",self.themename,"menu","mainbg.png")):
self.background = None
self.engine.loadImgDrawing(self, "BGText", os.path.join("themes",self.themename,"menu","maintext.png"))
self.engine.loadImgDrawing(self, "optionsBG", os.path.join("themes",self.themename,"menu","optionsbg.png"))
self.engine.loadImgDrawing(self, "optionsPanel", os.path.join("themes",self.themename,"menu","optionspanel.png"))
#racer: added version tag
if self.gfxVersionTag or self.engine.theme.versiontag == True:
if not self.engine.loadImgDrawing(self, "version", os.path.join("themes",self.themename,"menu","versiontag.png")):
if not self.engine.loadImgDrawing(self, "version", "versiontag.png"): #falls back on default versiontag.png in data\ folder
self.version = None
else:
self.version = None
#myfingershurt: random main menu music function, menu.ogg and menuXX.ogg (any filename with "menu" as the first 4 letters)
self.files = None
filepath = self.engine.getPath(os.path.join("themes",self.themename,"sounds"))
if os.path.isdir(filepath):
self.files = []
allfiles = os.listdir(filepath)
for name in allfiles:
if os.path.splitext(name)[1] == ".ogg":
if string.find(name,"menu") > -1:
self.files.append(name)
if self.files:
i = random.randint(0,len(self.files)-1)
filename = self.files[i]
sound = os.path.join("themes",self.themename,"sounds",filename)
self.menumusic = True
engine.menuMusic = True
self.song = Audio.Music(self.engine.resource.fileName(sound))
self.song.setVolume(self.engine.config.get("audio", "menu_volume"))
self.song.play(0) #no loop
else:
self.menumusic = False
self.opt_text_color = self.engine.theme.opt_text_colorVar
self.opt_selected_color = self.engine.theme.opt_selected_colorVar
#.........這裏部分代碼省略.........
示例10: int
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import set [as 別名]
nbrplayers = int(arg)
# Load the configuration file.
if configFile is not None:
if configFile.lower() == "reset":
fileName = os.path.join(VFS.getWritableResourcePath(), Version.PROGRAM_UNIXSTYLE_NAME + ".ini")
os.remove(fileName)
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
else:
config = Config.load(configFile, setAsDefault = True)
else:
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
#Lysdestic - Allow support for manipulating fullscreen via CLI
if fullscreen is not None:
Config.set("video", "fullscreen", fullscreen)
#Lysdestic - Change resolution from CLI
if resolution is not None:
Config.set("video", "resolution", resolution)
#Lysdestic - Alter theme from CLI
if theme is not None:
Config.set("coffee", "themename", theme)
engine = GameEngine(config)
engine.cmdPlay = 0
# Check for a valid invocation of one-shot mode.
if playing is not None:
Log.debug('Validating song directory for one-shot mode.')