|
@@ -10,17 +10,17 @@ languages = {'de', 'en', 'es', 'fr', 'hu', 'it', 'nl', 'jp'}
|
10
|
10
|
|
11
|
11
|
url_template = 'https://www.wikidata.org/w/api.php?action=wbgetentities&format=json&{query}&props=labels%7Cdatatype%7Cclaims%7Caliases&languages=' + '|'.join(languages)
|
12
|
12
|
url_wmflabs_template = 'http://wdq.wmflabs.org/api?q='
|
13
|
|
-url_wikidata_search_template='http://www.wikidata.org/w/api.php?action=query&list=search&format=json&srnamespace=0&srprop=sectiontitle&{query}'
|
|
13
|
+url_wikidata_search_template = 'http://www.wikidata.org/w/api.php?action=query&list=search&format=json&srnamespace=0&srprop=sectiontitle&{query}'
|
14
|
14
|
|
15
|
15
|
wmflabs_queries = [
|
16
|
|
- 'CLAIM[31:8142]', # all devise
|
|
16
|
+ 'CLAIM[31:8142]', # all devise
|
17
|
17
|
]
|
18
|
18
|
|
19
|
19
|
db = {
|
20
|
|
- 'iso4217' : {
|
21
|
|
- },
|
22
|
|
- 'names' : {
|
23
|
|
- }
|
|
20
|
+ 'iso4217': {
|
|
21
|
+ },
|
|
22
|
+ 'names': {
|
|
23
|
+ }
|
24
|
24
|
}
|
25
|
25
|
|
26
|
26
|
|
|
@@ -29,7 +29,7 @@ def remove_accents(data):
|
29
|
29
|
|
30
|
30
|
|
31
|
31
|
def normalize_name(name):
|
32
|
|
- return re.sub(' +',' ', remove_accents(name.lower()).replace('-', ' '))
|
|
32
|
+ return re.sub(' +', ' ', remove_accents(name.lower()).replace('-', ' '))
|
33
|
33
|
|
34
|
34
|
|
35
|
35
|
def add_currency_name(name, iso4217):
|
|
@@ -51,7 +51,7 @@ def add_currency_name(name, iso4217):
|
51
|
51
|
if iso4217_set is not None and iso4217 not in iso4217_set:
|
52
|
52
|
db_names[name].append(iso4217)
|
53
|
53
|
else:
|
54
|
|
- db_names[name] = [ iso4217 ]
|
|
54
|
+ db_names[name] = [iso4217]
|
55
|
55
|
|
56
|
56
|
|
57
|
57
|
def add_currency_label(label, iso4217, language):
|
|
@@ -96,7 +96,7 @@ def parse_currency(data):
|
96
|
96
|
|
97
|
97
|
|
98
|
98
|
def fetch_data(wikidata_ids):
|
99
|
|
- url = url_template.format(query=urlencode({'ids' : '|'.join(wikidata_ids)}))
|
|
99
|
+ url = url_template.format(query=urlencode({'ids': '|'.join(wikidata_ids)}))
|
100
|
100
|
htmlresponse = get(url)
|
101
|
101
|
jsonresponse = json.loads(htmlresponse.content)
|
102
|
102
|
entities = jsonresponse.get('entities', {})
|