annotate sat_frontends/jp/cmd_event.py @ 3032:95e2fd14a761

plugin XEP-0329: fixed ShareNode item() and values after Python 3 port
author Goffi <goffi@goffi.org>
date Fri, 16 Aug 2019 17:06:44 +0200
parents ab2696e34d29
children fee60f17ebac
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python2
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # jp: a SàT command line tool
2771
003b8b4b56a7 date update
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org)
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
20
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
21 from . import base
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from sat.core.i18n import _
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
23 from sat.tools.common.ansi import ANSI as A
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from sat_frontends.jp.constants import Const as C
2284
4fd010f29f99 jp (blog, event): added checkURI to some command to be able to enter a xmpp: uri as argument
Goffi <goffi@goffi.org>
parents: 2283
diff changeset
25 from sat_frontends.jp import common
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from functools import partial
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
27 from dateutil import parser as du_parser
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
28 import calendar
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
29 import time
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31 __commands__ = ["Event"]
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
32
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
33 OUTPUT_OPT_TABLE = "table"
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
34
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
35 # TODO: move date parsing to base, it may be useful for other commands
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
36
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
37
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
38 class Get(base.CommandBase):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
39 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
40 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
41 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
42 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
43 "get",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
44 use_output=C.OUTPUT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
45 use_pubsub=True,
2910
b2f323237fce jp, plugin merge-requests: used u'' as default for item id in pubsub arguments + fixed some required arguments:
Goffi <goffi@goffi.org>
parents: 2771
diff changeset
46 pubsub_flags={C.SINGLE_ITEM},
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
47 use_verbose=True,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
48 help=_("get event data"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
49 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
50 self.need_loop = True
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
51
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
52 def add_parser_options(self):
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
53 pass
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
54
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
55 def eventInviteeGetCb(self, result):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
56 event_date, event_data = result
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
57 event_data["date"] = event_date
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
58 self.output(event_data)
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
59 self.host.quit()
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
60
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
61 def start(self):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
62 self.host.bridge.eventGet(
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
63 self.args.service,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
64 self.args.node,
2283
5b04fc0c663d jp (pubsub/get): renamed --id option to --item for consistency with other commands
Goffi <goffi@goffi.org>
parents: 2247
diff changeset
65 self.args.item,
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
66 self.profile,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
67 callback=self.eventInviteeGetCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
68 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
69 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
70 msg=_("can't get event data: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
71 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
72 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
73 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
74
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
75
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
76 class EventBase(object):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
77 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
78 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
79 "-i",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
80 "--id",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
81 default="",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
82 help=_("ID of the PubSub Item"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
83 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
84 self.parser.add_argument(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
85 "-d", "--date", type=str, help=_("date of the event")
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
86 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
87 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
88 "-f",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
89 "--field",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
90 action="append",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
91 nargs=2,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
92 dest="fields",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
93 metavar=("KEY", "VALUE"),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
94 help=_("configuration field to set"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
95 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
96
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
97 def parseFields(self):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
98 return dict(self.args.fields) if self.args.fields else {}
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
99
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
100 def parseDate(self):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
101 if self.args.date:
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
102 try:
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
103 date = int(self.args.date)
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
104 except ValueError:
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
105 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
106 date_time = du_parser.parse(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
107 self.args.date, dayfirst=not ("-" in self.args.date)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
108 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
109 except ValueError as e:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
110 self.parser.error(_("Can't parse date: {msg}").format(msg=e))
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
111 if date_time.tzinfo is None:
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
112 date = calendar.timegm(date_time.timetuple())
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
113 else:
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
114 date = time.mktime(date_time.timetuple())
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
115 else:
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
116 date = -1
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
117 return date
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
118
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
119
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
120 class Create(EventBase, base.CommandBase):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
121 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
122 super(Create, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
123 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
124 "create",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
125 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
126 help=_("create or replace event"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
127 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
128 EventBase.__init__(self)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
129 self.need_loop = True
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
130
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
131 def eventCreateCb(self, node):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
132 self.disp(_("Event created successfuly on node {node}").format(node=node))
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
133 self.host.quit()
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
134
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
135 def start(self):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
136 fields = self.parseFields()
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
137 date = self.parseDate()
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
138 self.host.bridge.eventCreate(
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
139 date,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
140 fields,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
141 self.args.service,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
142 self.args.node,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
143 self.args.id,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
144 self.profile,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
145 callback=self.eventCreateCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
146 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
147 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
148 msg=_("can't create event: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
149 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
150 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
151 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
152
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
153
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
154 class Modify(EventBase, base.CommandBase):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
155 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
156 super(Modify, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
157 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
158 "modify",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
159 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
160 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
161 help=_("modify an existing event"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
162 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
163 EventBase.__init__(self)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
164 self.need_loop = True
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
165
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
166 def start(self):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
167 fields = self.parseFields()
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
168 date = 0 if not self.args.date else self.parseDate()
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
169 self.host.bridge.eventModify(
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
170 self.args.service,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
171 self.args.node,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
172 self.args.id,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
173 date,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
174 fields,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
175 self.profile,
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
176 callback=self.host.quit,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
177 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
178 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
179 msg=_("can't update event data: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
180 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
181 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
182 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
183
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
184
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
185 class InviteeGet(base.CommandBase):
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
186 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
187 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
188 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
189 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
190 "get",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
191 use_output=C.OUTPUT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
192 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
193 pubsub_flags={C.NODE, C.ITEM, C.SINGLE_ITEM},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
194 use_verbose=True,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
195 help=_("get event attendance"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
196 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
197 self.need_loop = True
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
198
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
199 def add_parser_options(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
200 pass
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
201
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
202 def eventInviteeGetCb(self, event_data):
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
203 self.output(event_data)
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
204 self.host.quit()
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
205
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
206 def start(self):
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
207 self.host.bridge.eventInviteeGet(
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
208 self.args.service,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
209 self.args.node,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
210 self.profile,
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
211 callback=self.eventInviteeGetCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
212 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
213 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
214 msg=_("can't get event data: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
215 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
216 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
217 )
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
218
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
219
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
220 class InviteeSet(base.CommandBase):
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
221 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
222 super(InviteeSet, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
223 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
224 "set",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
225 use_output=C.OUTPUT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
226 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
227 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
228 help=_("set event attendance"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
229 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
230 self.need_loop = True
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
231
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
232 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
233 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
234 "-f",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
235 "--field",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
236 action="append",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
237 nargs=2,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
238 dest="fields",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
239 metavar=("KEY", "VALUE"),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
240 help=_("configuration field to set"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
241 )
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
242
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
243 def start(self):
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
244 fields = dict(self.args.fields) if self.args.fields else {}
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
245 self.host.bridge.eventInviteeSet(
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
246 self.args.service,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
247 self.args.node,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
248 fields,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
249 self.profile,
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
250 callback=self.host.quit,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
251 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
252 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
253 msg=_("can't set event data: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
254 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
255 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
256 )
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
257
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
258
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
259 class InviteesList(base.CommandBase):
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
260 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
261 extra_outputs = {"default": self.default_output}
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
262 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
263 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
264 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
265 "list",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
266 use_output=C.OUTPUT_DICT_DICT,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
267 extra_outputs=extra_outputs,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
268 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
269 pubsub_flags={C.NODE},
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
270 use_verbose=True,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
271 help=_("get event attendance"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
272 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
273 self.need_loop = True
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
274
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
275 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
276 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
277 "-m",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
278 "--missing",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
279 action="store_true",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
280 help=_("show missing people (invited but no R.S.V.P. so far)"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
281 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
282 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
283 "-R",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
284 "--no-rsvp",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
285 action="store_true",
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
286 help=_("don't show people which gave R.S.V.P."),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
287 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
288
2491
5895e4daae8c jp (event): added missing arg to _attend_filter
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
289 def _attend_filter(self, attend, row):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
290 if attend == "yes":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
291 attend_color = C.A_SUCCESS
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
292 elif attend == "no":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
293 attend_color = C.A_FAILURE
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
294 else:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
295 attend_color = A.FG_WHITE
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
296 return A.color(attend_color, attend)
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
297
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
298 def _guests_filter(self, guests):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
299 return "(" + str(guests) + ")" if guests else ""
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
301 def default_output(self, event_data):
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
302 data = []
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
303 attendees_yes = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
304 attendees_maybe = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
305 attendees_no = 0
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
306 attendees_missing = 0
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
307 guests = 0
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
308 guests_maybe = 0
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
309 for jid_, jid_data in event_data.items():
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
310 jid_data["jid"] = jid_
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
311 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
312 guests_int = int(jid_data["guests"])
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
313 except (ValueError, KeyError):
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
314 pass
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
315 attend = jid_data.get("attend", "")
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
316 if attend == "yes":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
317 attendees_yes += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
318 guests += guests_int
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
319 elif attend == "maybe":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
320 attendees_maybe += 1
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
321 guests_maybe += guests_int
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
322 elif attend == "no":
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
323 attendees_no += 1
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
324 jid_data["guests"] = ""
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
325 else:
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
326 attendees_missing += 1
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
327 jid_data["guests"] = ""
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
328 data.append(jid_data)
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
329
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
330 show_table = OUTPUT_OPT_TABLE in self.args.output_opts
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
331
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
332 table = common.Table.fromDict(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
333 self.host,
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
334 data,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
335 ("nick",)
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
336 + (("jid",) if self.host.verbosity else ())
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
337 + ("attend", "guests"),
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
338 headers=None,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
339 filters={
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
340 "nick": A.color(C.A_HEADER, "{}" if show_table else "{} "),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
341 "jid": "{}" if show_table else "{} ",
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
342 "attend": self._attend_filter,
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
343 "guests": "{}" if show_table else self._guests_filter,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
344 },
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
345 defaults={"nick": "", "attend": "", "guests": 1},
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
346 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
347 if show_table:
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
348 table.display()
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
349 else:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
350 table.display_blank(show_header=False, col_sep="")
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
351
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
352 if not self.args.no_rsvp:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
353 self.disp("")
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
354 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
355 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
356 C.A_SUBHEADER,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
357 _("Attendees: "),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
358 A.RESET,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
359 str(len(data)),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
360 _(" ("),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
361 C.A_SUCCESS,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
362 _("yes: "),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
363 str(attendees_yes),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
364 A.FG_WHITE,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
365 _(", maybe: "),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
366 str(attendees_maybe),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
367 ", ",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
368 C.A_FAILURE,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
369 _("no: "),
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
370 str(attendees_no),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
371 A.RESET,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
372 ")",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
373 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
374 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
375 self.disp(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
376 A.color(C.A_SUBHEADER, _("confirmed guests: "), A.RESET, str(guests))
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
377 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
378 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
379 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
380 C.A_SUBHEADER,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
381 _("unconfirmed guests: "),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
382 A.RESET,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
383 str(guests_maybe),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
384 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
385 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
386 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
387 A.color(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
388 C.A_SUBHEADER, _("total: "), A.RESET, str(guests + guests_maybe)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
389 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
390 )
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
391 if attendees_missing:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
392 self.disp("")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
393 self.disp(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
394 A.color(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
395 C.A_SUBHEADER,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
396 _("missing people (no reply): "),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
397 A.RESET,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
398 str(attendees_missing),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
399 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
400 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
401
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
402 def eventInviteesListCb(self, event_data, prefilled_data):
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
403 """fill nicknames and keep only requested people
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
404
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
405 @param event_data(dict): R.S.V.P. answers
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
406 @param prefilled_data(dict): prefilled data with all people
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
407 only filled if --missing is used
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
408 """
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
409 if self.args.no_rsvp:
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
410 for jid_ in event_data:
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
411 # if there is a jid in event_data
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
412 # it must be there in prefilled_data too
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
413 # so no need to check for KeyError
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
414 del prefilled_data[jid_]
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
415 else:
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
416 # we replace empty dicts for existing people with R.S.V.P. data
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
417 prefilled_data.update(event_data)
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
418
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
419 # we get nicknames for everybody, make it easier for organisers
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
420 for jid_, data in prefilled_data.items():
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
421 id_data = self.host.bridge.identityGet(jid_, self.profile)
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
422 data["nick"] = id_data.get("nick", "")
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
423
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
424 self.output(prefilled_data)
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
425 self.host.quit()
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
426
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
427 def getList(self, prefilled_data={}):
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
428 self.host.bridge.eventInviteesList(
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
429 self.args.service,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
430 self.args.node,
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
431 self.profile,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
432 callback=partial(self.eventInviteesListCb, prefilled_data=prefilled_data),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
433 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
434 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
435 msg=_("can't get event data: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
436 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
437 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
438 )
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
439
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
440 def psNodeAffiliationsGetCb(self, affiliations):
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
441 # we fill all affiliations with empty data
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
442 # answered one will be filled in eventInviteesListCb
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
443 # we only consider people with "publisher" affiliation as invited, creators are not, and members can just observe
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
444 prefilled = {
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
445 jid_: {}
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
446 for jid_, affiliation in affiliations.items()
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
447 if affiliation in ("publisher",)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
448 }
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
449 self.getList(prefilled)
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
450
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
451 def start(self):
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
452 if self.args.no_rsvp and not self.args.missing:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
453 self.parser.error(_("you need to use --missing if you use --no-rsvp"))
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
454 if self.args.missing:
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
455 self.host.bridge.psNodeAffiliationsGet(
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
456 self.args.service,
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
457 self.args.node,
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
458 self.profile,
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
459 callback=self.psNodeAffiliationsGetCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
460 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
461 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
462 msg=_("can't get event data: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
463 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
464 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
465 )
2321
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
466 else:
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
467 self.getList()
c2a9da96e40b jp (event/attendee/list): added --missing to show missing people (ones who didn't replied) and --no-rsvp to hide ones who answered
Goffi <goffi@goffi.org>
parents: 2301
diff changeset
468
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
469
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
470 class InviteeInvite(base.CommandBase):
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
471 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
472 base.CommandBase.__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
473 self,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
474 host,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
475 "invite",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
476 use_pubsub=True,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
477 pubsub_flags={C.NODE, C.SINGLE_ITEM},
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
478 help=_("invite someone to the event through email"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
479 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
480 self.need_loop = True
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
481
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
482 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
483 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
484 "-e",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
485 "--email",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
486 action="append",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
487 default=[],
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
488 help="email(s) to send the invitation to",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
489 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
490 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
491 "-N",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
492 "--name",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
493 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
494 help="name of the invitee",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
495 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
496 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
497 "-H",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
498 "--host-name",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
499 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
500 help="name of the host",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
501 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
502 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
503 "-l",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
504 "--lang",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
505 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
506 help="main language spoken by the invitee",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
507 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
508 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
509 "-U",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
510 "--url-template",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
511 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
512 help="template to construct the URL",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
513 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
514 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
515 "-S",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
516 "--subject",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
517 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
518 help="subject of the invitation email (default: generic subject)",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
519 )
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
520 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
521 "-b",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
522 "--body",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
523 default="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
524 help="body of the invitation email (default: generic body)",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
525 )
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
526
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
527 def start(self):
2291
c05000d00dbb plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents: 2288
diff changeset
528 email = self.args.email[0] if self.args.email else None
c05000d00dbb plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents: 2288
diff changeset
529 emails_extra = self.args.email[1:]
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
530
2616
1cc88adb5142 plugin events: invitations improvments + personal list
Goffi <goffi@goffi.org>
parents: 2614
diff changeset
531 self.host.bridge.eventInviteByEmail(
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
532 self.args.service,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
533 self.args.node,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
534 self.args.item,
2291
c05000d00dbb plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents: 2288
diff changeset
535 email,
c05000d00dbb plugin events, invitations + jp (event/create, invitation/invitee/invite): several emails addresses can now be specified for a single invitation:
Goffi <goffi@goffi.org>
parents: 2288
diff changeset
536 emails_extra,
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
537 self.args.name,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
538 self.args.host_name,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
539 self.args.lang,
2532
772447ec070f jp: pubsub options refactoring:
Goffi <goffi@goffi.org>
parents: 2491
diff changeset
540 self.args.url_template,
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
541 self.args.subject,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
542 self.args.body,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
543 self.args.profile,
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
544 callback=self.host.quit,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
545 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
546 self.errback,
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
547 msg=_("can't create invitation: {}"),
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
548 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
549 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
550 )
2288
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
551
f4d8d83a50e2 jp (event/invitee/invite): command to use new eventInvite backend method
Goffi <goffi@goffi.org>
parents: 2284
diff changeset
552
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
553 class Invitee(base.CommandBase):
2300
173d56315529 jp (event/invitee): added list command to get R.S.V.P. :
Goffi <goffi@goffi.org>
parents: 2299
diff changeset
554 subcommands = (InviteeGet, InviteeSet, InviteesList, InviteeInvite)
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
555
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
556 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
557 super(Invitee, self).__init__(
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2910
diff changeset
558 host, "invitee", use_profile=False, help=_("manage invities")
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
559 )
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
560
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
561
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
562 class Event(base.CommandBase):
2244
9d49e66bdbf2 jp (event): creation/modification of main event + invitee commands are now in a "invitee" subcommand
Goffi <goffi@goffi.org>
parents: 2236
diff changeset
563 subcommands = (Get, Create, Modify, Invitee)
2236
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
564
4b1873ce6b61 jp (event): event handling commands, first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
565 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
566 super(Event, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
567 host, "event", use_profile=False, help=_("event management")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2616
diff changeset
568 )