-
Notifications
You must be signed in to change notification settings - Fork 41
/
grab_magic_key.py
executable file
·51 lines (45 loc) · 1.1 KB
/
grab_magic_key.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 sys
import pmagpy.pmag as pmag
def main():
"""
NAME
grab_magic_key.py
DESCRIPTION
picks out key and saves to file
SYNTAX
grab_magic_key.py [command line optins]
OPTIONS
-h prints help message and quits
-f FILE: specify input magic format file
-key KEY: specify key to print to standard output
"""
dir_path="./"
if '-WD' in sys.argv:
ind=sys.argv.index('-WD')
dir_path=sys.argv[ind+1]
if '-h' in sys.argv:
print main.__doc__
sys.exit()
if '-f' in sys.argv:
ind=sys.argv.index('-f')
magic_file=dir_path+'/'+sys.argv[ind+1]
else:
print main.__doc__
sys.exit()
if '-key' in sys.argv:
ind=sys.argv.index('-key')
grab_key=sys.argv[ind+1]
else:
print main.__doc__
sys.exit()
#
#
# get data read in
Data,file_type=pmag.magic_read(magic_file)
if len(Data)>0:
for rec in Data: print rec[grab_key]
else:
print 'bad file name'
if __name__ == "__main__":
main()