http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10379
Revision: 10379 Author: xqt Date: 2012-06-19 15:27:44 +0000 (Tue, 19 Jun 2012) Log Message: ----------- InvalidTitle error needed for cosmetic_changes.cleanUpLinks()
Modified Paths: -------------- branches/rewrite/pywikibot/exceptions.py branches/rewrite/pywikibot/page.py
Modified: branches/rewrite/pywikibot/exceptions.py =================================================================== --- branches/rewrite/pywikibot/exceptions.py 2012-06-19 13:59:34 UTC (rev 10378) +++ branches/rewrite/pywikibot/exceptions.py 2012-06-19 15:27:44 UTC (rev 10379) @@ -75,6 +75,9 @@
"""
+class InvalidTitle(Error): + """Invalid page title""" + class LockedPage(PageRelatedError): """Page is locked""" message = u"Page %s is locked."
Modified: branches/rewrite/pywikibot/page.py =================================================================== --- branches/rewrite/pywikibot/page.py 2012-06-19 13:59:34 UTC (rev 10378) +++ branches/rewrite/pywikibot/page.py 2012-06-19 15:27:44 UTC (rev 10379) @@ -2376,8 +2376,8 @@ # Reject illegal characters. m = Link.illegal_titles_pattern.search(t) if m: - raise pywikibot.Error( - u"Invalid title: contains illegal char(s) '%s'" % m.group(0)) + raise pywikibot.InvalidTitle( + u"contains illegal char(s) '%s'" % m.group(0))
# Pages with "/./" or "/../" appearing in the URLs will # often be unreachable due to the way web browsers deal @@ -2392,16 +2392,16 @@ or t.endswith(u"/.") or t.endswith(u"/..") ): - raise pywikibot.Error( - "Invalid title (contains . / combinations): '%s'" + raise pywikibot.InvalidTitle( + "(contains . / combinations): '%s'" % self._text)
# Magic tilde sequences? Nu-uh! if u"~~~" in t: - raise pywikibot.Error("Invalid title (contains ~~~): '%s'" % self._text) + raise pywikibot.InvalidTitle("(contains ~~~): '%s'" % self._text)
if self._namespace != -1 and len(t) > 255: - raise pywikibot.Error("Invalid title (over 255 bytes): '%s'" % t) + raise pywikibot.InvalidTitle("(over 255 bytes): '%s'" % t)
if self._site.case() == 'first-letter': t = t[:1].upper() + t[1:]
pywikipedia-svn@lists.wikimedia.org