| 1 |
#!/usr/bin/env python3 |
| 2 |
|
| 3 |
import sys |
| 4 |
import argparse |
| 5 |
|
| 6 |
parser = argparse.ArgumentParser() |
| 7 |
parser.add_argument('--input', dest='input', |
| 8 |
help='the input file') |
| 9 |
parser.add_argument('--output', dest='output', |
| 10 |
help='the output file') |
| 11 |
parser.add_argument('--upper', dest='upper', action='store_true', default=False, |
| 12 |
help='Convert to upper case.') |
| 13 |
|
| 14 |
c_templ = '''int %s(void) { |
| 15 |
return 0; |
| 16 |
} |
| 17 |
''' |
| 18 |
|
| 19 |
options = parser.parse_args(sys.argv[1:]) |
| 20 |
|
| 21 |
with open(options.input) as f: |
| 22 |
funcname = f.readline().strip() |
| 23 |
if options.upper: |
| 24 |
funcname = funcname.upper() |
| 25 |
|
| 26 |
with open(options.output, 'w', encoding='utf-8') as f: |
| 27 |
f.write(c_templ % funcname) |