Patchwork [4/5] pybootchartgui: Adopt the width of the index in split output files

login
register
mail settings
Submitter Peter Kjellerstedt
Date Jan. 21, 2014, 3:22 p.m.
Message ID <fe20103fab5dac7a6711f435db5088bd221de2bb.1390317718.git.pkj@axis.com>
Download mbox | patch
Permalink /patch/65361/
State Accepted
Commit 57c93e35074da2de5a66001b24a31cd40a9b2ca7
Headers show

Comments

Peter Kjellerstedt - Jan. 21, 2014, 3:22 p.m.
Add minimum width zero-padding to the index used in split output files
with -s and -o. I.e., if -s 200 is used, then the index will be
zero-padded to three digits width.

Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
---
 scripts/pybootchartgui/pybootchartgui/main.py.in | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Patch

diff --git a/scripts/pybootchartgui/pybootchartgui/main.py.in b/scripts/pybootchartgui/pybootchartgui/main.py.in
index cc9c40b..e9d2c74 100644
--- a/scripts/pybootchartgui/pybootchartgui/main.py.in
+++ b/scripts/pybootchartgui/pybootchartgui/main.py.in
@@ -155,11 +155,13 @@  def main(argv=None):
 			filename = _get_filename(options.output)
 			res_list = parsing.split_res(res, options.num)
 			n = 1
+			width = len(str(len(res_list)))
+			s = "_%%0%dd." % width
 			for r in res_list:
 				if len(res_list) == 1:
 					f = filename + "." + options.format
 				else:
-					f = filename + "_" + str(n) + "." + options.format
+					f = filename + s % n + options.format
 					n = n + 1
 				def render():
 					batch.render(writer, r, options, f)