Back to index

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

Functions

def unquoteFilename12
def convert_string
def qf_convert_string
def convert_file
def convert_textdir
def convert_pagedir
def convert_userdir
def convert_editlog

Variables

string from_encoding = 'iso8859-1'
string to_encoding = 'utf-8'
 unquoteWikiname12 = unquoteFilename12
string origdir = 'data.pre-mig1'

Function Documentation

def MoinMoin.script.old.migration.12_to_13_mig01.convert_editlog (   log_from,
  log_to,
  enc_from,
  enc_to 
)

Definition at line 140 of file 12_to_13_mig01.py.

00140 
00141 def convert_editlog(log_from, log_to, enc_from, enc_to):
00142         file_from = open(log_from)
00143         file_to = open(log_to, "w")
00144         for line in file_from:
00145             line = line.replace('\r', '')
00146             line = line.replace('\n', '')
00147             if not line.strip(): # skip empty lines
00148                 continue
00149             fields = line.split('\t')
00150             fields[0] = qf_convert_string(fields[0], enc_from, enc_to)
00151             fields[2] = str(wikiutil.timestamp2version(float(fields[2])))
00152             if len(fields) < 6:
00153                 fields.append('') # comment
00154             if len(fields) < 7:
00155                 fields.append('SAVE') # action
00156             fields[5] = convert_string(fields[5], enc_from, enc_to)
00157             line = '\t'.join(fields) + '\n'
00158             file_to.write(line)

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig01.convert_file (   fname_from,
  fname_to,
  enc_from,
  enc_to 
)

Definition at line 92 of file 12_to_13_mig01.py.

00092 
00093 def convert_file(fname_from, fname_to, enc_from, enc_to):
00094     print "%s -> %s" % (fname_from, fname_to)
00095     file_from = open(fname_from, "rb")
00096     if os.path.exists(fname_to):
00097         raise "file exists %s" % fname_to
00098     file_to = open(fname_to, "wb")
00099     for line in file_from:
00100         file_to.write(convert_string(line, enc_from, enc_to))
00101     file_to.close()
00102     file_from.close()
00103     st = os.stat(fname_from)
00104     os.utime(fname_to, (st.st_atime, st.st_mtime))

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig01.convert_pagedir (   dir_from,
  dir_to,
  enc_from,
  enc_to 
)

Definition at line 121 of file 12_to_13_mig01.py.

00121 
00122 def convert_pagedir(dir_from, dir_to, enc_from, enc_to):
00123     os.mkdir(dir_to)
00124     for dname_from in listdir(dir_from):
00125         dname_to = qf_convert_string(dname_from, enc_from, enc_to)
00126         print "%s -> %s" % (dname_from, dname_to)
00127         shutil.copytree(opj(dir_from, dname_from), opj(dir_to, dname_to), 1)
00128         try:
00129             convert_editlog(opj(dir_from, dname_from, 'last-edited'),
00130                             opj(dir_to, dname_to, 'last-edited'),
00131                             enc_from, enc_to)
00132         except IOError:
00133             pass # we ignore if it doesnt exist

Here is the call graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig01.convert_string (   str,
  enc_from,
  enc_to 
)

Definition at line 80 of file 12_to_13_mig01.py.

00080 
00081 def convert_string(str, enc_from, enc_to):
00082     try:
00083         newstr = str.decode(enc_from)
00084     except UnicodeDecodeError: # try again with iso
00085         newstr = str.decode('iso-8859-1')
00086     return newstr.encode(enc_to)

Here is the caller graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig01.convert_textdir (   dir_from,
  dir_to,
  enc_from,
  enc_to,
  is_backupdir = 0 
)

Definition at line 105 of file 12_to_13_mig01.py.

00105 
00106 def convert_textdir(dir_from, dir_to, enc_from, enc_to, is_backupdir=0):
00107     os.mkdir(dir_to)
00108     for fname_from in listdir(dir_from):
00109         if is_backupdir:
00110             fname, timestamp = fname_from.split('.', 1)
00111             timestamp = str(wikiutil.timestamp2version(float(timestamp)))
00112         else:
00113             fname = fname_from
00114         fname = qf_convert_string(fname, enc_from, enc_to)
00115         if is_backupdir:
00116             fname_to = '.'.join([fname, timestamp])
00117         else:
00118             fname_to = fname
00119         convert_file(opj(dir_from, fname_from), opj(dir_to, fname_to),
00120                      enc_from, enc_to)

Here is the call graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig01.convert_userdir (   dir_from,
  dir_to,
  enc_from,
  enc_to 
)

Definition at line 134 of file 12_to_13_mig01.py.

00134 
00135 def convert_userdir(dir_from, dir_to, enc_from, enc_to):
00136     os.mkdir(dir_to)
00137     for fname in listdir(dir_from):
00138         convert_file(opj(dir_from, fname), opj(dir_to, fname),
00139                      enc_from, enc_to)

Here is the call graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig01.qf_convert_string (   str,
  enc_from,
  enc_to 
)

Definition at line 87 of file 12_to_13_mig01.py.

00087 
00088 def qf_convert_string(str, enc_from, enc_to):
00089     str = unquoteWikiname12(str, enc_from)
00090     str = wikiutil.quoteWikinameFS(str, enc_to)
00091     return str

Here is the caller graph for this function:

Return decoded original filename when given an encoded filename.

@param filename: encoded filename
@rtype: string
@return: decoded, original filename

Definition at line 62 of file 12_to_13_mig01.py.

00062 
00063 def unquoteFilename12(filename, encoding):
00064     """
00065     Return decoded original filename when given an encoded filename.
00066 
00067     @param filename: encoded filename
00068     @rtype: string
00069     @return: decoded, original filename
00070     """
00071     str = urllib.unquote(filename.replace('_', '%'))
00072     try:
00073         newstr = str.decode(encoding)
00074     except UnicodeDecodeError: # try again with iso
00075         newstr = str.decode('iso-8859-1')
00076     return newstr


Variable Documentation

Definition at line 48 of file 12_to_13_mig01.py.

Definition at line 159 of file 12_to_13_mig01.py.

Definition at line 51 of file 12_to_13_mig01.py.

Definition at line 77 of file 12_to_13_mig01.py.