Created
July 10, 2011 02:27
-
-
Save ameerkat/1074174 to your computer and use it in GitHub Desktop.
Templatized header generator for a cpp project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sys import argv | |
import re | |
def header_def_name(camelcase): | |
word = "" | |
for ch in camelcase: | |
if ch.isupper() and len(word) > 0: | |
word += "_" | |
word += ch | |
return word.upper() | |
if __name__ == "__main__": | |
if(len(argv) <= 1): | |
print "error: must have at least one argument" | |
exit() | |
f = open(argv[1]) | |
if argv[1] == "generic_header.tpl": | |
# create header name for generic tpl if not provided | |
if(len(argv) <= 3): | |
argv.append(header_def_name(argv[2])) | |
infile = f.read() | |
print infile.format(*argv[2:]), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment