comparison sat_frontends/jp/cmd_event.py @ 3568:04283582966f

core, frontends: fix invalid translatable strings. Some f-strings where used in translatable text, this has been fixed by using explicit `format()` call (using a script based on `tokenize`). As tokenize messes with spaces, a reformating tool (`black`) has been applied to some files afterwards.
author Goffi <goffi@goffi.org>
date Mon, 14 Jun 2021 18:35:12 +0200
parents be6d91572633
children d8baf92cb921
comparison
equal deleted inserted replaced
3567:a240748ed686 3568:04283582966f
105 "-i", 105 "-i",
106 "--id", 106 "--id",
107 default="", 107 default="",
108 help=_("ID of the PubSub Item"), 108 help=_("ID of the PubSub Item"),
109 ) 109 )
110 self.parser.add_argument( 110 self.parser.add_argument("-d", "--date", type=str, help=_("date of the event"))
111 "-d", "--date", type=str, help=_("date of the event")
112 )
113 self.parser.add_argument( 111 self.parser.add_argument(
114 "-f", 112 "-f",
115 "--field", 113 "--field",
116 action="append", 114 action="append",
117 nargs=2, 115 nargs=2,
167 ) 165 )
168 except Exception as e: 166 except Exception as e:
169 self.disp(f"can't create event: {e}", error=True) 167 self.disp(f"can't create event: {e}", error=True)
170 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 168 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
171 else: 169 else:
172 self.disp(_(f"Event created successfuly on node {node}")) 170 self.disp(_("Event created successfuly on node {node}").format(node=node))
173 self.host.quit() 171 self.host.quit()
174 172
175 173
176 class Modify(EventBase, base.CommandBase): 174 class Modify(EventBase, base.CommandBase):
177 def __init__(self, host): 175 def __init__(self, host):
348 show_table = OUTPUT_OPT_TABLE in self.args.output_opts 346 show_table = OUTPUT_OPT_TABLE in self.args.output_opts
349 347
350 table = common.Table.fromListDict( 348 table = common.Table.fromListDict(
351 self.host, 349 self.host,
352 data, 350 data,
353 ("nick",) 351 ("nick",) + (("jid",) if self.host.verbosity else ()) + ("attend", "guests"),
354 + (("jid",) if self.host.verbosity else ())
355 + ("attend", "guests"),
356 headers=None, 352 headers=None,
357 filters={ 353 filters={
358 "nick": A.color(C.A_HEADER, "{}" if show_table else "{} "), 354 "nick": A.color(C.A_HEADER, "{}" if show_table else "{} "),
359 "jid": "{}" if show_table else "{} ", 355 "jid": "{}" if show_table else "{} ",
360 "attend": self._attend_filter, 356 "attend": self._attend_filter,
400 A.RESET, 396 A.RESET,
401 str(guests_maybe), 397 str(guests_maybe),
402 ) 398 )
403 ) 399 )
404 self.disp( 400 self.disp(
405 A.color( 401 A.color(C.A_SUBHEADER, _("total: "), A.RESET, str(guests + guests_maybe))
406 C.A_SUBHEADER, _("total: "), A.RESET, str(guests + guests_maybe)
407 )
408 ) 402 )
409 if attendees_missing: 403 if attendees_missing:
410 self.disp("") 404 self.disp("")
411 self.disp( 405 self.disp(
412 A.color( 406 A.color(
451 ) 445 )
452 except Exception as e: 446 except Exception as e:
453 self.disp(f"can't get event data: {e}", error=True) 447 self.disp(f"can't get event data: {e}", error=True)
454 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 448 self.host.quit(C.EXIT_BRIDGE_ERRBACK)
455 449
456 # we fill nicknames and keep only requested people 450 # we fill nicknames and keep only requested people
457 451
458 if self.args.no_rsvp: 452 if self.args.no_rsvp:
459 for jid_ in event_data: 453 for jid_ in event_data:
460 # if there is a jid in event_data it must be there in prefilled too 454 # if there is a jid in event_data it must be there in prefilled too
461 # otherwie somebody is not on the invitees list 455 # otherwie somebody is not on the invitees list
462 try: 456 try:
463 del prefilled[jid_] 457 del prefilled[jid_]
464 except KeyError: 458 except KeyError:
465 self.disp(A.color( 459 self.disp(
466 C.A_WARNING, 460 A.color(
467 f"We got a RSVP from somebody who was not in invitees " 461 C.A_WARNING,
468 f"list: {jid_}" 462 f"We got a RSVP from somebody who was not in invitees "
463 f"list: {jid_}",
469 ), 464 ),
470 error=True) 465 error=True,
466 )
471 else: 467 else:
472 # we replace empty dicts for existing people with R.S.V.P. data 468 # we replace empty dicts for existing people with R.S.V.P. data
473 prefilled.update(event_data) 469 prefilled.update(event_data)
474 470
475 # we get nicknames for everybody, make it easier for organisers 471 # we get nicknames for everybody, make it easier for organisers
476 for jid_, data in prefilled.items(): 472 for jid_, data in prefilled.items():
477 id_data = await self.host.bridge.identityGet(jid_, [], True, self.profile) 473 id_data = await self.host.bridge.identityGet(jid_, [], True, self.profile)
478 id_data = data_format.deserialise(id_data) 474 id_data = data_format.deserialise(id_data)
479 data["nick"] = id_data['nicknames'][0] 475 data["nick"] = id_data["nicknames"][0]
480 476
481 await self.output(prefilled) 477 await self.output(prefilled)
482 self.host.quit() 478 self.host.quit()
483 479
484 480