From 61df135beb9d45620d8e42185362dcab2ec16f85 Mon Sep 17 00:00:00 2001 From: Danilo Horta Date: Sat, 23 Apr 2016 14:46:09 +0100 Subject: [PATCH] permit the user to specify module's name together with the file path --- pylint/lint.py | 20 +++++++++----------- pylint/utils.py | 9 +++++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pylint/lint.py b/pylint/lint.py index a298c5b124..8fd8fb0f18 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -13,17 +13,9 @@ # 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., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -""" %prog [options] module_or_package +"""%prog [options] path - Check that a module satisfies a coding standard (and more !). - - %prog --help - - Display this help message and exit. - - %prog --help-msg [,] - - Display help messages about given message identifiers and exit. +Check python code for coding standard, static error, and coding style. """ from __future__ import print_function @@ -54,6 +46,12 @@ MANAGER = astroid.MANAGER +USAGE = __doc__ + """ +Argument: + path Package name, full module name, file path, or full + module name alongside with the file path separated + by the system-specific search path delimiter (e.g. + module.name{0}/path/to/file.py.)""".format(os.pathsep) def _get_new_args(message): @@ -452,7 +450,7 @@ def __init__(self, options=(), reporter=None, option_groups=(), utils.MessagesHandlerMixIn.__init__(self) utils.ReportsHandlerMixIn.__init__(self) super(PyLinter, self).__init__( - usage=__doc__, + usage=USAGE, version=full_version, config_file=pylintrc or config.PYLINTRC) checkers.BaseTokenChecker.__init__(self) diff --git a/pylint/utils.py b/pylint/utils.py index 3bf37700a1..adab5272be 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -718,7 +718,6 @@ def list_messages(self): print(msg.format_help(checkerref=False)) print("") - class ReportsHandlerMixIn(object): """a mix-in class containing all the reports and stats manipulation related methods for the main lint class @@ -805,7 +804,11 @@ def _basename_in_blacklist_re(base_name, black_list_re): def expand_modules(files_or_modules, black_list, black_list_re): """take a list of files/modules/packages and return the list of tuple - (file, module name) which have to be actually checked + (file, module name) which have to be actually checked. + + You might also provide the full module name alongside with the + file to be checked. Ex.: package.module.name:/path/to/file.py. + This prevent us from guessing the module name from the file path. """ result = [] errors = [] @@ -820,6 +823,8 @@ def expand_modules(files_or_modules, black_list, black_list_re): filepath = join(something, '__init__.py') else: filepath = something + elif os.pathsep in something: + modname, filepath = something.split(os.pathsep) else: # suppose it's a module or package modname = something