Revision: 8386
Author:   xqt
Date:     2010-08-07 13:35:28 +0000 (Sat, 07 Aug 2010)

Log Message:
-----------
remove old nn-comment - bug #2819556 (code recycled from cosmetic_changes.py)

Modified Paths:
--------------
    trunk/pywikipedia/add_text.py

Modified: trunk/pywikipedia/add_text.py
===================================================================
--- trunk/pywikipedia/add_text.py       2010-08-07 13:35:10 UTC (rev 8385)
+++ trunk/pywikipedia/add_text.py       2010-08-07 13:35:28 UTC (rev 8386)
@@ -243,18 +243,24 @@
             interwikiInside = pywikibot.getLanguageLinks(newtext, site)
             # Removing the interwiki
             newtext = pywikibot.removeLanguageLinks(newtext, site)
-            # nn got a message between the categories and the iw's and they 
want to
-            # keep it there, first remove it
+            # nn got a message between the categories and the iw's
+            # and they want to keep it there, first remove it
+            hasCommentLine = False
             if (site.language()==u'nn'):
-                newtext = newtext.replace(nn_iw_msg, '')
+                regex = re.compile('(<!-- ?interwiki \(no(?:/nb)?, ?sv, ?da 
first; then other languages alphabetically by name\) ?-->)')
+                found = regex.findall(newtext)
+                if found:
+                    hasCommentLine = True
+                    newtext = regex.sub('', newtext)
+
             # Adding the text
             newtext += u"\n%s" % addText
             # Reputting the categories
             newtext = pywikibot.replaceCategoryLinks(newtext,
                                                  categoriesInside, site, True)
             #Put the nn iw message back
-            if (site.language()==u'nn'):
-                newtext = newtext + u'\n' + nn_iw_msg
+            if site.language()==u'nn' and (interwikiInside or hasCommentLine):
+                newtext = newtext + u'\r\n\r\n' + nn_iw_msg
             # Dealing the stars' issue
             allstars = []
             starstext = pywikibot.removeDisabledParts(text)



_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn

Reply via email to