-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05)Check Code Style.py
More file actions
executable file
·39 lines (26 loc) · 984 Bytes
/
Copy path05)Check Code Style.py
File metadata and controls
executable file
·39 lines (26 loc) · 984 Bytes
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
#!/usr/bin/env python
"""Python code style check script for CotEditor
Check Python source code of the current document on CotEditor with pycodestyle.
This is a CotEditor script.
"""
__version__ = '1.1.0'
__date__ = '2017-10-17'
__author__ = '1024jp <http://wolfrosch.com/>'
__license__ = 'Creative Commons Attribution-NonCommercial 3.0 Unported License'
import sys
import os
from subprocess import Popen, PIPE
# setting -----------------------------------------------------------
# path to pycodestyle
command = '/usr/local/bin/pycodestyle'
# main --------------------------------------------------------------
def main(filepath):
# check pep8
results = Popen([command, filepath], stdout=PIPE).stdout
# write results to CotEditor's Console
sys.stderr.write('checked -> ' + os.path.basename(filepath) + '\n')
for line in results:
sys.stderr.write(line.split(':', 1)[-1])
if __name__ == "__main__":
filepath = sys.argv[1]
main(filepath)