Hello all
I recognized an issue, when executing the following code:
print userlib.User(pywikibot.getSite(), u'º_the_Bench_º')
results in
Traceback (most recent call last):
File "tests/dtbext_tester.py", line 279, in <module>
print userlib.User(pywikibot.getSite(), u'º_the_Bench_º')
UnicodeEncodeError: 'ascii' codec can't encode character u'\xba' in
position 13: ordinal not in range(128)
The u'\xba' is assigned to u'º' which raises an UnicodeEncodeError.
By using the patch attached, which simply adds an
'.encode(self.site().encoding())' to the string produced the issues
is solved for me. And produces:
wikipedia:de:º_the_Bench_º
May be the 'self.site().encoding()' should or has to be replaced by
another var or const. But the encoding to something like 'utf8' is
essential as statet in [1].
Thanks a lot and greetings
DrTrigon
[1] http://wiki.python.org/moin/UnicodeEncodeError
Hi,
I started a new wiki on wikia.com. I created a family file for it (luckily,
I found wowwiki_family, which colud be copied and modified), and made a
successful edit while commented out my Wikipedia usernames in
user-config.py.
Now, the question is, how can I use these two together? One day I would like
to edit Wikipedia, and on the other day my wikia wiki. So, how can I tell
the bot, which wiki to work on? (lang is 'hu' on both, the family is
different)
--
Bináris
Hello all
Is it ok, that page.getVersionHistory without a previous page.get is
not able to correctly resolve NoPage (and may be other). Example is the
page 'Wikipedia Diskussion:WikiProjekt
Portale/Baustelle/Portal:Biochemie' which throws the python error:
Traceback (most recent call last):
File "tests/dtbext_tester.py", line 240, in <module>
TEST_get()
File "tests/dtbext_tester.py", line 226, in TEST_get
page.getVersionHistory()
File "./wikipedia.py", line 2576, in getVersionHistory
dataQuery.extend(self._getVersionHistory(getAll, skip,
reverseOrder, revCount))
File "./wikipedia.py", line 2627, in _getVersionHistory
for r in result['query']['pages'].values()[0]['revisions']:
KeyError: 'revisions'
So it seams that getVersionHistory and _getVersionHistory do not resolve
and throw the needed exceptions.
Greetings
DrTrigon
Hello all!
The family 'wiki' is listed as known and gets returned by
'get_known_families', but yield a ValueError... Also the
file in families/ is missing. What does happen here? Bug?
Greetings
DrTrigon
Thanks a lot!
Am 15.09.2010 13:32, schrieb xqt(a)svn.wikimedia.org:
> Revision: 8561
> Author: xqt
> Date: 2010-09-15 11:32:15 +0000 (Wed, 15 Sep 2010)
>
> Log Message:
> -----------
> expandtemplates parameter for Page.get() - Fully resolve templates within page content submitted by DrTrogom. Thanks.
>
> Modified Paths:
> --------------
> trunk/pywikipedia/wikipedia.py
>
> Modified: trunk/pywikipedia/wikipedia.py
> ===================================================================
> --- trunk/pywikipedia/wikipedia.py 2010-09-15 10:11:05 UTC (rev 8560)
> +++ trunk/pywikipedia/wikipedia.py 2010-09-15 11:32:15 UTC (rev 8561)
> @@ -585,7 +585,7 @@
> return self.autoFormat()[0] is not None
>
> def get(self, force=False, get_redirect=False, throttle=True,
> - sysop=False, change_edit_time=True):
> + sysop=False, change_edit_time=True, expandtemplates=False):
> """Return the wiki-text of the page.
>
> This will retrieve the page from the server if it has not been
> @@ -604,6 +604,8 @@
> If change_edit_time is False, do not check this version for changes
> before saving. This should be used only if the page has been loaded
> previously.
> + If expandtemplates is True, all templates in the page content are
> + fully resolved too (if API is used).
>
> """
> # NOTE: The following few NoPage exceptions could already be thrown at
> @@ -622,7 +624,7 @@
> if self.site().isInterwikiLink(self.title()):
> raise NoPage('%s is not a local page on %s!'
> % (self.aslink(), self.site()))
> - if force:
> + if force or expandtemplates:
> # When forcing, we retry the page no matter what. Old exceptions
> # and contents do not apply any more.
> for attr in ['_redirarg', '_getexception', '_contents']:
> @@ -640,7 +642,8 @@
> # Make sure we did try to get the contents once
> if not hasattr(self, '_contents'):
> try:
> - self._contents = self._getEditPage(get_redirect = get_redirect, throttle = throttle, sysop = sysop)
> + self._contents = self._getEditPage(get_redirect=get_redirect, throttle=throttle, sysop=sysop,
> + expandtemplates = expandtemplates)
> hn = self.section()
> if hn:
> m = re.search("=+ *%s *=+" % hn, self._contents)
> @@ -669,7 +672,7 @@
> return self._contents
>
> def _getEditPage(self, get_redirect=False, throttle=True, sysop=False,
> - oldid=None, change_edit_time=True):
> + oldid=None, change_edit_time=True, expandtemplates=False):
> """Get the contents of the Page via API query
>
> Do not use this directly, use get() instead.
> @@ -677,6 +680,8 @@
> Arguments:
> oldid - Retrieve an old revision (by id), not the current one
> get_redirect - Get the contents, even if it is a redirect page
> + expandtemplates - Fully resolve templates within page content
> + (if API is used)
>
> This method returns the raw wiki text as a unicode string.
> """
> @@ -694,6 +699,8 @@
> }
> if oldid:
> params['rvstartid'] = oldid
> + if expandtemplates:
> + params[u'rvexpandtemplates'] = u''
>
> if throttle:
> get_throttle()
>
>
>
> _______________________________________________
> Pywikipedia-svn mailing list
> Pywikipedia-svn(a)lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn
Hello all!
I wondered why is in userlib.user.contributions() no message
output when accessing the wiki? This way such accesses are
completely silent...
Greetings