diff MoinMoin/script/migration/_conv160_wiki.py @ 2752:7f6093028a66

1.6 converter: create complete.txt (for reference, not used yet), use 1.5 underscore magic when looking up pages in rename map
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Wed, 22 Aug 2007 13:51:26 +0200
parents ef2268e5f605
children fe6098e2a895
line wrap: on
line diff
--- a/MoinMoin/script/migration/_conv160_wiki.py	Wed Aug 22 10:28:20 2007 +0200
+++ b/MoinMoin/script/migration/_conv160_wiki.py	Wed Aug 22 13:51:26 2007 +0200
@@ -105,15 +105,34 @@
         item_type, page_name, file_name = (key + (None, ))[:3]
         abs_page_name = wikiutil.AbsPageName(current_page, page_name)
         if item_type == 'PAGE':
-            item_name = page_name
             key = (item_type, abs_page_name)
+            new_name = self.renames.get(key)
+            if new_name is None:
+                # we don't have an entry in rename map - apply the same magic
+                # to the page name as 1.5 did (" " -> "_") and try again:
+                abs_magic_name = abs_page_name.replace(u' ', u'_')
+                key = (item_type, abs_magic_name)
+                new_name = self.renames.get(key)
+                if new_name is None:
+                    # we didn't find it under the magic name either -
+                    # that means we do not rename it!
+                    new_name = page_name
+            if new_name != page_name and abs_page_name != page_name:
+                # we have to fix the (absolute) new_name to be a relative name (as it was before)
+                new_name = wikiutil.RelPageName(current_page, new_name)
         elif item_type == 'FILE':
-            item_name = file_name
             key = (item_type, abs_page_name, file_name)
-        new_name = self.renames.get(key, item_name)
-        if item_type == 'PAGE' and new_name != item_name and abs_page_name != page_name:
-            # we have to fix the (absolute) new_name to be a relative name (as it was before)
-            new_name = wikiutil.RelPageName(current_page, new_name)
+            new_name = self.renames.get(key)
+            if new_name is None:
+                # we don't have an entry in rename map - apply the same magic
+                # to the page name as 1.5 did (" " -> "_") and try again:
+                abs_magic_name = abs_page_name.replace(u' ', u'_')
+                key = (item_type, abs_magic_name, file_name)
+                new_name = self.renames.get(key)
+                if new_name is None:
+                    # we didn't find it under the magic name either -
+                    # that means we do not rename it!
+                    new_name = file_name
         return new_name
 
     def _replace_target(self, target):