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

« back to all changes in this revision

Viewing changes to MoinMoin/script/old/migration/12_to_13_mig01.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:
62
62
def unquoteFilename12(filename, encoding):
63
63
    """
64
64
    Return decoded original filename when given an encoded filename.
65
 
    
 
65
 
66
66
    @param filename: encoded filename
67
67
    @rtype: string
68
68
    @return: decoded, original filename
83
83
    except UnicodeDecodeError: # try again with iso
84
84
        newstr = str.decode('iso-8859-1')
85
85
    return newstr.encode(enc_to)
86
 
    
 
86
 
87
87
def qf_convert_string(str, enc_from, enc_to):
88
88
    str = unquoteWikiname12(str, enc_from)
89
89
    str = wikiutil.quoteWikinameFS(str, enc_to)
99
99
        file_to.write(convert_string(line, enc_from, enc_to))
100
100
    file_to.close()
101
101
    file_from.close()
102
 
    st=os.stat(fname_from)
103
 
    os.utime(fname_to, (st.st_atime,st.st_mtime))
 
102
    st = os.stat(fname_from)
 
103
    os.utime(fname_to, (st.st_atime, st.st_mtime))
104
104
 
105
105
def convert_textdir(dir_from, dir_to, enc_from, enc_to, is_backupdir=0):
106
106
    os.mkdir(dir_to)
107
107
    for fname_from in listdir(dir_from):
108
108
        if is_backupdir:
109
 
            fname, timestamp = fname_from.split('.',1)
 
109
            fname, timestamp = fname_from.split('.', 1)
110
110
            timestamp = str(wikiutil.timestamp2version(float(timestamp)))
111
111
        else:
112
112
            fname = fname_from
115
115
            fname_to = '.'.join([fname, timestamp])
116
116
        else:
117
117
            fname_to = fname
118
 
        convert_file(opj(dir_from, fname_from), opj( dir_to, fname_to),
 
118
        convert_file(opj(dir_from, fname_from), opj(dir_to, fname_to),
119
119
                     enc_from, enc_to)
120
120
 
121
121
def convert_pagedir(dir_from, dir_to, enc_from, enc_to):
141
141
        file_from = open(log_from)
142
142
        file_to = open(log_to, "w")
143
143
        for line in file_from:
144
 
            line = line.replace('\r','')
145
 
            line = line.replace('\n','')
 
144
            line = line.replace('\r', '')
 
145
            line = line.replace('\n', '')
146
146
            if not line.strip(): # skip empty lines
147
147
                continue
148
148
            fields = line.split('\t')