本文整理汇总了Python中fife.extensions.serializers.simplexml.SimpleXMLSerializer.remove方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLSerializer.remove方法的具体用法?Python SimpleXMLSerializer.remove怎么用?Python SimpleXMLSerializer.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fife.extensions.serializers.simplexml.SimpleXMLSerializer
的用法示例。
在下文中一共展示了SimpleXMLSerializer.remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Setting
# 需要导入模块: from fife.extensions.serializers.simplexml import SimpleXMLSerializer [as 别名]
# 或者: from fife.extensions.serializers.simplexml.SimpleXMLSerializer import remove [as 别名]
#.........这里部分代码省略.........
@param name: Setting name
@param defaultValue: Specifies the default value to return if the setting is not found
@type defaultValue: C{str} or C{unicode} or C{int} or C{float} or C{bool} or C{list} or C{dict}
"""
if self._serializer:
if module is "FIFE":
# check whether getAllSettings has been called already
if self._readSettingsCompleted[module] is not True:
value = self._serializer.get(module, name, defaultValue)
if value is not None:
return value
else:
if name in self._defaultSetting[module]:
return self._defaultSetting[module][name]
else:
raise Exception(str(name) + ' is neither in settings.xml nor it has a default value set')
else:
if name in self._settingsFromFile[module]:
return self._settingsFromFile[module][name]
else:
raise Exception(str(name) + ' is neither in settings.xml nor it has a default value set')
else:
return self._serializer.get(module, name, defaultValue)
else:
"""
serializer not set, reading from default value
"""
if name in self._defaultSetting:
return self._defaultSetting[module][name]
else:
raise Exception(str(name) + ' is neither in settings.xml nor it has a default value set')
def set(self, module, name, value, extra_attrs={}):
"""
Sets a setting to specified value.
@param module: Module where the setting should be set
@param name: Name of setting
@param value: Value to assign to setting
@type value: C{str} or C{unicode} or C{int} or C{float} or C{bool} or C{list} or C{dict}
@param extra_attrs: Extra attributes to be stored in the XML-file
@type extra_attrs: C{dict}
"""
#update the setting cache
if module in self._settingsFromFile:
self._settingsFromFile[module][name] = value
else:
self._settingsFromFile[module] = { name: value }
if self._serializer:
self._serializer.set(module, name, value, extra_attrs)
def remove(self, module, name):
"""
Removes a variable
@param module: Module where the variable should be set
@param name: Name of the variable
"""
#update the setting cache
if module in self._settingsFromFile:
del self._settingsFromFile[module][name]
if self._serializer:
self._serializer.remove(module, name)
def setAvailableScreenResolutions(self, reslist):
"""
A list of valid default screen resolutions. This should be called once
right after you instantiate Settings.
Valid screen resolutions must be strings in the form of: WIDTHxHEIGHT
Example:
settings.setAvailableScreenResolutions(["800x600", "1024x768"])
"""
self._resolutions = reslist
def setDefaults(self):
"""
Overwrites the setting file with the default settings file.
"""
shutil.copyfile(self._default_settings_file, os.path.join(self._appdata, self._settings_file))
self.changesRequireRestart = True
self.initSerializer()
def _getEntries(self):
return self._entries
def _setEntries(self, entries):
self._entries = entries
def _getSerializer(self):
return self._serializer
entries = property(_getEntries, _setEntries)
serializer = property(_getSerializer)