Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_event.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 | d8baf92cb921 |
children | 4b842c1fb686 |
comparison
equal
deleted
inserted
replaced
4036:c4464d7ae97b | 4037:524856bd7b19 |
---|---|
60 def add_parser_options(self): | 60 def add_parser_options(self): |
61 pass | 61 pass |
62 | 62 |
63 async def start(self): | 63 async def start(self): |
64 try: | 64 try: |
65 events_data_s = await self.host.bridge.eventsGet( | 65 events_data_s = await self.host.bridge.events_get( |
66 self.args.service, | 66 self.args.service, |
67 self.args.node, | 67 self.args.node, |
68 self.args.items, | 68 self.args.items, |
69 self.getPubsubExtra(), | 69 self.get_pubsub_extra(), |
70 self.profile, | 70 self.profile, |
71 ) | 71 ) |
72 except Exception as e: | 72 except Exception as e: |
73 self.disp(f"can't get events data: {e}", error=True) | 73 self.disp(f"can't get events data: {e}", error=True) |
74 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 74 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
323 # we check self.args.end after get_event_data because it may be set there id | 323 # we check self.args.end after get_event_data because it may be set there id |
324 # --duration is used | 324 # --duration is used |
325 if self.args.end is None: | 325 if self.args.end is None: |
326 self.parser.error("--end or --duration must be set") | 326 self.parser.error("--end or --duration must be set") |
327 try: | 327 try: |
328 await self.host.bridge.eventCreate( | 328 await self.host.bridge.event_create( |
329 data_format.serialise(event_data), | 329 data_format.serialise(event_data), |
330 self.args.id, | 330 self.args.id, |
331 self.args.node, | 331 self.args.node, |
332 self.args.service, | 332 self.args.service, |
333 self.profile, | 333 self.profile, |
357 self.parser.add_argument("-N", "--name", help=_("name of the event")) | 357 self.parser.add_argument("-N", "--name", help=_("name of the event")) |
358 | 358 |
359 async def start(self): | 359 async def start(self): |
360 event_data = self.get_event_data() | 360 event_data = self.get_event_data() |
361 try: | 361 try: |
362 await self.host.bridge.eventModify( | 362 await self.host.bridge.event_modify( |
363 data_format.serialise(event_data), | 363 data_format.serialise(event_data), |
364 self.args.item, | 364 self.args.item, |
365 self.args.service, | 365 self.args.service, |
366 self.args.node, | 366 self.args.node, |
367 self.profile, | 367 self.profile, |
392 help=_("only retrieve RSVP from those JIDs") | 392 help=_("only retrieve RSVP from those JIDs") |
393 ) | 393 ) |
394 | 394 |
395 async def start(self): | 395 async def start(self): |
396 try: | 396 try: |
397 event_data_s = await self.host.bridge.eventInviteeGet( | 397 event_data_s = await self.host.bridge.event_invitee_get( |
398 self.args.service, | 398 self.args.service, |
399 self.args.node, | 399 self.args.node, |
400 self.args.item, | 400 self.args.item, |
401 self.args.jids, | 401 self.args.jids, |
402 "", | 402 "", |
434 | 434 |
435 async def start(self): | 435 async def start(self): |
436 # TODO: handle RSVP with XMLUI in a similar way as for `ad-hoc run` | 436 # TODO: handle RSVP with XMLUI in a similar way as for `ad-hoc run` |
437 fields = dict(self.args.fields) if self.args.fields else {} | 437 fields = dict(self.args.fields) if self.args.fields else {} |
438 try: | 438 try: |
439 self.host.bridge.eventInviteeSet( | 439 self.host.bridge.event_invitee_set( |
440 self.args.service, | 440 self.args.service, |
441 self.args.node, | 441 self.args.node, |
442 self.args.item, | 442 self.args.item, |
443 data_format.serialise(fields), | 443 data_format.serialise(fields), |
444 self.profile, | 444 self.profile, |
520 jid_data["guests"] = "" | 520 jid_data["guests"] = "" |
521 data.append(jid_data) | 521 data.append(jid_data) |
522 | 522 |
523 show_table = OUTPUT_OPT_TABLE in self.args.output_opts | 523 show_table = OUTPUT_OPT_TABLE in self.args.output_opts |
524 | 524 |
525 table = common.Table.fromListDict( | 525 table = common.Table.from_list_dict( |
526 self.host, | 526 self.host, |
527 data, | 527 data, |
528 ("nick",) + (("jid",) if self.host.verbosity else ()) + ("attend", "guests"), | 528 ("nick",) + (("jid",) if self.host.verbosity else ()) + ("attend", "guests"), |
529 headers=None, | 529 headers=None, |
530 filters={ | 530 filters={ |
594 if not self.args.missing: | 594 if not self.args.missing: |
595 prefilled = {} | 595 prefilled = {} |
596 else: | 596 else: |
597 # we get prefilled data with all people | 597 # we get prefilled data with all people |
598 try: | 598 try: |
599 affiliations = await self.host.bridge.psNodeAffiliationsGet( | 599 affiliations = await self.host.bridge.ps_node_affiliations_get( |
600 self.args.service, | 600 self.args.service, |
601 self.args.node, | 601 self.args.node, |
602 self.profile, | 602 self.profile, |
603 ) | 603 ) |
604 except Exception as e: | 604 except Exception as e: |
613 for jid_, affiliation in affiliations.items() | 613 for jid_, affiliation in affiliations.items() |
614 if affiliation in ("publisher",) | 614 if affiliation in ("publisher",) |
615 } | 615 } |
616 | 616 |
617 try: | 617 try: |
618 event_data = await self.host.bridge.eventInviteesList( | 618 event_data = await self.host.bridge.event_invitees_list( |
619 self.args.service, | 619 self.args.service, |
620 self.args.node, | 620 self.args.node, |
621 self.profile, | 621 self.profile, |
622 ) | 622 ) |
623 except Exception as e: | 623 except Exception as e: |
645 # we replace empty dicts for existing people with R.S.V.P. data | 645 # we replace empty dicts for existing people with R.S.V.P. data |
646 prefilled.update(event_data) | 646 prefilled.update(event_data) |
647 | 647 |
648 # we get nicknames for everybody, make it easier for organisers | 648 # we get nicknames for everybody, make it easier for organisers |
649 for jid_, data in prefilled.items(): | 649 for jid_, data in prefilled.items(): |
650 id_data = await self.host.bridge.identityGet(jid_, [], True, self.profile) | 650 id_data = await self.host.bridge.identity_get(jid_, [], True, self.profile) |
651 id_data = data_format.deserialise(id_data) | 651 id_data = data_format.deserialise(id_data) |
652 data["nick"] = id_data["nicknames"][0] | 652 data["nick"] = id_data["nicknames"][0] |
653 | 653 |
654 await self.output(prefilled) | 654 await self.output(prefilled) |
655 self.host.quit() | 655 self.host.quit() |
714 async def start(self): | 714 async def start(self): |
715 email = self.args.email[0] if self.args.email else None | 715 email = self.args.email[0] if self.args.email else None |
716 emails_extra = self.args.email[1:] | 716 emails_extra = self.args.email[1:] |
717 | 717 |
718 try: | 718 try: |
719 await self.host.bridge.eventInviteByEmail( | 719 await self.host.bridge.event_invite_by_email( |
720 self.args.service, | 720 self.args.service, |
721 self.args.node, | 721 self.args.node, |
722 self.args.item, | 722 self.args.item, |
723 email, | 723 email, |
724 emails_extra, | 724 emails_extra, |