plugin uri finder, jp (merge-request): labels handling:
- a label can now be specified as metadata after specifing a "xmpp:" URI in doc (with « use "[label]" label" » after the URI) - updated jp to handle new signature of URIFind - jp (merge-request/set): labels can now be specified using --label
This commit is contained in:
parent
a6aa637663
commit
e4c56da671
1 changed files with 41 additions and 10 deletions
|
|
@ -671,6 +671,13 @@ class URIFinder(object):
|
|||
"""Helper class to find URIs in well-known locations"""
|
||||
|
||||
def __init__(self, command, path, key, callback):
|
||||
"""
|
||||
@param command(CommandBase): command instance
|
||||
args of this instance will be updated with found values
|
||||
@param path(unicode): absolute path to use as a starting point to look for URIs
|
||||
@param key(unicode): key to look for
|
||||
@param callback(callable): method to call once URIs are found (or not)
|
||||
"""
|
||||
if not command.args.service and not command.args.node:
|
||||
self.host = command.host
|
||||
self.args = command.args
|
||||
|
|
@ -685,12 +692,26 @@ class URIFinder(object):
|
|||
else:
|
||||
callback()
|
||||
|
||||
def URIFindCb(self, uri_data):
|
||||
def URIFindCb(self, uris_data):
|
||||
try:
|
||||
uri = uri_data[self.key]
|
||||
uri_data = uris_data[self.key]
|
||||
except KeyError:
|
||||
self.host.disp(_(u"No {key} URI specified for this project, please specify service and node").format(key=self.key), error=True)
|
||||
self.host.quit(C.EXIT_NOT_FOUND)
|
||||
else:
|
||||
uri = uri_data[u'uri']
|
||||
labels_raw = uri_data.get(u'labels')
|
||||
|
||||
if labels_raw is not None:
|
||||
try:
|
||||
labels = self.args.labels
|
||||
except AttributeError:
|
||||
raise exceptions.InternalError(u'there is no "labels" arguments')
|
||||
else:
|
||||
if labels is None:
|
||||
labels = []
|
||||
labels.extend(json.loads(labels_raw))
|
||||
self.args.labels = labels
|
||||
parsed_uri = xmpp_uri.parseXMPPUri(uri)
|
||||
try:
|
||||
self.args.service = parsed_uri[u'path']
|
||||
|
|
|
|||
Loading…
Reference in a new issue