comparison sat_frontends/jp/cmd_uri.py @ 3040:fee60f17ebac

jp: jp asyncio port: /!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
author Goffi <goffi@goffi.org>
date Wed, 25 Sep 2019 08:56:41 +0200
parents ab2696e34d29
children 9d0df638c8b4
comparison
equal deleted inserted replaced
3039:a1bc34f90fa5 3040:fee60f17ebac
40 def add_parser_options(self): 40 def add_parser_options(self):
41 self.parser.add_argument( 41 self.parser.add_argument(
42 "uri", help=_("XMPP URI to parse") 42 "uri", help=_("XMPP URI to parse")
43 ) 43 )
44 44
45 def start(self): 45 async def start(self):
46 self.output(uri.parseXMPPUri(self.args.uri)) 46 await self.output(uri.parseXMPPUri(self.args.uri))
47 self.host.quit()
47 48
48 49
49 class Build(base.CommandBase): 50 class Build(base.CommandBase):
50 def __init__(self, host): 51 def __init__(self, host):
51 base.CommandBase.__init__( 52 base.CommandBase.__init__(
63 dest="fields", 64 dest="fields",
64 metavar=("KEY", "VALUE"), 65 metavar=("KEY", "VALUE"),
65 help=_("URI fields"), 66 help=_("URI fields"),
66 ) 67 )
67 68
68 def start(self): 69 async def start(self):
69 fields = dict(self.args.fields) if self.args.fields else {} 70 fields = dict(self.args.fields) if self.args.fields else {}
70 self.disp(uri.buildXMPPUri(self.args.type, path=self.args.path, **fields)) 71 self.disp(uri.buildXMPPUri(self.args.type, path=self.args.path, **fields))
72 self.host.quit()
71 73
72 74
73 class Uri(base.CommandBase): 75 class Uri(base.CommandBase):
74 subcommands = (Parse, Build) 76 subcommands = (Parse, Build)
75 77