Back to index

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

Functions

def convert_quicklinks
def convert_subscribed_pages
def convertUserData
def convertUsers

Variables

 join = os.path.join
string datadir = 'data'
string origdir = 'data.pre-mig9'
list names = ['edit-log', 'event-log', 'intermap.txt', 'pages', 'plugin']

Function Documentation

Convert quicklinks from pre patch-332 to new format 

Definition at line 60 of file 12_to_13_mig09.py.

00060 
00061 def convert_quicklinks(string):
00062     """ Convert quicklinks from pre patch-332 to new format """
00063     # No need to convert new style list
00064     if '\t' in string:
00065         return string
00066 
00067     names = [name.strip() for name in string.split(',')]
00068     names = [wikiutil.unquoteWikiname(name) for name in names if name != '']
00069     string = user.encodeList(names)
00070     return string
00071 

Here is the caller graph for this function:

Convert subscribed pages from pre patch-332 to new format 

Definition at line 72 of file 12_to_13_mig09.py.

00072 
00073 def convert_subscribed_pages(string):
00074     """ Convert subscribed pages from pre patch-332 to new format """
00075     # No need to convert new style list
00076     if '\t' in string:
00077         return string
00078 
00079     # This might break pages that contain ',' in the name, we can't do
00080     # anything about it. This was the reason we changed the format.
00081     names = [name.strip() for name in string.split(',')]
00082     string = user.encodeList(names)
00083     return string
00084 

Here is the caller graph for this function:

Convert user data

@param text: text of user file, unicode
@rtype: unicode
@return: convected user data

Definition at line 85 of file 12_to_13_mig09.py.

00085 
00086 def convertUserData(text):
00087     """ Convert user data
00088 
00089     @param text: text of user file, unicode
00090     @rtype: unicode
00091     @return: convected user data
00092     """
00093     lines = text.splitlines()
00094     for i in range(len(lines)):
00095         line = lines[i]
00096         try:
00097             key, value = line.split('=', 1)
00098         except ValueError:
00099             continue
00100         if key == u'quicklinks':
00101             value = convert_quicklinks(value)
00102         elif key == u'subscribed_pages':
00103             value = convert_subscribed_pages(value)
00104         lines[i] = u'%s=%s' % (key, value)
00105 
00106     # Join back, append newline to last line
00107     text = u'\n'.join(lines) + u'\n'
00108     return text
00109 

Here is the call graph for this function:

Here is the caller graph for this function:

Convert users files

@param srcdir: old users dir
@param dstdir: new users dir

Definition at line 110 of file 12_to_13_mig09.py.

00110 
00111 def convertUsers(srcdir, dstdir):
00112     """ Convert users files
00113 
00114     @param srcdir: old users dir
00115     @param dstdir: new users dir
00116     """
00117     charset = 'utf-8'
00118 
00119     # Create dstdir
00120     if not os.path.exists(dstdir):
00121         try:
00122             os.mkdir(dstdir)
00123         except OSError:
00124             migutil.fatalError("can't create user directory at '%s'" % dstdir)
00125 
00126     if not os.path.isdir(srcdir):
00127         migutil.fatalError("can't find user directory at '%s'" % srcdir)
00128 
00129     for name in migutil.listdir(srcdir):
00130         if name == 'README' or name.endswith('.trail'):
00131             # Copy as is
00132             migutil.copy_file(join(srcdir, name), join(dstdir, name))
00133         else:
00134             srcfile = join(srcdir, name)
00135             f = codecs.open(srcfile, 'rb', charset)
00136             text = f.read()
00137             f.close()
00138             text = convertUserData(text)
00139             dstfile = join(dstdir, name)
00140             f = codecs.open(dstfile, 'wb', charset)
00141             f.write(text)
00142             f.close()
00143             print "Converted '%s' to '%s'" % (srcfile, dstfile)
00144 

Here is the call graph for this function:


Variable Documentation

Definition at line 148 of file 12_to_13_mig09.py.

Definition at line 50 of file 12_to_13_mig09.py.

list MoinMoin.script.old.migration.12_to_13_mig09.names = ['edit-log', 'event-log', 'intermap.txt', 'pages', 'plugin']

Definition at line 154 of file 12_to_13_mig09.py.

Definition at line 149 of file 12_to_13_mig09.py.