Back to index

moin  1.9.0~rc2
Functions | Variables
MoinMoin.script.old.migration.12_to_13_mig10 Namespace Reference

Functions

def migrate

Variables

string from_encoding = 'iso8859-1'
string to_encoding = 'utf-8'
string origdir = 'data.pre-mig10'
string destdir = 'data'

Function Documentation

this removes edit-lock files from the pagedirs and
    converts attachment filenames

Definition at line 56 of file 12_to_13_mig10.py.

00056 
00057 def migrate(dir_to):
00058     """ this removes edit-lock files from the pagedirs and
00059         converts attachment filenames
00060     """
00061     pagesdir = opj(dir_to, 'pages')
00062     pagelist = listdir(pagesdir)
00063     for pagename in pagelist:
00064         pagedir = opj(pagesdir, pagename)
00065         editlock = opj(pagedir, 'edit-lock')
00066         try:
00067             os.remove(editlock)
00068         except:
00069             pass
00070 
00071         attachdir = os.path.join(pagedir, 'attachments')
00072         for root, dirs, files in os.walk(attachdir):
00073             for f in  files:
00074                 try:
00075                     f.decode(to_encoding)
00076                 except UnicodeDecodeError:
00077                     fnew = f.decode(from_encoding).encode(to_encoding)
00078                     os.rename(os.path.join(root, f), os.path.join(root, fnew))
00079                     print 'renamed', f, '\n ->', fnew, ' in dir:', root
00080 

Here is the call graph for this function:


Variable Documentation

Definition at line 82 of file 12_to_13_mig10.py.

Definition at line 42 of file 12_to_13_mig10.py.

Definition at line 81 of file 12_to_13_mig10.py.

Definition at line 45 of file 12_to_13_mig10.py.