本文整理匯總了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)