comparison sat_frontends/jp/cmd_account.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
78 ), 78 ),
79 ) 79 )
80 80
81 async def start(self): 81 async def start(self):
82 try: 82 try:
83 await self.host.bridge.inBandAccountNew( 83 await self.host.bridge.in_band_account_new(
84 self.args.jid, 84 self.args.jid,
85 self.args.password, 85 self.args.password,
86 self.args.email, 86 self.args.email,
87 self.args.host, 87 self.args.host,
88 self.args.port, 88 self.args.port,
110 self.host.quit() 110 self.host.quit()
111 111
112 112
113 self.disp(_("creating profile"), 2) 113 self.disp(_("creating profile"), 2)
114 try: 114 try:
115 await self.host.bridge.profileCreate( 115 await self.host.bridge.profile_create(
116 self.args.profile, 116 self.args.profile,
117 self.args.password, 117 self.args.password,
118 "", 118 "",
119 ) 119 )
120 except BridgeException as e: 120 except BridgeException as e:
139 self.disp(f"Internal error: {e}", error=True) 139 self.disp(f"Internal error: {e}", error=True)
140 self.host.quit(C.EXIT_INTERNAL_ERROR) 140 self.host.quit(C.EXIT_INTERNAL_ERROR)
141 141
142 self.disp(_("profile created"), 1) 142 self.disp(_("profile created"), 1)
143 try: 143 try:
144 await self.host.bridge.profileStartSession( 144 await self.host.bridge.profile_start_session(
145 self.args.password, 145 self.args.password,
146 self.args.profile, 146 self.args.profile,
147 ) 147 )
148 except Exception as e: 148 except Exception as e:
149 self.disp(f"can't start profile session: {e}", error=True) 149 self.disp(f"can't start profile session: {e}", error=True)
150 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 150 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
151 151
152 try: 152 try:
153 await self.host.bridge.setParam( 153 await self.host.bridge.param_set(
154 "JabberID", 154 "JabberID",
155 self.args.jid, 155 self.args.jid,
156 "Connection", 156 "Connection",
157 profile_key=self.args.profile, 157 profile_key=self.args.profile,
158 ) 158 )
159 except Exception as e: 159 except Exception as e:
160 self.disp(f"can't set JabberID parameter: {e}", error=True) 160 self.disp(f"can't set JabberID parameter: {e}", error=True)
161 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 161 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
162 162
163 try: 163 try:
164 await self.host.bridge.setParam( 164 await self.host.bridge.param_set(
165 "Password", 165 "Password",
166 self.args.password, 166 self.args.password,
167 "Connection", 167 "Connection",
168 profile_key=self.args.profile, 168 profile_key=self.args.profile,
169 ) 169 )
188 "password", help=_("new XMPP password") 188 "password", help=_("new XMPP password")
189 ) 189 )
190 190
191 async def start(self): 191 async def start(self):
192 try: 192 try:
193 await self.host.bridge.inBandPasswordChange( 193 await self.host.bridge.in_band_password_change(
194 self.args.password, 194 self.args.password,
195 self.args.profile, 195 self.args.profile,
196 ) 196 )
197 except Exception as e: 197 except Exception as e:
198 self.disp(f"can't change XMPP password: {e}", error=True) 198 self.disp(f"can't change XMPP password: {e}", error=True)
215 help=_("delete account without confirmation"), 215 help=_("delete account without confirmation"),
216 ) 216 )
217 217
218 async def start(self): 218 async def start(self):
219 try: 219 try:
220 jid_str = await self.host.bridge.asyncGetParamA( 220 jid_str = await self.host.bridge.param_get_a_async(
221 "JabberID", 221 "JabberID",
222 "Connection", 222 "Connection",
223 profile_key=self.profile, 223 profile_key=self.profile,
224 ) 224 )
225 except Exception as e: 225 except Exception as e:
231 message = ( 231 message = (
232 f"You are about to delete the XMPP account with jid {jid_!r}\n" 232 f"You are about to delete the XMPP account with jid {jid_!r}\n"
233 f"This is the XMPP account of profile {self.profile!r}\n" 233 f"This is the XMPP account of profile {self.profile!r}\n"
234 f"Are you sure that you want to delete this account?" 234 f"Are you sure that you want to delete this account?"
235 ) 235 )
236 await self.host.confirmOrQuit(message, _("Account deletion cancelled")) 236 await self.host.confirm_or_quit(message, _("Account deletion cancelled"))
237 237
238 try: 238 try:
239 await self.host.bridge.inBandUnregister(jid_.domain, self.args.profile) 239 await self.host.bridge.in_band_unregister(jid_.domain, self.args.profile)
240 except Exception as e: 240 except Exception as e:
241 self.disp(f"can't delete XMPP account with jid {jid_!r}: {e}", error=True) 241 self.disp(f"can't delete XMPP account with jid {jid_!r}: {e}", error=True)
242 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 242 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
243 243
244 self.host.quit() 244 self.host.quit()