Mercurial > libervia-backend
comparison sat/plugins/plugin_exp_invitation_file.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 |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
43 class FileSharingInvitation: | 43 class FileSharingInvitation: |
44 | 44 |
45 def __init__(self, host): | 45 def __init__(self, host): |
46 log.info(_("File Sharing Invitation plugin initialization")) | 46 log.info(_("File Sharing Invitation plugin initialization")) |
47 self.host = host | 47 self.host = host |
48 ns_fis = host.getNamespace("fis") | 48 ns_fis = host.get_namespace("fis") |
49 host.plugins["INVITATION"].registerNamespace(ns_fis, self.onInvitation) | 49 host.plugins["INVITATION"].register_namespace(ns_fis, self.on_invitation) |
50 host.bridge.addMethod( | 50 host.bridge.add_method( |
51 "FISInvite", | 51 "fis_invite", |
52 ".plugin", | 52 ".plugin", |
53 in_sign="ssssssss", | 53 in_sign="ssssssss", |
54 out_sign="", | 54 out_sign="", |
55 method=self._sendFileSharingInvitation, | 55 method=self._send_file_sharing_invitation, |
56 async_=True | 56 async_=True |
57 ) | 57 ) |
58 | 58 |
59 def _sendFileSharingInvitation( | 59 def _send_file_sharing_invitation( |
60 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None, | 60 self, invitee_jid_s, service_s, repos_type=None, namespace=None, path=None, |
61 name=None, extra_s='', profile_key=C.PROF_KEY_NONE): | 61 name=None, extra_s='', profile_key=C.PROF_KEY_NONE): |
62 client = self.host.getClient(profile_key) | 62 client = self.host.get_client(profile_key) |
63 invitee_jid = jid.JID(invitee_jid_s) | 63 invitee_jid = jid.JID(invitee_jid_s) |
64 service = jid.JID(service_s) | 64 service = jid.JID(service_s) |
65 extra = data_format.deserialise(extra_s) | 65 extra = data_format.deserialise(extra_s) |
66 return defer.ensureDeferred( | 66 return defer.ensureDeferred( |
67 self.host.plugins["INVITATION"].sendFileSharingInvitation( | 67 self.host.plugins["INVITATION"].send_file_sharing_invitation( |
68 client, invitee_jid, service, repos_type=repos_type or None, | 68 client, invitee_jid, service, repos_type=repos_type or None, |
69 namespace=namespace or None, path=path or None, name=name or None, | 69 namespace=namespace or None, path=path or None, name=name or None, |
70 extra=extra) | 70 extra=extra) |
71 ) | 71 ) |
72 | 72 |
73 def onInvitation( | 73 def on_invitation( |
74 self, | 74 self, |
75 client: SatXMPPEntity, | 75 client: SatXMPPEntity, |
76 namespace: str, | 76 namespace: str, |
77 name: str, | 77 name: str, |
78 extra: dict, | 78 extra: dict, |
95 'with namespace {sharing_ns!r} at path [{path}]').format( | 95 'with namespace {sharing_ns!r} at path [{path}]').format( |
96 profile=client.profile, type_human=type_human, sharing_ns=sharing_ns, | 96 profile=client.profile, type_human=type_human, sharing_ns=sharing_ns, |
97 path=path) | 97 path=path) |
98 ) | 98 ) |
99 return defer.ensureDeferred( | 99 return defer.ensureDeferred( |
100 self.host.plugins['LIST_INTEREST'].registerFileSharing( | 100 self.host.plugins['LIST_INTEREST'].register_file_sharing( |
101 client, service, repos_type, sharing_ns, path, name, extra | 101 client, service, repos_type, sharing_ns, path, name, extra |
102 ) | 102 ) |
103 ) | 103 ) |