Skip to content

Instantly share code, notes, and snippets.

@moskewcz
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save moskewcz/78f039ad9e06a46faf1c to your computer and use it in GitHub Desktop.
Save moskewcz/78f039ad9e06a46faf1c to your computer and use it in GitHub Desktop.
python fmtr.py < foo.prototxt.template > foo.prototxt.template.prototxt name=bar; cat foo.prototxt.template.prototxt
import sys
fmt_dict = { }
for arg in sys.argv[1:]:
eq_pos = arg.find("=")
if eq_pos == -1: raise ValueError( "missing = in arg:" + repr(arg) )
fmt_dict[arg[:eq_pos]] = arg[eq_pos+1:]
sys.stdout.write( sys.stdin.read() % fmt_dict )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment