Back to index

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

Functions

def convert_string
def convert_eventlog

Variables

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

Function Documentation

def MoinMoin.script.old.migration.12_to_13_mig06.convert_eventlog (   fname_from,
  fname_to,
  enc_from,
  enc_to 
)

Definition at line 59 of file 12_to_13_mig06.py.

00059 
00060 def convert_eventlog(fname_from, fname_to, enc_from, enc_to):
00061     print "%s -> %s" % (fname_from, fname_to)
00062     file_from = open(fname_from)
00063     file_to = open(fname_to, "w")
00064 
00065     for line in file_from:
00066         line = line.replace('\r', '')
00067         line = line.replace('\n', '')
00068         fields = line.split('\t')
00069         kvpairs = fields[2]
00070         kvpairs = kvpairs.split('&')
00071         kvlist = []
00072         for kvpair in kvpairs:
00073             key, val = kvpair.split('=')
00074             key = urllib.unquote(key)
00075             val = urllib.unquote(val)
00076             key = convert_string(key, enc_from, enc_to)
00077             val = convert_string(val, enc_from, enc_to)
00078             key = urllib.quote(key)
00079             val = urllib.quote(val)
00080             kvlist.append("%s=%s" % (key, val))
00081         fields[2] = '&'.join(kvlist)
00082         line = '\t'.join(fields) + '\n'
00083         file_to.write(line)
00084 
00085     file_to.close()
00086     file_from.close()
00087     st = os.stat(fname_from)
00088     os.utime(fname_to, (st.st_atime, st.st_mtime))

Here is the call graph for this function:

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

Definition at line 56 of file 12_to_13_mig06.py.

00056 
00057 def convert_string(str, enc_from, enc_to):
00058     return str.decode(enc_from).encode(enc_to)

Here is the caller graph for this function:


Variable Documentation

Definition at line 46 of file 12_to_13_mig06.py.

Definition at line 89 of file 12_to_13_mig06.py.

Definition at line 47 of file 12_to_13_mig06.py.