Mercurial > libervia-backend
diff src/memory/sqlite.py @ 587:952322b1d490
Remove trailing whitespaces.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 18 Jan 2013 17:55:34 +0100 |
parents | ca13633d3b6b |
children | beaf6bec2fcd |
line wrap: on
line diff
--- a/src/memory/sqlite.py Fri Jan 18 17:55:27 2013 +0100 +++ b/src/memory/sqlite.py Fri Jan 18 17:55:34 2013 +0100 @@ -68,7 +68,7 @@ def fillProfileCache(ignore): d = self.dbpool.runQuery("SELECT name,id FROM profiles").addCallback(self._profilesCache) d.chainDeferred(self.initialized) - + defer.DeferredList(init_defers).addCallback(fillProfileCache) #Profiles @@ -77,8 +77,8 @@ @param profiles_result: result of the sql profiles query""" for profile in profiles_result: name, id = profile - self.profiles[name] = id - + self.profiles[name] = id + def getProfilesList(self): """"Return list of all registered profiles""" return self.profiles.keys() @@ -87,23 +87,23 @@ """return True if profile_name exists @param profile_name: name of the profile to check""" return self.profiles.has_key(profile_name) - + def createProfile(self, name): """Create a new profile @param name: name of the profile @return: deferred triggered once profile is actually created""" def getProfileId(ignore): return self.dbpool.runQuery("SELECT (id) FROM profiles WHERE name = ?", (name,)) - + def profile_created(profile_id): _id = profile_id[0][0] self.profiles[name] = _id #we synchronise the cache - + d = self.dbpool.runQuery("INSERT INTO profiles(name) VALUES (?)", (name,)) d.addCallback(getProfileId) d.addCallback(profile_created) return d - + def deleteProfile(self, name): """Delete profile @param name: name of the profile @@ -126,7 +126,7 @@ for param in result: category,name,value = param params_gen[(category, name)] = value - debug(_("loading general parameters from database")) + debug(_("loading general parameters from database")) return self.dbpool.runQuery("SELECT category,name,value FROM param_gen").addCallback(fillParams) def loadIndParams(self, params_ind, profile): @@ -138,7 +138,7 @@ for param in result: category,name,value = param params_ind[(category, name)] = value - debug(_("loading individual parameters from database")) + debug(_("loading individual parameters from database")) d = self.dbpool.runQuery("SELECT category,name,value FROM param_ind WHERE profile_id=?", (self.profiles[profile],)) d.addCallback(fillParams) return d @@ -218,7 +218,7 @@ values.append(_jid.resource) return '(%s=? AND %s_res=?)' % (_type, _type) return '%s=?' % (_type,) - + if between: query_parts.append("(%s OR %s) AND (%s or %s)" % (test_jid('source', from_jid), test_jid('source', to_jid), @@ -233,7 +233,7 @@ if limit: query_parts.append("LIMIT ?") values.append(limit) - + d = self.dbpool.runQuery(" ".join(query_parts), values) return d.addCallback(sqliteToDict) @@ -247,7 +247,7 @@ for private in result: key,value = private private_gen[key] = value - debug(_("loading general private values [namespace: %s] from database") % (namespace,)) + debug(_("loading general private values [namespace: %s] from database") % (namespace,)) d = self.dbpool.runQuery("SELECT key,value FROM private_gen WHERE namespace=?", (namespace,)).addCallback(fillPrivates) return d.addErrback(lambda x: debug(_("No data present in database for namespace %s") % namespace)) @@ -273,7 +273,7 @@ @param value: value to set @return: deferred""" d = self.dbpool.runQuery("REPLACE INTO private_gen(namespace,key,value) VALUES (?,?,?)", (namespace,key,value)) - d.addErrback(lambda ignore: error(_("Can't set general private value (%(key)s) [namespace:%(namespace)s] in database" % + d.addErrback(lambda ignore: error(_("Can't set general private value (%(key)s) [namespace:%(namespace)s] in database" % {"namespace":namespace, "key":key}))) return d @@ -295,7 +295,7 @@ @param key: key of the private value @return: deferred""" d = self.dbpool.runQuery("DELETE FROM private_gen WHERE namespace=? AND key=?", (namespace,key)) - d.addErrback(lambda ignore: error(_("Can't delete general private value (%(key)s) [namespace:%(namespace)s] in database" % + d.addErrback(lambda ignore: error(_("Can't delete general private value (%(key)s) [namespace:%(namespace)s] in database" % {"namespace":namespace, "key":key}))) return d @@ -320,7 +320,7 @@ for private in result: key,value = private private_gen[key] = pickle.loads(str(value)) - debug(_("loading general private binary values [namespace: %s] from database") % (namespace,)) + debug(_("loading general private binary values [namespace: %s] from database") % (namespace,)) d = self.dbpool.runQuery("SELECT key,value FROM private_gen_bin WHERE namespace=?", (namespace,)).addCallback(fillPrivates) return d.addErrback(lambda x: debug(_("No binary data present in database for namespace %s") % namespace)) @@ -346,7 +346,7 @@ @param value: value to set @return: deferred""" d = self.dbpool.runQuery("REPLACE INTO private_gen_bin(namespace,key,value) VALUES (?,?,?)", (namespace,key,pickle.dumps(value,0))) - d.addErrback(lambda ignore: error(_("Can't set general private binary value (%(key)s) [namespace:%(namespace)s] in database" % + d.addErrback(lambda ignore: error(_("Can't set general private binary value (%(key)s) [namespace:%(namespace)s] in database" % {"namespace":namespace, "key":key}))) return d @@ -368,7 +368,7 @@ @param key: key of the private value @return: deferred""" d = self.dbpool.runQuery("DELETE FROM private_gen_bin WHERE namespace=? AND key=?", (namespace,key)) - d.addErrback(lambda ignore: error(_("Can't delete general private binary value (%(key)s) [namespace:%(namespace)s] in database" % + d.addErrback(lambda ignore: error(_("Can't delete general private binary value (%(key)s) [namespace:%(namespace)s] in database" % {"namespace":namespace, "key":key}))) return d