Skip to content

Commit fad427b

Browse files
committed
datatype -> type
1 parent de6912a commit fad427b

2 files changed

Lines changed: 11 additions & 10 deletions

File tree

wikidataintegrator/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import wikidataintegrator.wdi_helpers
66
import wikidataintegrator.wdi_login
77
import wikidataintegrator.sdc_core
8+
import wikidataintegrator.wdi_rdf
89

910
try:
1011
__version__ = pkg_resources.get_distribution("wikidataintegrator").version

wikidataintegrator/sdc_core.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ def execute_sparql_query(query, prefix=None, endpoint=None, user_agent=None, as_
144144
def _sparql_query_result_to_df(results):
145145

146146
def parse_value(item):
147-
if item.get("datatype") == "http://www.w3.org/2001/XMLSchema#decimal":
147+
if item.get("type") == "http://www.w3.org/2001/XMLSchema#decimal":
148148
return float(item['value'])
149-
if item.get("datatype") == "http://www.w3.org/2001/XMLSchema#integer":
149+
if item.get("type") == "http://www.w3.org/2001/XMLSchema#integer":
150150
return int(item['value'])
151-
if item.get("datatype") == "http://www.w3.org/2001/XMLSchema#dateTime":
151+
if item.get("type") == "http://www.w3.org/2001/XMLSchema#dateTime":
152152
return datetime.datetime.strptime(item['value'], '%Y-%m-%dT%H:%M:%SZ')
153153
return item['value']
154154

@@ -617,7 +617,7 @@ def parse_wd_json(self, wd_json):
617617
self.statements = []
618618
for prop in wd_data['statements']:
619619
for z in wd_data['statements'][prop]:
620-
data_type = [x for x in WDBaseDataType.__subclasses__() if x.DTYPE == z['mainsnak']['datatype']][0]
620+
data_type = [x for x in WDBaseDataType.__subclasses__() if x.DTYPE == z['mainsnak']['type']][0]
621621
statement = data_type.from_json(z)
622622
self.statements.append(statement)
623623

@@ -1267,7 +1267,7 @@ def write(self, login, bot_account=True, edit_summary='', entity_type='item', pr
12671267
return self.wd_item_id
12681268

12691269
if entity_type == 'property':
1270-
self.wd_json_representation['datatype'] = property_datatype
1270+
self.wd_json_representation['type'] = property_datatype
12711271
if 'sitelinks' in self.wd_json_representation:
12721272
del self.wd_json_representation['sitelinks']
12731273

@@ -1607,11 +1607,11 @@ def execute_sparql_query(query, prefix=None, endpoint=None,
16071607
def _sparql_query_result_to_df(results):
16081608

16091609
def parse_value(item):
1610-
if item.get("datatype") == "http://www.w3.org/2001/XMLSchema#decimal":
1610+
if item.get("type") == "http://www.w3.org/2001/XMLSchema#decimal":
16111611
return float(item['value'])
1612-
if item.get("datatype") == "http://www.w3.org/2001/XMLSchema#integer":
1612+
if item.get("type") == "http://www.w3.org/2001/XMLSchema#integer":
16131613
return int(item['value'])
1614-
if item.get("datatype") == "http://www.w3.org/2001/XMLSchema#dateTime":
1614+
if item.get("type") == "http://www.w3.org/2001/XMLSchema#dateTime":
16151615
return datetime.datetime.strptime(item['value'], '%Y-%m-%dT%H:%M:%SZ')
16161616
return item['value']
16171617

@@ -1911,7 +1911,7 @@ def __call__(self, *args):
19111911
return self.get_class_representation(jsn=self.json_representation)
19121912

19131913
def get_class_representation(self, jsn):
1914-
data_type = [x for x in WDBaseDataType.__subclasses__() if x.DTYPE == jsn['datatype']][0]
1914+
data_type = [x for x in WDBaseDataType.__subclasses__() if x.DTYPE == jsn['type']][0]
19151915
self.final = True
19161916
self.current_type = data_type
19171917
return data_type.from_json(jsn)
@@ -2009,7 +2009,7 @@ def __init__(self, value, snak_type, data_type, is_reference, is_qualifier, refe
20092009
"snaktype": self.snak_type,
20102010
"property": self.prop_nr,
20112011
"datavalue": {},
2012-
"datatype": self.data_type
2012+
"type": self.data_type
20132013
}
20142014

20152015
self.snak_types = ['value', 'novalue', 'somevalue']

0 commit comments

Comments
 (0)