http://www.mediawiki.org/wiki/Special:Code/pywikipedia/11597
Revision: 11597 Author: amir Date: 2013-05-30 12:57:34 +0000 (Thu, 30 May 2013) Log Message: ----------- adding option of data_type=date for creating claims
Modified Paths: -------------- trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2013-05-30 07:43:34 UTC (rev 11596) +++ trunk/pywikipedia/wikipedia.py 2013-05-30 12:57:34 UTC (rev 11597) @@ -4279,7 +4279,7 @@ return 302, response.msg, data['success'] return response.code, response.msg, data
- def editclaim(self, WDproperty, value,raw_value=False, refs=None, + def editclaim(self, WDproperty, value, data_type=None, raw_value=False, refs=None, comment=None, token=None, sysop=False, botflag=True): if isinstance(WDproperty, int): propertyID = WDproperty @@ -4300,7 +4300,7 @@ pass else: raise RuntimeError("Unknown property type: %s" % WDproperty) - if not raw_value: + if not raw_value and not data_type=="time": if isinstance(value, int): # for 'quantity' entity-type value = "{"entity-type":"item","numeric-id":%s}" % value elif isinstance(value, unicode): # for 'string' entity-type @@ -4323,6 +4323,9 @@ else: raise RuntimeError("Unknown property type: %s" % value) value = "{"entity-type":"item","numeric-id":%s}" % value + elif data_type=="time": + value="{"time":"%s","timezone":0,"before":0,"after":0,"precision":11,"calendarmodel":"http://www.wikidata.org/entity/Q1985727%5C%22%7D" % value + #about calendarmodel see https://bugzilla.wikimedia.org/show_bug.cgi?id=48965 else: pass claims = self.get()['claims']
pywikipedia-svn@lists.wikimedia.org