aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ekeyword/.pylintrc37
-rwxr-xr-xsrc/ekeyword/ekeyword.py15
-rwxr-xr-xsrc/ekeyword/ekeyword_unittest.py2
-rwxr-xr-xsrc/ekeyword/pylint49
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:]))