-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathlist.py
58 lines (49 loc) · 1.33 KB
/
list.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
import argparse
import pyessv
# Define command line options.
_ARGS = argparse.ArgumentParser('Writes an authority"s vocabularies to stdout.')
_ARGS.add_argument(
'--authority',
help='Authority to be displayed.',
dest='authority',
type=str
)
_ARGS.add_argument(
'--scope',
help='scope to be displayed.',
dest='scope',
type=str,
default=None
)
_ARGS.add_argument(
'--collection',
help='Collection to be displayed.',
dest='collection',
type=str,
default=None
)
_ARGS.add_argument(
'--term',
help='Term to be displayed.',
dest='term',
type=str,
default=None
)
def _main(args):
"""Main entry point.
"""
if args.authority is None or len(args.authority.strip()) == 0:
raise ValueError('Authority is a required parameter')
for scope in pyessv.load(args.authority):
if args.scope and args.scope != scope.canonical_name:
continue
for collection in scope:
if args.collection and args.collection != collection.canonical_name:
continue
for term in collection:
if args.term and args.term != term.canonical_name:
continue
print(term.namespace.replace(':', ' -> '))
# Entry point.
if __name__ == '__main__':
_main(_ARGS.parse_args())