Revision: 723
Author: keith.dart
Date: Fri May 10 18:33:24 2013
Log: Fix bug. The cycle command now substitures all occurances of
expansion character.
http://code.google.com/p/pycopia/source/detail?r=723
Modified:
/trunk/CLI/pycopia/CLI.py
=======================================
--- /trunk/CLI/pycopia/CLI.py Mon Apr 29 14:30:06 2013
+++ /trunk/CLI/pycopia/CLI.py Fri May 10 18:33:24 2013
@@ -571,8 +571,9 @@
def cycle(self, argv):
"""cycle <range> <command> [<arg>...]
- Cycle the variable symbol % through the range, and re-evaluate the
command
+ Cycle the variable symbol "%" through the range, and re-evaluate the
command
for each value.
+
Range is of the form [start':']end[':' step]
Where start defaults to zero and step defaults to one.
Or, range may be a list of values separated by ','.
@@ -584,10 +585,11 @@
rangetoken = argv.pop(0)
argv = self._expand_aliases(argv)
meth = getattr(self, argv[0])
+ slocs = []
for sloc, arg in enumerate(argv):
if arg.find("%") >= 0:
- break
- else:
+ slocs.append(sloc)
+ if not slocs:
self._ui.error("No %% substitution found.")
return
try:
@@ -596,7 +598,8 @@
raise CLISyntaxError(err)
for i in therange:
newargs = argv[:]
- newargs[sloc] = newargs[sloc].replace("%", str(i))
+ for sloc in slocs:
+ newargs[sloc] = newargs[sloc].replace("%", str(i))
self._ui.Print(" ".join(newargs))
meth(newargs)