massive refactoring to switch from camelCase to snake_case:
historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a pre-PEP8 code, to use the same coding style as in Twisted. However, snake_case is more readable and it's better to follow PEP8 best practices, so it has been decided to move on full snake_case. Because Libervia has a huge codebase, this ended with a ugly mix of camelCase and snake_case. To fix that, this patch does a big refactoring by renaming every function and method (including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case. This is a massive change, and may result in some bugs.
This commit is contained in:
parent
d50412c7f7
commit
6a6f15707a
1 changed files with 9945 additions and 9945 deletions
|
|
@ -47,29 +47,29 @@ class XEP_0092(object):
|
|||
def __init__(self, host):
|
||||
log.info(_("Plugin XEP_0092 initialization"))
|
||||
self.host = host
|
||||
host.bridge.addMethod(
|
||||
"getSoftwareVersion",
|
||||
host.bridge.add_method(
|
||||
"software_version_get",
|
||||
".plugin",
|
||||
in_sign="ss",
|
||||
out_sign="(sss)",
|
||||
method=self._getVersion,
|
||||
method=self._get_version,
|
||||
async_=True,
|
||||
)
|
||||
try:
|
||||
self.host.plugins[C.TEXT_CMDS].addWhoIsCb(self._whois, 50)
|
||||
self.host.plugins[C.TEXT_CMDS].add_who_is_cb(self._whois, 50)
|
||||
except KeyError:
|
||||
log.info(_("Text commands not available"))
|
||||
|
||||
def _getVersion(self, entity_jid_s, profile_key):
|
||||
def prepareForBridge(data):
|
||||
def _get_version(self, entity_jid_s, profile_key):
|
||||
def prepare_for_bridge(data):
|
||||
name, version, os = data
|
||||
return (name or "", version or "", os or "")
|
||||
|
||||
d = self.getVersion(jid.JID(entity_jid_s), profile_key)
|
||||
d.addCallback(prepareForBridge)
|
||||
d = self.version_get(jid.JID(entity_jid_s), profile_key)
|
||||
d.addCallback(prepare_for_bridge)
|
||||
return d
|
||||
|
||||
def getVersion(self, jid_, profile_key=C.PROF_KEY_NONE):
|
||||
def version_get(self, jid_, profile_key=C.PROF_KEY_NONE):
|
||||
""" Ask version of the client that jid_ is running
|
||||
@param jid_: jid from who we want to know client's version
|
||||
@param profile_key: %(doc_profile_key)s
|
||||
|
|
@ -78,24 +78,24 @@ class XEP_0092(object):
|
|||
- version: specific version of the software
|
||||
- os: operating system of the queried entity
|
||||
"""
|
||||
client = self.host.getClient(profile_key)
|
||||
client = self.host.get_client(profile_key)
|
||||
|
||||
def getVersion(__):
|
||||
def version_get(__):
|
||||
iq_elt = compat.IQ(client.xmlstream, "get")
|
||||
iq_elt["to"] = jid_.full()
|
||||
iq_elt.addElement("query", NS_VERSION)
|
||||
d = iq_elt.send()
|
||||
d.addCallback(self._gotVersion)
|
||||
d.addCallback(self._got_version)
|
||||
return d
|
||||
|
||||
d = self.host.checkFeature(client, NS_VERSION, jid_)
|
||||
d.addCallback(getVersion)
|
||||
d = self.host.check_feature(client, NS_VERSION, jid_)
|
||||
d.addCallback(version_get)
|
||||
reactor.callLater(
|
||||
TIMEOUT, d.cancel
|
||||
) # XXX: timeout needed because some clients don't answer the IQ
|
||||
return d
|
||||
|
||||
def _gotVersion(self, iq_elt):
|
||||
def _got_version(self, iq_elt):
|
||||
try:
|
||||
query_elt = next(iq_elt.elements(NS_VERSION, "query"))
|
||||
except StopIteration:
|
||||
|
|
@ -113,7 +113,7 @@ class XEP_0092(object):
|
|||
def _whois(self, client, whois_msg, mess_data, target_jid):
|
||||
""" Add software/OS information to whois """
|
||||
|
||||
def versionCb(version_data):
|
||||
def version_cb(version_data):
|
||||
name, version, os = version_data
|
||||
if name:
|
||||
whois_msg.append(_("Client name: %s") % name)
|
||||
|
|
@ -122,13 +122,13 @@ class XEP_0092(object):
|
|||
if os:
|
||||
whois_msg.append(_("Operating system: %s") % os)
|
||||
|
||||
def versionEb(failure):
|
||||
def version_eb(failure):
|
||||
failure.trap(exceptions.FeatureNotFound, defer.CancelledError)
|
||||
if failure.check(failure, exceptions.FeatureNotFound):
|
||||
whois_msg.append(_("Software version not available"))
|
||||
else:
|
||||
whois_msg.append(_("Client software version request timeout"))
|
||||
|
||||
d = self.getVersion(target_jid, client.profile)
|
||||
d.addCallbacks(versionCb, versionEb)
|
||||
d = self.version_get(target_jid, client.profile)
|
||||
d.addCallbacks(version_cb, version_eb)
|
||||
return d
|
||||
|
|
|
|||
Loading…
Reference in a new issue