comparison libervia/backend/plugins/plugin_import.py @ 4270:0d7bb4df2343

Reformatted code base using black.
author Goffi <goffi@goffi.org>
date Wed, 19 Jun 2024 18:44:57 +0200
parents 4b842c1fb686
children
comparison
equal deleted inserted replaced
4269:64a85ce8be70 4270:0d7bb4df2343
137 ) 137 )
138 ) 138 )
139 else: 139 else:
140 return importer.short_desc, importer.long_desc 140 return importer.short_desc, importer.long_desc
141 141
142 def _do_import(self, import_handler, name, location, options, pubsub_service="", 142 def _do_import(
143 pubsub_node="", profile=C.PROF_KEY_NONE): 143 self,
144 import_handler,
145 name,
146 location,
147 options,
148 pubsub_service="",
149 pubsub_node="",
150 profile=C.PROF_KEY_NONE,
151 ):
144 client = self.host.get_client(profile) 152 client = self.host.get_client(profile)
145 options = {key: str(value) for key, value in options.items()} 153 options = {key: str(value) for key, value in options.items()}
146 for option in import_handler.BOOL_OPTIONS: 154 for option in import_handler.BOOL_OPTIONS:
147 try: 155 try:
148 options[option] = C.bool(options[option]) 156 options[option] = C.bool(options[option])
167 pubsub_service, 175 pubsub_service,
168 pubsub_node or None, 176 pubsub_node or None,
169 ) 177 )
170 178
171 @defer.inlineCallbacks 179 @defer.inlineCallbacks
172 def do_import(self, client, import_handler, name, location, options=None, 180 def do_import(
173 pubsub_service=None, pubsub_node=None,): 181 self,
182 client,
183 import_handler,
184 name,
185 location,
186 options=None,
187 pubsub_service=None,
188 pubsub_node=None,
189 ):
174 """import data 190 """import data
175 191
176 @param import_handler(object): instance of the import handler 192 @param import_handler(object): instance of the import handler
177 @param name(unicode): name of the importer 193 @param name(unicode): name of the importer
178 @param location(unicode): location of the data to import 194 @param location(unicode): location of the data to import
322 @param long_desc(unicode): long description of the importer, its options, etc. 338 @param long_desc(unicode): long description of the importer, its options, etc.
323 """ 339 """
324 name = name.lower() 340 name = name.lower()
325 if name in import_handler.importers: 341 if name in import_handler.importers:
326 raise exceptions.ConflictError( 342 raise exceptions.ConflictError(
327 _( 343 _("An {handler_name} importer with the name {name} already exist").format(
328 "An {handler_name} importer with the name {name} already exist" 344 handler_name=import_handler.name, name=name
329 ).format(handler_name=import_handler.name, name=name) 345 )
330 ) 346 )
331 import_handler.importers[name] = Importer(callback, short_desc, long_desc) 347 import_handler.importers[name] = Importer(callback, short_desc, long_desc)
332 348
333 def unregister(self, import_handler, name): 349 def unregister(self, import_handler, name):
334 del import_handler.importers[name] 350 del import_handler.importers[name]