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.
This commit is contained in:
parent
80eb458024
commit
1bcdca4a2f
1 changed files with 26 additions and 23 deletions
|
|
@ -27,7 +27,6 @@ from twisted.web import client as web_client
|
|||
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 @@ OPT_IGNORE_TLS = 'ignore_tls_errors'
|
|||
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 @@ class BlogImportPlugin(object):
|
|||
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 @@ class BlogImportPlugin(object):
|
|||
|
||||
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 @@ class BlogImportPlugin(object):
|
|||
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
|
||||
|
|
|
|||
Loading…
Reference in a new issue