[apycotlib] update debian checkers for narval 4
authorPaul Tonelli <paul.tonelli@logilab.fr>
Fri, 18 Apr 2014 14:27:39 +0200
changeset 1481 1fd3dead3573
parent 1480 7d22bbad8323
child 1482 36756b6d7fcc
[apycotlib] update debian checkers for narval 4 - avoid name collision with existing python module "debian" - fix pylint_threshod option name (from jpl configs)
_apycotlib/checkers/apycot/debcheck.py
_apycotlib/checkers/apycot/debian.py
_apycotlib/checkers/apycot/python.py
test/unittest_checkers.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/_apycotlib/checkers/apycot/debcheck.py	Fri Apr 18 14:27:39 2014 +0200
@@ -0,0 +1,70 @@
+import apycotlib
+import logging
+import os
+import subprocess
+from checkers.apycot import BaseChecker
+
+def find_with_extension(path, extension):
+    path = os.path.expanduser(path)
+    for folder, subfolders, files in os.walk(path):
+        for filename in files:
+            if filename.endswith(extension):
+                yield os.path.join(folder, filename)
+
+class DebianLintianChecker(BaseChecker):
+    """Runs the lintian program after building a debian package. Lintian
+    checks for bugs and debian policy violations."""
+
+    id = 'lintian'
+
+    checked_extensions = ('.changes',)
+    options_def = {
+        'changes-files': {
+            'type': 'csv',
+            'required': False,
+            'help': 'changes files to check',
+        },
+    }
+    def get_output(self, path):
+        cmd = subprocess.Popen(['lintian', '-I', '--suppress-tags',
+                                'bad-distribution-in-changes-file', path],
+                               stdout=subprocess.PIPE,
+                               stdin=open('/dev/null'),
+                               stderr=subprocess.STDOUT)
+        for line in cmd.stdout:
+            yield line
+        cmd.wait()
+
+    def do_check(self, test):
+        status = apycotlib.SUCCESS
+        changes_files = self.options.get('changes-files')
+        if not changes_files:
+            build_folder = os.path.join(test.project_path(), os.pardir)
+            changes_files = find_with_extension(build_folder, '.changes')
+        if not changes_files:
+            status = apycotlib.NODATA
+        for f in changes_files:
+            iter_line = self.get_output(f)
+            for line in iter_line:
+                line_parts = line.split(':', 1)
+                try:
+                    mtype, msg = line_parts
+                except ValueError:
+                    self.writer.fatal('unexpected line %r' % line, path=f)
+                    for line in iter_line:
+                        self.writer.info('followed by: %r' % line, path=f)
+                    return apycotlib.ERROR
+                else:
+                    if mtype == 'I':
+                        self.writer.info(msg, path=f)
+                    elif mtype == 'W':
+                        self.writer.warning(msg, path=f)
+                    elif mtype == 'E':
+                        self.writer.error(msg, path=f)
+                        status = apycotlib.FAILURE
+                    else:
+                        self.writer.info(msg, path=f)
+        return status
+
+apycotlib.register('checker', DebianLintianChecker)
+
--- a/_apycotlib/checkers/apycot/debian.py	Tue Apr 01 16:14:34 2014 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-import apycotlib
-import logging
-import os
-import subprocess
-from checkers.apycot import BaseChecker
-
-def find_with_extension(path, extension):
-    path = os.path.expanduser(path)
-    for folder, subfolders, files in os.walk(path):
-        for filename in files:
-            if filename.endswith(extension):
-                yield os.path.join(folder, filename)
-
-class DebianLintianChecker(BaseChecker):
-    """Runs the lintian program after building a debian package. Lintian
-    checks for bugs and debian policy violations."""
-
-    id = 'lintian'
-
-    checked_extensions = ('.changes',)
-    options_def = {
-        'changes-files': {
-            'type': 'csv',
-            'required': False,
-            'help': 'changes files to check',
-        },
-    }
-
-    def get_output(self, path):
-        cmd = subprocess.Popen(['lintian', '-I', '--suppress-tags',
-                                'bad-distribution-in-changes-file', path],
-                               stdout=subprocess.PIPE, stdin=open('/dev/null'),
-                               stderr=subprocess.STDOUT)
-        for line in cmd.stdout:
-            yield line
-        cmd.wait()
-
-    def do_check(self, test):
-        status = apycotlib.SUCCESS
-        build_folder = os.path.join(test.project_path(), os.pardir)
-        change_files = find_with_extension(build_folder, '.changes')
-        if not change_files:
-            status = apycotlib.NODATA
-        for f in change_files:
-            iter_line = self.get_output(f)
-            for line in iter_line:
-                line_parts = line.split(':', 1)
-                try:
-                    mtype, msg = line_parts
-                except ValueError:
-                    self.writer.fatal('unexpected line %r' % line, path=f)
-                    for line in iter_line:
-                        self.writer.info('followed by: %r' % line, path=f)
-                    return apycotlib.ERROR
-                else:
-                    if mtype == 'I':
-                        self.writer.info(msg, path=f)
-                    elif mtype == 'W':
-                        self.writer.warning(msg, path=f)
-                    elif mtype == 'E':
-                        self.writer.error(msg, path=f)
-                        status = apycotlib.FAILURE
-                    else:
-                        self.writer.info(msg, path=f)
-        return status
-
-apycotlib.register('checker', DebianLintianChecker)
-
--- a/_apycotlib/checkers/apycot/python.py	Tue Apr 01 16:14:34 2014 +0200
+++ b/_apycotlib/checkers/apycot/python.py	Fri Apr 18 14:27:39 2014 +0200
@@ -456,7 +456,7 @@
         'pylintrc': {
             'help': ('path to a pylint configuration file.'),
             },
