summaryrefslogtreecommitdiff
path: root/helpcontent2/to-wiki
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@suse.cz>2010-12-03 13:33:28 +0100
committerJan Holesovsky <kendy@suse.cz>2010-12-03 13:33:28 +0100
commit15b1b660a11a0f2d05341e1181d93f89c21add18 (patch)
treedc6b5137654ee0954115d369bda2a5b29e9e43c1 /helpcontent2/to-wiki
parent28f9f37cce7fef09df98d9cdd30e2328777607d1 (diff)
wikihelp: Uploading of images.
Diffstat (limited to 'helpcontent2/to-wiki')
-rwxr-xr-xhelpcontent2/to-wiki/wikiconv2.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/helpcontent2/to-wiki/wikiconv2.py b/helpcontent2/to-wiki/wikiconv2.py
index fa191484c1..8dbb5bb132 100755
--- a/helpcontent2/to-wiki/wikiconv2.py
+++ b/helpcontent2/to-wiki/wikiconv2.py
@@ -20,6 +20,9 @@ hid_lst = {}
# names
redirects = []
+# to collect images that we will up-load later
+images = set()
+
# list of elements that we can directly convert to wiki text
replace_element = \
{'start':{'br': '<br/>',
@@ -424,7 +427,11 @@ class Image(ElementBase):
self.alttext = self.alttext + data
def get_all(self):
- wikitext = "[[Image:"+self.src+"|border|"+self.align+"|"
+ global images
+ images.add(self.src)
+
+ name = self.src[self.src.rfind('/') + 1:]
+ wikitext = "[[Image:"+name+"|border|"+self.align+"|"
if len(self.width):
wikitext = wikitext + self.width+"x"+self.height+"|"
wikitext = wikitext + self.alttext+"]]"
@@ -1084,11 +1091,22 @@ for title in titles:
time.sleep(0.1)
+# set of the images used here
+print 'Writing the collection of images to "images.txt"...'
+file = open('images.txt', "w")
+for image in images:
+ file.write('%s\n'% image)
+file.close()
+
# generate the redirects
-print "Generating the redirects..."
+print 'Generating the redirects...'
for redir in redirects:
- file = open('wiki/%s'% redir[0], "w")
- file.write('#REDIRECT [[%s]]\n'% redir[1])
- file.close()
+ fname = 'wiki/%s'% redir[0]
+ try:
+ file = open(fname, "w")
+ file.write('#REDIRECT [[%s]]\n'% redir[1])
+ file.close()
+ except:
+ sys.stderr.write('Unable to write "%s".\n'%'wiki/%s'% fname)
# vim:set shiftwidth=4 softtabstop=4 expandtab: