-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrepofind
More file actions
executable file
·73 lines (51 loc) · 1.59 KB
/
repofind
File metadata and controls
executable file
·73 lines (51 loc) · 1.59 KB
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
#!/usr/bin/env python
__author__ = 'cbarne02'
"""
to use:
1. clone your github repository
2. point this script at the root directory of your cloned repository
3. run the script to find the metadata in your local repository based on layer id
by default, uses layers.json to search and retrieve. may attempt a more general solution
for instances where layers.json is absent
"""
import sys
import getopt
from repo_utils import find_from_layer_id
def usage():
message = """'-r' or '--repository': repository path.
Defaults to directory 'REPO_PATH' specified in repo_utils.py.
'-i' or '--layer_id': unique id for the data layer described by the metadata.
REQUIRED
"""
print message
if __name__ == "__main__":
argv = sys.argv
repo_path = None
file_id = None
try:
opts, args = getopt.getopt(argv[1:], "hr:i:", ["help", "repository=", "layer_id="])
for opt, arg in opts:
if opt in ("-h", "--help"):
usage()
sys.exit()
elif opt in("-r", "--repository"):
repo_path = arg
elif opt in("-i", "--layer_id"):
file_id = arg
except getopt.GetoptError:
usage()
sys.exit(2)
if file_id is None:
# file id is required
usage()
sys.exit()
try:
if repo_path is None:
tup = find_from_layer_id(file_id)
else:
tup = find_from_layer_id(file_id, repo_path)
print tup[0]
print "contains types:" , tup[1]
except Exception as e:
print e.message
sys.exit(2)