-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse.py
More file actions
62 lines (61 loc) · 1.85 KB
/
parse.py
File metadata and controls
62 lines (61 loc) · 1.85 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
import sys
import getopt
import argparse
def parse():
booshow = False
boogif = False
boompg = False
boolog = False
opts,args = getopt.getopt(sys.argv[1:],'sgmlh')
for opt,arg in opts:
if opt == '-s':
print('Show = True')
booshow = True
elif opt == '-g':
print('Gif = True')
boogif = True
elif opt == '-m':
print('Mpeg = True')
boompg = True
elif opt == '-l':
print('Log = True')
boolog = True
elif opt == '-h':
print('-h for help')
print('-s for Show')
print('-g for gif')
print('-m for mpeg extra options')
print('-l for log')
else:
pass
return booshow,boogif,boompg,boolog
def parse2():
parser = argparse.ArgumentParser()
parser.add_argument('-s',help=('show'),action='store_true')
parser.add_argument('-g',help=('make gif'),action='store_true')
parser.add_argument('-m',help=('more compatible mpeg'),action='store_true')
parser.add_argument('-l',help=('log'),action='store_true')
parser.add_argument('-fps',help=('fps'),type=int,default=10)
parser.add_argument('-size',help=('matplotlib figsize'),type=float,default=5)
parser.add_argument('files',nargs="*",help=('filenames'))
args = parser.parse_args()
booshow = args.s
boogif = args.g
boompg = args.m
boolog = args.l
gfps = args.fps
files = [fn for fn in args.files if '.npy' in fn]
if len(files) > 0:
filename = files[0]
else:
filename = 'cube.npy'
if booshow:
print('Show = True')
if boogif:
print('Gif = True')
if boompg:
print('Mpeg = True')
if boolog:
print('Log = True')
print('fps =',gfps)
return booshow,boogif,boompg,boolog,gfps,filename,args