Show More
@@ -1,30 +1,30 b'' | |||
|
1 | 1 | import getopt |
|
2 | 2 | |
|
3 | 3 | def fancyopts(args, options, state): |
|
4 | 4 | long = [] |
|
5 | 5 | short = '' |
|
6 | 6 | map = {} |
|
7 | 7 | dt = {} |
|
8 | 8 | |
|
9 | 9 | for s, l, d, c in options: |
|
10 | 10 | pl = l.replace('-', '_') |
|
11 | 11 | map['-'+s] = map['--'+l] = pl |
|
12 | 12 | state[pl] = d |
|
13 | 13 | dt[pl] = type(d) |
|
14 | 14 | if not d is None and not callable(d): |
|
15 | 15 | if s: s += ':' |
|
16 | 16 | if l: l += '=' |
|
17 | 17 | if s: short = short + s |
|
18 | 18 | if l: long.append(l) |
|
19 | 19 | |
|
20 | 20 | opts, args = getopt.getopt(args, short, long) |
|
21 | 21 | |
|
22 | 22 | for opt, arg in opts: |
|
23 | 23 | if dt[map[opt]] is type(fancyopts): state[map[opt]](state, map[opt], arg) |
|
24 | 24 | elif dt[map[opt]] is type(1): state[map[opt]] = int(arg) |
|
25 | 25 | elif dt[map[opt]] is type(''): state[map[opt]] = arg |
|
26 | 26 | elif dt[map[opt]] is type([]): state[map[opt]].append(arg) |
|
27 |
elif dt[map[opt]] is type(None): state[map[opt]] = |
|
|
27 | elif dt[map[opt]] is type(None): state[map[opt]] = True | |
|
28 | 28 | |
|
29 | 29 | return args |
|
30 | 30 |
General Comments 0
You need to be logged in to leave comments.
Login now