Revision: 4966 Author: filnik Date: 2008-02-03 20:53:20 +0000 (Sun, 03 Feb 2008)
Log Message: ----------- Fix for now
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2008-02-03 20:28:34 UTC (rev 4965) +++ trunk/pywikipedia/wikipedia.py 2008-02-03 20:53:20 UTC (rev 4966) @@ -4694,7 +4694,10 @@
""" if default: - return self.family.redirect.get(self.lang, [u"REDIRECT"])[0] + if self.lang == 'ar': + return self.family.redirect.get(self.lang, [u"تحويل"])[0] + else: + return self.family.redirect.get(self.lang, [u"REDIRECT"])[0] else: return self.family.redirect.get(self.lang, None)
@@ -4704,16 +4707,16 @@ Group 1 in the regex match object will be the target title.
""" + redDefault = 'redirect' + red = 'redirect' + if self.lang == 'ar': + red = u"تحويل" try: - if self.site.lang == 'ar': - red = u'تحويل' - else: - red = u'redirect' redirKeywords = [red] + self.family.redirect[self.lang] - redirKeywordsR = r'(?:' + '|'.join(redirKeywords) + ')' + redirKeywordsR = r'(?:' + redDefault + '|'.join(redirKeywords) + ')' except KeyError: # no localized keyword for redirects - redirKeywordsR = r'%s' % red + redirKeywordsR = r'(?:%s|%s)' % (red, redDefault) # A redirect starts with hash (#), followed by a keyword, then # arbitrary stuff, then a wikilink. The wikilink may contain # a label, although this is not useful.
filnik@svn.wikimedia.org ha scritto:
if default:
return self.family.redirect.get(self.lang, [u"REDIRECT"])[0]
if self.lang == 'ar':
return self.family.redirect.get(self.lang,
[u"تحويل"])[0]
else:
return self.family.redirect.get(self.lang,
[u"REDIRECT"])[0]
else: return self.family.redirect.get(self.lang, None)
@@ -4704,16 +4707,16 @@ Group 1 in the regex match object will be the target title. """
redDefault = 'redirect'
red = 'redirect'
if self.lang == 'ar':
red = u"تحويل" try:
if self.site.lang == 'ar':
red = u'تحويل'
else:
red = u'redirect' redirKeywords = [red] + self.family.redirect[self.lang]
redirKeywordsR = r'(?:' + '|'.join(redirKeywords) + ')'
redirKeywordsR = r'(?:' + redDefault +
'|'.join(redirKeywords) + ')'
except KeyError: # no localized keyword for redirects
redirKeywordsR = r'%s' % red
redirKeywordsR = r'(?:%s|%s)' % (red, redDefault) # A redirect starts with hash (#), followed by a keyword, then # arbitrary stuff, then a wikilink. The wikilink may contain # a label, although this is not useful.
Why previous code wasn't good? I don't understand. What do you want fixing? 'تحويل' is already in family.py file and 'redirect' is a valid redirect code for ar.wiki.
With previous code the function return: #(?:redirect|thwyl).*?[[(.*?)(?:|.*?)?]]
With r4968 this: #(?:redirectthwyl|thwyl).*?[[(.*?)(?:|.*?)?]]
pywikipedia-l@lists.wikimedia.org