[chirp_devel] [PATCH 04/11] Fix pylint issues in cpep8.py (#159)

Zachary T Welch
Sun Mar 8 16:54:18 PDT 2015


# HG changeset patch
# User Zachary T Welch <zach at mandolincreekfarm.com>
# Fake Node ID 04619dcb09caa0274af44c54709234c74f3497bc

Fix pylint issues in cpep8.py (#159)


diff --git a/tools/cpep8.lintful b/tools/cpep8.lintful
index efb64b6..c3a2ebe 100644
--- a/tools/cpep8.lintful
+++ b/tools/cpep8.lintful
@@ -144,5 +144,4 @@
 ./tests/unit/test_settings.py
 ./tests/unit/test_shiftdialog.py
 ./tools/bitdiff.py
-./tools/cpep8.py
 ./tools/img2thd72.py
diff --git a/tools/cpep8.py b/tools/cpep8.py
index 655a17f..6973d8c 100755
--- a/tools/cpep8.py
+++ b/tools/cpep8.py
@@ -17,9 +17,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
+"""
+Checks CHIRP source code with pep8 and pylint.
+"""
+
 import os
 import sys
-import logging
 import argparse
 from pylint import lint, reporters
 from pylint.reporters import text
@@ -52,10 +55,10 @@ args = parser.parse_args()
 
 
 def file_to_lines(name):
-    fh = file(name, "r")
-    lines = fh.read().split("\n")
+    """Read a file and return the lines split into a list."""
+    with file(name, "r") as cfh:
+        lines = cfh.read().split("\n")
     lines.pop()
-    fh.close()
     return lines
 
 
@@ -92,9 +95,10 @@ if not args.strict:
         exceptions[filename] = codes
 
 
-def get_exceptions(f):
+def get_exceptions(name):
+    """Returns the list of exceptions for the given file name."""
     try:
-        ignore = exceptions[f]
+        ignore = exceptions[name]
     except KeyError:
         ignore = None
     return ignore




More information about the chirp_devel mailing list