[Pywikipedia-l] SVN: [5457] trunk/pywikipedia
nicdumz at svn.wikimedia.org
nicdumz at svn.wikimedia.org
Wed May 28 21:22:03 UTC 2008
Revision: 5457
Author: nicdumz
Date: 2008-05-28 21:22:02 +0000 (Wed, 28 May 2008)
Log Message:
-----------
* Regex fix for getFileVersionHistory when there's no comment
* Use getFileVersionHistory when there's no API
Modified Paths:
--------------
trunk/pywikipedia/imagecopy.py
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/imagecopy.py
===================================================================
--- trunk/pywikipedia/imagecopy.py 2008-05-28 20:32:28 UTC (rev 5456)
+++ trunk/pywikipedia/imagecopy.py 2008-05-28 21:22:02 UTC (rev 5457)
@@ -303,7 +303,11 @@
skip = True
else:
# The first upload is last in the list.
- username = imagepage.getLatestUploader()
+ try:
+ username = imagepage.getLatestUploader()
+ except NotImplementedError:
+ #No API, using the page file instead
+ (datetime, username, resolution, size, comment) = imagepage.getFileVersionHistory().pop()
while True:
# Do the Tkdialog to accept/reject and change te name
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2008-05-28 20:32:28 UTC (rev 5456)
+++ trunk/pywikipedia/wikipedia.py 2008-05-28 21:22:02 UTC (rev 5457)
@@ -2587,7 +2587,7 @@
result = []
history = re.search('(?s)<table class="filehistory">.+?</table>', self.getImagePageHtml())
if history:
- lineR = re.compile(r'<tr>(?:<td>.*?</td>){1,2}<td.*?><a href=".+?">(?P<datetime>.+?)</a></td><td>(?P<resolution>.*?) <span.*?>\((?P<filesize>.+?)\)</span></td><td><a href=".+?"(?: class="new"|) title=".+?">(?P<username>.+?)</a>.*?</td><td>.*?<span class="comment">\((?P<comment>.*?)\)</span></td></tr>')
+ lineR = re.compile(r'<tr>(?:<td>.*?</td>){1,2}<td.*?><a href=".+?">(?P<datetime>.+?)</a></td><td>(?P<resolution>.*?) <span.*?>\((?P<filesize>.+?)\)</span></td><td><a href=".+?"(?: class="new"|) title=".+?">(?P<username>.+?)</a>.*?</td><td>(?:.*?<span class="comment">\((?P<comment>.*?)\)</span>)?</td></tr>')
if not lineR.search(history.group()):
# b/c code
lineR = re.compile(r'<tr>(?:<td>.*?</td>){1,2}<td><a href=".+?">(?P<datetime>.+?)</a></td><td><a href=".+?"(?: class="new"|) title=".+?">(?P<username>.+?)</a>.*?</td><td>(?P<resolution>.*?)</td><td class=".+?">(?P<filesize>.+?)</td><td>(?P<comment>.*?)</td></tr>')
More information about the Pywikipedia-l
mailing list