Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_invitation.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 | 04283582966f |
children | 4b842c1fb686 |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
126 self.parser.error( | 126 self.parser.error( |
127 _("you need to specify an email address to send email invitation") | 127 _("you need to specify an email address to send email invitation") |
128 ) | 128 ) |
129 | 129 |
130 try: | 130 try: |
131 invitation_data = await self.host.bridge.invitationCreate( | 131 invitation_data = await self.host.bridge.invitation_create( |
132 email, | 132 email, |
133 emails_extra, | 133 emails_extra, |
134 self.args.jid, | 134 self.args.jid, |
135 self.args.password, | 135 self.args.password, |
136 self.args.name, | 136 self.args.name, |
176 await self.output(data) | 176 await self.output(data) |
177 self.host.quit() | 177 self.host.quit() |
178 | 178 |
179 async def start(self): | 179 async def start(self): |
180 try: | 180 try: |
181 invitation_data = await self.host.bridge.invitationGet( | 181 invitation_data = await self.host.bridge.invitation_get( |
182 self.args.id, | 182 self.args.id, |
183 ) | 183 ) |
184 except Exception as e: | 184 except Exception as e: |
185 self.disp(msg=_("can't get invitation data: {e}").format(e=e), error=True) | 185 self.disp(msg=_("can't get invitation data: {e}").format(e=e), error=True) |
186 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 186 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
188 if not self.args.with_jid: | 188 if not self.args.with_jid: |
189 await self.output_data(invitation_data) | 189 await self.output_data(invitation_data) |
190 else: | 190 else: |
191 profile = invitation_data["guest_profile"] | 191 profile = invitation_data["guest_profile"] |
192 try: | 192 try: |
193 await self.host.bridge.profileStartSession( | 193 await self.host.bridge.profile_start_session( |
194 invitation_data["password"], | 194 invitation_data["password"], |
195 profile, | 195 profile, |
196 ) | 196 ) |
197 except Exception as e: | 197 except Exception as e: |
198 self.disp(msg=_("can't start session: {e}").format(e=e), error=True) | 198 self.disp(msg=_("can't start session: {e}").format(e=e), error=True) |
199 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 199 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
200 | 200 |
201 try: | 201 try: |
202 jid_ = await self.host.bridge.asyncGetParamA( | 202 jid_ = await self.host.bridge.param_get_a_async( |
203 "JabberID", | 203 "JabberID", |
204 "Connection", | 204 "Connection", |
205 profile_key=profile, | 205 profile_key=profile, |
206 ) | 206 ) |
207 except Exception as e: | 207 except Exception as e: |
224 def add_parser_options(self): | 224 def add_parser_options(self): |
225 self.parser.add_argument("id", help=_("invitation UUID")) | 225 self.parser.add_argument("id", help=_("invitation UUID")) |
226 | 226 |
227 async def start(self): | 227 async def start(self): |
228 try: | 228 try: |
229 await self.host.bridge.invitationDelete( | 229 await self.host.bridge.invitation_delete( |
230 self.args.id, | 230 self.args.id, |
231 ) | 231 ) |
232 except Exception as e: | 232 except Exception as e: |
233 self.disp(msg=_("can't delete guest account: {e}").format(e=e), error=True) | 233 self.disp(msg=_("can't delete guest account: {e}").format(e=e), error=True) |
234 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 234 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
300 "you can't set {arg_name} in both optional argument and extra" | 300 "you can't set {arg_name} in both optional argument and extra" |
301 ).format(arg_name=arg_name) | 301 ).format(arg_name=arg_name) |
302 ) | 302 ) |
303 extra[arg_name] = value | 303 extra[arg_name] = value |
304 try: | 304 try: |
305 await self.host.bridge.invitationModify( | 305 await self.host.bridge.invitation_modify( |
306 self.args.id, | 306 self.args.id, |
307 extra, | 307 extra, |
308 self.args.replace, | 308 self.args.replace, |
309 ) | 309 ) |
310 except Exception as e: | 310 except Exception as e: |
346 help=_("return only invitations linked to this profile"), | 346 help=_("return only invitations linked to this profile"), |
347 ) | 347 ) |
348 | 348 |
349 async def start(self): | 349 async def start(self): |
350 try: | 350 try: |
351 data = await self.host.bridge.invitationList( | 351 data = await self.host.bridge.invitation_list( |
352 self.args.profile, | 352 self.args.profile, |
353 ) | 353 ) |
354 except Exception as e: | 354 except Exception as e: |
355 self.disp(f"return only invitations linked to this profile: {e}", error=True) | 355 self.disp(f"return only invitations linked to this profile: {e}", error=True) |
356 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 356 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |