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

code style reformatting using black
author Goffi <goffi@goffi.org>
date Wed, 27 Jun 2018 20:14:46 +0200
parents 26edcf3a30eb
children 003b8b4b56a7
comparison
equal deleted inserted replaced
2623:49533de4540b 2624:56f94936df1e
27 27
28 # TODO: move date parsing to base, it may be useful for other commands 28 # TODO: move date parsing to base, it may be useful for other commands
29 29
30 30
31 class Get(base.CommandBase): 31 class Get(base.CommandBase):
32
33 def __init__(self, host): 32 def __init__(self, host):
34 base.CommandBase.__init__(self, 33 base.CommandBase.__init__(
35 host, 34 self,
36 'get', 35 host,
37 use_output=C.OUTPUT_DICT, 36 "get",
38 use_verbose=True, 37 use_output=C.OUTPUT_DICT,
39 help=_(u'get identity data')) 38 use_verbose=True,
40 self.need_loop=True 39 help=_(u"get identity data"),
40 )
41 self.need_loop = True
41 42
42 def add_parser_options(self): 43 def add_parser_options(self):
43 self.parser.add_argument("jid", type=base.unicode_decoder, help=_(u"entity to check")) 44 self.parser.add_argument(
45 "jid", type=base.unicode_decoder, help=_(u"entity to check")
46 )
44 47
45 def identityGetCb(self, data): 48 def identityGetCb(self, data):
46 self.output(data) 49 self.output(data)
47 self.host.quit() 50 self.host.quit()
48 51
50 jid_ = self.host.check_jids([self.args.jid])[0] 53 jid_ = self.host.check_jids([self.args.jid])[0]
51 self.host.bridge.identityGet( 54 self.host.bridge.identityGet(
52 jid_, 55 jid_,
53 self.profile, 56 self.profile,
54 callback=self.identityGetCb, 57 callback=self.identityGetCb,
55 errback=partial(self.errback, 58 errback=partial(
56 msg=_(u"can't get identity data: {}"), 59 self.errback,
57 exit_code=C.EXIT_BRIDGE_ERRBACK)) 60 msg=_(u"can't get identity data: {}"),
61 exit_code=C.EXIT_BRIDGE_ERRBACK,
62 ),
63 )
58 64
59 65
60 class Set(base.CommandBase): 66 class Set(base.CommandBase):
61 def __init__(self, host): 67 def __init__(self, host):
62 super(Set, self).__init__(host, 'set', help=_('modify an existing event')) 68 super(Set, self).__init__(host, "set", help=_("modify an existing event"))
63 69
64 def add_parser_options(self): 70 def add_parser_options(self):
65 self.parser.add_argument("-f", "--field", type=base.unicode_decoder, action='append', nargs=2, dest='fields', 71 self.parser.add_argument(
66 metavar=(u"KEY", u"VALUE"), required=True, help=_(u"identity field(s) to set")) 72 "-f",
67 self.need_loop=True 73 "--field",
74 type=base.unicode_decoder,
75 action="append",
76 nargs=2,
77 dest="fields",
78 metavar=(u"KEY", u"VALUE"),
79 required=True,
80 help=_(u"identity field(s) to set"),
81 )
82 self.need_loop = True
68 83
69 def start(self): 84 def start(self):
70 fields = dict(self.args.fields) 85 fields = dict(self.args.fields)
71 self.host.bridge.identitySet( 86 self.host.bridge.identitySet(
72 fields, 87 fields,
73 self.profile, 88 self.profile,
74 callback=self.host.quit, 89 callback=self.host.quit,
75 errback=partial(self.errback, 90 errback=partial(
76 msg=_(u"can't set identity data data: {}"), 91 self.errback,
77 exit_code=C.EXIT_BRIDGE_ERRBACK)) 92 msg=_(u"can't set identity data data: {}"),
93 exit_code=C.EXIT_BRIDGE_ERRBACK,
94 ),
95 )
78 96
79 97
80 class Identity(base.CommandBase): 98 class Identity(base.CommandBase):
81 subcommands = (Get, Set) 99 subcommands = (Get, Set)
82 100
83 def __init__(self, host): 101 def __init__(self, host):
84 super(Identity, self).__init__(host, 'identity', use_profile=False, help=_('identity management')) 102 super(Identity, self).__init__(
103 host, "identity", use_profile=False, help=_("identity management")
104 )