Created
January 17, 2015 02:57
-
-
Save anonymous/8824ef73e15394e1a565 to your computer and use it in GitHub Desktop.
moinmoin 2 dokuwiki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from dokuwiki import DokuWiki, DokuWikiError | |
import sys | |
import subprocess | |
import fileinput | |
import glob | |
def to_doku(page_id, txt): | |
try: | |
d = DokuWiki('http://xx.xx/wiki', 'xx', 'xx', allow_none=True) | |
except DokuWikiError as err: | |
print err | |
# sys.exit(1) | |
# print d.pages.list() | |
try: | |
d.pages.set(page_id, txt) | |
except DokuWikiError as err: | |
print err | |
def cat(f): | |
return subprocess.check_output('cat '+ f +' | iconv -f cp949 -t utf8' , shell=True) | |
def moin2doku(f): | |
return subprocess.check_output('cat '+ f+' | iconv -f cp949 -t utf8 | perl migrate.pl' , shell=True) | |
import time | |
for f in glob.glob('*'): | |
print f | |
to_doku(f, moin2doku(f)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -ni.bak | |
BEGIN { $readblank = 0; } | |
$readblank = 1 if /^$/; | |
# Fix line-endings for Unix | |
# $//; | |
# Ignore all pragmas | |
next if !$readblank and /^#/; | |
# Fix different a href linking styles | |
s/\[(http:\S+)\s+(.*?)]/[\[$1|$2\]]/g; | |
# Fix lists that aren't indented enough | |
s/^ \*/ \*/; | |
# Fix ordered lists | |
s/^(\s+)\d+\./$1-/; | |
# Fix code blocks | |
s/^{{{$/<code>/; | |
s/^}}}$/<\/code>/; | |
# Fix monospace/code text | |
s/`/''/g; | |
s/{{{(.*?)}}}/''$1''/g; | |
# Fix headers | |
s/^= (.*) =$/====== $1 ======/g; | |
s/^== (.*) ==$/===== $1 =====/g; | |
s/^=== (.*) ===$/==== $1 ====/g; | |
print; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment