public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit-dev commit in: src/ekeyword/
Date: Thu, 16 Feb 2017 07:25:34 +0000 (UTC)	[thread overview]
Message-ID: <1487229875.aa32986eecd93ed87cbdb347c3ee4f943f397510.vapier@gentoo> (raw)

commit:     aa32986eecd93ed87cbdb347c3ee4f943f397510
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 16 07:24:35 2017 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> 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 <vapier@gentoo.org>
 
+# 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:]))


             reply	other threads:[~2017-02-16  7:25 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-16  7:25 Mike Frysinger [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-03-08  0:16 [gentoo-commits] proj/gentoolkit:gentoolkit-dev commit in: src/ekeyword/ Mike Frysinger
2017-03-08  0:16 Mike Frysinger
2017-02-18  5:24 Mike Frysinger
2017-02-16  7:25 Mike Frysinger
2016-01-27 23:35 Mike Frysinger
2016-01-27 23:35 Mike Frysinger
2015-04-04 21:26 Mike Frysinger
2015-04-04 21:26 Mike Frysinger
2015-04-04 21:26 Mike Frysinger
2014-11-18 18:24 Mike Gilbert
2014-11-13 22:51 Mike Frysinger
2014-01-27 23:14 Mike Frysinger
2014-01-25 22:00 Mike Frysinger
2014-01-25 22:00 Mike Frysinger
2014-01-25 22:00 Mike Frysinger
2014-01-20 16:29 Mike Frysinger
2014-01-20  6:17 Mike Frysinger
2012-04-23  3:02 Christian Ruppert
2012-04-23  3:02 Christian Ruppert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1487229875.aa32986eecd93ed87cbdb347c3ee4f943f397510.vapier@gentoo \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox