Mercurial > moin > 1.9
changeset 2750:f12b39c07405
1.6 converter: make RENAMES_FIELDSEP easily changeable
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Wed, 22 Aug 2007 09:57:42 +0200 |
parents | ef2268e5f605 |
children | 7a6b5f0c92c9 |
files | MoinMoin/script/migration/1059999.py MoinMoin/script/migration/_conv160.py |
diffstat | 2 files changed, 11 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/script/migration/1059999.py Wed Aug 22 09:31:31 2007 +0200 +++ b/MoinMoin/script/migration/1059999.py Wed Aug 22 09:57:42 2007 +0200 @@ -16,9 +16,10 @@ rename2_map = os.path.join(data_dir, 'rename2.txt') if not os.path.exists(rename2_map): print "You must first edit %s." % rename1_map - print "For editing it, please use an editor that honours TAB chars and is able to edit UTF-8 encoded files." - print "Carefully edit - the fields are separated by a single TAB char, do not change this!" - print "You may ONLY edit the rightmost field (this is the NEW name - in case you want to rename the page or file)." + print "For editing it, please use an editor that is able to edit UTF-8 encoded files." + print "Carefully edit - the fields are separated by a %r char, do not change this!" % DataConverter.RENAMES_FIELDSEP + print "Fields in this file are: TYPE OLDNAME NEWNAME" + print "You may ONLY edit the rightmost field (NEWNAME - in case you want to rename the page or file)." print print "After you have finished editing, rename the file to %s and re-issue the moin migrate command." % rename2_map return None # terminate here
--- a/MoinMoin/script/migration/_conv160.py Wed Aug 22 09:31:31 2007 +0200 +++ b/MoinMoin/script/migration/_conv160.py Wed Aug 22 09:57:42 2007 +0200 @@ -424,15 +424,18 @@ self.renames[('FILE', pn, fn)] = None self.save_renames() + RENAMES_FIELDSEP = u'|' # in case | makes trouble, one can use \t tab char + def save_renames(self): f = codecs.open(self.rename_fname1, 'w', 'utf-8') for k in self.renames: rtype, pn, fn = (k + (None, ))[:3] if rtype == 'PAGE': - line = u"%s\t%s\t%s\r\n" % (rtype, pn, pn) + line = (rtype, pn, pn) elif rtype == 'FILE': - line = u"%s\t%s\t%s\t%s\r\n" % (rtype, pn, fn, fn) - f.write(line) + line = (rtype, pn, fn, fn) + line = self.RENAMES_FIELDSEP.join(line) + f.write(line + u'\n') f.close() def load_renames(self): @@ -441,7 +444,7 @@ line = line.rstrip() if not line: continue - t = line.split(u'\t') + t = line.split(self.RENAMES_FIELDSEP) rtype, p1, p2, p3 = (t + [None]*3)[:4] if rtype == u'PAGE': self.renames[(str(rtype), p1)] = p2