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
56 changed files with 215 additions and 215 deletions

View file

@ -58,7 +58,7 @@ class EmbeddedConstructor(base_constructor.Constructor):
if async_:
completion["cb_or_lambda"] = (
"callback" if function["sig_out"] else "lambda dummy: callback()"
"callback" if function["sig_out"] else "lambda __: callback()"
)
completion[
"ret_routine"

View file

@ -54,7 +54,7 @@ class _Bridge(object):
if async_:
d = self._methods_cbs[name](*args, **kwargs)
if callback is not None:
d.addCallback(callback if out_sign else lambda dummy: callback())
d.addCallback(callback if out_sign else lambda __: callback())
if errback is None:
d.addErrback(lambda failure_: log.error(failure_))
else:

View file

@ -58,7 +58,7 @@ class pbConstructor(base_constructor.Constructor):
"args_no_def": self.getArguments(function["sig_in"], name=arg_doc),
"callback": "callback"
if function["sig_out"]
else "lambda dummy: callback()",
else "lambda __: callback()",
"debug": ""
if not self.args.debug
else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "),

View file

@ -119,7 +119,7 @@ class Bridge(object):
reactor.connectTCP("localhost", 8789, factory)
d = factory.getRootObject()
d.addCallback(self._set_root)
d.addCallback(lambda dummy: callback())
d.addCallback(lambda __: callback())
d.addErrback(errback)
def register_signal(self, functionName, handler, iface="core"):

View file

@ -411,7 +411,7 @@ class SAT(service.Service):
if options is None:
options = {}
def connectProfile(dummy=None):
def connectProfile(__=None):
if self.isConnected(profile):
log.info(_("already connected !"))
return True
@ -420,7 +420,7 @@ class SAT(service.Service):
d = xmpp.SatXMPPComponent.startConnection(self, profile, max_retries)
else:
d = xmpp.SatXMPPClient.startConnection(self, profile, max_retries)
return d.addCallback(lambda dummy: False)
return d.addCallback(lambda __: False)
d = self.memory.startSession(password, profile)
d.addCallback(connectProfile)
@ -492,7 +492,7 @@ class SAT(service.Service):
def getContacts(self, profile_key):
client = self.getClient(profile_key)
def got_roster(dummy):
def got_roster(__):
ret = []
for item in client.roster.getItems(): # we get all items for client's roster
# and convert them to expected format
@ -1032,7 +1032,7 @@ class SAT(service.Service):
progress_all[profile] = progress_dict
for (
progress_id,
(dummy, progress_metadata),
(__, progress_metadata),
) in client._progress_cb.iteritems():
progress_dict[progress_id] = progress_metadata
return progress_all
@ -1052,7 +1052,7 @@ class SAT(service.Service):
profile = client.profile
progress_dict = {}
progress_all[profile] = progress_dict
for progress_id, (progress_cb, dummy) in client._progress_cb.iteritems():
for progress_id, (progress_cb, __) in client._progress_cb.iteritems():
progress_dict[progress_id] = progress_cb(progress_id, profile)
return progress_all

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

View file

@ -306,7 +306,7 @@ class BlogImportPlugin(object):
filename = filename.replace(
u"%", u"_"
) # FIXME: tmp workaround for a bug in prosody http upload
dummy, download_d = yield self._u.upload(
__, download_d = yield self._u.upload(
client, tmp_file, filename, options=upload_options
)
download_url = yield download_d

View file

@ -92,7 +92,7 @@ class FileSharing(object):
os.makedirs(path)
@defer.inlineCallbacks
def _fileTransferedCb(self, dummy, client, peer_jid, file_data, file_path):
def _fileTransferedCb(self, __, client, peer_jid, file_data, file_path):
"""post file reception tasks
on file is received, this method create hash/thumbnails if necessary

View file

@ -612,7 +612,7 @@ class Events(object):
# first we authorize our invitee to see the nodes of interest
yield self._p.setNodeAffiliations(client, service, node, {invitee_jid: u"member"})
log.debug(_(u"affiliation set on event node"))
dummy, event_data = yield self.eventGet(client, service, node, item_id)
__, event_data = yield self.eventGet(client, service, node, item_id)
log.debug(_(u"got event data"))
invitees_service = jid.JID(event_data["invitees_service"])
invitees_node = event_data["invitees_node"]
@ -625,7 +625,7 @@ class Events(object):
yield self._p.setNodeAffiliations(
client, blog_service, blog_node, {invitee_jid: u"member"}
)
blog_items, dummy = yield self._b.mbGet(client, blog_service, blog_node, None)
blog_items, __ = yield self._b.mbGet(client, blog_service, blog_node, None)
for item in blog_items:
try:

View file

@ -291,7 +291,7 @@ class JingleStream(object):
log.warning(u"FIXME: unmanaged action {}".format(action))
return desc_elt
def _finishedCb(self, dummy, client, session, content_name, content_data):
def _finishedCb(self, __, client, session, content_name, content_data):
log.info(u"Pipe transfer completed")
self._j.contentTerminate(client, session, content_name)
content_data["stream_object"].stopStream()

View file

@ -121,8 +121,8 @@ class MercurialHandler(object):
def check(self, repository):
d = MercurialProtocol.run(repository, 'identify')
d.addCallback(lambda dummy: True)
d.addErrback(lambda dummy: False)
d.addCallback(lambda __: True)
d.addErrback(lambda __: False)
return d
def export(self, repository):

View file

@ -225,7 +225,7 @@ class MiscAccount(object):
@return Deferred
"""
d = self.createProfile(password, jid_s, profile)
d.addCallback(lambda dummy: self.sendEmails(email, profile))
d.addCallback(lambda __: self.sendEmails(email, profile))
return d
def createProfile(self, password, jid_s, profile):
@ -246,7 +246,7 @@ class MiscAccount(object):
return defer.fail(Failure(exceptions.ConflictError))
d = self.host.memory.createProfile(profile, password)
d.addCallback(lambda dummy: self.profileCreated(password, jid_s, profile))
d.addCallback(lambda __: self.profileCreated(password, jid_s, profile))
return d
def profileCreated(self, password, jid_s, profile):
@ -267,7 +267,7 @@ class MiscAccount(object):
jid_ = jid.JID(jid_s)
d = self.host.plugins["XEP-0077"].registerNewAccount(jid_, password)
def setParams(dummy):
def setParams(__):
self.host.memory.setParam(
"JabberID", jid_s, "Connection", profile_key=profile
)
@ -280,9 +280,9 @@ class MiscAccount(object):
self.host.memory.asyncDeleteProfile(profile)
return failure
d.addCallback(lambda dummy: self.host.memory.startSession(password, profile))
d.addCallback(lambda __: self.host.memory.startSession(password, profile))
d.addCallback(setParams)
d.addCallback(lambda dummy: self.host.memory.stopSession(profile))
d.addCallback(lambda __: self.host.memory.stopSession(profile))
d.addErrback(removeProfile)
return d
@ -317,12 +317,12 @@ class MiscAccount(object):
admins_emails_txt = u", ".join([u"<" + addr + u">" for addr in admins_emails])
d_admin.addCallbacks(
lambda dummy: log.debug(
lambda __: log.debug(
u"Account creation notification sent to admin(s) {}".format(
admins_emails_txt
)
),
lambda dummy: log.error(
lambda __: log.error(
u"Failed to send account creation notification to admin {}".format(
admins_emails_txt
)
@ -343,7 +343,7 @@ class MiscAccount(object):
# FIXME: delete the profile if the email could not been sent?
d_user = sat_email.sendEmail(self.host, [email], subject, body)
d_user.addCallbacks(
lambda dummy: log.debug(
lambda __: log.debug(
u"Account creation confirmation sent to <{}>".format(email)
),
self._sendEmailEb,
@ -485,7 +485,7 @@ class MiscAccount(object):
@param password (str): the new password
@param profile (str): %(doc_profile)s
"""
session_id, dummy = self._sessions.newSession(
session_id, __ = self._sessions.newSession(
{"new_password": password}, profile=profile
)
form_ui = xml_tools.XMLUI(
@ -511,7 +511,7 @@ class MiscAccount(object):
password = self._sessions.profileGet(data["session_id"], profile)["new_password"]
del self._sessions[data["session_id"]]
def passwordChanged(dummy):
def passwordChanged(__):
d = self.host.memory.setParam(
C.PROFILE_PASS_PATH[1],
password,
@ -519,7 +519,7 @@ class MiscAccount(object):
profile_key=profile,
)
d.addCallback(
lambda dummy: self.host.memory.setParam(
lambda __: self.host.memory.setParam(
"Password", password, "Connection", profile_key=profile
)
)
@ -576,7 +576,7 @@ class MiscAccount(object):
"""
client = self.host.getClient(profile)
def userDeleted(dummy):
def userDeleted(__):
# FIXME: client should be disconnected at this point, so 2 next loop should be removed (to be confirmed)
for jid_ in client.roster._jids: # empty roster
@ -594,7 +594,7 @@ class MiscAccount(object):
d = self.host.plugins["GROUPBLOG"].deleteAllGroupBlogsAndComments(
profile_key=profile
)
d.addCallback(lambda dummy: delete_profile())
d.addCallback(lambda __: delete_profile())
else:
delete_profile()
@ -739,7 +739,7 @@ class MiscAccount(object):
d = self.createProfile(password, jid_s, jid_s)
d.addCallback(
lambda dummy: self.host.memory.getProfileName(jid_s)
lambda __: self.host.memory.getProfileName(jid_s)
) # checks if the profile has been successfuly created
d.addCallback(self.host.connect, password, {}, 0)

View file

@ -105,7 +105,7 @@ class NatPort(object):
@return (None, str): found IP address, or None of something got wrong
"""
def getIP(dummy):
def getIP(__):
if self._upnp is None:
return None
# lanaddr can be the empty string if not found,

View file

@ -81,7 +81,7 @@ class RegisterAccount(object):
session_data["user"], host, resource = jid.parse(session_data["JabberID"])
session_data["server"] = session_data[C.FORCE_SERVER_PARAM] or host
session_id, dummy = self._sessions.newSession(session_data, profile=profile)
session_id, __ = self._sessions.newSession(session_data, profile=profile)
form_ui = xml_tools.XMLUI(
"form",
title=D_("Register new account"),
@ -129,7 +129,7 @@ class RegisterAccount(object):
def _registerNewAccount(self, client, jid_, password, email, server):
#  FIXME: port is not set here
def registeredCb(dummy):
def registeredCb(__):
xmlui = xml_tools.XMLUI(u"popup", title=D_(u"Confirmation"))
xmlui.addText(D_("Registration successful."))
return {"xmlui": xmlui.toXml()}

View file

@ -488,7 +488,7 @@ class RoomGame(object):
user_jid = self.host.getJidNStream(profile)[0]
d = self.host.plugins["XEP-0045"].join(room_jid, user_jid.user, {}, profile)
return d.addCallback(
lambda dummy: self._createOrInvite(client, room_jid, other_players)
lambda __: self._createOrInvite(client, room_jid, other_players)
)
def userJoinedTrigger(self, room, user, profile):
@ -520,7 +520,7 @@ class RoomGame(object):
)
return True
other_players = self.invitations[room_jid][batch][1]
(auth, nicks, dummy) = self._checkWaitAuth(room, other_players)
(auth, nicks, __) = self._checkWaitAuth(room, other_players)
if auth:
del self.invitations[room_jid][batch]
nicks.insert(0, profile_nick) # add the referee

View file

@ -87,7 +87,7 @@ class UploadPlugin(object):
"""
def uploadCb(data):
progress_id, dummy = data
progress_id, __ = data
return {"progress": progress_id}
def uploadEb(fail):

Some files were not shown because too many files have changed in this diff Show more