From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id BB1FD139694 for ; Thu, 16 Feb 2017 07:25:42 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 2E46BE0D52; Thu, 16 Feb 2017 07:25:42 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id F1DAAE0D52 for ; Thu, 16 Feb 2017 07:25:36 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 24AAC341265 for ; Thu, 16 Feb 2017 07:25:36 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id BB2A14992 for ; Thu, 16 Feb 2017 07:25:34 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1487229875.aa32986eecd93ed87cbdb347c3ee4f943f397510.vapier@gentoo> Subject: [gentoo-commits] proj/gentoolkit:gentoolkit-dev commit in: src/ekeyword/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: src/ekeyword/.pylintrc src/ekeyword/ekeyword.py src/ekeyword/ekeyword_unittest.py src/ekeyword/pylint X-VCS-Directories: src/ekeyword/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: aa32986eecd93ed87cbdb347c3ee4f943f397510 X-VCS-Branch: gentoolkit-dev Date: Thu, 16 Feb 2017 07:25:34 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: d114bab1-a451-48b1-ba72-eafabdbe6acd X-Archives-Hash: e0d58fd72f5615800db4cf381dce675f commit: aa32986eecd93ed87cbdb347c3ee4f943f397510 Author: Mike Frysinger gentoo org> AuthorDate: Thu Feb 16 07:24:35 2017 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Thu Feb 16 07:24:35 2017 +0000 URL: https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=aa32986e ekeyword: add a linter helper src/ekeyword/.pylintrc | 37 +++++++++++++++++++++++++++++ src/ekeyword/ekeyword.py | 15 ++++++++---- src/ekeyword/ekeyword_unittest.py | 2 ++ src/ekeyword/pylint | 49 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+), 4 deletions(-) diff --git a/src/ekeyword/.pylintrc b/src/ekeyword/.pylintrc new file mode 100644 index 0000000..6a040d8 --- /dev/null +++ b/src/ekeyword/.pylintrc @@ -0,0 +1,37 @@ +[MESSAGES CONTROL] +# Disable the message, report, category or checker with the given id(s). You +# can either give multiple identifier separated by comma (,) or put this option +# multiple times (only on the command line, not in the configuration file where +# it should appear only once). +disable= + missing-docstring, + too-many-lines, + too-many-branches, + too-many-statements, + too-few-public-methods, + too-many-instance-attributes, + too-many-public-methods, + too-many-locals, + too-many-arguments, + locally-enabled, + locally-disabled, + fixme, + bad-whitespace, + bad-continuation, + invalid-name, + +[REPORTS] +reports=no + +[FORMAT] +max-line-length=80 +indent-string='\t' + +[SIMILARITIES] +min-similarity-lines=20 + +[VARIABLES] +dummy-variables-rgx=_ + +[DESIGN] +max-parents=10 diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py index a36dcd3..56e284b 100755 --- a/src/ekeyword/ekeyword.py +++ b/src/ekeyword/ekeyword.py @@ -179,7 +179,7 @@ def process_keywords(keywords, ops, arch_status=None): # Process all possible keywords. We use the arch_status as a # master list. If it lacks some keywords, then we might miss # somethings here, but not much we can do. - arches = old_arches + arches = list(old_arches) # We ignore the glob arch as we never want to tweak it. if '*' in arches: @@ -192,7 +192,7 @@ def process_keywords(keywords, ops, arch_status=None): # in these cases. arches = [x for x in arches if '-' + x not in new_keywords] else: - arches = (oarch,) + arches = [oarch] if refarch: # Figure out the state for this arch based on the reference arch. @@ -319,6 +319,13 @@ def process_ebuild(ebuild, ops, arch_status=None, verbose=0, quiet=0, return updated +def portage_settings(): + """Return the portage settings we care about.""" + # Portage creates the db member on the fly which confuses the linter. + # pylint: disable=no-member + return portage.db['/']['vartree'].settings + + def load_profile_data(portdir=None, repo='gentoo'): """Load the list of known arches from the tree @@ -331,7 +338,7 @@ def load_profile_data(portdir=None, repo='gentoo'): {'x86': 'stable', 'mips': 'dev', ...} """ if portdir is None: - portdir = portage.db['/']['vartree'].settings.repositories[repo].location + portdir = portage_settings().repositories[repo].location arch_status = {} @@ -497,7 +504,7 @@ def main(argv): parser.error('need arches/ebuilds to process') if opts.style == 'auto': - if not portage.db['/']['vartree'].settings.get('NOCOLOR', 'false').lower() in ('no', 'false'): + if not portage_settings().get('NOCOLOR', 'false').lower() in ('no', 'false'): nocolor() opts.style = 'short' else: diff --git a/src/ekeyword/ekeyword_unittest.py b/src/ekeyword/ekeyword_unittest.py index 7b9017e..be84cc1 100755 --- a/src/ekeyword/ekeyword_unittest.py +++ b/src/ekeyword/ekeyword_unittest.py @@ -3,6 +3,8 @@ # Distributed under the terms of the GNU General Public License v2 # Written by Mike Frysinger +# pylint: disable=no-self-use + """Unittests for ekeyword""" import os diff --git a/src/ekeyword/pylint b/src/ekeyword/pylint new file mode 100755 index 0000000..3a9a368 --- /dev/null +++ b/src/ekeyword/pylint @@ -0,0 +1,49 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- +# Copyright 1999-2017 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +"""Run pylint with the right settings.""" + +from __future__ import print_function + +import os +import sys + + +def find_all_modules(source_root): + """Locate all python modules in the tree for scanning""" + ret = [] + + for root, _dirs, files in os.walk(source_root, topdown=False): + # Add all of the .py modules in the tree. + ret += [os.path.join(root, x) for x in files if x.endswith('.py')] + + # Add the main scripts that don't end in .py. + ret += [os.path.join(source_root, x) for x in ('pylint',)] + + return ret + + +def main(argv): + """The main entry point""" + source_root = os.path.dirname(os.path.realpath(__file__)) + + if not argv: + argv = find_all_modules(source_root) + + pympath = source_root + pythonpath = os.environ.get('PYTHONPATH') + if pythonpath is None: + pythonpath = pympath + else: + pythonpath = pympath + ':' + pythonpath + os.environ['PYTHONPATH'] = pythonpath + + pylintrc = os.path.join(source_root, '.pylintrc') + cmd = ['pylint', '--rcfile', pylintrc] + os.execvp(cmd[0], cmd + argv) + + +if __name__ == '__main__': + sys.exit(main(sys.argv[1:]))