diff src/plugins/plugin_blog_import.py @ 2370:2c2b826b0bb3

plugin import: node can now be specified + added a "session" dict to keep import session data: import session data are data that can be used by importer to store anything which can be useful to keep between import methods.
author Goffi <goffi@goffi.org>
date Fri, 06 Oct 2017 08:52:51 +0200
parents cdaa58e14553
children 66baa687c682
line wrap: on
line diff
--- a/src/plugins/plugin_blog_import.py	Sun Oct 01 12:21:23 2017 +0200
+++ b/src/plugins/plugin_blog_import.py	Fri Oct 06 08:52:51 2017 +0200
@@ -27,7 +27,6 @@
 from twisted.words.xish import domish
 from sat.core import exceptions
 from sat.tools import xml_tools
-import collections
 import os
 import os.path
 import tempfile
@@ -53,9 +52,6 @@
 URL_REDIRECT_PREFIX = 'url_redirect_'
 
 
-BlogImporter = collections.namedtuple('BlogImporter', ('callback', 'short_desc', 'long_desc'))
-
-
 class BlogImportPlugin(object):
     BOOL_OPTIONS = (OPT_UPLOAD_IMAGES, OPT_IGNORE_TLS)
     OPT_DEFAULTS = {OPT_UPLOAD_IMAGES: True,
@@ -70,10 +66,10 @@
         self._s = self.host.plugins['TEXT-SYNTAXES']
         host.plugins['IMPORT'].initialize(self, u'blog')
 
-    def importItem(self, client, item_import_data, options, return_data, service, node):
+    def importItem(self, client, item_import_data, session, options, return_data, service, node):
         """importItem specialized for blog import
 
-        @param items_import_data(iterable[dict]):
+        @param item_import_data(dict):
             * mandatory keys:
                 'blog' (dict): microblog data of the blog post (cf. http://wiki.goffi.org/wiki/Bridge_API_-_Microblogging/en)
                     the importer MUST NOT create node or call XEP-0277 plugin itself
@@ -124,7 +120,7 @@
 
         return mb_data
 
-    def importSubItems(self, client, item_import_data, mb_data, options):
+    def importSubItems(self, client, item_import_data, mb_data, session, options):
         # comments data
         if len(item_import_data['comments']) != 1:
             raise NotImplementedError(u"can't manage multiple comment links")
@@ -143,12 +139,12 @@
                 raise exceptions.DataError(u"allow_comments set to False, but comments are there")
             return None
 
-    def publishItem(self, client, mb_data, service, node):
+    def publishItem(self, client, mb_data, service, node, session):
         log.debug(u"uploading item [{id}]: {title}".format(id=mb_data['id'], title=mb_data.get('title','')))
         return self._m.send(client, mb_data, service, node)
 
     @defer.inlineCallbacks
-    def itemFilters(self, client, mb_data, options):
+    def itemFilters(self, client, mb_data, session, options):
         """Apply filters according to options
 
         modify mb_data in place