misc: replaced all "dummy" by the more conventional and readable "__" ("_" being used for gettext)

This commit is contained in:
Goffi 2019-01-11 11:13:15 +01:00
commit 7a9ee35cfc
5 changed files with 215 additions and 215 deletions

View file

@ -299,7 +299,7 @@ class Discovery(object):
d = self.getItems(client, jid_)
d.addCallback(gotItems)
d.addCallback(lambda dummy: found_entities)
d.addCallback(lambda __: found_entities)
reactor.callLater(
TIMEOUT, d.cancel
) # FIXME: one bad service make a general timeout
@ -338,7 +338,7 @@ class Discovery(object):
d = self.getItems(client, jid_)
d.addCallback(gotItems)
d.addCallback(lambda dummy: found_entities)
d.addCallback(lambda __: found_entities)
reactor.callLater(
TIMEOUT, d.cancel
) # FIXME: one bad service make a general timeout

View file

@ -353,14 +353,14 @@ class Memory(object):
"""
profile = self.getProfileName(profile)
def createSession(dummy):
def createSession(__):
"""Called once params are loaded."""
self._entities_cache[profile] = {}
log.info(u"[{}] Profile session started".format(profile))
return False
def backendInitialised(dummy):
def doStartSession(dummy=None):
def backendInitialised(__):
def doStartSession(__=None):
if self.isSessionStarted(profile):
log.info("Session already started!")
return True
@ -558,7 +558,7 @@ class Memory(object):
d = self.params.createProfile(name, component)
def initPersonalKey(dummy):
def initPersonalKey(__):
# be sure to call this after checking that the profile doesn't exist yet
personal_key = BlockCipher.getRandomKey(
base64=True
@ -567,24 +567,24 @@ class Memory(object):
{C.MEMORY_CRYPTO_KEY: personal_key}, profile=name
) # will be encrypted by setParam
def startFakeSession(dummy):
def startFakeSession(__):
# avoid ProfileNotConnected exception in setParam
self._entities_cache[name] = None
self.params.loadIndParams(name)
def stopFakeSession(dummy):
def stopFakeSession(__):
del self._entities_cache[name]
self.params.purgeProfile(name)
d.addCallback(initPersonalKey)
d.addCallback(startFakeSession)
d.addCallback(
lambda dummy: self.setParam(
lambda __: self.setParam(
C.PROFILE_PASS_PATH[1], password, C.PROFILE_PASS_PATH[0], profile_key=name
)
)
d.addCallback(stopFakeSession)
d.addCallback(lambda dummy: self.auth_sessions.profileDelUnique(name))
d.addCallback(lambda __: self.auth_sessions.profileDelUnique(name))
return d
def asyncDeleteProfile(self, name, force=False):
@ -596,7 +596,7 @@ class Memory(object):
@return: a Deferred instance
"""
def cleanMemory(dummy):
def cleanMemory(__):
self.auth_sessions.profileDelUnique(name)
try:
del self._entities_cache[name]
@ -1100,7 +1100,7 @@ class Memory(object):
return d.addCallback(cb)
def done(dummy):
def done(__):
log.debug(
_(u"Personal data (%(ns)s, %(key)s) has been successfuly encrypted")
% {"ns": C.MEMORY_CRYPTO_NAMESPACE, "key": data_key}

View file

@ -294,7 +294,7 @@ class Params(object):
if (
len(cat_node.childNodes) == to_remove_count
): # remove empty category
for dummy in xrange(0, to_remove_count):
for __ in xrange(0, to_remove_count):
to_remove.pop()
to_remove.append(cat_node)
for node in to_remove:
@ -714,7 +714,7 @@ class Params(object):
prof_xml.unlink()
dlist = defer.gatherResults(names_d_list)
dlist.addCallback(lambda dummy: ret)
dlist.addCallback(lambda __: ret)
return ret
d = self._constructProfileXml(security_limit, "", profile)
@ -1071,7 +1071,7 @@ class Params(object):
profile=profile,
)
d.addCallback(
lambda dummy: PasswordHasher.hash(value)
lambda __: PasswordHasher.hash(value)
) # profile password is hashed (empty value stays empty)
elif value: # other non empty passwords are encrypted with the personal key
d = BlockCipher.encrypt(personal_key, value)

