本文整理汇总了Python中fife.extensions.serializers.simplexml.SimpleXMLSerializer.getModuleNameList方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLSerializer.getModuleNameList方法的具体用法?Python SimpleXMLSerializer.getModuleNameList怎么用?Python SimpleXMLSerializer.getModuleNameList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fife.extensions.serializers.simplexml.SimpleXMLSerializer
的用法示例。
在下文中一共展示了SimpleXMLSerializer.getModuleNameList方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_project
# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import getModuleNameList [as 别名]
def load_project(self, filepath):
"""Tries to load a project
Args:
filepath: The path to the project file.
Returns: True of the project was loaded. False if not."""
try:
self.clear()
except Exception as error: # pylint: disable=broad-except
print(error)
settings = SimpleXMLSerializer()
try:
settings.load(filepath)
except (InvalidFormat, ET.ParseError):
return False
if "fife-rpg" in settings.getModuleNameList():
self.project = settings
project_dir = str(os.path.normpath(os.path.split(filepath)[0]))
self.engine.getVFS().addNewSource(project_dir)
self.project_source = project_dir
self.project_dir = project_dir
self.load_project_settings()
self.changed_maps = []
self.project_changed = False
self.entity_changed = False
try:
old_dir = os.getcwd()
os.chdir(self.project_dir)
self.load_maps()
os.chdir(old_dir)
except: # pylint: disable=bare-except
pass
return True
return False
示例2: Setting
# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import getModuleNameList [as 别名]
#.........这里部分代码省略.........
'LogModules':['controller','script'],
'FrameLimitEnabled':False, 'FrameLimit':60,
'MouseSensitivity':0.0,
'MouseAcceleration':False
}
# has the settings file been read
self._readSettingsCompleted = {}
# the global dictionary from which we will read after self._readSettingsCompleted is True
self._settingsFromFile = {}
# the logger needed to write in log file. It will be initialized in this file when self.getSettings()
# method is called by logger
self._logger = None
#default settings
self._resolutions = self._validSetting['FIFE']['ScreenResolution']
self._renderbackends = self._validSetting['FIFE']['RenderBackend']
self._lightingmodels = self._validSetting['FIFE']['Lighting']
#Used to stylize the options gui
self._gui_style = "default"
#Initialize the serializer
if serializer:
self._serializer = serializer
else:
self._serializer = SimpleXMLSerializer()
self.initSerializer()
# Get all modules and initialize reading of them from xml file as false
self._allModules = self._serializer.getModuleNameList()
# print("All Module Names:",self._allModules)
for module in self._allModules:
self._readSettingsCompleted[module] = False
self._initDefaultSettingEntries()
#self.setOneSetting('FIFE','Font','fonts/FreeSans.ttf',False)
#print self.getSettingsFromFile('unknownhorizons')
# set all Settings in either validSetting or defaultSetting
def setAllSettings(self,module,settings,validSetting = True):
if validSettings:
self._validSetting[module] = settings
else:
self._defaultSetting[module] = settings
# set an entry in the validSetting or defaultSetting dictionary
def setOneSetting(self,module,name,value,validSetting = True):
if validSetting:
self._validSetting[module][name] = value
else:
self._defaultSetting[module][name] = value
# get all the Settings(either validSetting or defaultSetting)
def getAllSettings(self,module,validSetting = True):
if validSetting:
return self._validSetting[module]
else:
return self._defaultSetting[module]
# get an entry from either validSetting or defaultSetting