comparison src/plugins/plugin_misc_merge_requests.py @ 2473:447c3de6b9e5

plugin merge-requests: fixed "set" method
author Goffi <goffi@goffi.org>
date Sat, 13 Jan 2018 10:12:15 +0100
parents 3f0a3a0ed290
children 0046283a285d
comparison
equal deleted inserted replaced
2472:3f0a3a0ed290 2473:447c3de6b9e5
31 PLUGIN_INFO = { 31 PLUGIN_INFO = {
32 C.PI_NAME: _("Merge requests management"), 32 C.PI_NAME: _("Merge requests management"),
33 C.PI_IMPORT_NAME: "MERGE_REQUESTS", 33 C.PI_IMPORT_NAME: "MERGE_REQUESTS",
34 C.PI_TYPE: "EXP", 34 C.PI_TYPE: "EXP",
35 C.PI_PROTOCOLS: [], 35 C.PI_PROTOCOLS: [],
36 C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA"], 36 C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "TICKETS"],
37 C.PI_MAIN: "MergeRequests", 37 C.PI_MAIN: "MergeRequests",
38 C.PI_HANDLER: "no", 38 C.PI_HANDLER: "no",
39 C.PI_DESCRIPTION: _("""Merge requests management plugin""") 39 C.PI_DESCRIPTION: _("""Merge requests management plugin""")
40 } 40 }
41 41
66 log.info(_(u"Merge requests plugin initialization")) 66 log.info(_(u"Merge requests plugin initialization"))
67 self.host = host 67 self.host = host
68 host.registerNamespace('merge_requests', NS_MERGE_REQUESTS) 68 host.registerNamespace('merge_requests', NS_MERGE_REQUESTS)
69 self._p = self.host.plugins["XEP-0060"] 69 self._p = self.host.plugins["XEP-0060"]
70 self._s = self.host.plugins["PUBSUB_SCHEMA"] 70 self._s = self.host.plugins["PUBSUB_SCHEMA"]
71 self._t = self.host.plugins["TICKETS"]
71 self._handlers = {} 72 self._handlers = {}
72 self._handlers_list = [] # handlers sorted by priority 73 self._handlers_list = [] # handlers sorted by priority
73 self._type_handlers = {} # data type => handler map 74 self._type_handlers = {} # data type => handler map
74 host.bridge.addMethod("mergeRequestsGet", ".plugin", 75 host.bridge.addMethod("mergeRequestsGet", ".plugin",
75 in_sign='ssiassa{ss}s', out_sign='(asa{ss}aaa{ss})', 76 in_sign='ssiassa{ss}s', out_sign='(asa{ss}aaa{ss})',
183 @param repository(unicode): path to the repository where the code stands 184 @param repository(unicode): path to the repository where the code stands
184 @param method(unicode): name of one of the registered handler, or "auto" to try autodetection. 185 @param method(unicode): name of one of the registered handler, or "auto" to try autodetection.
185 other arguments are same as for [TICKETS.set] 186 other arguments are same as for [TICKETS.set]
186 @return (unicode): id of the created item 187 @return (unicode): id of the created item
187 """ 188 """
189 if not node:
190 node = NS_MERGE_REQUESTS
188 if values is None: 191 if values is None:
189 values = {} 192 values = {}
190 193
191 if FIELD_DATA in values: 194 if FIELD_DATA in values:
192 raise exceptions.DataError(_(u"{field} is set by backend, you must not set it in frontend").format( 195 raise exceptions.DataError(_(u"{field} is set by backend, you must not set it in frontend").format(
222 if not values.get(u'body'): 225 if not values.get(u'body'):
223 values[u'body'] = u'\n'.join(msg_lines[1:]) 226 values[u'body'] = u'\n'.join(msg_lines[1:])
224 227
225 values[FIELD_DATA] = data 228 values[FIELD_DATA] = data
226 229
227 item_id = yield self._t.set(client, service, node, values, schema, item_id, extra, deserialise, default_node=NS_MERGE_REQUESTS, form_ns=NS_MERGE_REQUESTS) 230 item_id = yield self._t.set(client, service, node, values, schema, item_id, extra, deserialise, form_ns=NS_MERGE_REQUESTS)
228 defer.returnValue(item_id) 231 defer.returnValue(item_id)
229 232
230 def _parseData(self, data_type, data): 233 def _parseData(self, data_type, data):
231 d = self.parseData(data_type, data) 234 d = self.parseData(data_type, data)
232 d.addCallback(lambda parsed_patches: 235 d.addCallback(lambda parsed_patches: