Revision: 4823
Author: rotem
Date: 2008-01-06 18:50:34 +0000 (Sun, 06 Jan 2008)
Log Message:
-----------
In wikipedia.formatInterwiki, first parsing all obsolete codes to their regular forms (or None if they don't exist anymore), so that they are not put in the list though they are in alphabetic order. Adding back the exception of obsolete languages, which shouldn't cause this problem now (constructor will raise an exception if an interwiki link with an obsolete code gets inside the dict, but this will happen before wikipedia.interwikiFormat, but when the keys of the dict are created, and shouldn't happen anyway).
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-06 15:19:02 UTC (rev 4822)
+++ trunk/pywikipedia/wikipedia.py 2008-01-06 18:50:34 UTC (rev 4823)
@@ -3026,10 +3026,9 @@
def replaceLanguageLinks(oldtext, new, site = None):
"""Replace interlanguage links in the text with a new set of links.
- 'new' should be a dict with the language names as keys, and Page objects
+ 'new' should be a dict with the Site objects as keys, and Page objects
as values (i.e., just like the dict returned by getLanguageLinks
function).
-
"""
# Find a marker that is not already in the text.
marker = '@@'
@@ -3062,26 +3061,16 @@
def interwikiFormat(links, insite = None):
"""Convert interwiki link dict into a wikitext string.
- 'links' should be a dict with the language codes as keys, and Page
+ 'links' should be a dict with the Site objects as keys, and Page
objects as values.
Return a unicode string that is formatted for inclusion in insite
(defaulting to the current site).
-
"""
if insite is None:
insite = getSite()
if not links:
return ''
- # Security check: site may not refer to itself.
- #
- # Disabled because MediaWiki was changed so that such links appear like
- # normal links, and some people accidentally use them for normal links.
- # While such links are bad style, they are not worth crashing the bot.
- #
- #for pl in links.values():
- # if pl.site() == insite:
- # raise ValueError("Trying to add interwiki link to self")
s = []
ar = links.keys()
ar.sort()
@@ -3091,7 +3080,9 @@
ar2 = []
for code in putfirst:
# The code may not exist in this family?
- if code in getSite().validLanguageLinks():
+ if code in insite.family.obsolete:
+ code = insite.family.obsolete[code]
+ if code in insite.validLanguageLinks():
site = insite.getSite(code = code)
if site in ar:
del ar[ar.index(site)]
@@ -3667,9 +3658,7 @@
self.lang = self.family.obsolete[self.lang]
else:
# no such language anymore
- # disable exception for the moment - interwiki links problems
- # raise KeyError("Language %s in family %s is obsolete" % (self.lang, self.family.name))
- pass
+ raise KeyError("Language %s in family %s is obsolete" % (self.lang, self.family.name))
if self.lang not in self.languages():
if self.lang == 'zh-classic' and 'zh-classical' in self.languages():
Bugs item #1864919, was opened at 2008-01-06 08:11
Message generated for change (Comment added) made by rotemliss
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864919&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Interface (example)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex S.H. Lin (lin4h)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'obsolete' problem stop interwiki
Initial Comment:
Traceback (most recent call last):
File "interwiki.py", line 1587, in ?
bot.run()
File "interwiki.py", line 1364, in run
self.queryStep()
File "interwiki.py", line 1343, in queryStep
subj.finish(self)
File "interwiki.py", line 950, in finish
if self.replaceLinks(page, new, bot):
File "interwiki.py", line 1043, in replaceLinks
newtext = wikipedia.replaceLanguageLinks(oldtext, new, site = page.site())
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 3040, in replaceLanguageLinks
s = interwikiFormat(new, insite = site)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 3095, in interwikiFormat
site = insite.getSite(code = code)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 4988, in getSite
return getSite(code = code, fam = self.family, user=self.user)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 5109, in getSite
_sites[key] = Site(code=code, fam=fam, user=user, persistent_http=persistent_http)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 3670, in __init__
raise KeyError("Language %s in family %s is obsolete" % (self.lang, self.family.name))
KeyError: 'Language cho in family wikipedia is obsolete'
I cannot run interwiki because this error in any project.
----------------------------------------------------------------------
Comment By: Rotem Liss (rotemliss)
Date: 2008-01-06 17:21
Message:
Logged In: YES
user_id=1327030
Originator: NO
Disabled exception for the moment in r4822. I will check the problem
later.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864919&group_…
Revision: 4822
Author: rotem
Date: 2008-01-06 15:19:02 +0000 (Sun, 06 Jan 2008)
Log Message:
-----------
Disable exception about obsolete wikis for the moment - interwiki links problems (e.g. bug 1864919).
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-01-06 12:49:18 UTC (rev 4821)
+++ trunk/pywikipedia/wikipedia.py 2008-01-06 15:19:02 UTC (rev 4822)
@@ -3667,7 +3667,9 @@
self.lang = self.family.obsolete[self.lang]
else:
# no such language anymore
- raise KeyError("Language %s in family %s is obsolete" % (self.lang, self.family.name))
+ # disable exception for the moment - interwiki links problems
+ # raise KeyError("Language %s in family %s is obsolete" % (self.lang, self.family.name))
+ pass
if self.lang not in self.languages():
if self.lang == 'zh-classic' and 'zh-classical' in self.languages():
Bugs item #1864970, was opened at 2008-01-06 17:21
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864970&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: interwiki
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex S.H. Lin (lin4h)
Assigned to: Nobody/Anonymous (nobody)
Summary: Cannot detect page protected in zh-wikinews.
Initial Comment:
I tried to make interwiki in a protected page, it cannot use sysop account automatic.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864970&group_…
Bugs item #1864919, was opened at 2008-01-06 14:11
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864919&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Interface (example)
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex S.H. Lin (lin4h)
Assigned to: Nobody/Anonymous (nobody)
Summary: 'obsolete' problem stop interwiki
Initial Comment:
Traceback (most recent call last):
File "interwiki.py", line 1587, in ?
bot.run()
File "interwiki.py", line 1364, in run
self.queryStep()
File "interwiki.py", line 1343, in queryStep
subj.finish(self)
File "interwiki.py", line 950, in finish
if self.replaceLinks(page, new, bot):
File "interwiki.py", line 1043, in replaceLinks
newtext = wikipedia.replaceLanguageLinks(oldtext, new, site = page.site())
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 3040, in replaceLanguageLinks
s = interwikiFormat(new, insite = site)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 3095, in interwikiFormat
site = insite.getSite(code = code)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 4988, in getSite
return getSite(code = code, fam = self.family, user=self.user)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 5109, in getSite
_sites[key] = Site(code=code, fam=fam, user=user, persistent_http=persistent_http)
File "/usr/home/alexsh/mwbot/pywikipedia/wikipedia.py", line 3670, in __init__
raise KeyError("Language %s in family %s is obsolete" % (self.lang, self.family.name))
KeyError: 'Language cho in family wikipedia is obsolete'
I cannot run interwiki because this error in any project.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864919&group_…
Bugs item #1864659, was opened at 2008-01-06 03:35
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864659&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: General
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Alex S.H. Lin (lin4h)
Assigned to: Nobody/Anonymous (nobody)
Summary: Cannot input parameter without english
Initial Comment:
I run interwiki.py and replace.py, all reback "UnicodeDecodeError: 'utf8' codec can't decode byte...." when I type Chinese and Japanese
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864659&group_…
Bugs item #1864547, was opened at 2008-01-05 08:12
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864547&group_…
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: add_text damages interwiki encoding
Initial Comment:
When running add_text.py on pl.wikipedia with:
add_text.py -cat:"III wiek" -text:"{{Commonscat}}" -except:"\{\{(?:[Ss]zablon:|)[Cc]ommonscat}}"
text is added correctly but the interwiki links encoding is destroyed ie. not UTF-8 anymore.
example of live change:
http://pl.wikipedia.org/w/index.php?title=201&diff=10859565&oldid=10786774
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2008-01-05 11:08
Message:
Logged In: NO
It really works in r4816. You can close it.
----------------------------------------------------------------------
Comment By: Rotem Liss (rotemliss)
Date: 2008-01-05 09:23
Message:
Logged In: YES
user_id=1327030
Originator: NO
Should be fixed in r4816.
----------------------------------------------------------------------
Comment By: Filnik (filnik)
Date: 2008-01-05 08:29
Message:
Logged In: YES
user_id=1834469
Originator: NO
Uhm, unfortunately that's a really big problem. I've tried almost
everything, so I would be glad if anyone can help fixing the problem
(search .decode(' in the code, you can't lose it). Maybe the old version
works better (but I think not). Try
http://botwiki.sno.cc/w/index.php?title=Python:Add_text.py&action=history
until I can work on it.
Filnik
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1864547&group_…