Back to index

moin  1.9.0~rc2
1059998.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: iso-8859-1 -*-
00003 """
00004     MoinMoin - 2nd pass of 1.6 migration
00005 
00006     @copyright: 2007 by Thomas Waldmann
00007     @license: GNU GPL, see COPYING for details.
00008 """
00009 
00010 import os, shutil
00011 
00012 from _conv160a import DataConverter
00013 
00014 def execute(script, data_dir, rev):
00015     rename1_map = os.path.join(data_dir, 'rename1.txt')
00016     rename2_map = os.path.join(data_dir, 'rename2.txt')
00017     fieldsep = DataConverter.LIST_FIELDSEP
00018     if fieldsep == u'\t':
00019         fieldsep = u'TAB'
00020     if not os.path.exists(rename2_map):
00021         print "You must first edit %s." % rename1_map
00022         print "For editing it, please use an editor that is able to edit UTF-8 encoded files."
00023         print "Carefully edit - the fields are separated by a %s char, do not change this!" % fieldsep
00024         print "Entries in this file look like:"
00025         print "PAGE OLDPAGENAME NEWPAGENAME"
00026         print "FILE OLDPAGENAME OLDFILENAME NEWFILENAME"
00027         print "You may ONLY edit the rightmost field (the new name - in case you want to rename the page or file)."
00028         print
00029         print "After you have finished editing, rename the file to %s and re-issue the moin migrate command." % rename2_map
00030         return None # terminate here
00031     # the second pass does the conversion, reading <data_dir>/rename2.txt
00032     src_data_dir = os.path.abspath(os.path.join(data_dir, '..', 'data.pre160')) # keep the orig data_dir here
00033     dst_data_dir = data_dir
00034     shutil.move(data_dir, src_data_dir)
00035     # the 1.5 parser checks page existance, so we must use the orig, fully populated dir:
00036     saved_data_dir = script.request.cfg.data_dir
00037     script.request.cfg.data_dir = src_data_dir
00038     os.mkdir(dst_data_dir)
00039     shutil.move(os.path.join(src_data_dir, 'cache'), os.path.join(dst_data_dir, 'cache')) # mig script has locks there
00040     dc = DataConverter(script.request, src_data_dir, dst_data_dir)
00041     dc.pass2()
00042     # restore correct data dir:
00043     script.request.cfg.data_dir = saved_data_dir
00044     return 1060000
00045