Mercurial > libervia-backend
diff sat/plugins/plugin_xep_0095.py @ 4037:524856bd7b19
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:54:42 +0200 |
parents | be6d91572633 |
children |
line wrap: on
line diff
--- a/sat/plugins/plugin_xep_0095.py Fri Apr 07 15:18:39 2023 +0200 +++ b/sat/plugins/plugin_xep_0095.py Sat Apr 08 13:54:42 2023 +0200 @@ -55,10 +55,10 @@ self.host = host self.si_profiles = {} # key: SI profile, value: callback - def getHandler(self, client): + def get_handler(self, client): return XEP_0095_handler(self) - def registerSIProfile(self, si_profile, callback): + def register_si_profile(self, si_profile, callback): """Add a callback for a SI Profile @param si_profile(unicode): SI profile name (e.g. file-transfer) @@ -66,7 +66,7 @@ """ self.si_profiles[si_profile] = callback - def unregisterSIProfile(self, si_profile): + def unregister_si_profile(self, si_profile): try: del self.si_profiles[si_profile] except KeyError: @@ -76,7 +76,7 @@ ) ) - def streamInit(self, iq_elt, client): + def stream_init(self, iq_elt, client): """This method is called on stream initiation (XEP-0095 #3.2) @param iq_elt: IQ element @@ -117,7 +117,7 @@ client.send(iq_error_elt) - def acceptStream(self, client, iq_elt, feature_elt, misc_elts=None): + def accept_stream(self, client, iq_elt, feature_elt, misc_elts=None): """Send the accept stream initiation answer @param iq_elt(domish.Element): initial SI request @@ -134,7 +134,7 @@ si_elt.addChild(elt) client.send(result_elt) - def _parseOfferResult(self, iq_elt): + def _parse_offer_result(self, iq_elt): try: si_elt = next(iq_elt.elements(NS_SI, "si")) except StopIteration: @@ -142,7 +142,7 @@ raise exceptions.DataError return (iq_elt, si_elt) - def proposeStream( + def propose_stream( self, client, to_jid, @@ -178,7 +178,7 @@ si.addChild(feature_elt) offer_d = offer.send() - offer_d.addCallback(self._parseOfferResult) + offer_d.addCallback(self._parse_offer_result) return sid, offer_d @@ -191,7 +191,7 @@ def connectionInitialized(self): self.xmlstream.addObserver( - SI_REQUEST, self.plugin_parent.streamInit, client=self.parent + SI_REQUEST, self.plugin_parent.stream_init, client=self.parent ) def getDiscoInfo(self, requestor, target, nodeIdentifier=""):