Revision: 5983
Author: filnik
Date: 2008-10-16 16:49:37 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
New function: pageAPInfo() to know if a page is a redirect or it's empty calling the API to improve the performance in some situations
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-10-16 16:49:27 UTC (rev 5982)
+++ trunk/pywikipedia/wikipedia.py 2008-10-16 16:49:37 UTC (rev 5983)
@@ -885,6 +885,33 @@
return False
return True
+ def pageAPInfo(self):
+ """Return True if page exists on the wiki,
+ Raise IsRedirectPage if it's a redirect
+ Raise NoPage if the page doesn't exist
+
+ Using the API should be a lot faster.
+ Function done in order to improve the scripts performance.
+
+ """
+ params = {
+ 'action' :'query',
+ 'prop' :'info',
+ 'titles' :self.title(),
+ }
+ data = query.GetData(params,
+ useAPI = True, encodeTitle = False)
+ pageid = data['query']['pages'].keys()[0]
+ if data['query']['pages'][pageid].keys()[0] == 'lastrevid':
+ return True
+ elif data['query']['pages'][pageid].keys()[0] == 'redirect':
+ raise IsRedirectPage
+ else:
+ # should not exists, OR we have problems.
+ # better double check in this situations
+ x = self.get()
+ return True # if we reach this point, we had no problems.
+
def isRedirectPage(self):
"""Return True if this is a redirect, False if not or not existing."""
try:
Revision: 5982
Author: filnik
Date: 2008-10-16 16:49:27 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
New function: pageAPInfo() to know if a page is a redirect or it's empty calling the API to improve the performance in some situations
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2008-10-16 16:14:56 UTC (rev 5981)
+++ trunk/pywikipedia/checkimages.py 2008-10-16 16:49:27 UTC (rev 5982)
@@ -633,7 +633,8 @@
# Getting the talk page's history, to check if there is another advise...
# The try block is used to prevent error if you use an old wikipedia.py's version.
edit_to_load = 10
- if self.talk_page.exists():
+ try:
+ testoattuale = self.talk_page.get()
try:
history = self.talk_page.getVersionHistory(False, False, False, edit_to_load)
except TypeError:
@@ -641,24 +642,22 @@
latest_edit = history[0]
latest_user = latest_edit[2]
wikipedia.output(u'The latest user that has written something is: %s' % latest_user)
- try:
- testoattuale = self.talk_page.get() # Actual text
- except wikipedia.IsRedirectPage:
- wikipedia.output(u'The user talk is a redirect, trying to get the right talk...')
- try:
- self.talk_page = self.talk_page.getRedirectTarget()
- testoattuale = self.talk_page.get()
- except wikipedia.NoPage:
- second_text = False
- ti_es_ti = wikipedia.translate(self.site, empty)
- testoattuale = ti_es_ti
for i in self.botolist:
if latest_user == i:
second_text = True
# A block to prevent the second message if the bot also welcomed users...
if latest_edit == history[-1]:
second_text = False
- else:
+ except wikipedia.IsRedirectPage:
+ wikipedia.output(u'The user talk is a redirect, trying to get the right talk...')
+ try:
+ self.talk_page = self.talk_page.getRedirectTarget()
+ testoattuale = self.talk_page.get()
+ except wikipedia.NoPage:
+ second_text = False
+ ti_es_ti = wikipedia.translate(self.site, empty)
+ testoattuale = ti_es_ti
+ except wikipedia.NoPage:
wikipedia.output(u'The user page is blank')
second_text = False
ti_es_ti = wikipedia.translate(self.site, empty)
@@ -944,7 +943,7 @@
try:
text_get = another_page.get()
except wikipedia.NoPage:
- text_get = str()
+ text_get = ''
except wikipedia.IsRedirectPage:
text_get = another_page.getRedirectTarget().get()
if len(text_get) >= self.logFulNumber:
@@ -1030,11 +1029,11 @@
#print template.exists()
template = wikipedia.Page(self.site, 'Template:%s' % license_selected)
try:
- template.get()
+ template.pageAPInfo()
except wikipedia.NoPage:
try:
template = wikipedia.Page(self.site, license_selected)
- template.get()
+ template.pageAPInfo()
except (wikipedia.NoPage, wikipedia.IsRedirectPage):
return None # break and exit
except wikipedia.IsRedirectPage:
Revision: 5980
Author: filnik
Date: 2008-10-16 13:02:32 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Bugfix: do not check in the <pre> or <nowiki> fields
Modified Paths:
--------------
trunk/pywikipedia/checkimages.py
Modified: trunk/pywikipedia/checkimages.py
===================================================================
--- trunk/pywikipedia/checkimages.py 2008-10-16 05:12:44 UTC (rev 5979)
+++ trunk/pywikipedia/checkimages.py 2008-10-16 13:02:32 UTC (rev 5980)
@@ -1391,6 +1391,10 @@
except wikipedia.IsRedirectPage:
wikipedia.output(u"The file description for %s is a redirect?!" % imageName)
continue
+ # Delete the fields where the templates cannot be loaded
+ regex_nowiki = re.compile(r'<nowiki>(.*?)</nowiki>', re.DOTALL)
+ regex_pre = re.compile(r'<pre>(.*?)</pre>', re.DOTALL)
+ g = regex_nowiki.sub('', g); g = regex_pre.sub('', g)
# Check on commons if there's already an image with the same name
if commonsActive == True:
response = mainClass.checkImageOnCommons()
Revision: 5979
Author: purodha
Date: 2008-10-16 05:12:44 +0000 (Thu, 16 Oct 2008)
Log Message:
-----------
Minimal description tweaking.
Modified Paths:
--------------
trunk/pywikipedia/interwiki.py
Modified: trunk/pywikipedia/interwiki.py
===================================================================
--- trunk/pywikipedia/interwiki.py 2008-10-16 04:59:55 UTC (rev 5978)
+++ trunk/pywikipedia/interwiki.py 2008-10-16 05:12:44 UTC (rev 5979)
@@ -149,10 +149,10 @@
These arguments specify in which way the bot should follow interwiki links:
- -noredirect do not follow redirects (note: without ending colon)
+ -noredirect do not follow redirects. (note: without ending colon)
-initialredirect work on target if a redirect is entered on the command
- line (note: without ending colon)
+ line. (note: without ending colon)
-neverlink: used as -neverlink:xx where xx is a language code:
Disregard any links found to language xx. You can also
@@ -173,7 +173,7 @@
-back only work on pages that have no backlink from any other
language; if a backlink is found, all work on the page
- will be halted.
+ will be halted. (note: without ending colon)
The following arguments are only important for users who have accounts for
multiple languages, and specify on which sites the bot should modify pages:
Feature Requests item #2170392, was opened at 2008-10-16 03:48
Message generated for change (Comment added) made by purodha
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2170392&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
Priority: 5
Private: No
Submitted By: Purodha B Blissenbach (purodha)
Assigned to: Nobody/Anonymous (nobody)
Summary: add -hint:latin to interwiki.py
Initial Comment:
interwiki.py already supports -hint:cyril so as to select all wikis of a familiy using the cyrillic script.
Adding -hint:latin only appears logical, an will be useful e.g. when dealing with proper names that
can most often be expected to be spellt alike in almost all languages using the Latin script.
----------------------------------------------------------------------
Comment By: Purodha B Blissenbach (purodha)
Date: 2008-10-16 03:50
Message:
This artifact has been marked as a duplicate of artifact 2168298 with
reason:
No explanation provided.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2170392&group_…
Feature Requests item #2170392, was opened at 2008-10-16 03:48
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2170392&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
Priority: 5
Private: No
Submitted By: Purodha B Blissenbach (purodha)
Assigned to: Nobody/Anonymous (nobody)
Summary: add -hint:latin to interwiki.py
Initial Comment:
interwiki.py already supports -hint:cyril so as to select all wikis of a familiy using the cyrillic script.
Adding -hint:latin only appears logical, an will be useful e.g. when dealing with proper names that
can most often be expected to be spellt alike in almost all languages using the Latin script.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2170392&group_…
Feature Requests item #2170330, was opened at 2008-10-16 03:20
Message generated for change (Comment added) made by purodha
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2170330&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
Priority: 5
Private: No
Submitted By: Purodha B Blissenbach (purodha)
Assigned to: Nobody/Anonymous (nobody)
Summary: add -hint:latin to interwiki.py
Initial Comment:
interwiki.py already supports -hint:cyril so as to select all wikis of a familiy using the cyrillic script.
Adding -hint:latin only appears logical, an will be useful e.g. when dealing with proper names that
can most often be expected to be spellt alike in almost all languages using the Latin script.
----------------------------------------------------------------------
Comment By: Purodha B Blissenbach (purodha)
Date: 2008-10-16 03:47
Message:
This artifact has been marked as a duplicate of artifact 2168298 with
reason:
No explanation provided.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603141&aid=2170330&group_…