From c92ce5da75482379b92887c51ff37d268cf5b04f Mon Sep 17 00:00:00 2001 From: Goffi Date: Thu, 25 Feb 2016 16:05:31 +0100 Subject: [PATCH] plugin blog import dokuwiki: fixed bad use of MissingModule and unmodified docstring --- src/plugins/plugin_blog_import_dokuwiki.py | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/plugins/plugin_blog_import_dokuwiki.py b/src/plugins/plugin_blog_import_dokuwiki.py index 64abf7d8..0e471c07 100755 --- a/src/plugins/plugin_blog_import_dokuwiki.py +++ b/src/plugins/plugin_blog_import_dokuwiki.py @@ -1,7 +1,7 @@ #!/usr/bin/python # -*- coding: utf-8 -*- -# SàT plugin to import external blogs +# SàT plugin to import dokuwiki blogs # Copyright (C) 2009-2016 Jérôme Poisson (goffi@goffi.org) # Copyright (C) 2013-2016 Adrien Cossa (souliane@mailoo.org) @@ -41,10 +41,6 @@ try: from PIL import Image # this is already needed by plugin XEP-0054 except: raise exceptions.MissingModule(u"Missing module pillow, please download/install it from https://python-pillow.github.io") -try: - from plugin_blog_import import OPT_HOST, OPT_UPLOAD_IMAGES -except: - raise exceptions.MissingModule(u'Missing module plugin_blog_import, please install the Salut à Toi "BLOG_IMPORT" plugin') PLUGIN_INFO = { "name": "Dokuwiki import", @@ -83,7 +79,7 @@ namespace: DokuWiki namespace to import (default: root namespace "/") media_repo: URL to the new remote media repository (default: none) limit: maximal number of posts to import (default: 100) -Example of usage: +Example of usage (with jp frontend): jp import dokuwiki -p dave --pwd xxxxxx --connect http://127.0.1.1 -o user souliane -o passwd qwertz @@ -176,7 +172,7 @@ class Importer(DokuWiki): page = link["page"] backlinks.append(page[1:] if page.startswith(":") else page) - content = self.pages.get(id_) + self.pages.get(id_) content_xhtml = self.processContent(self.pages.html(id_), backlinks, profile_jid) # XXX: title is already in content_xhtml and difficult to remove, so leave it @@ -344,7 +340,8 @@ class DokuwikiImport(object): def __init__(self, host): log.info(_("plugin Dokuwiki Import initialization")) self.host = host - host.plugins['BLOG_IMPORT'].register('dokuwiki', self.DkImport, SHORT_DESC, LONG_DESC) + self._blog_import = host.plugins['BLOG_IMPORT'] + self._blog_import.register('dokuwiki', self.DkImport, SHORT_DESC, LONG_DESC) def DkImport(self, client, location, options=None): """Import from DokuWiki to PubSub @@ -356,7 +353,7 @@ class DokuwikiImport(object): - namespace (unicode): DokuWiki namespace to import - media_repo (unicode): New remote media repository """ - options[OPT_HOST] = location + options[self._blog_import.OPT_HOST] = location try: user = options["user"] except KeyError: @@ -366,11 +363,11 @@ class DokuwikiImport(object): except KeyError: raise exceptions.DataError('parameter "passwd" is required') - opt_upload_images = options.get(OPT_UPLOAD_IMAGES, None) + opt_upload_images = options.get(self._blog_import.OPT_UPLOAD_IMAGES, None) try: media_repo = options["media_repo"] if opt_upload_images: - options[OPT_UPLOAD_IMAGES] = False # force using --no-images-upload + options[self._blog_import.OPT_UPLOAD_IMAGES] = False # force using --no-images-upload info_msg = _("DokuWiki media files will be *downloaded* to {temp_dir} - to finish the import you have to upload them *manually* to {media_repo}") except KeyError: media_repo = DEFAULT_MEDIA_REPO