Remove trailing whitespaces.
This commit is contained in:
parent
310e2cc347
commit
27b3592e16
1 changed files with 899 additions and 899 deletions
|
|
@ -40,7 +40,7 @@ SAVEFILE_DATABASE="/sat.db"
|
|||
class Params():
|
||||
"""This class manage parameters with xml"""
|
||||
### TODO: add desciption in params
|
||||
|
||||
|
||||
#TODO: move Watched in a plugin
|
||||
default_xml = u"""
|
||||
<params>
|
||||
|
|
@ -84,7 +84,7 @@ class Params():
|
|||
source_set = set(source_map.keys())
|
||||
dest_set = set(dest_map.keys())
|
||||
to_add = source_set.difference(dest_set)
|
||||
|
||||
|
||||
for node_key in to_add:
|
||||
dest_node.appendChild(source_map[node_key].cloneNode(True))
|
||||
|
||||
|
|
@ -97,12 +97,12 @@ class Params():
|
|||
self.dom = minidom.parse(xml_file)
|
||||
default_dom = minidom.parseString(Params.default_xml.encode('utf-8'))
|
||||
self._mergeParams(default_dom.documentElement, self.dom.documentElement)
|
||||
|
||||
|
||||
def loadGenParams(self):
|
||||
"""Load general parameters data from storage
|
||||
@return: deferred triggered once params are loaded"""
|
||||
return self.storage.loadGenParams(self.params_gen)
|
||||
|
||||
|
||||
def loadIndParams(self, profile, cache=None):
|
||||
"""Load individual parameters
|
||||
set self.params cache or a temporary cache
|
||||
|
|
@ -112,7 +112,7 @@ class Params():
|
|||
if cache == None:
|
||||
self.params[profile] = {}
|
||||
return self.storage.loadIndParams(self.params[profile] if cache==None else cache, profile)
|
||||
|
||||
|
||||
def purgeProfile(self, profile):
|
||||
"""Remove cache data of a profile
|
||||
@param profile: %(doc_profile)s"""
|
||||
|
|
@ -279,7 +279,7 @@ class Params():
|
|||
@param category: category of the parameter
|
||||
@param attr: name of the attribute (default: "value")
|
||||
@param profile: owner of the param (@ALL@ for everyone)
|
||||
|
||||
|
||||
@return: attribute"""
|
||||
#FIXME: looks really dirty and buggy, need to be reviewed/refactored
|
||||
node = self.__getParamNode(name, category)
|
||||
|
|
@ -290,19 +290,19 @@ class Params():
|
|||
if node[0] == 'general':
|
||||
value = self.__getParam(None, category, name, 'general')
|
||||
return self.__getAttr(node[1], attr, value)
|
||||
|
||||
|
||||
assert(node[0] == 'individual')
|
||||
|
||||
profile = self.getProfileName(profile_key)
|
||||
if not profile:
|
||||
error(_('Requesting a param for an non-existant profile'))
|
||||
raise exceptions.ProfileUnknownError
|
||||
|
||||
|
||||
if profile not in self.params:
|
||||
error(_('Requesting synchronous param for not connected profile'))
|
||||
raise exceptions.NotConnectedProfileError(profile)
|
||||
|
||||
if attr == "value":
|
||||
if attr == "value":
|
||||
value = self.__getParam(profile, category, name)
|
||||
return self.__getAttr(node[1], attr, value)
|
||||
|
||||
|
|
@ -325,15 +325,15 @@ class Params():
|
|||
if node[0] == 'general':
|
||||
value = self.__getParam(None, category, name, 'general')
|
||||
return defer.succeed(self.__getAttr(node[1], attr, value))
|
||||
|
||||
|
||||
assert(node[0] == 'individual')
|
||||
|
||||
profile = self.getProfileName(profile_key)
|
||||
if not profile:
|
||||
error(_('Requesting a param for a non-existant profile'))
|
||||
return defer.fail()
|
||||
|
||||
if attr != "value":
|
||||
|
||||
if attr != "value":
|
||||
return defer.succeed(node[1].getAttribute(attr))
|
||||
try:
|
||||
value = self.__getParam(profile, category, name)
|
||||
|
|
@ -396,7 +396,7 @@ class Params():
|
|||
|
||||
for param_node in params:
|
||||
name = param_node.getAttribute('name')
|
||||
|
||||
|
||||
if name not in dest_params:
|
||||
dest_params[name] = param_node.cloneNode(True)
|
||||
dest_cat.appendChild(dest_params[name])
|
||||
|
|
@ -407,8 +407,8 @@ class Params():
|
|||
if new_node:
|
||||
prof_xml.documentElement.appendChild(dest_cat)
|
||||
return prof_xml
|
||||
|
||||
|
||||
|
||||
|
||||
if self.params.has_key(profile):
|
||||
d = defer.succeed(None)
|
||||
profile_cache = self.params[profile]
|
||||
|
|
@ -435,13 +435,13 @@ class Params():
|
|||
if not profile:
|
||||
error(_("Asking params for inexistant profile"))
|
||||
return ""
|
||||
|
||||
|
||||
def returnXML(prof_xml):
|
||||
return_xml = prof_xml.toxml()
|
||||
prof_xml.unlink()
|
||||
return return_xml
|
||||
|
||||
return self.__constructProfileXml(profile).addCallback(returnXML)
|
||||
return self.__constructProfileXml(profile).addCallback(returnXML)
|
||||
|
||||
def getParamsForCategory(self, category, profile_key):
|
||||
"""Return node's xml for selected category"""
|
||||
|
|
@ -460,7 +460,7 @@ class Params():
|
|||
|
||||
prof_xml.unlink()
|
||||
return "<category />"
|
||||
|
||||
|
||||
d = self.__constructProfileXml(profile)
|
||||
return d.addCallback(returnCategoryXml)
|
||||
|
||||
|
|
@ -475,7 +475,7 @@ class Params():
|
|||
@return: a tuple with the node type and the the node, or None if not found"""
|
||||
|
||||
for type_node in self.dom.documentElement.childNodes:
|
||||
if ( ((_type == "@ALL@" or _type == "@GENERAL@") and type_node.nodeName == 'general')
|
||||
if ( ((_type == "@ALL@" or _type == "@GENERAL@") and type_node.nodeName == 'general')
|
||||
or ( (_type == "@ALL@" or _type == "@INDIVIDUAL@") and type_node.nodeName == 'individual') ):
|
||||
for node in type_node.getElementsByTagName('category'):
|
||||
if node.getAttribute("name") == category:
|
||||
|
|
@ -484,7 +484,7 @@ class Params():
|
|||
if param.getAttribute("name") == name:
|
||||
return (type_node.nodeName, param)
|
||||
return None
|
||||
|
||||
|
||||
def getParamsCategories(self):
|
||||
"""return the categories availables"""
|
||||
categories=[]
|
||||
|
|
@ -507,7 +507,7 @@ class Params():
|
|||
if not node:
|
||||
error(_('Requesting an unknown parameter (%(category)s/%(name)s)') % {'category':category, 'name':name})
|
||||
return
|
||||
|
||||
|
||||
if node[0] == 'general':
|
||||
self.params_gen[(category, name)] = value
|
||||
self.storage.setGenParam(category, name, value)
|
||||
|
|
@ -515,10 +515,10 @@ class Params():
|
|||
if self.host.isConnected(profile):
|
||||
self.host.bridge.paramUpdate(name, value, category, profile)
|
||||
return
|
||||
|
||||
|
||||
assert (node[0] == 'individual')
|
||||
assert (profile_key != "@NONE@")
|
||||
|
||||
|
||||
_type = node[1].getAttribute("type")
|
||||
if _type=="button":
|
||||
print "clique",node.toxml()
|
||||
|
|
@ -533,7 +533,7 @@ class Memory:
|
|||
|
||||
def __init__(self, host):
|
||||
info (_("Memory manager init"))
|
||||
self.initialized = defer.Deferred()
|
||||
self.initialized = defer.Deferred()
|
||||
self.host = host
|
||||
self.entitiesCache={} #XXX: keep presence/last resource/other data in cache
|
||||
# /!\ an entity is not necessarily in roster
|
||||
|
|
@ -611,7 +611,7 @@ class Memory:
|
|||
@param profile: %(doc_profile)s"""
|
||||
info(_("[%s] Profile session started" % profile))
|
||||
self.entitiesCache[profile] = {}
|
||||
|
||||
|
||||
def purgeProfileSession(self, profile):
|
||||
"""Delete cache of data of profile
|
||||
@param profile: %(doc_profile)s"""
|
||||
|
|
@ -628,7 +628,7 @@ class Memory:
|
|||
#TODO: need to encrypt files (at least passwords !) and set permissions
|
||||
param_file_xml = os.path.expanduser(self.getConfig('','local_dir')+
|
||||
self.host.get_const('savefile_param_xml'))
|
||||
|
||||
|
||||
self.params.save_xml(param_file_xml)
|
||||
debug(_("params saved"))
|
||||
|
||||
|
|
@ -647,13 +647,13 @@ class Memory:
|
|||
@param name: Profile name
|
||||
"""
|
||||
return self.params.createProfile(name)
|
||||
|
||||
|
||||
def asyncCreateProfile(self, name):
|
||||
"""Create a new profile
|
||||
@param name: Profile name
|
||||
"""
|
||||
return self.params.asyncCreateProfile(name)
|
||||
|
||||
|
||||
def deleteProfile(self, name):
|
||||
"""Delete an existing profile
|
||||
@param name: Name of the profile"""
|
||||
|
|
@ -674,7 +674,7 @@ class Memory:
|
|||
if not self.server_features.has_key(profile):
|
||||
self.server_features[profile] = []
|
||||
self.server_features[profile].append(feature)
|
||||
|
||||
|
||||
def addServerIdentity(self, category, _type, entity, profile):
|
||||
"""Add an identity discovered from server
|
||||
@param feature: string of the feature
|
||||
|
|
@ -727,7 +727,7 @@ class Memory:
|
|||
return self.entitiesCache[profile][entity]["last_resource"]
|
||||
except KeyError:
|
||||
return ""
|
||||
|
||||
|
||||
def getPresenceStatus(self, profile_key):
|
||||
profile = self.getProfileName(profile_key)
|
||||
if not profile:
|
||||
|
|
@ -782,7 +782,7 @@ class Memory:
|
|||
if there is no value of a given key, resulting dict will
|
||||
have nothing with that key nether
|
||||
@raise: exceptions.UnknownEntityError if entity is not in cache
|
||||
exceptions.ProfileNotInCacheError if profile is not in cache
|
||||
exceptions.ProfileNotInCacheError if profile is not in cache
|
||||
"""
|
||||
profile = self.getProfileName(profile_key)
|
||||
if not profile:
|
||||
|
|
@ -819,14 +819,14 @@ class Memory:
|
|||
if not self.subscriptions.has_key(profile):
|
||||
self.subscriptions[profile] = {}
|
||||
self.subscriptions[profile][entity_jid] = _type
|
||||
|
||||
|
||||
def delWaitingSub(self, entity_jid, profile_key):
|
||||
"""Called when a subcription request is finished"""
|
||||
profile = self.getProfileName(profile_key)
|
||||
assert(profile)
|
||||
if self.subscriptions.has_key(profile) and self.subscriptions[profile].has_key(entity_jid):
|
||||
del self.subscriptions[profile][entity_jid]
|
||||
|
||||
|
||||
def getWaitingSub(self, profile_key):
|
||||
"""Called to get a list of currently waiting subscription requests"""
|
||||
profile = self.getProfileName(profile_key)
|
||||
|
|
@ -835,38 +835,38 @@ class Memory:
|
|||
return {}
|
||||
if not self.subscriptions.has_key(profile):
|
||||
return {}
|
||||
|
||||
|
||||
return self.subscriptions[profile]
|
||||
|
||||
def getStringParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
return self.params.getStringParamA(name, category, attr, profile_key)
|
||||
|
||||
|
||||
def getParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
return self.params.getParamA(name, category, attr, profile_key)
|
||||
|
||||
|
||||
def asyncGetParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
return self.params.asyncGetParamA(name, category, attr, profile_key)
|
||||
|
||||
|
||||
def asyncGetStringParamA(self, name, category, attr="value", profile_key='@DEFAULT@'):
|
||||
return self.params.asyncGetStringParamA(name, category, attr, profile_key)
|
||||
|
||||
|
||||
def getParamsUI(self, profile_key):
|
||||
return self.params.getParamsUI(profile_key)
|
||||
|
||||
|
||||
def getParams(self, profile_key):
|
||||
return self.params.getParams(profile_key)
|
||||
|
||||
return self.params.getParams(profile_key)
|
||||
|
||||
def getParamsForCategory(self, category, profile_key):
|
||||
return self.params.getParamsForCategory(category, profile_key)
|
||||
|
||||
return self.params.getParamsForCategory(category, profile_key)
|
||||
|
||||
def getParamsCategories(self):
|
||||
return self.params.getParamsCategories()
|
||||
|
||||
|
||||
def setParam(self, name, value, category, profile_key):
|
||||
return self.params.setParam(name, value, category, profile_key)
|
||||
|
||||
def importParams(self, xml):
|
||||
return self.params.importParams(xml)
|
||||
|
||||
|
||||
def setDefault(self, name, category, callback, errback=None):
|
||||
return self.params.setDefault(name, category, callback, errback)
|
||||
|
|
|
|||
Loading…
Reference in a new issue