Commits

Carl Meyer  committed 2ffebca

arg interpolation in filename

  • Participants
  • Parent commits c1f3acc

Comments (0)

Files changed (1)

 
 gridimg.py - command-line grid image generator.
 
-Time-stamp: <2009-06-15 19:28:29 carljm gridimg.py>
+Time-stamp: <2009-06-15 19:53:25 carljm gridimg.py>
 
 """
 import sys
 parser = OptionParser(usage=usage)
 parser.add_option("-g", "--gutter-color", dest="gutter_color",
                   default="#fcc",
-                  help="use COLOR for gutter line",
+                  help="use COLOR for gutter line (default #fcc)",
                   metavar="COLOR")
 parser.add_option("-b", "--baseline-color", dest="baseline_color",
                   default="#999",
-                  help="use COLOR for text baseline",
+                  help="use COLOR for text baseline (default #999)",
                   metavar="COLOR")
 parser.add_option("-f", "--output-file", dest="output_file",
-                  default="grid.png",
-                  help="output grid image to FILE (format autodetected from extension)",
+                  default="grid_%l_%c_%g.png",
+                  help="output grid image to FILE "
+                  "(format autodetected from extension) "
+                  "%l, %c, %g replaced with line-height, col-width, gutter-width "
+                  "(default grid_%l_%c_%g.png)",
                   metavar="FILE")
 
 (options, args) = parser.parse_args()
 draw.rectangle(((width - gutter, 0), (width, height)), fill=g_color)
 draw.line(((0, height - 1), (width, height - 1)), fill=b_color)
 
-im.save(options.output_file)
+output_file = options.output_file.replace('%l', str(height)
+                                          ).replace('%c', str(column)
+                                                    ).replace('%g', str(gutter))
+
+im.save(output_file)