-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path00)New Document.py
More file actions
executable file
·63 lines (38 loc) · 1.3 KB
/
00)New Document.py
File metadata and controls
executable file
·63 lines (38 loc) · 1.3 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
59
60
61
62
63
#!/usr/bin/env python
"""Open New Document on CotEditor with Python Template.
This is a CotEditor script.
%%%{CotEditorXInput=None}%%%
%%%{CotEditorXOutput=NewDocument}%%%
"""
from __future__ import print_function
__version__ = '1.0.2'
__date__ = '2013-02-16'
__author__ = '1024jp <http://wolfrosch.com/>'
__license__ = "Creative Commons Attribution-NonCommercial 3.0 Unported License"
from subprocess import Popen, PIPE
from datetime import date
# template ----------------------------------------------------------
AUTHOR = '1024jp <http://wolfrosch.com/>'
TEMPLATE = """#!/usr/bin/env python
from __future__ import division, print_function
__date__ = '{date}'
__author__ = '{author}'
main():
pass
if __name__ == "__main__":
main()
""".format(date=date.today(), author=AUTHOR)
# main --------------------------------------------------------------
def run_osascript(script):
"""Run osascript."""
p = Popen(['osascript', '-'], stdin=PIPE, stdout=PIPE)
stdout, stderr = p.communicate(script)
return stdout.rstrip()
def main():
# insert template
print(TEMPLATE, end='')
# # set coloring style to Python
# run_osascript('tell application "CotEditor" '
# 'to set coloring style of front document to "Python"')
if __name__ == "__main__":
main()