Revision: 5914 Author: wikipedian Date: 2008-09-22 16:15:37 +0000 (Mon, 22 Sep 2008)
Log Message: ----------- Fixed the Esperanto X-convention bug [ 2006208 ] by rolling back many changes that concerned Esperanto X-conv.
I fixed this on 2008-08-21 already, but somehow my commit seems to have failed (sorry), so now I retry to commit it.
Modified Paths: -------------- trunk/pywikipedia/families/wikipedia_family.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/families/wikipedia_family.py =================================================================== --- trunk/pywikipedia/families/wikipedia_family.py 2008-09-22 09:58:41 UTC (rev 5913) +++ trunk/pywikipedia/families/wikipedia_family.py 2008-09-22 16:15:37 UTC (rev 5914) @@ -966,16 +966,4 @@ return self.code2encoding(code),
def shared_image_repository(self, code): - return ('commons', 'commons') - - def post_get_convert(self, site, getText): - if site.lang == 'eo': - return wikipedia.decodeEsperantoX(getText) - else: - return getText - - def pre_put_convert(self, site, getText): - if site.lang == 'eo': - return wikipedia.encodeEsperantoX(getText) - else: - return getText + return ('commons', 'commons') \ No newline at end of file
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-09-22 09:58:41 UTC (rev 5913) +++ trunk/pywikipedia/wikipedia.py 2008-09-22 16:15:37 UTC (rev 5914) @@ -799,12 +799,12 @@ else: self._isWatched = False # Now process the contents of the textarea - # Unescape HTML characters, strip whitespace and postconvert - pagetext = text[i1:i2] - pagetext = unescape(pagetext) - pagetext = pagetext.rstrip() - pagetext = self.site().post_get_convert(pagetext) - + # Unescape HTML characters, strip whitespace + pagetext = text[i1:i2] + pagetext = unescape(pagetext) + pagetext = pagetext.rstrip() + if self.site().lang == 'eo': + pagetext = decodeEsperantoX(pagetext) m = self.site().redirectRegex().match(pagetext) if m: # page text matches the redirect pattern @@ -1295,7 +1295,12 @@ import watchlist watchArticle = watchlist.isWatched(self.title(), site = self.site()) newPage = not self.exists() - newtext = self.site().pre_put_convert(newtext) + # if posting to an Esperanto wiki, we must e.g. write Bordeauxx instead + # of Bordeaux + if self.site().lang == 'eo': + newtext = encodeEsperantoX(newtext) + comment = encodeEsperantoX(comment) + return self._putPage(newtext, comment, watchArticle, minorEdit, newPage, self.site().getToken(sysop = sysop), sysop = sysop)
@@ -2237,7 +2242,7 @@ reason = input(u'Please enter a reason for the deletion:') answer = 'y' if prompt and not hasattr(self.site(), '_noDeletePrompt'): - answer = inputChoice(u'Do you want to delete %s?' % self.aslink(forceInterwiki = True), ['Yes', 'No', 'All'], ['Y', 'N', 'A'], 'N') + answer = inputChoice(u'Do you want to delete %s?' % self.aslink(forceInterwiki = True), ['yes', 'no', 'all'], ['y', 'N', 'a'], 'N') if answer == 'a': answer = 'y' self.site()._noDeletePrompt = True @@ -2939,6 +2944,9 @@ def getData(self): address = self.site.export_address() pagenames = [page.sectionFreeTitle() for page in self.pages] + # We need to use X convention for requested page titles. + if self.site.lang == 'eo': + pagenames = [encodeEsperantoX(pagetitle) for pagetitle in pagenames] pagenames = u'\r\n'.join(pagenames) if type(pagenames) is not unicode: output(u'Warning: xmlreader.WikipediaXMLHandler.getData() got non-unicode page names. Please report this.') @@ -3995,11 +4003,6 @@ linktrail: Return regex for trailing chars displayed as part of a link. disambcategory: Category in which disambiguation pages are listed.
- post_get_convert: Converts text data from the site immediatly after get - i.e. EsperantoX -> unicode - pre_put_convert: Converts text data from the site immediatly before put - i.e. unicode -> EsperantoX - Methods that yield Page objects derived from a wiki's Special: pages (note, some methods yield other information in a tuple along with the Pages; see method docs for details) -- @@ -5840,12 +5843,6 @@ """Return regex for trailing chars displayed as part of a link.""" return self.family.linktrail(self.lang)
- def post_get_convert(self, getText): - return self.family.post_get_convert(self, getText) - - def pre_put_convert(self, putText): - return self.family.pre_put_convert(self, putText) - def language(self): """Return Site's language code.""" return self.lang
On Mon, September 22, 2008 5:15 pm, wikipedian@svn.wikimedia.org wrote:
Revision: 5914 Author: wikipedian Date: 2008-09-22 16:15:37 +0000 (Mon, 22 Sep 2008)
Log Message:
Fixed the Esperanto X-convention bug [ 2006208 ] by rolling back many changes that concerned Esperanto X-conv. (...)
On a general note, I would be grateful if reverts would be accompanied by an e-mail: I don't always have the time to read all commits, and a accompanying email is much more visible. I only found out by accident the more systematic rewrite was reverted back in september. Additionally, please revert the /complete/ commit: the default pre_page_save and post_page_get functions are still in family.py, while their calls in wikipedia.py were removed...
I'll take a look at re-implementing my rewrite later...I am fairly certain my changes were not the cause of the mentioned problems.
--valhallasw
pywikipedia-l@lists.wikimedia.org