~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/script/old/migration/12_to_13_mig07.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
"""
3
3
    12_to_13.py - converting CRLF / LF style to the future standard
4
4
    Use this to convert from 1.3 pre patch-275 to patch-275.
5
 
    
 
5
 
6
6
    Changes:
7
7
    * use OS style for logs (== no change, same as it was)
8
8
    * use CRLF for page files on any platform (text/* mandates it!) -
30
30
    fi = open(fni, "rb")
31
31
    data = fi.read()
32
32
    fi.close()
33
 
    data = data.replace("\r","")
 
33
    data = data.replace("\r", "")
34
34
    lines = data.split("\n")
35
35
    data = "\r\n".join(lines)
36
36
    if data[-2:] != "\r\n":
38
38
    fo = open(fno, "wb")
39
39
    fo.write(data)
40
40
    fo.close()
41
 
    st=os.stat(fni)
42
 
    os.utime(fno, (st.st_atime,st.st_mtime))
43
 
                
 
41
    st = os.stat(fni)
 
42
    os.utime(fno, (st.st_atime, st.st_mtime))
 
43
 
44
44
def process_pagedirs(dir_from, dir_to):
45
45
    pagelist = listdir(dir_from)
46
46
    for pagename in pagelist:
47
47
        pagedir_from = opj(dir_from, pagename)
48
48
        pagedir_to = opj(dir_to, pagename)
49
 
        
 
49
 
50
50
        # first we copy all, even the stuff we convert later:
51
51
        copy_dir(pagedir_from, pagedir_to)
52
 
        
 
52
 
53
53
        rev_from = opj(pagedir_from, 'revisions')
54
54
        rev_to = opj(pagedir_to, 'revisions')
55
55
        if os.path.exists(rev_from):
68
68
    print "You need to be in the directory where your copy of the 'data' directory is located."
69
69
    sys.exit(1)
70
70
 
71
 
os.makedirs(opj('data','pages'))
 
71
os.makedirs(opj('data', 'pages'))
72
72
 
73
73
process_pagedirs(opj(origdir, 'pages'), opj('data', 'pages'))
74
74