Back to index

moin  1.9.0~rc2
Functions
MoinMoin.script.migration.1059998 Namespace Reference

Functions

def execute

Function Documentation

def MoinMoin.script.migration.1059998.execute (   script,
  data_dir,
  rev 
)

Definition at line 14 of file 1059998.py.

00014 
00015 def execute(script, data_dir, rev):
00016     rename1_map = os.path.join(data_dir, 'rename1.txt')
00017     rename2_map = os.path.join(data_dir, 'rename2.txt')
00018     fieldsep = DataConverter.LIST_FIELDSEP
00019     if fieldsep == u'\t':
00020         fieldsep = u'TAB'
00021     if not os.path.exists(rename2_map):
00022         print "You must first edit %s." % rename1_map
00023         print "For editing it, please use an editor that is able to edit UTF-8 encoded files."
00024         print "Carefully edit - the fields are separated by a %s char, do not change this!" % fieldsep
00025         print "Entries in this file look like:"
00026         print "PAGE OLDPAGENAME NEWPAGENAME"
00027         print "FILE OLDPAGENAME OLDFILENAME NEWFILENAME"
00028         print "You may ONLY edit the rightmost field (the new name - in case you want to rename the page or file)."
00029         print
00030         print "After you have finished editing, rename the file to %s and re-issue the moin migrate command." % rename2_map
00031         return None # terminate here
00032     # the second pass does the conversion, reading <data_dir>/rename2.txt
00033     src_data_dir = os.path.abspath(os.path.join(data_dir, '..', 'data.pre160')) # keep the orig data_dir here
00034     dst_data_dir = data_dir
00035     shutil.move(data_dir, src_data_dir)
00036     # the 1.5 parser checks page existance, so we must use the orig, fully populated dir:
00037     saved_data_dir = script.request.cfg.data_dir
00038     script.request.cfg.data_dir = src_data_dir
00039     os.mkdir(dst_data_dir)
00040     shutil.move(os.path.join(src_data_dir, 'cache'), os.path.join(dst_data_dir, 'cache')) # mig script has locks there
00041     dc = DataConverter(script.request, src_data_dir, dst_data_dir)
00042     dc.pass2()
00043     # restore correct data dir:
00044     script.request.cfg.data_dir = saved_data_dir
00045     return 1060000
00046