Back to index

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

Functions

def unquoteWikinameOld
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 = 'utf-8'
string to_encoding = 'utf-8'
string origdir = 'data.pre-mig2'

Function Documentation

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

Definition at line 139 of file 12_to_13_mig02.py.

00139 
00140 def convert_editlog(log_from, log_to, enc_from, enc_to):
00141         file_from = open(log_from)
00142         file_to = open(log_to, "w")
00143         for line in file_from:
00144             fields = line.split('\t')
00145             fields[0] = qf_convert_string(fields[0], enc_from, enc_to)
00146             fields[5] = convert_string(fields[5], enc_from, enc_to)
00147             line = '\t'.join(fields)
00148             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_mig02.convert_file (   fname_from,
  fname_to,
  enc_from,
  enc_to 
)

Definition at line 91 of file 12_to_13_mig02.py.

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

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 119 of file 12_to_13_mig02.py.

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

Here is the call graph for this function:

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

Definition at line 71 of file 12_to_13_mig02.py.

00071 
00072 def convert_string(str, enc_from, enc_to):
00073     return str.decode(enc_from).encode(enc_to)
00074 

Here is the caller graph for this function:

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

Definition at line 103 of file 12_to_13_mig02.py.

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

Here is the call graph for this function:

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

Definition at line 132 of file 12_to_13_mig02.py.

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

Here is the call graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig02.qf_convert_string (   str,
  enc_from,
  enc_to 
)
Convert filename from pre patch 78 quoting to new quoting

The old quoting function from patch 77 can convert name ONLY from
the old way to the new, so if you have a partially converted
directory, as it the situation as of moin--main--1.3--patch-86,
it does not work.

The new unquoting function is backward compatible, and can unquote
both post and pre patch 78 file names.

Definition at line 75 of file 12_to_13_mig02.py.

00075 
00076 def qf_convert_string(str, enc_from, enc_to):
00077     """ Convert filename from pre patch 78 quoting to new quoting
00078 
00079     The old quoting function from patch 77 can convert name ONLY from
00080     the old way to the new, so if you have a partially converted
00081     directory, as it the situation as of moin--main--1.3--patch-86,
00082     it does not work.
00083 
00084     The new unquoting function is backward compatible, and can unquote
00085     both post and pre patch 78 file names.
00086     """
00087     str = wikiutil.unquoteWikiname(str, [enc_from])
00088     str = wikiutil.quoteWikinameFS(str, enc_to)
00089     return str
00090 

Here is the caller graph for this function:

def MoinMoin.script.old.migration.12_to_13_mig02.unquoteWikinameOld (   filename,
  charsets = [from_encoding 
)
Return decoded original filename when given an encoded filename.
@param filename: encoded filename
@rtype: string
@return: decoded, original filename

Definition at line 44 of file 12_to_13_mig02.py.

00044 
00045 def unquoteWikinameOld(filename, charsets=[from_encoding, ]):
00046     """
00047     Return decoded original filename when given an encoded filename.
00048     @param filename: encoded filename
00049     @rtype: string
00050     @return: decoded, original filename
00051     """
00052     if isinstance(filename, type(u'')): # from some places we get called with unicode
00053         filename = filename.encode(from_encoding)
00054     fn = ''
00055     i = 0
00056     while i < len(filename):
00057         c = filename[i]
00058         if c == '(':
00059             c1 = filename[i+1]
00060             c2 = filename[i+2]
00061             close = filename[i+3]
00062             if close != ')':
00063                 raise Exception('filename encoding invalid')
00064             i += 4
00065             fn = fn + chr(16 * int(c1, 16) + int(c2, 16))
00066         else:
00067             fn = fn + c
00068             i += 1
00069     return wikiutil.decodeUserInput(fn, charsets)
00070 


Variable Documentation

Definition at line 33 of file 12_to_13_mig02.py.

Definition at line 149 of file 12_to_13_mig02.py.

Definition at line 34 of file 12_to_13_mig02.py.