summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2012-09-14 13:25:22 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2012-09-14 13:25:22 +0200
commitfc36a2c8ecb64dedabda0530ad1d05731693ee3f (patch)
treedd6ecdae4e40d18cf054c8fd7d2b19cf3ed68cf5
parent33503108d2f1fe1825cfc5dc3eadc15adc7e821b (diff)
downloadpylint-fc36a2c8ecb64dedabda0530ad1d05731693ee3f.tar.gz
create a console_scripts entry point to be used by easy_install, buildout and pip. Closes #103949
uniformize run interface and update licensing on the way
-rw-r--r--ChangeLog3
-rw-r--r--__init__.py34
-rwxr-xr-xbin/pylint5
-rwxr-xr-xbin/pylint-gui8
-rwxr-xr-xbin/pyreverse5
-rwxr-xr-xbin/symilar4
-rw-r--r--checkers/similar.py9
-rwxr-xr-xepylint.py24
-rw-r--r--gui.py18
-rw-r--r--pyreverse/main.py21
-rw-r--r--setup.py17
-rw-r--r--test/test_similar.py34
12 files changed, 123 insertions, 59 deletions
diff --git a/ChangeLog b/ChangeLog
index ab37974..6d6555c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,9 @@ ChangeLog for PyLint
* #103656: fix W0231 false positive for missing call to object.__init__
(patch by lothiraldan@gmail.com)
+ * #103949: create a console_scripts entry point to be used by
+ easy_install, buildout and pip
+
* fix cross-interpreter issue (non compatible access to __builtins__)
* stop including tests files in distribution, they causes crash when
diff --git a/__init__.py b/__init__.py
index 0c4bd13..dfb4386 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,3 +1,6 @@
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
@@ -10,7 +13,32 @@
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-""" Copyright (c) 2002-2008 LOGILAB S.A. (Paris, FRANCE).
-http://www.logilab.fr/ -- mailto:contact@logilab.fr
-"""
+import sys
+
+def run_pylint():
+ """run pylint"""
+ from pylint.lint import Run
+ Run(sys.argv[1:])
+
+def run_pylint_gui():
+ """run pylint-gui"""
+ try:
+ from pylint.gui import Run
+ Run(sys.argv[1:])
+ except ImportError:
+ sys.exit('tkinter is not available')
+
+def run_epylint():
+ """run pylint"""
+ from pylint.epylint import Run
+ Run()
+
+def run_pyreverse():
+ """run pyreverse"""
+ from pylint.pyreverse.main import Run
+ Run(sys.argv[1:])
+def run_symilar():
+ """run symilar"""
+ from pylint.checkers.similar import Run
+ Run(sys.argv[1:])
diff --git a/bin/pylint b/bin/pylint
index e20e031..e3e520f 100755
--- a/bin/pylint
+++ b/bin/pylint
@@ -1,4 +1,3 @@
#!/usr/bin/env python
-import sys
-from pylint import lint
-lint.Run(sys.argv[1:])
+from pylint import run_pylint
+run_pylint()
diff --git a/bin/pylint-gui b/bin/pylint-gui
index 025378f..02c6c45 100755
--- a/bin/pylint-gui
+++ b/bin/pylint-gui
@@ -1,7 +1,3 @@
#!/usr/bin/env python
-import sys
-try:
- from pylint import gui
- gui.Run(sys.argv[1:])
-except ImportError:
- sys.exit('tkinter is not available')
+from pylint import run_pylint_gui
+run_pylint_gui()
diff --git a/bin/pyreverse b/bin/pyreverse
index 7492c1f..5d06bb4 100755
--- a/bin/pyreverse
+++ b/bin/pyreverse
@@ -1,4 +1,3 @@
#!/usr/bin/python
-import sys
-from pylint.pyreverse import main
-main.Run(sys.argv[1:])
+from pylint import run_pyreverse
+run_pyreverse()
diff --git a/bin/symilar b/bin/symilar
index 7ca139f..ef94462 100755
--- a/bin/symilar
+++ b/bin/symilar
@@ -1,3 +1,3 @@
#!/usr/bin/env python
-from pylint.checkers import similar
-similar.run()
+from pylint import run_symilar
+run_symilar()
diff --git a/checkers/similar.py b/checkers/similar.py
index 1e38ed6..2907e39 100644
--- a/checkers/similar.py
+++ b/checkers/similar.py
@@ -1,5 +1,5 @@
# pylint: disable=W0622
-# Copyright (c) 2004-2006 LOGILAB S.A. (Paris, FRANCE).
+# Copyright (c) 2004-2012 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
@@ -16,8 +16,6 @@
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""a similarities / code duplication command line tool and pylint checker
"""
-from __future__ import generators
-
import sys
from itertools import izip
@@ -306,7 +304,7 @@ def usage(status=0):
[-i|--ignore-comments] file1...'
sys.exit(status)
-def run(argv=None):
+def Run(argv=None):
"""standalone command line access point"""
if argv is None:
argv = sys.argv[1:]
@@ -329,6 +327,7 @@ def run(argv=None):
for filename in args:
sim.append_stream(filename, open(filename))
sim.run()
+ sys.exit(0)
if __name__ == '__main__':
- run()
+ Run()
diff --git a/epylint.py b/epylint.py
index 780cf79..db2ed82 100755
--- a/epylint.py
+++ b/epylint.py
@@ -1,5 +1,19 @@
-#!/usr/bin/env python
# -*- coding: utf-8; mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=python:et:sw=4:ts=4:sts=4
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Emacs and Flymake compatible Pylint.
This script is for integration with emacs and is compatible with flymake mode.
@@ -91,9 +105,6 @@ def lint(filename):
process.wait()
return process.returncode
-def Run():
- sys.exit(lint(sys.argv[1]))
-
def py_run(command_options='', return_std=False, stdout=None, stderr=None,
script='epylint'):
@@ -146,6 +157,9 @@ def py_run(command_options='', return_std=False, stdout=None, stderr=None,
return (p.stdout, p.stderr)
+def Run():
+ sys.exit(lint(sys.argv[1]))
+
if __name__ == '__main__':
- lint(sys.argv[1])
+ Run()
diff --git a/gui.py b/gui.py
index 2d8e81e..f590397 100644
--- a/gui.py
+++ b/gui.py
@@ -1,3 +1,18 @@
+# Copyright (c) 2003-2012 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
"""Tkinker gui for pylint"""
import os
@@ -444,9 +459,10 @@ def Run(args):
"""launch pylint gui from args"""
if args:
print 'USAGE: pylint-gui\n launch a simple pylint gui using Tk'
- return
+ sys.exit(1)
gui = LintGui()
gui.mainloop()
+ sys.exit(0)
if __name__ == '__main__':
Run(sys.argv[1:])
diff --git a/pyreverse/main.py b/pyreverse/main.py
index da80bd6..4e4458c 100644
--- a/pyreverse/main.py
+++ b/pyreverse/main.py
@@ -1,4 +1,4 @@
-# # Copyright (c) 2000-2010 LOGILAB S.A. (Paris, FRANCE).
+# # Copyright (c) 2000-2012 LOGILAB S.A. (Paris, FRANCE).
# http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This program is free software; you can redistribute it and/or modify it under
@@ -16,7 +16,7 @@
"""
%prog [options] <packages>
- create UML diagrams for classes and modules in <packages>
+ create UML diagrams for classes and modules in <packages>
"""
import sys, os
@@ -31,7 +31,7 @@ from pylint.pyreverse.utils import insert_default_options
OPTIONS = (
("filter-mode",
dict(short='f', default='PUB_ONLY', dest='mode', type='string',
- action='store', metavar='<mode>',
+ action='store', metavar='<mode>',
help="""filter attributes and functions according to
<mode>. Correct modes are :
'PUB_ONLY' filter all non public attributes
@@ -81,10 +81,10 @@ this disables -f values")),
help="create a *.<format> output file if format available.")),
)
# FIXME : quiet mode
-#( ('quiet',
+#( ('quiet',
#dict(help='run quietly', action='store_true', short='q')), )
-class PyreverseCommand(ConfigurationMixIn):
+class Run(ConfigurationMixIn):
"""base class providing common behaviour for pyreverse commands"""
options = OPTIONS
@@ -95,13 +95,13 @@ class PyreverseCommand(ConfigurationMixIn):
self.manager = ASTNGManager()
self.register_options_provider(self.manager)
args = self.load_command_line_configuration()
- self.run(args)
+ sys.exit(self.run(args))
def run(self, args):
"""checking arguments and run project"""
if not args:
print self.help()
- return
+ return 1
# insert current working directory to the python path to recognize
# dependencies to local modules even if cwd is not in the PYTHONPATH
sys.path.insert(0, os.getcwd())
@@ -117,13 +117,8 @@ class PyreverseCommand(ConfigurationMixIn):
writer.VCGWriter(self.config).write(diadefs)
else:
writer.DotWriter(self.config).write(diadefs)
+ return 0
-class Run:
- """pyreverse main class"""
- def __init__(self, args):
- """run pyreverse"""
- PyreverseCommand(args)
-
if __name__ == '__main__':
Run(sys.argv[1:])
diff --git a/setup.py b/setup.py
index 33854b5..509e548 100644
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=W0404,W0622,W0704,W0613
-# copyright 2003-2010 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+# copyright 2003-2012 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
# contact http://www.logilab.fr/ -- mailto:contact@logilab.fr
#
# This file is part of pylint.
@@ -139,6 +139,7 @@ class MyInstallLib(install_lib.install_lib):
shutil.rmtree(dest, ignore_errors=True)
shutil.copytree(directory, dest)
+
def install(**kwargs):
"""setup entry point"""
if USE_SETUPTOOLS:
@@ -156,9 +157,17 @@ def install(**kwargs):
else:
kwargs['package_dir'] = {modname : '.'}
packages = [modname] + get_packages(os.getcwd(), modname)
- if USE_SETUPTOOLS and install_requires:
- kwargs['install_requires'] = install_requires
- kwargs['dependency_links'] = dependency_links
+ if USE_SETUPTOOLS:
+ if install_requires:
+ kwargs['install_requires'] = install_requires
+ kwargs['dependency_links'] = dependency_links
+ kwargs['entry_points'] = {'console_scripts': [
+ 'pylint = pylint:run_pylint',
+ 'pylint-gui = pylint:run_pylint_gui',
+ 'epylint = pylint:run_epylint',
+ 'pyreverse = pylint:run_pyreverse',
+ 'symilar = pylint:run_symilar',
+ ]}
kwargs['packages'] = packages
return setup(name = distname,
version = version,
diff --git a/test/test_similar.py b/test/test_similar.py
index 68aff83..91299df 100644
--- a/test/test_similar.py
+++ b/test/test_similar.py
@@ -15,8 +15,12 @@ class SimilarTC(TestCase):
def test_ignore_comments(self):
sys.stdout = StringIO()
try:
- similar.run(['--ignore-comments', SIMILAR1, SIMILAR2])
+ similar.Run(['--ignore-comments', SIMILAR1, SIMILAR2])
+ except SystemExit, ex:
+ self.assertEqual(ex.code, 0)
output = sys.stdout.getvalue()
+ else:
+ self.fail('not system exit')
finally:
sys.stdout = sys.__stdout__
self.assertMultiLineEqual(output.strip(), ("""
@@ -37,8 +41,12 @@ TOTAL lines=38 duplicates=7 percent=18.42
def test_dont_ignore_comments(self):
sys.stdout = StringIO()
try:
- similar.run([SIMILAR1, SIMILAR2])
+ similar.Run([SIMILAR1, SIMILAR2])
+ except SystemExit, ex:
+ self.assertEqual(ex.code, 0)
output = sys.stdout.getvalue()
+ else:
+ self.fail('not system exit')
finally:
sys.stdout = sys.__stdout__
self.assertMultiLineEqual(output.strip(), """
@@ -48,24 +56,22 @@ TOTAL lines=38 duplicates=0 percent=0.00
def test_help(self):
sys.stdout = StringIO()
try:
- try:
- similar.run(['--help'])
- except SystemExit, ex:
- self.assertEqual(ex.code, 0)
- else:
- self.fail()
+ similar.Run(['--help'])
+ except SystemExit, ex:
+ self.assertEqual(ex.code, 0)
+ else:
+ self.fail('not system exit')
finally:
sys.stdout = sys.__stdout__
def test_no_args(self):
sys.stdout = StringIO()
try:
- try:
- similar.run([])
- except SystemExit, ex:
- self.assertEqual(ex.code, 1)
- else:
- self.fail()
+ similar.Run([])
+ except SystemExit, ex:
+ self.assertEqual(ex.code, 1)
+ else:
+ self.fail('not system exit')
finally:
sys.stdout = sys.__stdout__