Mercurial > libervia-backend
comparison sat/plugins/plugin_xep_0422.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 | 60724ff3f273 |
children |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
58 class XEP_0422(object): | 58 class XEP_0422(object): |
59 | 59 |
60 def __init__(self, host): | 60 def __init__(self, host): |
61 log.info(_("XEP-0422 (Message Fastening) plugin initialization")) | 61 log.info(_("XEP-0422 (Message Fastening) plugin initialization")) |
62 self.host = host | 62 self.host = host |
63 host.registerNamespace("fasten", NS_FASTEN) | 63 host.register_namespace("fasten", NS_FASTEN) |
64 | 64 |
65 def getHandler(self, __): | 65 def get_handler(self, __): |
66 return XEP_0422_handler() | 66 return XEP_0422_handler() |
67 | 67 |
68 def applyToElt( | 68 def apply_to_elt( |
69 self, | 69 self, |
70 message_elt: domish.Element, | 70 message_elt: domish.Element, |
71 origin_id: str, | 71 origin_id: str, |
72 clear: Optional[bool] = None, | 72 clear: Optional[bool] = None, |
73 shell: Optional[bool] = None, | 73 shell: Optional[bool] = None, |
91 @return: <apply-to> element, which is already added to the wrapping message_elt | 91 @return: <apply-to> element, which is already added to the wrapping message_elt |
92 """ | 92 """ |
93 apply_to_elt = message_elt.addElement((NS_FASTEN, "apply-to")) | 93 apply_to_elt = message_elt.addElement((NS_FASTEN, "apply-to")) |
94 apply_to_elt["id"] = origin_id | 94 apply_to_elt["id"] = origin_id |
95 if clear is not None: | 95 if clear is not None: |
96 apply_to_elt["clear"] = C.boolConst(clear) | 96 apply_to_elt["clear"] = C.bool_const(clear) |
97 if shell is not None: | 97 if shell is not None: |
98 apply_to_elt["shell"] = C.boolConst(shell) | 98 apply_to_elt["shell"] = C.bool_const(shell) |
99 if children is not None: | 99 if children is not None: |
100 for child in children: | 100 for child in children: |
101 apply_to_elt.addChild(child) | 101 apply_to_elt.addChild(child) |
102 if external is not None: | 102 if external is not None: |
103 for ext in external: | 103 for ext in external: |
109 external_elt["name"] = name | 109 external_elt["name"] = name |
110 external_elt["element-namespace"] = ns | 110 external_elt["element-namespace"] = ns |
111 return apply_to_elt | 111 return apply_to_elt |
112 | 112 |
113 @async_lru(maxsize=5) | 113 @async_lru(maxsize=5) |
114 async def getFastenedElts( | 114 async def get_fastened_elts( |
115 self, | 115 self, |
116 client: SatXMPPEntity, | 116 client: SatXMPPEntity, |
117 message_elt: domish.Element | 117 message_elt: domish.Element |
118 ) -> Optional[FastenMetadata]: | 118 ) -> Optional[FastenMetadata]: |
119 """Get fastened elements | 119 """Get fastened elements |