-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
69 lines (66 loc) · 2.17 KB
/
run.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
from inquisitor.question import RDFInquisitor
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Question your Remote RDF")
parser.add_argument(
"-u", "--uri", dest="uri", help="URI to negotiate", required=True
)
parser.add_argument(
"-o",
"--operation",
dest="operation",
help="Operation you want to run: download_rdf, get_labels, get_label_by_lang, get_types, get_range,"
"recurse_types",
required=True,
)
parser.add_argument(
"-f",
"--file_format",
dest="file_format",
help="When downloading rdf, specify how you want to serialize things.",
default="ttl",
)
parser.add_argument(
"-p",
"--file_path",
dest="file_path",
help="When downloading rdf, where you want to serialize to disk without extension",
default="rdf",
)
parser.add_argument(
"-s",
"--subject",
dest="subject",
help="Specify a subject. See docs for details.",
)
parser.add_argument(
"-x", "--extra", dest="extra", help="Specify an extra. See docs for details."
)
args = parser.parse_args()
x = RDFInquisitor(args.uri)
if args.operation == "download_rdf":
print(x.download_rdf(args.file_path, args.file_format))
elif args.operation == "get_labels":
if args.subject is not None:
print(x.get_labels(args.subject))
else:
print(x.get_labels())
elif args.operation == "get_label_by_lang":
if args.extra is not None:
print(x.get_label_by_language(args.subject, args.extra))
else:
print(x.get_label_by_language(args.subject, "en"))
elif args.operation == "get_range":
if args.extra is not None:
print(x.get_range(args.extra))
else:
print(x.get_range())
elif args.operation == "get_types":
if args.extra is not None:
print(x.get_types(args.extra))
else:
print(x.get_types())
elif args.operation == "recurse_types":
print(x.recurse_types())
else:
print("Operation not valid.")