View file

@ -59,7 +59,7 @@ class PersistentDict(object):
"""
d = self.storage.getPrivates(self.namespace, binary=self.binary, profile=self.profile)
d.addCallback(self._setCache)
d.addCallback(lambda dummy: self)
d.addCallback(lambda __: self)
return d
def iteritems(self):

View file

@ -289,7 +289,7 @@ class SqliteStorage(object):
def setComponent(profile_id):
id_ = profile_id[0][0]
d_comp = self.dbpool.runQuery("INSERT INTO components(profile_id, entry_point) VALUES (?, ?)", (id_, component))
d_comp.addCallback(lambda dummy: profile_id)
d_comp.addCallback(lambda __: profile_id)
return d_comp
def profile_created(profile_id):
@ -401,7 +401,7 @@ class SqliteStorage(object):
## History
def _addToHistoryCb(self, dummy, data):
def _addToHistoryCb(self, __, data):
# Message metadata were successfuly added to history
# now we can add message and subject
uid = data['uid']
@ -409,7 +409,7 @@ class SqliteStorage(object):
for lang, value in data[key].iteritems():
d = self.dbpool.runQuery("INSERT INTO {key}(history_uid, {key}, language) VALUES (?,?,?)".format(key=key),
(uid, value, lang or None))
d.addErrback(lambda dummy: log.error(_(u"Can't save following {key} in history (uid: {uid}, lang:{lang}): {value}".format(
d.addErrback(lambda __: log.error(_(u"Can't save following {key} in history (uid: {uid}, lang:{lang}): {value}".format(
key=key, uid=uid, lang=lang, value=value))))
try:
thread = data['extra']['thread']
@ -419,7 +419,7 @@ class SqliteStorage(object):
thread_parent = data['extra'].get('thread_parent')
d = self.dbpool.runQuery("INSERT INTO thread(history_uid, thread_id, parent_id) VALUES (?,?,?)",
(uid, thread, thread_parent))
d.addErrback(lambda dummy: log.error(_(u"Can't save following thread in history (uid: {uid}): thread:{thread}), parent:{parent}".format(
d.addErrback(lambda __: log.error(_(u"Can't save following thread in history (uid: {uid}): thread:{thread}), parent:{parent}".format(
uid=uid, thread=thread, parent=thread_parent))))
def _addToHistoryEb(self, failure_, data):
@ -1362,7 +1362,7 @@ class Updater(object):
if rows:
log.info("fixing duplicate timestamp")
fixed = []
for timestamp, dummy in rows:
for timestamp, __ in rows:
ids_rows = yield self.dbpool.runQuery("SELECT id from history where timestamp=?", (timestamp,))
for idx, (id_,) in enumerate(ids_rows):
fixed.append(id_)
@ -1486,7 +1486,7 @@ class Updater(object):
list_.append(d)
d_list = defer.DeferredList(list_)
d_list.addCallback(lambda dummy: ret)
d_list.addCallback(lambda __: ret)
return d_list
def updateLiberviaConf(values):
@ -1507,6 +1507,6 @@ class Updater(object):
d = self.dbpool.runQuery("SELECT id FROM profiles WHERE name='libervia'")
d.addCallback(updateLiberviaConf)
d.addCallback(lambda dummy: self.dbpool.runQuery("SELECT profile_id,value FROM param_ind WHERE category=? AND name=?", xmpp_pass_path))
d.addCallback(lambda __: self.dbpool.runQuery("SELECT profile_id,value FROM param_ind WHERE category=? AND name=?", xmpp_pass_path))
d.addCallback(encrypt_values)
return d