-
Notifications
You must be signed in to change notification settings - Fork 7
/
catalog.py
executable file
·51 lines (38 loc) · 1.45 KB
/
catalog.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
#!/usr/bin/env python
import argparse
import logging
import sys
import ptp.docs
def main():
parser = argparse.ArgumentParser(description="Catalog dataset files")
parser.add_argument('-f',
'--file',
default=None,
help='Dataset JSON file to be cataloged \
(default: %(default)s)')
parser.add_argument('-d',
'--directory',
default='data/',
help='Dataset directory (default: %(default)s)')
parser.add_argument('-r',
'--reset',
default=False,
action='store_true',
help="Reset catalog (default: %(default)s)")
parser.add_argument('--verbose',
'-v',
action='count',
default=1,
help="Verbosity level (default: %(default)s)")
args = parser.parse_args()
logging_level = 70 - (10 * args.verbose) if args.verbose > 0 else 0
logging.basicConfig(stream=sys.stderr, level=logging_level)
docs = ptp.docs.Docs(cfg_path=args.directory, reset=args.reset)
if (args.file):
# If a specific dataset was given, just add it to the dataset
docs.add_dataset(args.file)
else:
# Generate table with all datasets
docs.process()
if __name__ == '__main__':
main()