direct-io.hg
changeset 1827:6c3bbbf7e1cf
bitkeeper revision 1.1108.2.2 (40fbf4de21Jj1rHIoB288QJ0sKILVg)
Tweak xm command parsing - can now use unambiguous prefixes to identify the
command. For instance: 'xm list' can be 'xm l' 'xm li' 'xm lis'.
Tweak xm command parsing - can now use unambiguous prefixes to identify the
command. For instance: 'xm list' can be 'xm l' 'xm li' 'xm lis'.
author | mwilli2@equilibrium.research.intel-research.net |
---|---|
date | Mon Jul 19 16:20:46 2004 +0000 (2004-07-19) |
parents | 44e286624053 |
children | 1c630e7af56e |
files | tools/python/xen/xm/main.py |
line diff
1.1 --- a/tools/python/xen/xm/main.py Mon Jul 19 15:30:45 2004 +0000 1.2 +++ b/tools/python/xen/xm/main.py Mon Jul 19 16:20:46 2004 +0000 1.3 @@ -105,8 +105,23 @@ class Xm: 1.4 1.5 def getprog(self, name, val=None): 1.6 """Get a sub-program. 1.7 + name Name of the sub-program (or optionally, an unambiguous 1.8 + prefix of its name) 1.9 + val Default return value if no (unique) match is found 1.10 """ 1.11 - return self.progs.get(name, val) 1.12 + 1.13 + match = None 1.14 + for progname in self.progs.keys(): 1.15 + if progname == name: 1.16 + match = progname 1.17 + break 1.18 + if progname.startswith(name): 1.19 + if not match: 1.20 + match = progname 1.21 + else: 1.22 + return val # name is ambiguous - bail out 1.23 + 1.24 + return self.progs.get(match, val) 1.25 1.26 def proglist(self): 1.27 """Get a list of sub-programs, ordered by group.