http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11704
Revision: 11704
Author: siebrand
Date: 2013-06-30 17:01:59 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
Localisation updates from http://translatewiki.net.
Modified Paths:
--------------
branches/rewrite/scripts/i18n/weblinkchecker.py
Modified: branches/rewrite/scripts/i18n/weblinkchecker.py
===================================================================
--- branches/rewrite/scripts/i18n/weblinkchecker.py 2013-06-30 12:20:15 UTC (rev 11703)
+++ branches/rewrite/scripts/i18n/weblinkchecker.py 2013-06-30 17:01:59 UTC (rev 11704)
@@ -327,8 +327,10 @@
},
# Author: Dbc334
'sl': {
+ 'weblinkchecker-archive_msg': u'Spletno stran je shranil Internet Archive. Prosimo, razmislite o povezavi na ustrezno arhivirano različico: [%(URL)s].',
'weblinkchecker-caption': u'Mrtva povezava',
'weblinkchecker-summary': u'Robot: Poročanje o nedosegljivi zunanji povezavi',
+ 'weblinkchecker-report': u'Med več samodejnimi zaganjanji je bot ugotovil, da naslednja zunanja povezava ni na voljo. Prosimo, preverite, ali povezava zares ne deluje, in jo v tem primeru popravite ali odstranite.',
},
# Author: Rancher
'sr': {
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11703
Revision: 11703
Author: multichill
Date: 2013-06-30 12:20:15 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
Globe can be null like at https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q9831&format=js… . Than "data['globe']"==None so globes[data['globe']] will throw a Keyerror. Changed it to default to earth when it's null.
Modified Paths:
--------------
branches/rewrite/pywikibot/__init__.py
Modified: branches/rewrite/pywikibot/__init__.py
===================================================================
--- branches/rewrite/pywikibot/__init__.py 2013-06-30 02:03:30 UTC (rev 11702)
+++ branches/rewrite/pywikibot/__init__.py 2013-06-30 12:20:15 UTC (rev 11703)
@@ -164,9 +164,17 @@
for k in site.globes():
globes[site.globes()[k]] = k
+ globekey = data['globe']
+ if globekey:
+ # FIXME: Should probably use get() with some error handling when it's an unknown globe
+ globe = globes[data['globe']]
+ else:
+ # Default to earth or should we use None here?
+ globe = 'earth'
+
return Coordinate(data['latitude'], data['longitude'],
data['altitude'], data['precision'],
- globes[data['globe']], site=site)
+ globe, site=site)
@property
def precision(self):
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11702
Revision: 11702
Author: legoktm
Date: 2013-06-30 02:03:30 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
Update documentation, ItemPage.getSiteLink() returns a string
Modified Paths:
--------------
branches/rewrite/pywikibot/page.py
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2013-06-30 01:47:43 UTC (rev 11701)
+++ branches/rewrite/pywikibot/page.py 2013-06-30 02:03:30 UTC (rev 11702)
@@ -2510,7 +2510,7 @@
def getSitelink(self, site, force=False):
"""
- Returns a page object for the specific site
+ Returns the title (unicode string) for the specific site
site is a pywikibot.Site or database name
force will override caching
If the item doesn't have that language, raise NoPage
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11701
Revision: 11701
Author: legoktm
Date: 2013-06-30 01:47:43 +0000 (Sun, 30 Jun 2013)
Log Message:
-----------
Implement WikibasePage.__cmp__ with a unit test.
Modified Paths:
--------------
branches/rewrite/pywikibot/page.py
branches/rewrite/tests/page_tests.py
Modified: branches/rewrite/pywikibot/page.py
===================================================================
--- branches/rewrite/pywikibot/page.py 2013-06-29 09:14:29 UTC (rev 11700)
+++ branches/rewrite/pywikibot/page.py 2013-06-30 01:47:43 UTC (rev 11701)
@@ -2237,6 +2237,25 @@
self.repo = self.site
self._isredir = False # Wikibase pages cannot be a redirect
+ def __cmp__(self, other):
+ """Test for equality and inequality of WikibasePage objects.
+
+ Page objects are "equal" if and only if they are on the same site
+ and have the same normalized title, including section if any.
+
+ Page objects are sortable by namespace first, then by title.
+
+ This is basically the same as Page.__cmp__ but slightly different.
+ """
+ if not isinstance(other, Page):
+ # especially, return -1 if other is None
+ return -1
+ if self.site != other.site:
+ return cmp(self.site, other.site)
+ if self.namespace() != other.namespace():
+ return cmp(self.namespace(), other.namespace())
+ return cmp(self.title(), other.title())
+
def title(self, **kwargs):
if self.namespace() == 0:
self._link._text = self.getID()
Modified: branches/rewrite/tests/page_tests.py
===================================================================
--- branches/rewrite/tests/page_tests.py 2013-06-29 09:14:29 UTC (rev 11700)
+++ branches/rewrite/tests/page_tests.py 2013-06-30 01:47:43 UTC (rev 11701)
@@ -315,6 +315,9 @@
claim.setTarget(pywikibot.ItemPage(repo, 'q1'))
self.assertEqual(claim._formatDataValue(), {'entity-type': 'item', 'numeric-id': 1})
+ # test WikibasePage.__cmp__
+ self.assertEqual(pywikibot.ItemPage.fromPage(mainpage), pywikibot.ItemPage(repo, 'q5296'))
+
def testItemPageExtensionability(self):
class MyItemPage(pywikibot.ItemPage):
pass
http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11700
Revision: 11700
Author: legoktm
Date: 2013-06-29 09:14:29 +0000 (Sat, 29 Jun 2013)
Log Message:
-----------
Write a constructor to create Site objects from their dbname, only for some WMF sites.
Modified Paths:
--------------
branches/rewrite/pywikibot/site.py
branches/rewrite/tests/site_tests.py
Modified: branches/rewrite/pywikibot/site.py
===================================================================
--- branches/rewrite/pywikibot/site.py 2013-06-28 08:24:28 UTC (rev 11699)
+++ branches/rewrite/pywikibot/site.py 2013-06-29 09:14:29 UTC (rev 11700)
@@ -729,6 +729,24 @@
self._loginstatus = LoginStatus.NOT_ATTEMPTED
return
+ @staticmethod
+ def fromDBName(dbname):
+ # TODO this only works for some WMF sites
+ req = api.CachedRequest(datetime.timedelta(days=10),
+ site=pywikibot.Site('meta', 'meta'),
+ action='sitematrix')
+ data = req.submit()
+ for num in data['sitematrix']:
+ if num in ['specials', 'count']:
+ continue
+ lang = data['sitematrix'][num]['code']
+ for site in data['sitematrix'][num]['site']:
+ if site['dbname'] == dbname:
+ if site['code'] == 'wiki':
+ site['code'] = 'wikipedia'
+ return APISite(lang, site['code'])
+ raise ValueError("Cannot parse a site out of %s." % dbname)
+
def _generator(self, gen_class, type_arg=None, namespaces=None,
step=None, total=None, **args):
"""Convenience method that returns an API generator.
Modified: branches/rewrite/tests/site_tests.py
===================================================================
--- branches/rewrite/tests/site_tests.py 2013-06-28 08:24:28 UTC (rev 11699)
+++ branches/rewrite/tests/site_tests.py 2013-06-29 09:14:29 UTC (rev 11700)
@@ -66,6 +66,15 @@
"nosuchright"):
self.assertType(mysite.has_right(rgt), bool)
+ def testConstructors(self):
+ """Test cases for site constructors"""
+ self.assertEqual(pywikibot.site.APISite.fromDBName('enwiki'), pywikibot.Site('en', 'wikipedia'))
+ self.assertEqual(pywikibot.site.APISite.fromDBName('eswikisource'), pywikibot.Site('es', 'wikisource'))
+ self.assertEqual(pywikibot.site.APISite.fromDBName('dewikinews'), pywikibot.Site('de', 'wikinews'))
+ self.assertEqual(pywikibot.site.APISite.fromDBName('ukwikivoyage'), pywikibot.Site('uk', 'wikivoyage'))
+
+ self.assertRaises(ValueError, pywikibot.site.APISite.fromDBName, 'metawiki')
+
def testLanguageMethods(self):
"""Test cases for languages() and related methods"""