-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpytemplate.py
More file actions
executable file
·58 lines (40 loc) · 1 KB
/
Copy pathpytemplate.py
File metadata and controls
executable file
·58 lines (40 loc) · 1 KB
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
52
53
54
55
56
57
58
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 12/20/16 9:39PM
# @Author : hehez
# @File : main.py
# @Version : 1.0.0
"""
A simple script to generate python file with header comment
"""
import os
from time import strftime
time = strftime('%D %-I:%-M%p')
auther = 'hehez'
init_version = '0.1.0'
title = raw_input("Enter a file name for your script: ")
# Add .py to the end of the script.
if not title.endswith('.py'):
title = title + '.py'
# Convert all letters to lower case.
title = title.lower()
# Remove spaces from the title.
title = title.replace(' ', '_')
header = """#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : %s
# @Author : %s
# @File : %s
# @Version : %s
\"\"\"Here's your Module Docstring!
Start More specific detail Docstring here!
\"\"\"
# Import the modules needed to run the script.
def main():
pass
if __name__ == '__main__':
main()
""" % (time, auther, title, init_version)
filename = open(title, 'w')
filename.write(header)
filename.close()