http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9491
Revision: 9491 Author: xqt Date: 2011-09-03 10:48:13 +0000 (Sat, 03 Sep 2011) Log Message: ----------- update string asignement from rewrite; faster string formatting
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2011-09-03 10:33:51 UTC (rev 9490) +++ trunk/pywikipedia/wikipedia.py 2011-09-03 10:48:13 UTC (rev 9491) @@ -384,12 +384,13 @@ if self._namespace == 14: raise InvalidTitle(u"Invalid section in category '%s'" % t) else: - self._section = t[sectionStart+1 : ].lstrip(" ") + t, sec = t.split(u'#', 1) + self._section = sec.lstrip() self._section = sectionencode(self._section, self._site.encoding()) if not self._section: self._section = None - t = t[ : sectionStart].rstrip(" ") + t = t.rstrip() elif sectionStart == 0: raise InvalidTitle(u"Invalid title starting with a #: '%s'" % t) else: @@ -401,7 +402,7 @@
# reassemble the title from its parts if self._namespace != 0: - t = self._site.namespace(self._namespace) + u':' + t + t = u'%s:%s' % (self._site.namespace(self._namespace), t) if self._section: t += u'#' + self._section
@@ -457,7 +458,6 @@
If underscore is True, replace all ' ' characters with '_'. If savetitle is True, encode any wiki syntax in the title. - If decode is True, decodes the section title """ title = self._title if asLink:
pywikipedia-svn@lists.wikimedia.org