1: #line 10 "options.ipk"
2: import re
3:
4: longopts=re.compile('^--([A-Za-z][-A-Za-z_0-9]*)(?:=(.*))?$')
5: shortopts=re.compile('^-([A-Za-z]+)(?:=(.*))?$')
6:
7:
8: def getopt(args):
9: wordno = 0
10: result = []
11: opts=[]
12: while wordno<len(args):
13: filename = ''
14: word = args[wordno]
15:
16: match = longopts.match(word)
17: if match:
18: opts.append((match.group(1),match.group(2)))
19:
20: else:
21: match = shortopts.match(word)
22: if match:
23:
24: for letter in match.group(1)[:-1]:
25: opts.append((letter,None))
26: opts.append((match.group(1)[-1],match.group(2)))
27: else:
28:
29: filename = args[wordno]
30: result.append((opts,filename))
31: opts=[]
32: wordno = wordno + 1
33:
34: if opts:
35: result.append((opts,filename))
36: return result