-        'pylint.threshold': {
+        'pylint_threshold': {
             'type': 'int', 'default': 7,
             'help': ('integer between 1 and 10 telling expected pylint note to '
                      'pass this check. Default to 7.'),
@@ -582,7 +582,7 @@
     """
     id = 'pycoverage'
     options_def = {
-        'coverage_threshold': {
+        'pycoverage_threshold': {
             'type': 'int', 'default': 80,
             'help': ('integer between 1 and 100 telling expected percent coverage '
                      'to pass this check. Default to 80.\n'
@@ -602,7 +602,7 @@
 
     def do_check(self, test):
         """run the checker against <path> (usually a directory)"""
-        self.threshold = float(self.options.get('coverage_threshold')) / 100
+        self.threshold = float(self.options.get('pycoverage_threshold')) / 100
         coverage_data = self.options.get('coverage_data')
         if coverage_data == None or not exists(coverage_data):
             self.writer.fatal('no coverage information', path=coverage_data)
--- a/test/unittest_checkers.py	Tue Apr 01 16:14:34 2014 +0200
+++ b/test/unittest_checkers.py	Fri Apr 18 14:27:39 2014 +0200
@@ -16,6 +16,7 @@
 
 from apycotlib import SUCCESS, FAILURE, PARTIAL, NODATA, ERROR
 from checkers.apycot.python import *
+from checkers.apycot.debcheck import *
 
 WRITER = MockCheckWriter()
 
@@ -68,7 +69,6 @@
             msg.append('last messages:')
             msg.extend(WRITER._logs[-5:])
             msg = '\n'.join(msg)
-
             self.failUnlessEqual(status, expected, msg)#+'\n-----\n'+WRITER.stderr.getvalue())
 
     def chks_test_file_success(self):
@@ -236,10 +236,10 @@
 
         pycoverage = PyCoverageChecker(WRITER, {'coverage_data': osp.join(datadir, 'data/unknown')})
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_nodata'))
-        pycoverage = PyCoverageChecker(WRITER, {'coverage_threshold': 80,
+        pycoverage = PyCoverageChecker(WRITER, {'pycoverage_threshold': 80,
                                                 'coverage_data': goodfile})
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_failure'))
-        pycoverage = PyCoverageChecker(WRITER, {'coverage_threshold': 0,
+        pycoverage = PyCoverageChecker(WRITER, {'pycoverage_threshold': 0,
                                                 'coverage_data': goodfile})
         addTest(ModuleCheckerTest(pycoverage, ['goodpkg'], 'chks_test_success'))
 
@@ -248,7 +248,7 @@
     addTest(ModuleCheckerTest(pylint, ['pylint_ok.py'], 'chks_test_success'))
     addTest(ModuleCheckerTest(pylint, ['pylint_bad.py'], 'chks_test_failure'))
 
-    pylint_rc = PyLintChecker(WRITER, {'pylint.threshold': 7,
+    pylint_rc = PyLintChecker(WRITER, {'pylint_threshold': 7,
                                        'pylintrc':input_path("pylintrc"),
                                        "pylint.show_categories": "F,E,W,C"})
     addTest(ModuleCheckerTest(pylint_rc, ['pylint_bad.py'], 'chks_test_success'))