Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0428.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 | 2033fa3c5b85 |
children |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
44 | 44 |
45 class XEP_0428(object): | 45 class XEP_0428(object): |
46 | 46 |
47 def __init__(self, host): | 47 def __init__(self, host): |
48 log.info(_("XEP-0428 (Fallback Indication) plugin initialization")) | 48 log.info(_("XEP-0428 (Fallback Indication) plugin initialization")) |
49 host.registerNamespace("fallback", NS_FALLBACK) | 49 host.register_namespace("fallback", NS_FALLBACK) |
50 | 50 |
51 def addFallbackElt( | 51 def add_fallback_elt( |
52 self, | 52 self, |
53 message_elt: domish.Element, | 53 message_elt: domish.Element, |
54 msg: Optional[str] = None | 54 msg: Optional[str] = None |
55 ) -> None: | 55 ) -> None: |
56 """Add the fallback indication element | 56 """Add the fallback indication element |
62 """ | 62 """ |
63 message_elt.addElement((NS_FALLBACK, "fallback")) | 63 message_elt.addElement((NS_FALLBACK, "fallback")) |
64 if msg is not None: | 64 if msg is not None: |
65 message_elt.addElement("body", content=msg) | 65 message_elt.addElement("body", content=msg) |
66 | 66 |
67 def hasFallback(self, message_elt: domish.Element) -> bool: | 67 def has_fallback(self, message_elt: domish.Element) -> bool: |
68 """Tell if a message has a fallback indication""" | 68 """Tell if a message has a fallback indication""" |
69 try: | 69 try: |
70 next(message_elt.elements(NS_FALLBACK, "fallback")) | 70 next(message_elt.elements(NS_FALLBACK, "fallback")) |
71 except StopIteration: | 71 except StopIteration: |
72 return False | 72 return False |
73 else: | 73 else: |
74 return True | 74 return True |
75 | 75 |
76 def getHandler(self, __): | 76 def get_handler(self, __): |
77 return XEP_0428_handler() | 77 return XEP_0428_handler() |
78 | 78 |
79 | 79 |
80 @implementer(disco.IDisco) | 80 @implementer(disco.IDisco) |
81 class XEP_0428_handler(xmlstream.XMPPHandler): | 81 class XEP_0428_handler(xmlstream.XMPPHandler): |