Mercurial > hg
view mercurial/fancyopts.py @ 925:5a034646e472
run-tests: remove '+ hg' trick
This was causing me a fair amount of debugging confusion. Let's just
forget it entirely. Updated tests to match.
author | mpm@selenic.com |
---|---|
date | Tue, 16 Aug 2005 19:03:01 -0800 |
parents | 31a9aa890016 |
children | 0aaeee519c66 4f81068ed8cd |
line wrap: on
line source
import getopt def fancyopts(args, options, state): long=[] short='' map={} dt={} for s, l, d, c in options: map['-'+s] = map['--'+l]=l state[l] = d dt[l] = type(d) if not d is None and not callable(d): s, l=s+':', l+'=' if s: short = short + s if l: long.append(l) opts, args = getopt.getopt(args, short, long) for opt, arg in opts: if dt[map[opt]] is type(fancyopts): state[map[opt]](state,map[opt],arg) elif dt[map[opt]] is type(1): state[map[opt]] = int(arg) elif dt[map[opt]] is type(''): state[map[opt]] = arg elif dt[map[opt]] is type([]): state[map[opt]].append(arg) elif dt[map[opt]] is type(None): state[map[opt]] = 1 return args