Bugs item #1905228, was opened at 2008-03-01 11:38
Message generated for change (Comment added) made by nicdumz
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=190522…
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: Alex S.H. Lin (lin4h)
Assigned to: Nobody/Anonymous (nobody)
Summary: ValueError in category.py
Initial Comment:
category.py tidy
Target Category is [[zh:Category:日本天皇]].When the script reading the article [[大友皇子即位論]],
it rollback this error:
Treating page 大友皇子即位論, currently in Category:日本天皇
Dumping to category.dump.bz2, please wait...
Traceback (most recent call last):
File "D:\My Documents\SOURCE\mwbot\pywikipedia\category.py", line 896, in
<mod
ule>
bot.run()
File "D:\My Documents\SOURCE\mwbot\pywikipedia\category.py", line 697, in run
self.move_to_category(article, cat, cat)
File "D:\My Documents\SOURCE\mwbot\pywikipedia\category.py", line 601, in
move
_to_category
contextLength = full_text.index('\n\n', contextLength+2)
ValueError: substring not found
----------------------------------------------------------------------
Comment By: NicDumZ — Nicolas Dumazet (nicdumz)
Date: 2008-03-01 15:41
Message:
Logged In: YES
user_id=1963242
Originator: NO
Index: category.py
===================================================================
--- category.py (révision 5095)
+++ category.py (copie de travail)
@@ -595,7 +595,7 @@
contextLength = 500
if full_text.startswith(u'[['): # probably an image
# Add extra paragraph.
- contextLength = full_text.index('\n\n', contextLength+2)
+ contextLength = full_text.find('\n\n', contextLength+2)
if contextLength > 1000 or contextLength < 0:
contextLength = 500
print
Simply replacing "index()" by find() line 601 (597 in trunk) will do :
If the substring is not found, then contextLength will be -1 ; and will
get defaulted to 500 on the next line
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=603138&aid=190522…