plugin blog import dokuwiki: fixed bad use of MissingModule and unmodified docstring

This commit is contained in:
Goffi 2016-02-25 16:05:31 +01:00
commit c92ce5da75

View file

@ -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