Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_list.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 |
---|---|
50 | 50 |
51 async def start(self): | 51 async def start(self): |
52 await common.fill_well_known_uri(self, os.getcwd(), "tickets", meta_map={}) | 52 await common.fill_well_known_uri(self, os.getcwd(), "tickets", meta_map={}) |
53 try: | 53 try: |
54 lists_data = data_format.deserialise( | 54 lists_data = data_format.deserialise( |
55 await self.host.bridge.listGet( | 55 await self.host.bridge.list_get( |
56 self.args.service, | 56 self.args.service, |
57 self.args.node, | 57 self.args.node, |
58 self.args.max, | 58 self.args.max, |
59 self.args.items, | 59 self.args.items, |
60 "", | 60 "", |
61 self.getPubsubExtra(), | 61 self.get_pubsub_extra(), |
62 self.profile, | 62 self.profile, |
63 ), | 63 ), |
64 type_check=list, | 64 type_check=list, |
65 ) | 65 ) |
66 except Exception as e: | 66 except Exception as e: |
121 values.setdefault(field_data[0], []).extend(field_data[1:]) | 121 values.setdefault(field_data[0], []).extend(field_data[1:]) |
122 | 122 |
123 extra = {"update": update} | 123 extra = {"update": update} |
124 | 124 |
125 try: | 125 try: |
126 item_id = await self.host.bridge.listSet( | 126 item_id = await self.host.bridge.list_set( |
127 self.args.service, | 127 self.args.service, |
128 self.args.node, | 128 self.args.node, |
129 values, | 129 values, |
130 "", | 130 "", |
131 self.args.item, | 131 self.args.item, |
169 self.parser.error(_("You need to specify a list item to delete")) | 169 self.parser.error(_("You need to specify a list item to delete")) |
170 if not self.args.force: | 170 if not self.args.force: |
171 message = _("Are you sure to delete list item {item_id} ?").format( | 171 message = _("Are you sure to delete list item {item_id} ?").format( |
172 item_id=self.args.item | 172 item_id=self.args.item |
173 ) | 173 ) |
174 await self.host.confirmOrQuit(message, _("item deletion cancelled")) | 174 await self.host.confirm_or_quit(message, _("item deletion cancelled")) |
175 try: | 175 try: |
176 await self.host.bridge.listDeleteItem( | 176 await self.host.bridge.list_delete_item( |
177 self.args.service, | 177 self.args.service, |
178 self.args.node, | 178 self.args.node, |
179 self.args.item, | 179 self.args.item, |
180 self.args.notify, | 180 self.args.notify, |
181 self.profile, | 181 self.profile, |
190 | 190 |
191 class Import(base.CommandBase): | 191 class Import(base.CommandBase): |
192 # TODO: factorize with blog/import | 192 # TODO: factorize with blog/import |
193 | 193 |
194 def __init__(self, host): | 194 def __init__(self, host): |
195 super(Import, self).__init__( | 195 super().__init__( |
196 host, | 196 host, |
197 "import", | 197 "import", |
198 use_progress=True, | 198 use_progress=True, |
199 use_verbose=True, | 199 use_verbose=True, |
200 help=_("import tickets from external software/dataset"), | 200 help=_("import tickets from external software/dataset"), |
251 "importer data location (see importer description), nothing to show " | 251 "importer data location (see importer description), nothing to show " |
252 "importer description" | 252 "importer description" |
253 ), | 253 ), |
254 ) | 254 ) |
255 | 255 |
256 async def onProgressStarted(self, metadata): | 256 async def on_progress_started(self, metadata): |
257 self.disp(_("Tickets upload started"), 2) | 257 self.disp(_("Tickets upload started"), 2) |
258 | 258 |
259 async def onProgressFinished(self, metadata): | 259 async def on_progress_finished(self, metadata): |
260 self.disp(_("Tickets uploaded successfully"), 2) | 260 self.disp(_("Tickets uploaded successfully"), 2) |
261 | 261 |
262 async def onProgressError(self, error_msg): | 262 async def on_progress_error(self, error_msg): |
263 self.disp( | 263 self.disp( |
264 _("Error while uploading tickets: {error_msg}").format(error_msg=error_msg), | 264 _("Error while uploading tickets: {error_msg}").format(error_msg=error_msg), |
265 error=True, | 265 error=True, |
266 ) | 266 ) |
267 | 267 |