changeset 1853:1a9c12644552

plugin blog import dokuwiki: fixed bad use of MissingModule and unmodified docstring
author Goffi <goffi@goffi.org>
date Thu, 25 Feb 2016 16:05:31 +0100 (2016-02-25)
parents 569c48e4cf0d
children 3c0bb714a80b
files src/plugins/plugin_blog_import_dokuwiki.py
diffstat 1 files changed, 8 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/plugins/plugin_blog_import_dokuwiki.py	Wed Feb 24 16:11:36 2016 +0100
+++ b/src/plugins/plugin_blog_import_dokuwiki.py	Thu Feb 25 16:05:31 2016 +0100
@@ -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 @@
     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 @@
 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 @@
                 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 @@
     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 @@
             - 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 @@
         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