Skip to content

Commit ed9dfae

Browse files
Merge branch 'develop'
2 parents 3fddce9 + adab8db commit ed9dfae

File tree

7 files changed

+163
-157
lines changed

7 files changed

+163
-157
lines changed

controlled_vocabulary/management/commands/vocab.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ def handle(self, *args, **options):
6868
action_method = getattr(self, "action_" + action, None)
6969
if action_method:
7070
show_help = False
71-
action_method()
71+
res = action_method()
72+
if res not in [None, True]:
73+
import sys
74+
sys.exit(1)
7275

7376
if show_help:
7477
self.stdout.write(self.help)
@@ -107,25 +110,37 @@ def action_managers(self):
107110
def action_update(self):
108111
vocs = self.app.write_vocabulary_records_from_managers()
109112
if self.options["verbosity"] > 0:
110-
for voc in vocs.values():
111-
self.stdout.write(voc.__module__)
113+
if vocs:
114+
for voc in vocs.values():
115+
self.stdout.write(voc.__module__)
116+
else:
117+
self.stdout.write('Please run django migrate.')
112118

113119
def action_refetch(self):
114-
self.action_fetch(True)
120+
return self.action_fetch(True)
115121

116122
def action_fetch(self, overwrite=False):
123+
ret = True
124+
117125
for voc in self._get_vocabularies():
118126
download_method = getattr(voc, "download", None)
119127
if download_method:
120128
if self.options["verbosity"] > 0:
121129
self.stdout.write(voc.prefix)
122130
url, filepath, size, downloaded = download_method(overwrite=overwrite)
123131
if self.options["verbosity"] > 0:
124-
self.stdout.write(
125-
"\t{}\n\t{}\n\t{:.3f}MB".format(
126-
url, filepath, size / 1024 / 1024
132+
if size > 0:
133+
self.stdout.write(
134+
"\t{}\n\t{}\n\t{:.3f}MB".format(
135+
url, filepath, size / 1024 / 1024
136+
)
127137
)
128-
)
138+
else:
139+
self.stdout.write(f"ERROR: vocabulary download failed {url}.")
140+
if size < 1:
141+
ret = False
142+
143+
return ret
129144

130145
def action_init(self):
131146
self.action_update()

controlled_vocabulary/vocabularies/fast_topic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
from .base_http import VocabularyHTTP
21
import re
32

3+
from .base_http import VocabularyHTTP
4+
45

56
class VocabularyFastTopic(VocabularyHTTP):
67
# https://www.oclc.org/developer/develop/web-services/fast-api/linked-data.en.html
@@ -12,7 +13,7 @@ class VocabularyFastTopic(VocabularyHTTP):
1213
description = "Topic list from the Faceted Application of Subject Terminology"
1314
source = {
1415
# 'url': 'http://fast.oclc.org/searchfast/fastsuggest?query={query}&fl=suggest50&rows=10',
15-
"url": "https://fast.oclc.org/searchfast/fastsuggest?&query={pattern}&queryIndex=suggest50&queryReturn=suggest50,id&sort=usage desc&suggest=fastSuggest",
16+
"url": "https://fast.oclc.org/searchfast/fastsuggest?&query={pattern}&queryIndex=suggest50&queryReturn=suggest50,id&sort=usage desc&suggest=fastSuggest&rows=20",
1617
# https://www.oclc.org/research/themes/data-science/fast/download.html
1718
# 'url': 'https://researchworks.oclc.org/researchdata/fast/FASTTopical.nt.zip',
1819
}
@@ -30,5 +31,4 @@ def parse_search_response(self, res):
3031

3132
for doc in res["response"]["docs"]:
3233
ret.append([self._get_clean_id(doc["id"]), doc["suggest50"]])
33-
3434
return ret

controlled_vocabulary/vocabularies/iso15924.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ class VocabularyISO15924(VocabularyBaseCSV):
1212
concept = "wikidata:Q8192:writing system"
1313
description = "Codes for the Representation of names of scripts"
1414
source = {
15-
"url": "https://www.unicode.org/iso15924/iso15924.txt.zip",
16-
"extract": "iso15924-utf8-*.txt",
15+
"url": "https://www.unicode.org/iso15924/iso15924.txt",
1716
"processed": "iso15924-utf8.txt",
1817
'delimiter': ';',
1918
}

0 commit comments

Comments
 (0)