http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10397
Revision: 10397
Author: xqt
Date: 2012-06-20 22:41:21 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
fix blocker from unexprected keyword site; update from trunk
Modified Paths:
--------------
branches/rewrite/pywikibot/titletranslate.py
Modified: branches/rewrite/pywikibot/titletranslate.py
===================================================================
--- branches/rewrite/pywikibot/titletranslate.py 2012-06-20 22:37:58 UTC (rev 10396)
+++ branches/rewrite/pywikibot/titletranslate.py 2012-06-20 22:41:21 UTC (rev 10397)
@@ -13,14 +13,25 @@
import pywikibot
import pywikibot.date as date
-def translate(page, hints = None, auto = True, removebrackets = False):
+def translate(page, hints=None, auto=True, removebrackets=False, site=None, family=None):
"""
- Please comment your source code! --Daniel
+ Goes through all entries in 'hints'. Returns a list of pages.
- Does some magic stuff. Returns a list of Links.
+ Entries for single page titles list those pages. Page titles for entries
+ such as "all:" or "xyz:" or "20:" are first built from the page title of
+ 'page' and then listed. When 'removebrackets' is True, a trailing pair of
+ brackets and the text between them is removed from the page title.
+ If 'auto' is true, known year and date page titles are autotranslated
+ to all known target languages and inserted into the list.
+
"""
result = []
- site = page.site
+ if site is None and page:
+ site = page.site
+ if family is None and site:
+ family = site.family
+ if site:
+ sitelang = site.language()
if hints:
for h in hints:
if ':' not in h:
@@ -33,9 +44,11 @@
# if given as -hint:xy or -hint:xy:, assume that there should
# be a page in language xy with the same title as the page
# we're currently working on ...
+ if page is None:
+ continue
ns = page.namespace()
if ns:
- newname = u'%s:%s' % (site.family.namespace('_default', ns),
+ newname = u'%s:%s' % (family.namespace('_default', ns),
page.title(withNamespace=False))
else:
# article in the main namespace
@@ -66,7 +79,7 @@
# Autotranslate dates into all other languages, the rest will come from
# existing interwiki links.
- if auto:
+ if auto and page:
# search inside all dictionaries for this link
dictName, value = date.getAutoFormat(page.site.code,
page.title())
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10396
Revision: 10396
Author: xqt
Date: 2012-06-20 22:37:58 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
fix identation error, replace site() method with site property
Modified Paths:
--------------
trunk/pywikipedia/titletranslate.py
Modified: trunk/pywikipedia/titletranslate.py
===================================================================
--- trunk/pywikipedia/titletranslate.py 2012-06-20 22:19:15 UTC (rev 10395)
+++ trunk/pywikipedia/titletranslate.py 2012-06-20 22:37:58 UTC (rev 10396)
@@ -18,7 +18,7 @@
if x not in result:
result.append(x)
-def translate(page, hints = None, auto = True, removebrackets = False, site = None, family = None):
+def translate(page, hints=None, auto=True, removebrackets=False, site=None, family=None):
"""
Goes through all entries in 'hints'. Returns a list of pages.
@@ -32,11 +32,11 @@
"""
result = []
if site is None and page:
- site = page.site()
+ site = page.site
if family is None and site:
- family = site.family
+ family = site.family
if site:
- sitelang = site.language()
+ sitelang = site.language()
if hints:
for h in hints:
if ':' not in h:
@@ -135,7 +135,7 @@
"""
result = []
pywikibot.output(u'getting poisoned links for %s' % pl.title())
- dictName, value = date.getAutoFormat(pl.site().language(), pl.title())
+ dictName, value = date.getAutoFormat(pl.site.language(), pl.title())
if dictName is not None:
pywikibot.output( u'date found in %s' % dictName )
# errors in year BC
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10393
Revision: 10393
Author: russblau
Date: 2012-06-20 20:33:57 +0000 (Wed, 20 Jun 2012)
Log Message:
-----------
Make sure to log in as correct user; this facilitates use of the bot with multiple user accounts.
Modified Paths:
--------------
branches/rewrite/pywikibot/site.py
Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py 2012-06-20 19:45:46 UTC (rev 10392)
+++ branches/rewrite/pywikibot/site.py 2012-06-20 20:33:57 UTC (rev 10393)
@@ -713,7 +713,7 @@
self._loginstatus = LoginStatus.IN_PROGRESS
if not hasattr(self, "_userinfo"):
self.getuserinfo()
- if self.logged_in(sysop):
+ if self.userinfo['name'] == self._username[sysop] and self.logged_in(sysop):
return
loginMan = api.LoginManager(site=self, sysop=sysop,
user=self._username[sysop])