Revision: 4748
Author: filnik
Date: 2007-12-22 13:06:46 +0000 (Sat, 22 Dec 2007)
Log Message:
-----------
Adding a \n in the commons' message to prevent errors
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2007-12-22 10:27:48 UTC (rev 4747)
+++ trunk/pywikipedia/checkimages.py 2007-12-22 13:06:46 UTC (rev 4748)
@@ -166,7 +166,7 @@
}
# That's the text that the bot will add if it doesn't find the license.
nothing_notification = {
- 'commons':"{{subst:User:Filnik/untagged|Image:%s}}\n\n''This message was '''added automatically by [[User:Filbot|Filbot]]''', if you need some help about it, ask [[User:Filnik|its master]] or go to the [[Commons:Help desk]]''. --~~~~",
+ 'commons':"\n{{subst:User:Filnik/untagged|Image:%s}}\n\n''This message was '''added automatically by [[User:Filbot|Filbot]]''', if you need some help about it, ask [[User:Filnik|its master]] or go to the [[Commons:Help desk]]''. --~~~~",
'en' :"{{subst:image source|Image:%s}} --~~~~",
'it' :"{{subst:Utente:Filbot/Senza licenza|%s}} --~~~~",
'hu' :u"{{subst:adjforrást|Kép:%s}} \n Ezt az üzenetet ~~~ automatikusan helyezte el a vitalapodon, kérdéseddel fordulj a gazdájához, vagy a [[WP:KF|Kocsmafalhoz]]. --~~~~",
Revision: 4743
Author: rotem
Date: 2007-12-21 18:58:54 +0000 (Fri, 21 Dec 2007)
Log Message:
-----------
Creating wikipedia.site.prefixindex (which still uses wikipedia.site.allpages), and making pagegenerators.PrefixingPageGenerator use it.
Modified Paths:
--------------
trunk/pywikipedia/pagegenerators.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/pagegenerators.py
===================================================================
--- trunk/pywikipedia/pagegenerators.py 2007-12-21 18:46:24 UTC (rev 4742)
+++ trunk/pywikipedia/pagegenerators.py 2007-12-21 18:58:54 UTC (rev 4743)
@@ -117,18 +117,22 @@
"""
if site is None:
site = wikipedia.getSite()
+ page = wikipedia.Page(site, start)
if namespace is None:
- namespace = wikipedia.Page(site, start).namespace()
- title = wikipedia.Page(site, start).titleWithoutNamespace()
- for page in site.allpages(start=title, namespace=namespace, includeredirects = includeredirects):
+ namespace = page.namespace()
+ title = page.titleWithoutNamespace()
+ for page in site.allpages(start = title, namespace = namespace, includeredirects = includeredirects):
yield page
def PrefixingPageGenerator(prefix, namespace = None, includeredirects = True, site = None):
- for page in AllpagesPageGenerator(prefix, namespace, includeredirects, site):
- if page.titleWithoutNamespace().startswith(prefix):
- yield page
- else:
- break
+ if site is None:
+ site = wikipedia.getSite()
+ page = wikipedia.Page(site, prefix)
+ if namespace is None:
+ namespace = page.namespace()
+ title = page.titleWithoutNamespace()
+ for page in site.prefixindex(prefix = title, namespace = namespace, includeredirects = includeredirects):
+ yield page
def NewpagesPageGenerator(number = 100, get_redirect = False, repeat = False, site = None):
if site is None:
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-12-21 18:46:24 UTC (rev 4742)
+++ trunk/pywikipedia/wikipedia.py 2007-12-21 18:58:54 UTC (rev 4743)
@@ -3491,6 +3491,7 @@
search(query): query results from Special:Search
allpages(): Special:Allpages
+ prefixindex(): Special:Prefixindex
newpages(): Special:Newpages
newimages(): Special:Log&type=upload
longpages(): Special:Longpages
@@ -4456,6 +4457,29 @@
else:
break
+ def prefixindex(self, prefix, namespace=0, includeredirects=True):
+ """Yield all pages with a given prefix.
+
+ Parameters:
+ prefix The prefix of the pages.
+ namespace Namespace number; defaults to 0.
+ MediaWiki software will only return pages in one namespace
+ at a time.
+
+ If includeredirects is False, redirects will not be found.
+ If includeredirects equals the string 'only', only redirects
+ will be found. Note that this has not been tested on older
+ versions of the MediaWiki code.
+
+ It is advised not to use this directly, but to use the
+ PrefixingPageGenerator from pagegenerators.py instead.
+ """
+ for page in self.allpages(start = prefix, namespace = namespace, includeredirects = includeredirects):
+ if page.titleWithoutNamespace().startswith(prefix):
+ yield page
+ else:
+ break
+
def linksearch(self, siteurl):
"""Yield Pages from results of Special:Linksearch for 'siteurl'."""
if siteurl.startswith('*.'):
Bugs item #1855071, was opened at 2007-12-20 13:10
Message generated for change (Comment added) made by russblau
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1855071&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: Nicolas Dumazet (nicdumz)
Assigned to: Nobody/Anonymous (nobody)
Summary: "redirect.py double -xml:xx -namespace:x" crashing
Initial Comment:
It is not even loading the XML, i get an instant error :
python redirect.py double -namespace:0 -xml:frwiki-20071203-pages-articles.xml
Checked for running processes. 1 processes currently running, including the current process.
Reading XML dump...
Traceback (most recent call last):
File "redirect.py", line 377, in <module>
main()
File "redirect.py", line 373, in main
bot.run()
File "redirect.py", line 328, in run
self.fix_double_redirects()
File "redirect.py", line 255, in fix_double_redirects
for redir_name in self.generator.retrieve_double_redirects():
File "redirect.py", line 199, in retrieve_double_redirects
dict = self.get_redirects_from_dump()
File "redirect.py", line 123, in get_redirects_from_dump
if self.namespace and self.namespace != entry.namespace:
AttributeError: XmlEntry instance has no attribute 'namespace'
----------------------------------------------------------------------
Comment By: Russell Blau (russblau)
Date: 2007-12-20 13:40
Message:
Logged In: YES
user_id=855050
Originator: NO
fixed in r4741
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1855071&group_…
Bugs item #1855044, was opened at 2007-12-20 12:20
Message generated for change (Comment added) made by russblau
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1855044&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: Nicolas Dumazet (nicdumz)
Assigned to: Nobody/Anonymous (nobody)
Summary: redirect.py crashes when finding a bad page
Initial Comment:
When doing a simple "redirect.py double -xml:xx.xml", I got :
Traceback (most recent call last):
File "redirect.py", line 377, in <module>
main()
File "redirect.py", line 373, in main
bot.run()
File "redirect.py", line 328, in run
self.fix_double_redirects()
File "redirect.py", line 273, in fix_double_redirects
secondTargetPage = secondRedir.getRedirectTarget()
File "/home/nico/projets/pywikipedia/wikipedia.py", line 1576, in
getRedirectTarget
self.get()
File "/home/nico/projets/pywikipedia/wikipedia.py", line 595, in get
self._contents, self._isWatched, self.editRestriction =
self._getEditPage(get_redirect = get_redirect, throttle = throttle, sysop =
sysop, nofollow_redirects=nofollow_redirects)
File "/home/nico/projets/pywikipedia/wikipedia.py", line 679, in
_getEditPage
raise BadTitle('BadTitle: %s' % self)
wikipedia.BadTitle: BadTitle: [[../Projet/Sciences/Champs magnétiques B et
H]]
Now, the redirect page was :
#REDIRECT [[../Projet/Sciences/Champs magnétiques B et H]], which is not
correct.
But I think that redirect.py is supposed to ask the user if not skipping
it, instead of crashing ;)
Thanks,
Nicolas Dumazet.
----------------------------------------------------------------------
Comment By: Russell Blau (russblau)
Date: 2007-12-20 13:39
Message:
Logged In: YES
user_id=855050
Originator: NO
fixed in r4741
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=1855044&group_…