本文整理匯總了Python中configuration.Config.load方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.load方法的具體用法?Python Config.load怎麽用?Python Config.load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類configuration.Config
的用法示例。
在下文中一共展示了Config.load方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: activateMod
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
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)
示例2: setUp
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
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)
示例3: testLoading
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
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
示例4: savePlayers
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def savePlayers():
for pref in _playerDB.execute('SELECT * FROM `players` WHERE `changed` = 1').fetchall():
try:
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
c.set("player","leftymode",int(pref[1]))
c.set("player","drumflip",int(pref[2]))
c.set("player","auto_kick",int(pref[3]))
c.set("player","assist_mode",int(pref[4]))
c.set("player","two_chord_max",int(pref[5]))
c.set("player","necktype",int(pref[6]))
c.set("player","neck",str(pref[7]))
c.set("player","part",int(pref[8]))
c.set("player","difficulty",int(pref[9]))
c.set("player","name",str(pref[10]))
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
except:
c = VFS.open(_makePlayerIniName(str(pref[0])), "w")
c.close()
c = Config.load(VFS.resolveWrite(_makePlayerIniName(str(pref[0]))), type = 2)
c.set("player","leftymode",int(pref[1]))
c.set("player","drumflip",int(pref[2]))
c.set("player","auto_kick",int(pref[3]))
c.set("player","assist_mode",int(pref[4]))
c.set("player","two_chord_max",int(pref[5]))
c.set("player","necktype",int(pref[6]))
c.set("player","neck",str(pref[7]))
c.set("player","part",int(pref[8]))
c.set("player","difficulty",int(pref[9]))
c.set("player","name",str(pref[10]))
c.set("player","controller",int(pref[11]))
del c
_playerDB.execute('UPDATE `players` SET `changed` = 0 WHERE `name` = ?', [pref[0]])
_playerDB.execute('UPDATE `players` SET `loaded` = 0')
_playerDB.commit()
示例5: testSaving
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def testSaving(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
e = GameEngine(config)
# Make a temp copy
tmp = "songtest_tmp"
files = ["song.ini", "guitar.ogg", "song.ogg", "notes.mid"]
try:
os.mkdir(tmp)
for f in files:
shutil.copy(e.resource.fileName("tutorials", "bangbang", f), tmp)
infoFile = os.path.join(tmp, "song.ini")
guitarFile = os.path.join(tmp, "guitar.ogg")
songFile = os.path.join(tmp, "song.ogg")
noteFile = os.path.join(tmp, "notes.mid")
song = Song(e, infoFile, guitarFile, songFile, None, noteFile)
events1 = song.track[0].getAllEvents()
song.save()
song = Song(e, infoFile, guitarFile, songFile, None, noteFile)
events2 = song.track[0].getAllEvents()
notes1 = [(time, event) for time, event in events1 if isinstance(event, Note)]
notes2 = [(time, event) for time, event in events2 if isinstance(event, Note)]
for i, event in enumerate(zip(notes1, notes2)):
t1, n1 = event[0]
t2, n2 = event[1]
if "-v" in sys.argv:
print "%8d. %.3f + %.3f\t%2d\t %.3f + %.3f\t%2d" % (i, t1, n1.length, n1.number, t2, n2.length, n2.number)
# Allow 2ms of rounding error
assert abs(t1 - t2) < 2
assert abs(n1.length - n2.length) < 2
assert n1.number == n2.number
finally:
# Load another song to free the copy
pygame.mixer.music.load(e.resource.fileName("tutorials", "bangbang", "guitar.ogg"))
shutil.rmtree(tmp)
示例6: loadPlayers
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def loadPlayers():
global playername, playerpref, playerstat
playername = []
playerpref = []
playerstat = []
allplayers = VFS.listdir(playerpath)
for name in allplayers:
if name == "default.ini":
continue
if name.lower().endswith(".ini") and len(name) > 4:
playername.append(name[0:len(name)-4])
pref = _playerDB.execute('SELECT * FROM `players` WHERE `name` = ?', [playername[-1]]).fetchone()
try:
if len(pref) == 14:
playerpref.append((pref[1], pref[2], pref[3], pref[4], pref[5], pref[6], pref[7], pref[8], pref[9], pref[10]))
except TypeError:
try:
c = Config.load(VFS.resolveRead(_makePlayerIniName(name[:-4])), type = 2)
lefty = c.get("player","leftymode")
drumf = c.get("player","drumflip")
autok = c.get("player","auto_kick")
assist = c.get("player","assist_mode")
twoch = c.get("player","two_chord_max")
neck = c.get("player","neck")
neckt = c.get("player","necktype")
part = c.get("player","part")
diff = c.get("player","difficulty")
upname = c.get("player","name")
control= c.get("player","controller")
del c
_playerDB.execute('INSERT INTO `players` VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0, 1)', [playername[-1], lefty, drumf, autok, assist, twoch, neckt, neck, part, diff, upname, control])
playerpref.append((lefty, drumf, autok, assist, twoch, neckt, neck, part, diff, upname))
except IOError:
_playerDB.execute('INSERT INTO `players` VALUES (?, 0, 0, 0, 0, 0, 0, ``, 0, 2, ``, 0, 0, 1)', [playername[-1]])
playerpref.append((0, 0, 0, 0, 0, 0, '', 0, 2, '', 0))
_playerDB.execute('UPDATE `players` SET `loaded` = 1 WHERE `name` = ?', [playername[-1]])
_playerDB.commit()
return 1
示例7: testNetworking
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def testNetworking(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
e1 = GameEngine(config)
e1.startServer()
session1 = e1.connect("localhost")
session2 = e1.connect("localhost")
while not session1.isConnected() or not session2.isConnected():
e1.run()
session1.world.createPlayer("mario")
session2.world.createPlayer("luigi")
for i in range(10):
e1.run()
assert len(e1.server.world.players) == 2
assert len(session1.world.players) == 2
assert len(session2.world.players) == 2
session3 = e1.connect("localhost")
for i in range(10):
e1.run()
assert len(session3.world.players) == 2
session1.disconnect()
for i in range(10):
e1.run()
assert len(e1.server.world.players) == 1
assert len(session2.world.players) == 1
e1.quit()
示例8: setUp
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def setUp(self):
config = Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault = True)
self.e = GameEngine(config)
示例9: __init__
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [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"))
#.........這裏部分代碼省略.........
示例10: getAvailableLanguages
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
import Version
from util import Log
import gettext
import os
import glob
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
示例11: setUp
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def setUp(self):
Config.load(Version.PROGRAM_UNIXSTYLE_NAME + ".ini", setAsDefault=True)
# Resource expects game_priority to be an integer,
# Config won't know unless we define it as such.
Config.define("performance", "game_priority", int, 2)
self.e = GameEngine()
示例12: __init__
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
def __init__(self, config = None):
Log.debug("GameEngine class init (GameEngine.py)...")
self.mainMenu = None #placeholder for main menu object - to prevent reinstantiation
self.currentScene = None
self.versionString = version #stump: other version stuff moved to allow full version string to be retrieved without instantiating GameEngine
self.uploadVersion = "%s-4.0" % Version.PROGRAM_NAME #akedrou - the version passed to the upload site.
self.dataPath = Version.dataPath()
Log.debug(self.versionString + " starting up...")
Log.debug("Python version: " + sys.version.split(' ')[0])
Log.debug("Pygame version: " + str(pygame.version.ver) )
Log.debug("PyOpenGL version: " + OpenGL.__version__)
Log.debug("Numpy version: " + np.__version__)
Log.debug("PIL version: " + Image.VERSION)
Log.debug("sys.argv: " + repr(sys.argv))
Log.debug("os.name: " + os.name)
Log.debug("sys.platform: " + sys.platform)
if os.name == 'nt':
import win32api
Log.debug("win32api.GetVersionEx(1): " + repr(win32api.GetVersionEx(1)))
elif os.name == 'posix':
Log.debug("os.uname(): " + repr(os.uname()))
"""
Constructor.
@param config: L{Config} instance for settings
"""
self.tutorialFolder = "tutorials"
if not config:
config = Config.load()
self.config = config
fps = self.config.get("video", "fps")
self.tasks = []
self.frameTasks = []
self.fps = fps
self.currentTask = None
self.paused = []
self.running = True
self.clock = pygame.time.Clock()
self.title = self.versionString
self.restartRequested = False
# evilynux - Check if theme icon exists first, then fallback on FoFiX icon.
themename = self.config.get("coffee", "themename")
themeicon = os.path.join(Version.dataPath(), "themes", themename, "icon.png")
fofixicon = os.path.join(Version.dataPath(), "fofix_icon.png")
icon = None
if os.path.exists(themeicon):
icon = themeicon
elif os.path.exists(fofixicon):
icon = fofixicon
self.video = Video(self.title, icon)
if self.config.get("video", "disable_screensaver"):
self.video.disableScreensaver()
self.audio = Audio()
self.frames = 0
self.fpsEstimate = 0
self.priority = self.config.get("engine", "highpriority")
self.show_fps = self.config.get("video", "show_fps")
self.advSettings = self.config.get("game", "adv_settings")
self.restartRequired = False
self.quicksetRestart = False
self.quicksetPerf = self.config.get("quickset", "performance")
self.scrollRate = self.config.get("game", "scroll_rate")
self.scrollDelay = self.config.get("game", "scroll_delay")
Log.debug("Initializing audio.")
frequency = self.config.get("audio", "frequency")
bits = self.config.get("audio", "bits")
stereo = self.config.get("audio", "stereo")
bufferSize = self.config.get("audio", "buffersize")
self.audio.open(frequency = frequency, bits = bits, stereo = stereo, bufferSize = bufferSize)
self.cmdPlay = 0
self.cmdMode = None
self.cmdDiff = None
self.cmdPart = None
self.gameStarted = False
self.world = None
self.audioSpeedFactor = 1.0
Log.debug("Initializing video.")
#myfingershurt: ensuring windowed mode starts up in center of the screen instead of cascading positions:
os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
width, height = [int(s) for s in self.config.get("video", "resolution").split("x")]
fullscreen = self.config.get("video", "fullscreen")
#.........這裏部分代碼省略.........
示例13: int
# 需要導入模塊: from configuration import Config [as 別名]
# 或者: from configuration.Config import load [as 別名]
if opt in ["--part", "-p"]:
part = arg
if opt in ["--diff", "-d", "-l"]:
difficulty = arg
#evilynux - Multiplayer and mode selection support
if opt in ["--mode", "-m"]:
mode = int(arg)
if opt in ["--nbrplayers", "-n"]:
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: