http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11431
Revision: 11431
Author: legoktm
Date: 2013-04-22 10:21:37 +0000 (Mon, 22 Apr 2013)
Log Message:
-----------
Add "imported from" source using a hardcoded list of items
Modified Paths:
--------------
branches/rewrite/scripts/claimit.py
Modified: branches/rewrite/scripts/claimit.py
===================================================================
--- branches/rewrite/scripts/claimit.py 2013-04-22 09:52:39 UTC (rev 11430)
+++ branches/rewrite/scripts/claimit.py 2013-04-22 10:21:37 UTC (rev 11431)
@@ -17,7 +17,30 @@
from pywikibot import pagegenerators
repo = pywikibot.Site().data_repository()
+source_values = {'en': pywikibot.ItemPage(repo, 'Q328'),
+ 'sv': pywikibot.ItemPage(repo, 'Q169514'),
+ 'de': pywikibot.ItemPage(repo, 'Q48183'),
+ 'it': pywikibot.ItemPage(repo, 'Q11920'),
+ 'no': pywikibot.ItemPage(repo, 'Q191769'),
+ 'ar': pywikibot.ItemPage(repo, 'Q199700'),
+ 'es': pywikibot.ItemPage(repo, 'Q8449'),
+ 'pl': pywikibot.ItemPage(repo, 'Q1551807'),
+ 'ca': pywikibot.ItemPage(repo, 'Q199693'),
+ 'fr': pywikibot.ItemPage(repo, 'Q8447'),
+ 'nl': pywikibot.ItemPage(repo, 'Q10000'),
+ 'pt': pywikibot.ItemPage(repo, 'Q11921'),
+ 'ru': pywikibot.ItemPage(repo, 'Q206855'),
+ 'vi': pywikibot.ItemPage(repo, 'Q200180'),
+ 'be': pywikibot.ItemPage(repo, 'Q877583'),
+ 'uk': pywikibot.ItemPage(repo, 'Q199698'),
+ 'tr': pywikibot.ItemPage(repo, 'Q58255'),
+ } # TODO: This should include all projects
+imported_from = pywikibot.Claim(repo, 'p143')
+source = source_values.get(pywikibot.Site().language(), None)
+if source:
+ imported_from.setTarget(source)
+
def addClaims(page, claims):
'''
The function will add the claims to the wikibase page
@@ -36,7 +59,8 @@
else:
pywikibot.output('Adding %s --> %s' % (claim.getID(),
claim.getTarget().getID()))
item.addClaim(claim)
- #TODO FIXME: We should add a source for each claim that is added
+ if source:
+ claim.addSource(imported_from, bot=True)
#TODO FIXME: We need to check that we aren't adding a duplicate
_______________________________________________
Pywikipedia-svn mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikipedia-svn