This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp_additions_vocab.py
69 lines (54 loc) · 2.25 KB
/
app_additions_vocab.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# ROUTE one vocab
# @app.route("/collection/<string:vocab_id>/<int:vocab_version>/")
# def vocabuary_version(vocab_id, vocab_version):
# vocab_uri = None
# for v in g.VOCABS.keys():
# if vocab_id in v:
# vocab_uri = v
#
# return return_vocab2(vocab_uri, None)
@app.route("/collection/<string:vocab_id>/current/")
@app.route("/collection/<string:vocab_id>/current/<string:acc_dep>/")
def vocabulary(vocab_id, acc_dep=None):
if acc_dep is not None:
if acc_dep not in ["accepted", "deprecated", "all"]:
return concept(vocab_id, acc_dep)
def vocab_id_uri_list():
return [(k.split("/")[-3], k) for k, v in g.VOCABS.items() if v.collections == "Collection"]
vocab_uri = None
for v in g.VOCABS.keys():
if vocab_id in v:
vocab_uri = v
if vocab_uri is None:
return render_template("vocabulary_404.html", id=vocab_id), 404
return return_vocab2(vocab_uri, acc_dep)
@app.route("/scheme/<string:vocab_id>/current/")
@app.route("/scheme/<string:vocab_id>/current/<string:acc_dep>/")
def scheme(vocab_id, acc_dep=None):
def vocab_id_uri_list():
return [(k.split("/")[-3], k) for k, v in g.VOCABS.items() if v.collections == "Collection"]
vocab_uri = None
for v in g.VOCABS.keys():
if vocab_id in v:
vocab_uri = v
if vocab_uri is None:
return return_vocprez_error(
"vocab_id not valid",
400,
markdown.markdown(
"The 'vocab_id' you supplied could not be translated to a valid vocab's URI. Valid vocab_ids are:\n\n"
"{}".format("".join(["* [{}]({}) \n".format(x[0], x[1]) for x in vocab_id_uri_list()]))
),
)
return return_vocab2(vocab_uri, acc_dep)
@app.route("/standard_name/")
def standard_name(acc_dep=None):
return return_vocab2(config.ABS_URI_BASE_IN_DATA + "/standard_name/", acc_dep)
def return_vocab2(uri, acc_dep):
if uri in g.VOCABS.keys():
# get vocab details using appropriate source handler
vocab = source.nvs_sparql.NvsSPARQL(request, language=request.values.get("lang")).get_vocabulary(acc_dep)
return NvsVocabularyRenderer(request, vocab).render()
else:
return None
# END ROUTE one vocab