annotate libervia/backend/plugins/plugin_misc_merge_requests.py @ 4291:39ac821ebbdb

plugin XEP-0167: handle conferences: - SDP can now be answered by component instead of frontend. This is useful for A/V conferences component to handle A/V call jingle sessions. - new `call_update` and method, and `content-add` action preparation. This is not yet used by A/V conference, but it's a preparation for a potential future use. - Add NS_AV_CONFERENCES to features as required by the newly proposed A/V Conferences protoXEP. rel 447
author Goffi <goffi@goffi.org>
date Mon, 29 Jul 2024 03:31:09 +0200
parents 0d7bb4df2343
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
1 #!/usr/bin/env python3
3137
559a625a236b fixed shebangs
Goffi <goffi@goffi.org>
parents: 3136
diff changeset
2
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # SAT plugin for Pubsub Schemas
3479
be6d91572633 date update
Goffi <goffi@goffi.org>
parents: 3459
diff changeset
5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org)
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
20 from collections import namedtuple
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
21 from twisted.internet import defer
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
22 from twisted.words.protocols.jabber import jid
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
23 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
24 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
25 from libervia.backend.core import exceptions
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
26 from libervia.backend.tools.common import data_format
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4037
diff changeset
27 from libervia.backend.core.log import getLogger
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
28
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
29
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 log = getLogger(__name__)
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
31
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
32 APP_NS_MERGE_REQUESTS = "org.salut-a-toi.merge_requests:0"
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 PLUGIN_INFO = {
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 C.PI_NAME: _("Merge requests management"),
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 C.PI_IMPORT_NAME: "MERGE_REQUESTS",
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_TYPE: "EXP",
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_PROTOCOLS: [],
3459
8dc26e5edcd3 plugin tickets, merge_requests: renamed "tickets" feature to "lists":
Goffi <goffi@goffi.org>
parents: 3458
diff changeset
39 C.PI_DEPENDENCIES: ["XEP-0060", "XEP-0346", "LISTS", "TEXT_SYNTAXES"],
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_MAIN: "MergeRequests",
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_HANDLER: "no",
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
42 C.PI_DESCRIPTION: _("""Merge requests management plugin"""),
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 }
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
45 FIELD_DATA_TYPE = "type"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
46 FIELD_DATA = "request_data"
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
49 MergeRequestHandler = namedtuple(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
50 "MergeRequestHandler", ["name", "handler", "data_types", "short_desc", "priority"]
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
51 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
52
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
53
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 class MergeRequests(object):
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
55 META_AUTHOR = "author"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
56 META_EMAIL = "email"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
57 META_TIMESTAMP = "timestamp"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
58 META_HASH = "hash"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
59 META_PARENT_HASH = "parent_hash"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
60 META_COMMIT_MSG = "commit_msg"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
61 META_DIFF = "diff"
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 # index of the diff in the whole data
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 # needed to retrieve comments location
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
64 META_DIFF_IDX = "diff_idx"
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 def __init__(self, host):
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
67 log.info(_("Merge requests plugin initialization"))
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 self.host = host
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
69 self._s = self.host.plugins["XEP-0346"]
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
70 self.namespace = self._s.get_submitted_ns(APP_NS_MERGE_REQUESTS)
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
71 host.register_namespace("merge_requests", self.namespace)
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
72 self._p = self.host.plugins["XEP-0060"]
3459
8dc26e5edcd3 plugin tickets, merge_requests: renamed "tickets" feature to "lists":
Goffi <goffi@goffi.org>
parents: 3458
diff changeset
73 self._t = self.host.plugins["LISTS"]
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 self._handlers = {}
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
75 self._handlers_list = [] # handlers sorted by priority
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 self._type_handlers = {} # data type => handler map
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
77 host.bridge.add_method(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
78 "merge_requests_get",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
79 ".plugin",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
80 in_sign="ssiassss",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
81 out_sign="s",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
82 method=self._get,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
83 async_=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
84 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
85 host.bridge.add_method(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
86 "merge_request_set",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
87 ".plugin",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
88 in_sign="ssssa{sas}ssss",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
89 out_sign="s",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
90 method=self._set,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
91 async_=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
92 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
93 host.bridge.add_method(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
94 "merge_requests_schema_get",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
95 ".plugin",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
96 in_sign="sss",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
97 out_sign="s",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
98 method=lambda service, nodeIdentifier, profile_key: self._s._get_ui_schema(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
99 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
100 nodeIdentifier,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
101 default_node=self.namespace,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
102 profile_key=profile_key,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
103 ),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
104 async_=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
105 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
106 host.bridge.add_method(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
107 "merge_request_parse_data",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
108 ".plugin",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
109 in_sign="ss",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
110 out_sign="aa{ss}",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
111 method=self._parse_data,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
112 async_=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
113 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
114 host.bridge.add_method(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
115 "merge_requests_import",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
116 ".plugin",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
117 in_sign="ssssa{ss}s",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
118 out_sign="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
119 method=self._import,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
120 async_=True,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
121 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
122
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 def register(self, name, handler, data_types, short_desc, priority=0):
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 """register an merge request handler
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
125
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 @param name(unicode): name of the handler
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 @param handler(object): instance of the handler.
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 It must have the following methods, which may all return a Deferred:
3040
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
129 - check(repository)->bool: True if repository can be handled
fee60f17ebac jp: jp asyncio port:
Goffi <goffi@goffi.org>
parents: 3028
diff changeset
130 - export(repository)->str: return export data, i.e. the patches
2622
8fb99ed47db4 core: lines limit
Goffi <goffi@goffi.org>
parents: 2604
diff changeset
131 - parse(export_data): parse report data and return a list of dict
8fb99ed47db4 core: lines limit
Goffi <goffi@goffi.org>
parents: 2604
diff changeset
132 (1 per patch) with:
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 - title: title of the commit message (first line)
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 - body: body of the commit message
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 @aram data_types(list[unicode]): data types that his handler can generate or parse
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 """
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 if name in self._handlers:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
138 raise exceptions.ConflictError(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
139 _("a handler with name {name} already " "exists!").format(name=name)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
140 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
141 self._handlers[name] = MergeRequestHandler(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
142 name, handler, data_types, short_desc, priority
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
143 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 self._handlers_list.append(name)
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 self._handlers_list.sort(key=lambda name: self._handlers[name].priority)
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
146 if isinstance(data_types, str):
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 data_types = [data_types]
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 for data_type in data_types:
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 if data_type in self._type_handlers:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
150 log.warning(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
151 _(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
152 "merge requests of type {type} are already handled by "
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
153 "{old_handler}, ignoring {new_handler}"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
154 ).format(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
155 type=data_type,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
156 old_handler=self._type_handlers[data_type].name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
157 new_handler=name,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
158 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
159 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 continue
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 self._type_handlers[data_type] = self._handlers[name]
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
162
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
163 def serialise(self, get_data):
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
164 tickets_xmlui, metadata, items_patches = get_data
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
165 tickets_xmlui_s, metadata = self._p.trans_items_data((tickets_xmlui, metadata))
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
166 return data_format.serialise(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
167 {
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
168 "items": tickets_xmlui_s,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
169 "metadata": metadata,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
170 "items_patches": items_patches,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
171 }
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
172 )
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
173
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
174 def _get(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
175 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
176 service="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
177 node="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
178 max_items=10,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
179 item_ids=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
180 sub_id=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
181 extra="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
182 profile_key=C.PROF_KEY_NONE,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
183 ):
3586
5f65f4e9f8cb plugin XEP-0060: getItems extra is now serialised dict
Goffi <goffi@goffi.org>
parents: 3479
diff changeset
184 extra = data_format.deserialise(extra)
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
185 client, service, node, max_items, extra, sub_id = self._s.prepare_bridge_get(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
186 service, node, max_items, sub_id, extra, profile_key
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
187 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
188 d = self.get(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
189 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
190 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
191 node or None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
192 max_items,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
193 item_ids,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
194 sub_id or None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
195 extra.rsm_request,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
196 extra.extra,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
197 )
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
198 d.addCallback(self.serialise)
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 return d
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
200
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 @defer.inlineCallbacks
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
202 def get(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
203 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
204 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
205 service=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
206 node=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
207 max_items=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
208 item_ids=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
209 sub_id=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
210 rsm_request=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
211 extra=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
212 ):
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 """Retrieve merge requests and convert them to XMLUI
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
214
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 @param extra(XEP-0060.parse, None): can have following keys:
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 - update(bool): if True, will return list of parsed request data
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
217 other params are the same as for [TICKETS._get]
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 @return (tuple[list[unicode], list[dict[unicode, unicode]])): tuple with
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 - XMLUI of the tickets, like [TICKETS._get]
2541
65695b9343d3 jp (xmlui): added whitelist, read_only and values_only options:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
220 - node metadata
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 - list of parsed request data (if extra['parse'] is set, else empty list)
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 """
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 if not node:
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
224 node = self.namespace
2603
5d4ac5415b40 plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
225 if extra is None:
5d4ac5415b40 plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
226 extra = {}
5d4ac5415b40 plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
227 # XXX: Q&D way to get list for labels when displaying them, but text when we
5d4ac5415b40 plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
228 # have to modify them
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
229 if C.bool(extra.get("labels_as_list", C.BOOL_FALSE)):
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
230 filters = {"labels": self._s.textbox_2_list_filter}
2603
5d4ac5415b40 plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
231 else:
5d4ac5415b40 plugins schema, merge-requests, tickets: convert labels from textbox to list only when "labels_as_list" is set in extra parameters.
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
232 filters = {}
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
233 tickets_xmlui, metadata = yield defer.ensureDeferred(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
234 self._s.get_data_form_items(
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
235 client,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
236 service,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
237 node,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
238 max_items=max_items,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
239 item_ids=item_ids,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
240 sub_id=sub_id,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
241 rsm_request=rsm_request,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
242 extra=extra,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
243 form_ns=APP_NS_MERGE_REQUESTS,
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
244 filters=filters,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
245 )
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
246 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 parsed_patches = []
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
248 if extra.get("parse", False):
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
249 for ticket in tickets_xmlui:
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
250 request_type = ticket.named_widgets[FIELD_DATA_TYPE].value
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
251 request_data = ticket.named_widgets[FIELD_DATA].value
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
252 parsed_data = yield self.parse_data(request_type, request_data)
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
253 parsed_patches.append(parsed_data)
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
254 defer.returnValue((tickets_xmlui, metadata, parsed_patches))
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
255
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
256 def _set(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
257 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
258 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
259 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
260 repository,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
261 method,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
262 values,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
263 schema=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
264 item_id=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
265 extra="",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
266 profile_key=C.PROF_KEY_NONE,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
267 ):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
268 client, service, node, schema, item_id, extra = self._s.prepare_bridge_set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
269 service, node, schema, item_id, extra, profile_key
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
270 )
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
271 d = defer.ensureDeferred(
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
272 self.set(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
273 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
274 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
275 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
276 repository,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
277 method,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
278 values,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
279 schema,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
280 item_id or None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
281 extra,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
282 deserialise=True,
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
283 )
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
284 )
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
285 d.addCallback(lambda ret: ret or "")
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
286 return d
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
287
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
288 async def set(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
289 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
290 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
291 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
292 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
293 repository,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
294 method="auto",
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
295 values=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
296 schema=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
297 item_id=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
298 extra=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
299 deserialise=False,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
300 ):
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 """Publish a tickets
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
302
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 @param service(None, jid.JID): Pubsub service to use
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
304 @param node(unicode, None): Pubsub node to use
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
305 None to use default tickets node
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
306 @param repository(unicode): path to the repository where the code stands
2622
8fb99ed47db4 core: lines limit
Goffi <goffi@goffi.org>
parents: 2604
diff changeset
307 @param method(unicode): name of one of the registered handler,
8fb99ed47db4 core: lines limit
Goffi <goffi@goffi.org>
parents: 2604
diff changeset
308 or "auto" to try autodetection.
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
309 other arguments are same as for [TICKETS.set]
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
310 @return (unicode): id of the created item
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
311 """
2473
447c3de6b9e5 plugin merge-requests: fixed "set" method
Goffi <goffi@goffi.org>
parents: 2472
diff changeset
312 if not node:
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
313 node = self.namespace
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
314 if values is None:
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
315 values = {}
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
316 update = extra.get("update", False)
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
317 if not repository and not update:
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
318 # in case of update, we may re-user former patches data
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
319 # so repository is not mandatory
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
320 raise exceptions.DataError(_("repository must be specified"))
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
321
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
322 if FIELD_DATA in values:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
323 raise exceptions.DataError(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
324 _("{field} is set by backend, you must not set " "it in frontend").format(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
325 field=FIELD_DATA
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
326 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
327 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
328
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
329 if repository:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
330 if method == "auto":
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
331 for name in self._handlers_list:
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
332 handler = self._handlers[name].handler
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
333 can_handle = await handler.check(repository)
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
334 if can_handle:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
335 log.info(_("{name} handler will be used").format(name=name))
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
336 break
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
337 else:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
338 log.warning(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
339 _(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
340 "repository {path} can't be handled by any installed "
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
341 "handler"
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
342 ).format(path=repository)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
343 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
344 raise exceptions.NotFound(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
345 _("no handler for this repository has " "been found")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
346 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
347 else:
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
348 try:
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
349 handler = self._handlers[name].handler
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
350 except KeyError:
3028
ab2696e34d29 Python 3 port:
Goffi <goffi@goffi.org>
parents: 2959
diff changeset
351 raise exceptions.NotFound(_("No handler of this name found"))
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
352
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
353 data = await handler.export(repository)
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
354 if not data.strip():
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
355 raise exceptions.DataError(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
356 _("export data is empty, do you have any " "change to send?")
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
357 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
358
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
359 if not values.get("title") or not values.get("body"):
3875
a0666f17f300 plugin merge-requests: fix `await` use on blocking method
Goffi <goffi@goffi.org>
parents: 3586
diff changeset
360 patches = handler.parse(data, values.get(FIELD_DATA_TYPE))
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
361 commits_msg = patches[-1][self.META_COMMIT_MSG]
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
362 msg_lines = commits_msg.splitlines()
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
363 if not values.get("title"):
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
364 values["title"] = msg_lines[0]
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
365 if not values.get("body"):
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
366 ts = self.host.plugins["TEXT_SYNTAXES"]
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
367 xhtml = await ts.convert(
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
368 "\n".join(msg_lines[1:]),
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
369 syntax_from=ts.SYNTAX_TEXT,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
370 syntax_to=ts.SYNTAX_XHTML,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
371 profile=client.profile,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
372 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
373 values["body"] = '<div xmlns="{ns}">{xhtml}</div>'.format(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
374 ns=C.NS_XHTML, xhtml=xhtml
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
375 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
376
2604
700327fa9281 plugin merge-requests: allow to set empty repository when "update" is set in extra parameters:
Goffi <goffi@goffi.org>
parents: 2603
diff changeset
377 values[FIELD_DATA] = data
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
378
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
379 item_id = await self._t.set(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
380 client,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
381 service,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
382 node,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
383 values,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
384 schema,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
385 item_id,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
386 extra,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
387 deserialise,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
388 form_ns=APP_NS_MERGE_REQUESTS,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
389 )
3309
71761e9fb984 plugins tickets, merge-requests: `ticketsGet` and `mergeRequestsGet` serialisation:
Goffi <goffi@goffi.org>
parents: 3137
diff changeset
390 return item_id
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
391
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
392 def _parse_data(self, data_type, data):
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
393 d = self.parse_data(data_type, data)
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
394 d.addCallback(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
395 lambda parsed_patches: {
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
396 key: str(value) for key, value in parsed_patches.items()
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
397 }
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
398 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
399 return d
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
400
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
401 def parse_data(self, data_type, data):
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
402 """Parse a merge request data according to type
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
403
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
404 @param data_type(unicode): type of the data to parse
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
405 @param data(unicode): data to parse
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
406 @return(list[dict[unicode, unicode]]): parsed data
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
407 key of dictionary are self.META_* or keys specifics to handler
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
408 @raise NotFound: no handler can parse this data_type
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
409 """
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
410 try:
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
411 handler = self._type_handlers[data_type]
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
412 except KeyError:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
413 raise exceptions.NotFound(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
414 _('No handler can handle data type "{type}"').format(type=data_type)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
415 )
2448
637ac234424f plugin merge requests: first draft:
Goffi <goffi@goffi.org>
parents:
diff changeset
416 return defer.maybeDeferred(handler.handler.parse, data, data_type)
2544
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
417
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
418 def _import(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
419 self,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
420 repository,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
421 item_id,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
422 service=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
423 node=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
424 extra=None,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
425 profile_key=C.PROF_KEY_NONE,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
426 ):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
427 client = self.host.get_client(profile_key)
2544
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
428 service = jid.JID(service) if service else None
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
429 d = self.import_request(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
430 client, repository, item_id, service, node or None, extra=extra or None
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
431 )
2544
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
432 return d
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
433
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
434 @defer.inlineCallbacks
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
435 def import_request(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
436 self, client, repository, item, service=None, node=None, extra=None
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
437 ):
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
438 """import a merge request in specified directory
2544
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
439
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
440 @param repository(unicode): path to the repository where the code stands
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
441 """
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
442 if not node:
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
443 node = self.namespace
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
444 tickets_xmlui, metadata = yield defer.ensureDeferred(
4037
524856bd7b19 massive refactoring to switch from camelCase to snake_case:
Goffi <goffi@goffi.org>
parents: 3875
diff changeset
445 self._s.get_data_form_items(
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
446 client,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
447 service,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
448 node,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
449 max_items=1,
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
450 item_ids=[item],
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
451 form_ns=APP_NS_MERGE_REQUESTS,
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
452 )
3452
bb0225aaf4e6 plugin XEP-0346: "Form Discovery and Publishing" implementation:
Goffi <goffi@goffi.org>
parents: 3309
diff changeset
453 )
2544
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
454 ticket_xmlui = tickets_xmlui[0]
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
455 data = ticket_xmlui.named_widgets[FIELD_DATA].value
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
456 data_type = ticket_xmlui.named_widgets[FIELD_DATA_TYPE].value
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
457 try:
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
458 handler = self._type_handlers[data_type]
a64887289931 plugin merge-requests, mercurial merge-requests: merge request import implementation
Goffi <goffi@goffi.org>
parents: 2541
diff changeset
459 except KeyError:
4270
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
460 raise exceptions.NotFound(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
461 _("No handler found to import {data_type}").format(data_type=data_type)
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
462 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
463 log.info(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
464 _("Importing patch [{item_id}] using {name} handler").format(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
465 item_id=item, name=handler.name
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
466 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
467 )
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
468 yield handler.handler.import_(
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
469 repository, data, data_type, item, service, node, extra
0d7bb4df2343 Reformatted code base using black.
Goffi <goffi@goffi.org>
parents: 4071
diff changeset
470 )