Skip to content

Instantly share code, notes, and snippets.

@JosephKiranBabu
Last active September 24, 2018 18:58
Show Gist options
  • Save JosephKiranBabu/999353faeaa9b4bb5b932a0f7a9d0e5f to your computer and use it in GitHub Desktop.
Save JosephKiranBabu/999353faeaa9b4bb5b932a0f7a9d0e5f to your computer and use it in GitHub Desktop.
A badly written script to import Dokuwiki files into MediaWiki
#!/usr/bin/python3
import os
from urllib.parse import unquote
MEDIAWIKI_DIR = '/var/lib/mediawiki/'
# Files are assumed to be in a dir called mod
# in the same directory as the script
[(_, _, file_names)] = os.walk('mod')
os.chdir(os.path.join(MEDIAWIKI_DIR, 'maintenance'))
for file_name in file_names:
page_name = unquote(file_name.split('.')[0])
print('Importing:', page_name)
os.system(
'php edit.php -u admin -s "Migrated from old wiki" {0} < /vagrant/mod/{1}'.
format(page_name, file_name))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment