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