comparison sat_frontends/jp/cmd_event.py @ 2624:56f94936df1e

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 1cc88adb5142
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
28 import calendar 28 import calendar
29 import time 29 import time
30 30
31 __commands__ = ["Event"] 31 __commands__ = ["Event"]
32 32
33 OUTPUT_OPT_TABLE = u'table' 33 OUTPUT_OPT_TABLE = u"table"
34 34
35 # TODO: move date parsing to base, it may be useful for other commands 35 # TODO: move date parsing to base, it may be useful for other commands
36 36
37 37
38 class Get(base.CommandBase): 38 class Get(base.CommandBase):
39 39 def __init__(self, host):
40 def __init__(self, host): 40 base.CommandBase.__init__(
41 base.CommandBase.__init__(self, 41 self,
42 host, 42 host,
43 'get', 43 "get",
44 use_output=C.OUTPUT_DICT, 44 use_output=C.OUTPUT_DICT,
45 use_pubsub=True, pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM}, 45 use_pubsub=True,
46 use_verbose=True, 46 pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
47 help=_(u'get event data')) 47 use_verbose=True,
48 self.need_loop=True 48 help=_(u"get event data"),
49 )
50 self.need_loop = True
49 51
50 def add_parser_options(self): 52 def add_parser_options(self):
51 pass 53 pass
52 54
53 def eventInviteeGetCb(self, result): 55 def eventInviteeGetCb(self, result):
54 event_date, event_data = result 56 event_date, event_data = result
55 event_data['date'] = event_date 57 event_data["date"] = event_date
56 self.output(event_data) 58 self.output(event_data)
57 self.host.quit() 59 self.host.quit()
58 60
59 def start(self): 61 def start(self):
60 self.host.bridge.eventGet( 62 self.host.bridge.eventGet(
61 self.args.service, 63 self.args.service,
62 self.args.node, 64 self.args.node,
63 self.args.item, 65 self.args.item,
64 self.profile, 66 self.profile,
65 callback=self.eventInviteeGetCb, 67 callback=self.eventInviteeGetCb,
66 errback=partial(self.errback, 68 errback=partial(
67 msg=_(u"can't get event data: {}"), 69 self.errback,
68 exit_code=C.EXIT_BRIDGE_ERRBACK)) 70 msg=_(u"can't get event data: {}"),
71 exit_code=C.EXIT_BRIDGE_ERRBACK,
72 ),
73 )
69 74
70 75
71 class EventBase(object): 76 class EventBase(object):
72
73 def add_parser_options(self): 77 def add_parser_options(self):
74 self.parser.add_argument("-i", "--id", type=base.unicode_decoder, default=u'', help=_(u"ID of the PubSub Item")) 78 self.parser.add_argument(
75 self.parser.add_argument("-d", "--date", type=unicode, help=_(u"date of the event")) 79 "-i",
76 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', 80 "--id",
77 metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set")) 81 type=base.unicode_decoder,
82 default=u"",
83 help=_(u"ID of the PubSub Item"),
84 )
85 self.parser.add_argument(
86 "-d", "--date", type=unicode, help=_(u"date of the event")
87 )
88 self.parser.add_argument(
89 "-f",
90 "--field",
91 type=base.unicode_decoder,
92 action="append",
93 nargs=2,
94 dest="fields",
95 metavar=(u"KEY", u"VALUE"),
96 help=_(u"configuration field to set"),
97 )
78 98
79 def parseFields(self): 99 def parseFields(self):
80 return dict(self.args.fields) if self.args.fields else {} 100 return dict(self.args.fields) if self.args.fields else {}
81 101
82 def parseDate(self): 102 def parseDate(self):
83 if self.args.date: 103 if self.args.date:
84 try: 104 try:
85 date = int(self.args.date) 105 date = int(self.args.date)
86 except ValueError: 106 except ValueError:
87 try: 107 try:
88 date_time = du_parser.parse(self.args.date, dayfirst=not (u'-' in self.args.date)) 108 date_time = du_parser.parse(
109 self.args.date, dayfirst=not (u"-" in self.args.date)
110 )
89 except ValueError as e: 111 except ValueError as e:
90 self.parser.error(_(u"Can't parse date: {msg}").format(msg=e)) 112 self.parser.error(_(u"Can't parse date: {msg}").format(msg=e))
91 if date_time.tzinfo is None: 113 if date_time.tzinfo is None:
92 date = calendar.timegm(date_time.timetuple()) 114 date = calendar.timegm(date_time.timetuple())
93 else: 115 else:
97 return date 119 return date
98 120
99 121
100 class Create(EventBase, base.CommandBase): 122 class Create(EventBase, base.CommandBase):
101 def __init__(self, host): 123 def __init__(self, host):
102 super(Create, self).__init__(host, 'create', use_pubsub=True, pubsub_flags={C.NODE}, help=_('create or replace event')) 124 super(Create, self).__init__(
125 host,
126 "create",
127 use_pubsub=True,
128 pubsub_flags={C.NODE},
129 help=_("create or replace event"),
130 )
103 EventBase.__init__(self) 131 EventBase.__init__(self)
104 self.need_loop=True 132 self.need_loop = True
105 133
106 def eventCreateCb(self, node): 134 def eventCreateCb(self, node):
107 self.disp(_(u'Event created successfuly on node {node}').format(node=node)) 135 self.disp(_(u"Event created successfuly on node {node}").format(node=node))
108 self.host.quit() 136 self.host.quit()
109 137
110 def start(self): 138 def start(self):
111 fields = self.parseFields() 139 fields = self.parseFields()
112 date = self.parseDate() 140 date = self.parseDate()
116 self.args.service, 144 self.args.service,
117 self.args.node, 145 self.args.node,
118 self.args.id, 146 self.args.id,
119 self.profile, 147 self.profile,
120 callback=self.eventCreateCb, 148 callback=self.eventCreateCb,
121 errback=partial(self.errback, 149 errback=partial(
122 msg=_(u"can't create event: {}"), 150 self.errback,
123 exit_code=C.EXIT_BRIDGE_ERRBACK)) 151 msg=_(u"can't create event: {}"),
152 exit_code=C.EXIT_BRIDGE_ERRBACK,
153 ),
154 )
124 155
125 156
126 class Modify(EventBase, base.CommandBase): 157 class Modify(EventBase, base.CommandBase):
127 def __init__(self, host): 158 def __init__(self, host):
128 super(Modify, self).__init__(host, 'modify', use_pubsub=True, pubsub_flags={C.NODE}, help=_('modify an existing event')) 159 super(Modify, self).__init__(
160 host,
161 "modify",
162 use_pubsub=True,
163 pubsub_flags={C.NODE},
164 help=_("modify an existing event"),
165 )
129 EventBase.__init__(self) 166 EventBase.__init__(self)
130 self.need_loop=True 167 self.need_loop = True
131 168
132 def start(self): 169 def start(self):
133 fields = self.parseFields() 170 fields = self.parseFields()
134 date = 0 if not self.args.date else self.parseDate() 171 date = 0 if not self.args.date else self.parseDate()
135 self.host.bridge.eventModify( 172 self.host.bridge.eventModify(
138 self.args.id, 175 self.args.id,
139 date, 176 date,
140 fields, 177 fields,
141 self.profile, 178 self.profile,
142 callback=self.host.quit, 179 callback=self.host.quit,
143 errback=partial(self.errback, 180 errback=partial(
144 msg=_(u"can't update event data: {}"), 181 self.errback,
145 exit_code=C.EXIT_BRIDGE_ERRBACK)) 182 msg=_(u"can't update event data: {}"),
183 exit_code=C.EXIT_BRIDGE_ERRBACK,
184 ),
185 )
146 186
147 187
148 class InviteeGet(base.CommandBase): 188 class InviteeGet(base.CommandBase):
149 189 def __init__(self, host):
150 def __init__(self, host): 190 base.CommandBase.__init__(
151 base.CommandBase.__init__(self, 191 self,
152 host, 192 host,
153 'get', 193 "get",
154 use_output=C.OUTPUT_DICT, 194 use_output=C.OUTPUT_DICT,
155 use_pubsub=True, pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM}, 195 use_pubsub=True,
156 use_verbose=True, 196 pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
157 help=_(u'get event attendance')) 197 use_verbose=True,
158 self.need_loop=True 198 help=_(u"get event attendance"),
199 )
200 self.need_loop = True
159 201
160 def add_parser_options(self): 202 def add_parser_options(self):
161 pass 203 pass
162 204
163 def eventInviteeGetCb(self, event_data): 205 def eventInviteeGetCb(self, event_data):
168 self.host.bridge.eventInviteeGet( 210 self.host.bridge.eventInviteeGet(
169 self.args.service, 211 self.args.service,
170 self.args.node, 212 self.args.node,
171 self.profile, 213 self.profile,
172 callback=self.eventInviteeGetCb, 214 callback=self.eventInviteeGetCb,
173 errback=partial(self.errback, 215 errback=partial(
174 msg=_(u"can't get event data: {}"), 216 self.errback,
175 exit_code=C.EXIT_BRIDGE_ERRBACK)) 217 msg=_(u"can't get event data: {}"),
218 exit_code=C.EXIT_BRIDGE_ERRBACK,
219 ),
220 )
176 221
177 222
178 class InviteeSet(base.CommandBase): 223 class InviteeSet(base.CommandBase):
179 def __init__(self, host): 224 def __init__(self, host):
180 super(InviteeSet, self).__init__(host, 'set', use_output=C.OUTPUT_DICT, use_pubsub=True, pubsub_flags={C.NODE}, help=_('set event attendance')) 225 super(InviteeSet, self).__init__(
181 self.need_loop=True 226 host,
227 "set",
228 use_output=C.OUTPUT_DICT,
229 use_pubsub=True,
230 pubsub_flags={C.NODE},
231 help=_("set event attendance"),
232 )
233 self.need_loop = True
182 234
183 def add_parser_options(self): 235 def add_parser_options(self):
184 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', 236 self.parser.add_argument(
185 metavar=(u"KEY", u"VALUE"), help=_(u"configuration field to set")) 237 "-f",
238 "--field",
239 type=base.unicode_decoder,
240 action="append",
241 nargs=2,
242 dest="fields",
243 metavar=(u"KEY", u"VALUE"),
244 help=_(u"configuration field to set"),
245 )
186 246
187 def start(self): 247 def start(self):
188 fields = dict(self.args.fields) if self.args.fields else {} 248 fields = dict(self.args.fields) if self.args.fields else {}
189 self.host.bridge.eventInviteeSet( 249 self.host.bridge.eventInviteeSet(
190 self.args.service, 250 self.args.service,
191 self.args.node, 251 self.args.node,
192 fields, 252 fields,
193 self.profile, 253 self.profile,
194 callback=self.host.quit, 254 callback=self.host.quit,
195 errback=partial(self.errback, 255 errback=partial(
196 msg=_(u"can't set event data: {}"), 256 self.errback,
197 exit_code=C.EXIT_BRIDGE_ERRBACK)) 257 msg=_(u"can't set event data: {}"),
258 exit_code=C.EXIT_BRIDGE_ERRBACK,
259 ),
260 )
198 261
199 262
200 class InviteesList(base.CommandBase): 263 class InviteesList(base.CommandBase):
201 264 def __init__(self, host):
202 def __init__(self, host): 265 extra_outputs = {"default": self.default_output}
203 extra_outputs = {'default': self.default_output} 266 base.CommandBase.__init__(
204 base.CommandBase.__init__(self, 267 self,
205 host, 268 host,
206 'list', 269 "list",
207 use_output=C.OUTPUT_DICT_DICT, 270 use_output=C.OUTPUT_DICT_DICT,
208 extra_outputs=extra_outputs, 271 extra_outputs=extra_outputs,
209 use_pubsub=True, pubsub_flags={C.NODE}, 272 use_pubsub=True,
210 use_verbose=True, 273 pubsub_flags={C.NODE},
211 help=_(u'get event attendance')) 274 use_verbose=True,
212 self.need_loop=True 275 help=_(u"get event attendance"),
276 )
277 self.need_loop = True
213 278
214 def add_parser_options(self): 279 def add_parser_options(self):
215 self.parser.add_argument('-m', '--missing', action='store_true', help=_(u'show missing people (invited but no R.S.V.P. so far)')) 280 self.parser.add_argument(
216 self.parser.add_argument('-R', '--no-rsvp', action='store_true', help=_(u"don't show people which gave R.S.V.P.")) 281 "-m",
282 "--missing",
283 action="store_true",
284 help=_(u"show missing people (invited but no R.S.V.P. so far)"),
285 )
286 self.parser.add_argument(
287 "-R",
288 "--no-rsvp",
289 action="store_true",
290 help=_(u"don't show people which gave R.S.V.P."),
291 )
217 292
218 def _attend_filter(self, attend, row): 293 def _attend_filter(self, attend, row):
219 if attend == u'yes': 294 if attend == u"yes":
220 attend_color = C.A_SUCCESS 295 attend_color = C.A_SUCCESS
221 elif attend == u'no': 296 elif attend == u"no":
222 attend_color = C.A_FAILURE 297 attend_color = C.A_FAILURE
223 else: 298 else:
224 attend_color = A.FG_WHITE 299 attend_color = A.FG_WHITE
225 return A.color(attend_color, attend) 300 return A.color(attend_color, attend)
226 301
227 def _guests_filter(self, guests): 302 def _guests_filter(self, guests):
228 return u'(' + unicode(guests) + ')' if guests else u'' 303 return u"(" + unicode(guests) + ")" if guests else u""
229 304
230 def default_output(self, event_data): 305 def default_output(self, event_data):
231 data = [] 306 data = []
232 attendees_yes = 0 307 attendees_yes = 0
233 attendees_maybe = 0 308 attendees_maybe = 0
234 attendees_no = 0 309 attendees_no = 0
235 attendees_missing = 0 310 attendees_missing = 0
236 guests = 0 311 guests = 0
237 guests_maybe = 0 312 guests_maybe = 0
238 for jid_, jid_data in event_data.iteritems(): 313 for jid_, jid_data in event_data.iteritems():
239 jid_data[u'jid'] = jid_ 314 jid_data[u"jid"] = jid_
240 try: 315 try:
241 guests_int = int(jid_data['guests']) 316 guests_int = int(jid_data["guests"])
242 except (ValueError, KeyError): 317 except (ValueError, KeyError):
243 pass 318 pass
244 attend = jid_data.get(u'attend',u'') 319 attend = jid_data.get(u"attend", u"")
245 if attend == 'yes': 320 if attend == "yes":
246 attendees_yes += 1 321 attendees_yes += 1
247 guests += guests_int 322 guests += guests_int
248 elif attend == 'maybe': 323 elif attend == "maybe":
249 attendees_maybe += 1 324 attendees_maybe += 1
250 guests_maybe += guests_int 325 guests_maybe += guests_int
251 elif attend == 'no': 326 elif attend == "no":
252 attendees_no += 1 327 attendees_no += 1
253 jid_data[u'guests'] = '' 328 jid_data[u"guests"] = ""
254 else: 329 else:
255 attendees_missing += 1 330 attendees_missing += 1
256 jid_data[u'guests'] = '' 331 jid_data[u"guests"] = ""
257 data.append(jid_data) 332 data.append(jid_data)
258 333
259 show_table = OUTPUT_OPT_TABLE in self.args.output_opts 334 show_table = OUTPUT_OPT_TABLE in self.args.output_opts
260 335
261 table = common.Table.fromDict(self.host, 336 table = common.Table.fromDict(
337 self.host,
262 data, 338 data,
263 (u'nick',) + ((u'jid',) if self.host.verbosity else ()) + (u'attend', 'guests'), 339 (u"nick",)
340 + ((u"jid",) if self.host.verbosity else ())
341 + (u"attend", "guests"),
264 headers=None, 342 headers=None,
265 filters = { u'nick': A.color(C.A_HEADER, u'{}' if show_table else u'{} '), 343 filters={
266 u'jid': u'{}' if show_table else u'{} ', 344 u"nick": A.color(C.A_HEADER, u"{}" if show_table else u"{} "),
267 u'attend': self._attend_filter, 345 u"jid": u"{}" if show_table else u"{} ",
268 u'guests': u'{}' if show_table else self._guests_filter, 346 u"attend": self._attend_filter,
269 }, 347 u"guests": u"{}" if show_table else self._guests_filter,
270 defaults = { u'nick': u'', 348 },
271 u'attend': u'', 349 defaults={u"nick": u"", u"attend": u"", u"guests": 1},
272 u'guests': 1 350 )
273 }
274 )
275 if show_table: 351 if show_table:
276 table.display() 352 table.display()
277 else: 353 else:
278 table.display_blank(show_header=False, col_sep=u'') 354 table.display_blank(show_header=False, col_sep=u"")
279 355
280 if not self.args.no_rsvp: 356 if not self.args.no_rsvp:
281 self.disp(u'') 357 self.disp(u"")
282 self.disp(A.color( 358 self.disp(
283 C.A_SUBHEADER, 359 A.color(
284 _(u'Attendees: '), 360 C.A_SUBHEADER,
285 A.RESET, 361 _(u"Attendees: "),
286 unicode(len(data)), 362 A.RESET,
287 _(u' ('), 363 unicode(len(data)),
288 C.A_SUCCESS, 364 _(u" ("),
289 _(u'yes: '), 365 C.A_SUCCESS,
290 unicode(attendees_yes), 366 _(u"yes: "),
291 A.FG_WHITE, 367 unicode(attendees_yes),
292 _(u', maybe: '), 368 A.FG_WHITE,
293 unicode(attendees_maybe), 369 _(u", maybe: "),
294 u', ', 370 unicode(attendees_maybe),
295 C.A_FAILURE, 371 u", ",
296 _(u'no: '), 372 C.A_FAILURE,
297 unicode(attendees_no), 373 _(u"no: "),
298 A.RESET, 374 unicode(attendees_no),
299 u')' 375 A.RESET,
300 )) 376 u")",
301 self.disp(A.color(C.A_SUBHEADER, _(u'confirmed guests: '), A.RESET, unicode(guests))) 377 )
302 self.disp(A.color(C.A_SUBHEADER, _(u'unconfirmed guests: '), A.RESET, unicode(guests_maybe))) 378 )
303 self.disp(A.color(C.A_SUBHEADER, _(u'total: '), A.RESET, unicode(guests+guests_maybe))) 379 self.disp(
380 A.color(C.A_SUBHEADER, _(u"confirmed guests: "), A.RESET, unicode(guests))
381 )
382 self.disp(
383 A.color(
384 C.A_SUBHEADER,
385 _(u"unconfirmed guests: "),
386 A.RESET,
387 unicode(guests_maybe),
388 )
389 )
390 self.disp(
391 A.color(
392 C.A_SUBHEADER, _(u"total: "), A.RESET, unicode(guests + guests_maybe)
393 )
394 )
304 if attendees_missing: 395 if attendees_missing:
305 self.disp('') 396 self.disp("")
306 self.disp(A.color(C.A_SUBHEADER, _(u'missing people (no reply): '), A.RESET, unicode(attendees_missing))) 397 self.disp(
398 A.color(
399 C.A_SUBHEADER,
400 _(u"missing people (no reply): "),
401 A.RESET,
402 unicode(attendees_missing),
403 )
404 )
307 405
308 def eventInviteesListCb(self, event_data, prefilled_data): 406 def eventInviteesListCb(self, event_data, prefilled_data):
309 """fill nicknames and keep only requested people 407 """fill nicknames and keep only requested people
310 408
311 @param event_data(dict): R.S.V.P. answers 409 @param event_data(dict): R.S.V.P. answers
323 prefilled_data.update(event_data) 421 prefilled_data.update(event_data)
324 422
325 # we get nicknames for everybody, make it easier for organisers 423 # we get nicknames for everybody, make it easier for organisers
326 for jid_, data in prefilled_data.iteritems(): 424 for jid_, data in prefilled_data.iteritems():
327 id_data = self.host.bridge.identityGet(jid_, self.profile) 425 id_data = self.host.bridge.identityGet(jid_, self.profile)
328 data[u'nick'] = id_data.get(u'nick', u'') 426 data[u"nick"] = id_data.get(u"nick", u"")
329 427
330 self.output(prefilled_data) 428 self.output(prefilled_data)
331 self.host.quit() 429 self.host.quit()
332 430
333 def getList(self, prefilled_data={}): 431 def getList(self, prefilled_data={}):
334 self.host.bridge.eventInviteesList( 432 self.host.bridge.eventInviteesList(
335 self.args.service, 433 self.args.service,
336 self.args.node, 434 self.args.node,
337 self.profile, 435 self.profile,
338 callback=partial(self.eventInviteesListCb, 436 callback=partial(self.eventInviteesListCb, prefilled_data=prefilled_data),
339 prefilled_data=prefilled_data), 437 errback=partial(
340 errback=partial(self.errback, 438 self.errback,
341 msg=_(u"can't get event data: {}"), 439 msg=_(u"can't get event data: {}"),
342 exit_code=C.EXIT_BRIDGE_ERRBACK)) 440 exit_code=C.EXIT_BRIDGE_ERRBACK,
441 ),
442 )
343 443
344 def psNodeAffiliationsGetCb(self, affiliations): 444 def psNodeAffiliationsGetCb(self, affiliations):
345 # we fill all affiliations with empty data 445 # we fill all affiliations with empty data
346 # answered one will be filled in eventInviteesListCb 446 # answered one will be filled in eventInviteesListCb
347 # we only consider people with "publisher" affiliation as invited, creators are not, and members can just observe 447 # we only consider people with "publisher" affiliation as invited, creators are not, and members can just observe
348 prefilled = {jid_: {} for jid_, affiliation in affiliations.iteritems() if affiliation in (u'publisher',)} 448 prefilled = {
449 jid_: {}
450 for jid_, affiliation in affiliations.iteritems()
451 if affiliation in (u"publisher",)
452 }
349 self.getList(prefilled) 453 self.getList(prefilled)
350 454
351 def start(self): 455 def start(self):
352 if self.args.no_rsvp and not self.args.missing: 456 if self.args.no_rsvp and not self.args.missing:
353 self.parser.error(_(u"you need to use --missing if you use --no-rsvp")) 457 self.parser.error(_(u"you need to use --missing if you use --no-rsvp"))
355 self.host.bridge.psNodeAffiliationsGet( 459 self.host.bridge.psNodeAffiliationsGet(
356 self.args.service, 460 self.args.service,
357 self.args.node, 461 self.args.node,
358 self.profile, 462 self.profile,
359 callback=self.psNodeAffiliationsGetCb, 463 callback=self.psNodeAffiliationsGetCb,
360 errback=partial(self.errback, 464 errback=partial(
361 msg=_(u"can't get event data: {}"), 465 self.errback,
362 exit_code=C.EXIT_BRIDGE_ERRBACK)) 466 msg=_(u"can't get event data: {}"),
467 exit_code=C.EXIT_BRIDGE_ERRBACK,
468 ),
469 )
363 else: 470 else:
364 self.getList() 471 self.getList()
365 472
366 473
367 class InviteeInvite(base.CommandBase): 474 class InviteeInvite(base.CommandBase):
368 475 def __init__(self, host):
369 def __init__(self, host): 476 base.CommandBase.__init__(
370 base.CommandBase.__init__(self, host, 'invite', use_pubsub=True, pubsub_flags={C.NODE, C.SINGLE_ITEM}, help=_(u'invite someone to the event through email')) 477 self,
371 self.need_loop=True 478 host,
479 "invite",
480 use_pubsub=True,
481 pubsub_flags={C.NODE, C.SINGLE_ITEM},
482 help=_(u"invite someone to the event through email"),
483 )
484 self.need_loop = True
372 485
373 def add_parser_options(self): 486 def add_parser_options(self):
374 self.parser.add_argument("-e", "--email", action="append", type=base.unicode_decoder, default=[], help='email(s) to send the invitation to') 487 self.parser.add_argument(
375 self.parser.add_argument("-N", "--name", type=base.unicode_decoder, default='', help='name of the invitee') 488 "-e",
376 self.parser.add_argument("-H", "--host-name", type=base.unicode_decoder, default='', help='name of the host') 489 "--email",
377 self.parser.add_argument("-l", "--lang", type=base.unicode_decoder, default='', help='main language spoken by the invitee') 490 action="append",
378 self.parser.add_argument("-U", "--url-template", type=base.unicode_decoder, default='', help='template to construct the URL') 491 type=base.unicode_decoder,
379 self.parser.add_argument("-S", "--subject", type=base.unicode_decoder, default='', help='subject of the invitation email (default: generic subject)') 492 default=[],
380 self.parser.add_argument("-b", "--body", type=base.unicode_decoder, default='', help='body of the invitation email (default: generic body)') 493 help="email(s) to send the invitation to",
494 )
495 self.parser.add_argument(
496 "-N",
497 "--name",
498 type=base.unicode_decoder,
499 default="",
500 help="name of the invitee",
501 )
502 self.parser.add_argument(
503 "-H",
504 "--host-name",
505 type=base.unicode_decoder,
506 default="",
507 help="name of the host",
508 )
509 self.parser.add_argument(
510 "-l",
511 "--lang",
512 type=base.unicode_decoder,
513 default="",
514 help="main language spoken by the invitee",
515 )
516 self.parser.add_argument(
517 "-U",
518 "--url-template",
519 type=base.unicode_decoder,
520 default="",
521 help="template to construct the URL",
522 )
523 self.parser.add_argument(
524 "-S",
525 "--subject",
526 type=base.unicode_decoder,
527 default="",
528 help="subject of the invitation email (default: generic subject)",
529 )
530 self.parser.add_argument(
531 "-b",
532 "--body",
533 type=base.unicode_decoder,
534 default="",
535 help="body of the invitation email (default: generic body)",
536 )
381 537
382 def start(self): 538 def start(self):
383 email = self.args.email[0] if self.args.email else None 539 email = self.args.email[0] if self.args.email else None
384 emails_extra = self.args.email[1:] 540 emails_extra = self.args.email[1:]
385 541
395 self.args.url_template, 551 self.args.url_template,
396 self.args.subject, 552 self.args.subject,
397 self.args.body, 553 self.args.body,
398 self.args.profile, 554 self.args.profile,
399 callback=self.host.quit, 555 callback=self.host.quit,
400 errback=partial(self.errback, 556 errback=partial(
401 msg=_(u"can't create invitation: {}"), 557 self.errback,
402 exit_code=C.EXIT_BRIDGE_ERRBACK)) 558 msg=_(u"can't create invitation: {}"),
559 exit_code=C.EXIT_BRIDGE_ERRBACK,
560 ),
561 )
403 562
404 563
405 class Invitee(base.CommandBase): 564 class Invitee(base.CommandBase):
406 subcommands = (InviteeGet, InviteeSet, InviteesList, InviteeInvite) 565 subcommands = (InviteeGet, InviteeSet, InviteesList, InviteeInvite)
407 566
408 def __init__(self, host): 567 def __init__(self, host):
409 super(Invitee, self).__init__(host, 'invitee', use_profile=False, help=_(u'manage invities')) 568 super(Invitee, self).__init__(
569 host, "invitee", use_profile=False, help=_(u"manage invities")
570 )
410 571
411 572
412 class Event(base.CommandBase): 573 class Event(base.CommandBase):
413 subcommands = (Get, Create, Modify, Invitee) 574 subcommands = (Get, Create, Modify, Invitee)
414 575
415 def __init__(self, host): 576 def __init__(self, host):
416 super(Event, self).__init__(host, 'event', use_profile=False, help=_('event management')) 577 super(Event, self).__init__(
578 host, "event", use_profile=False, help=_("event management")
579 )