Revision: 6154 Author: purodha Date: 2008-12-16 07:49:38 +0000 (Tue, 16 Dec 2008)
Log Message: ----------- code logic simplified for later amendment.
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-12-15 16:15:39 UTC (rev 6153) +++ trunk/pywikipedia/wikipedia.py 2008-12-16 07:49:38 UTC (rev 6154) @@ -3546,8 +3546,9 @@ s = interwikiFormat(new, insite = site) s2 = removeLanguageLinks(oldtext, site = site, marker = marker) if s: + separator = site.family.interwiki_text_separator if site.language() in site.family.interwiki_attop: - newtext = s + site.family.interwiki_text_separator + s2.replace(marker,'').strip() + newtext = s + separator + s2.replace(marker,'').strip() else: # calculate what was after the language links on the page firstafter = s2.find(marker) + len(marker) @@ -3556,10 +3557,10 @@ newtext = s2[:firstafter] + s + s2[firstafter:] elif site.language() in site.family.categories_last: cats = getCategoryLinks(s2, site = site) - s2 = removeCategoryLinks(s2.replace(marker,'').strip(), site) + site.family.interwiki_text_separator + s + s2 = removeCategoryLinks(s2.replace(marker,'').strip(), site) + separator + s newtext = replaceCategoryLinks(s2, cats, site=site) else: - newtext = s2.replace(marker,'').strip() + site.family.interwiki_text_separator + s + newtext = s2.replace(marker,'').strip() + separator + s newtext = newtext.replace(marker,'') else: newtext = s2.replace(marker,'') @@ -3719,8 +3720,9 @@ s2 = removeCategoryLinks(oldtext, site = site, marker = marker)
if s: + separator = site.family.category_text_separator if site.language() in site.family.category_attop: - newtext = s + site.family.category_text_separator + s2 + newtext = s + separator + s2 else: # calculate what was after the categories links on the page firstafter = s2.find(marker) @@ -3728,10 +3730,10 @@ if "</noinclude>" in s2[firstafter:]: newtext = s2[:firstafter] + s + s2[firstafter:] elif site.language() in site.family.categories_last: - newtext = s2.replace(marker,'').strip() + site.family.category_text_separator + s + newtext = s2.replace(marker,'').strip() + separator + s else: interwiki = getLanguageLinks(s2) - s2 = removeLanguageLinks(s2.replace(marker,''), site) + site.family.category_text_separator + s + s2 = removeLanguageLinks(s2.replace(marker,''), site) + separator + s newtext = replaceLanguageLinks(s2, interwiki, site) newtext = newtext.replace(marker,'') else: