Merge pull request #104 from atom/pylint

Lint python and coffee scripts
This commit is contained in:
Cheng Zhao 2013-09-26 20:06:10 -07:00
commit 10a46b4229
14 changed files with 85 additions and 29 deletions

View file

@ -38,11 +38,11 @@ process.on 'uncaughtException', (error) ->
# Show error in GUI. # Show error in GUI.
message = error.stack ? "#{error.name}: #{error.message}" message = error.stack ? "#{error.name}: #{error.message}"
require('dialog').showMessageBox require('dialog').showMessageBox
type: 'warning' type: 'warning'
title: 'An javascript error occured in the browser' title: 'An javascript error occured in the browser'
message: 'uncaughtException' message: 'uncaughtException'
detail: message detail: message
buttons: ['OK'] buttons: ['OK']
# Load the RPC server. # Load the RPC server.
require './rpc-server.js' require './rpc-server.js'

View file

@ -9,7 +9,8 @@
"walkdir": "*", "walkdir": "*",
"unzip": "*", "unzip": "*",
"d3": "*", "d3": "*",
"int64-native": "*" "int64-native": "*",
"coffeelint": "*"
}, },
"private": true, "private": true,

View file

@ -1,12 +1,11 @@
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
import errno
import os import os
import subprocess import subprocess
import sys import sys
from lib.util import * from lib.util import scoped_cwd
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
@ -68,7 +67,7 @@ def update_apm():
def update_node_modules(): def update_node_modules():
for dirname in ['.', 'browser/default_app', 'spec']: for dirname in ['.', 'browser/default_app', 'spec']:
update_node_modules_for_dir(dirname); update_node_modules_for_dir(dirname)
def update_node_modules_for_dir(dirname): def update_node_modules_for_dir(dirname):

View file

@ -11,6 +11,8 @@ SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
def main(): def main():
run_script('bootstrap.py') run_script('bootstrap.py')
run_script('cpplint.py') run_script('cpplint.py')
run_script('pylint.py')
run_script('coffeelint.py')
run_script('build.py') run_script('build.py')
run_script('test.py', ['--ci']) run_script('test.py', ['--ci'])
run_script('create-dist.py') run_script('create-dist.py')

6
script/coffeelint.json Normal file
View file

@ -0,0 +1,6 @@
{
"max_line_length": {
"value": 80,
"level": "ignore"
}
}

31
script/coffeelint.py Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env python
import glob
import os
import subprocess
import sys
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
def main():
os.chdir(SOURCE_ROOT)
coffeelint = os.path.join(SOURCE_ROOT, 'node_modules', 'coffeelint', 'bin',
'coffeelint')
settings = ['--quiet', '-f', os.path.join('script', 'coffeelint.json')]
files = glob.glob('browser/api/lib/*.coffee') + \
glob.glob('renderer/api/lib/*.coffee') + \
glob.glob('common/api/lib/*.coffee') + \
glob.glob('browser/atom/*.coffee')
if sys.platform in ['win32', 'cygwin']:
subprocess.check_call(['node', coffeelint] + settings + files,
executable='C:/Program Files/nodejs/node.exe')
else:
subprocess.check_call(['node', coffeelint] + settings + files)
if __name__ == '__main__':
sys.exit(main())

View file

@ -4,8 +4,6 @@ import os
import subprocess import subprocess
import sys import sys
from lib.util import *
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__)) SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
@ -22,5 +20,6 @@ def main():
else: else:
subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file]) subprocess.check_call(['node', coffee, '-c', '-o', output_dir, input_file])
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())

2
script/cpplint.py vendored
View file

@ -31,7 +31,7 @@ def main():
def list_files(directories, filters): def list_files(directories, filters):
matches = [] matches = []
for directory in directories: for directory in directories:
for root, dirs, filenames, in os.walk(directory): for root, _, filenames, in os.walk(directory):
for f in filters: for f in filters:
for filename in fnmatch.filter(filenames, f): for filename in fnmatch.filter(filenames, f):
matches.append(os.path.join(root, filename)) matches.append(os.path.join(root, filename))

View file

