Mercurial > libervia-backend
diff frontends/src/jp/common.py @ 2279:e2f96cd1887b
jp (cmd_pubsub): xmpp: uri handling, first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 28 Jun 2017 19:19:08 +0200 |
parents | 5cd45a79775b |
children | 4bc9a2c2d6c9 |
line wrap: on
line diff
--- a/frontends/src/jp/common.py Wed Jun 28 01:28:41 2017 +0200 +++ b/frontends/src/jp/common.py Wed Jun 28 19:19:08 2017 +0200 @@ -20,6 +20,7 @@ from sat_frontends.jp.constants import Const as C from sat.core.i18n import _ from sat.tools.common import regex +from sat.tools.common import uri from sat.tools import config from ConfigParser import NoSectionError, NoOptionError import json @@ -81,6 +82,32 @@ return [] +def checkURI(args): + """check if args.node is an URI + + if a valid xmpp: URI is found, args.service, args.node and args.item will be set + """ + # FIXME: Q&D way to handle xmpp: uris, a generic way is needed + # and it should be merged with code in BaseEdit + if not args.service and args.node.startswith('xmpp:'): + try: + uri_data = uri.parseXMPPUri(args.node) + except ValueError: + pass + else: + if uri_data[u'type'] == 'pubsub': + args.service = uri_data[u'path'] + args.node = uri_data[u'node'] + if u'item' in uri_data: + try: + item = getattr(uri_data, 'item') + except AttributeError: + pass + else: + if item is None: + args.item = uri_data + + class BaseEdit(object): u"""base class for editing commands