comparison src/plugins/plugin_import.py @ 2396:66baa687c682

plugins tickets import, jp (ticket/import): implemented mapping: - mapping is an option allowing do map imported field to a specific field in the newly created item - importers can now use complexe data types in options using JSON
author Goffi <goffi@goffi.org>
date Fri, 27 Oct 2017 17:58:05 +0200
parents f57a8eaec8ed
children 8b37a62336c3
comparison
equal deleted inserted replaced
2395:713cedc99752 2396:66baa687c682
24 from twisted.internet import defer 24 from twisted.internet import defer
25 from sat.core import exceptions 25 from sat.core import exceptions
26 from functools import partial 26 from functools import partial
27 import collections 27 import collections
28 import uuid 28 import uuid
29 import json
29 30
30 31
31 PLUGIN_INFO = { 32 PLUGIN_INFO = {
32 C.PI_NAME: "import", 33 C.PI_NAME: "import",
33 C.PI_IMPORT_NAME: "IMPORT", 34 C.PI_IMPORT_NAME: "IMPORT",
108 for option in import_handler.BOOL_OPTIONS: 109 for option in import_handler.BOOL_OPTIONS:
109 try: 110 try:
110 options[option] = C.bool(options[option]) 111 options[option] = C.bool(options[option])
111 except KeyError: 112 except KeyError:
112 pass 113 pass
114 for option in import_handler.JSON_OPTIONS:
115 try:
116 options[option] = json.loads(options[option])
117 except ValueError:
118 raise exceptions.DataError(_(u'invalid json option: {name}').format(name=option))
113 return self.doImport(client, import_handler, unicode(name), unicode(location), options, pubsub_service or None, pubsub_node or None) 119 return self.doImport(client, import_handler, unicode(name), unicode(location), options, pubsub_service or None, pubsub_node or None)
114 120
115 @defer.inlineCallbacks 121 @defer.inlineCallbacks
116 def doImport(self, client, import_handler, name, location, options=None, pubsub_service=None, pubsub_node=None): 122 def doImport(self, client, import_handler, name, location, options=None, pubsub_service=None, pubsub_node=None):
117 """Import data 123 """Import data