comparison cmd2.py @ 189:06119abd352e

synch
author catherine@Elli.myhome.westell.com
date Fri, 30 Jan 2009 05:53:12 -0500
parents 183dd2fffec5
children 51c15fe803a4
comparison
equal deleted inserted replaced
188:7ce8db01a847 189:06119abd352e
24 As of 0.3.0, options should be specified as `optparse` options. See README.txt. 24 As of 0.3.0, options should be specified as `optparse` options. See README.txt.
25 flagReader.py options are still supported for backward compatibility 25 flagReader.py options are still supported for backward compatibility
26 """ 26 """
27 import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest, unittest, string 27 import cmd, re, os, sys, optparse, subprocess, tempfile, pyparsing, doctest, unittest, string
28 from optparse import make_option 28 from optparse import make_option
29 __version__ = '0.4.4' 29 __version__ = '0.4.5'
30 30
31 class OptionParser(optparse.OptionParser): 31 class OptionParser(optparse.OptionParser):
32 def exit(self, status=0, msg=None): 32 def exit(self, status=0, msg=None):
33 self.values._exit = True 33 self.values._exit = True
34 if msg: 34 if msg:
46 def remainingArgs(oldArgs, newArgList): 46 def remainingArgs(oldArgs, newArgList):
47 ''' 47 '''
48 >>> remainingArgs('-f bar bar cow', ['bar', 'cow']) 48 >>> remainingArgs('-f bar bar cow', ['bar', 'cow'])
49 'bar cow' 49 'bar cow'
50 ''' 50 '''
51 pattern = '\s+'.join(newArgList) + '\s*$' 51 pattern = '\s+'.join(re.escape(a) for a in newArgList) + '\s*$'
52 matchObj = re.search(pattern, oldArgs) 52 matchObj = re.search(pattern, oldArgs)
53 return oldArgs[matchObj.start():] 53 return oldArgs[matchObj.start():]
54 54
55 def options(option_list): 55 def options(option_list):
56 def option_setup(func): 56 def option_setup(func):