|
| 1 | +#!/bin/env python |
| 2 | +#========================================================================= |
| 3 | +# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public |
| 4 | +# License (GPL) version 3, as described at www.opensource.org. |
| 5 | +# Copyright (C)2016 William H. Majoros (martiandna@gmail.com). |
| 6 | +#========================================================================= |
| 7 | +from __future__ import (absolute_import, division, print_function, |
| 8 | + unicode_literals, generators, nested_scopes, with_statement) |
| 9 | +from builtins import (bytes, dict, int, list, object, range, str, ascii, |
| 10 | + chr, hex, input, next, oct, open, pow, round, super, filter, map, zip) |
| 11 | +import os |
| 12 | +import sys |
| 13 | +import ProgramName |
| 14 | + |
| 15 | +# Process command line |
| 16 | +name=ProgramName.get(); |
| 17 | +if(len(sys.argv)!=2): |
| 18 | + sys.exit(name+" <classname>") |
| 19 | +className=sys.argv[1] |
| 20 | + |
| 21 | +# Write file |
| 22 | +filename=className+".py" |
| 23 | +if(os.path.exists(filename)): |
| 24 | + sys.exit(filename+" exists"); |
| 25 | +fh=open(filename,"w") |
| 26 | +header="\n".join(["#=========================================================================", |
| 27 | + "# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public", |
| 28 | + "# License (GPL) version 3, as described at www.opensource.org.", |
| 29 | + "# Copyright (C)2016 William H. Majoros (martiandna@gmail.com).", |
| 30 | + "#=========================================================================", |
| 31 | + "from __future__ import (absolute_import, division, print_function", |
| 32 | + " unicode_literals, generators, nested_scopes, with_statement)", |
| 33 | + "from builtins import (bytes, dict, int, list, object, range, str, ascii,", |
| 34 | + " chr, hex, input, next, oct, open, pow, round, super, filter, map, zip)", |
| 35 | + "\n" |
| 36 | + "#=========================================================================", |
| 37 | + "# Attributes:", |
| 38 | + "# ", |
| 39 | + "# Methods:", |
| 40 | + "# "+className+"()", |
| 41 | + "#=========================================================================\n", |
| 42 | + ]) |
| 43 | +fh.write(header) |
| 44 | +fh.write("class "+className+":\n") |
| 45 | +fh.write(" \"\"\""+className+"\"\"\"\n"); |
| 46 | +fh.write(" def __init__(self):\n") |
| 47 | +fh.write(" pass\n") |
| 48 | +fh.write("\n\n\n") |
| 49 | +fh.close() |
| 50 | + |
| 51 | + |
0 commit comments