@ -1,14 +1,13 @@
#!/usr/bin/env python #!/usr/bin/env python
import errno
import glob
import os import os
import shutil import shutil
import subprocess import subprocess
import sys import sys
import tarfile import tarfile
from lib.util import * from lib.util import scoped_cwd, rm_rf, get_atom_shell_version, make_zip, \
safe_mkdir
ATOM_SHELL_VRESION = get_atom_shell_version() ATOM_SHELL_VRESION = get_atom_shell_version()
@ -79,7 +78,7 @@ def main():
def force_build(): def force_build():
build = os.path.join(SOURCE_ROOT, 'script', 'build.py') build = os.path.join(SOURCE_ROOT, 'script', 'build.py')
subprocess.check_call([sys.executable, build, '-c', 'Release']); subprocess.check_call([sys.executable, build, '-c', 'Release'])
def copy_binaries(): def copy_binaries():
@ -99,7 +98,7 @@ def copy_headers():
# Copy standard node headers from node. repository. # Copy standard node headers from node. repository.
for include_path in HEADERS_DIRS: for include_path in HEADERS_DIRS:
abs_path = os.path.join(NODE_DIR, include_path) abs_path = os.path.join(NODE_DIR, include_path)
for dirpath, dirnames, filenames in os.walk(abs_path): for dirpath, _, filenames in os.walk(abs_path):
for filename in filenames: for filename in filenames:
extension = os.path.splitext(filename)[1] extension = os.path.splitext(filename)[1]
if extension not in HEADERS_SUFFIX: if extension not in HEADERS_SUFFIX:
@ -111,7 +110,7 @@ def copy_headers():
# Copy V8 headers from chromium's repository. # Copy V8 headers from chromium's repository.
src = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download', src = os.path.join(SOURCE_ROOT, 'vendor', 'brightray', 'vendor', 'download',
'libchromiumcontent', 'src') 'libchromiumcontent', 'src')
for dirpath, dirnames, filenames in os.walk(os.path.join(src, 'v8')): for dirpath, _, filenames in os.walk(os.path.join(src, 'v8')):
for filename in filenames: for filename in filenames:
extension = os.path.splitext(filename)[1] extension = os.path.splitext(filename)[1]
if extension not in HEADERS_SUFFIX: if extension not in HEADERS_SUFFIX:
@ -122,8 +121,7 @@ def copy_headers():
def copy_license(): def copy_license():
license = os.path.join(SOURCE_ROOT, 'LICENSE') shutil.copy2(os.path.join(SOURCE_ROOT, 'LICENSE'), DIST_DIR)
shutil.copy2(license, DIST_DIR)
def create_version(): def create_version():

View file

@ -17,7 +17,7 @@ class GitHub:
def __getattr__(self, attr): def __getattr__(self, attr):
return _Callable(self, '/%s' % attr) return _Callable(self, '/%s' % attr)
def _http(self, method, path, **kw): def send(self, method, path, **kw):
if not 'headers' in kw: if not 'headers' in kw:
kw['headers'] = dict() kw['headers'] = dict()
headers = kw['headers'] headers = kw['headers']
@ -47,7 +47,7 @@ class _Executable:
self._path = path self._path = path
def __call__(self, **kw): def __call__(self, **kw):
return self._gh._http(self._method, self._path, **kw) return self._gh.send(self._method, self._path, **kw)
class _Callable(object): class _Callable(object):

22
script/pylint.py Executable file
View file

@ -0,0 +1,22 @@
#!/usr/bin/env python
import glob
import os
import subprocess
import sys
SOURCE_ROOT = os.path.dirname(os.path.dirname(__file__))
def main():
os.chdir(SOURCE_ROOT)
pylint = os.path.join(SOURCE_ROOT, 'vendor', 'depot_tools', 'pylint.py')
settings = ['--rcfile=vendor/depot_tools/pylintrc']
pys = glob.glob('script/*.py')
subprocess.check_call([sys.executable, pylint] + settings + pys,
env=dict(PYTHONPATH='script'))
if __name__ == '__main__':
sys.exit(main())

View file

@ -3,11 +3,11 @@
import sys import sys
import os import os
from lib.util import * from lib.util import safe_mkdir, extract_zip, tempdir, download
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
FRAMEWORKS_URL='https://gh-contractor-zcbenz.s3.amazonaws.com/frameworks' FRAMEWORKS_URL = 'https://gh-contractor-zcbenz.s3.amazonaws.com/frameworks'
def main(): def main():

View file

@ -1,10 +1,9 @@
#!/usr/bin/env python #!/usr/bin/env python
import os
import subprocess import subprocess
import sys import sys
from lib.util import *
SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__)))

View file

@ -4,12 +4,11 @@ import argparse
import errno import errno
import glob import glob
import os import os
import requests
import subprocess import subprocess
import sys import sys
import tempfile import tempfile
from lib.util import * from lib.util import get_atom_shell_version, scoped_cwd, safe_mkdir
from lib.github import GitHub from lib.github import GitHub