From 359da472023bac5eefcfbf491bf5819d988bf943 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Fri, 3 Jul 2009 15:07:50 +0530
Subject: [PATCH] * BuildRootCheck.py, GachReporter.py,
SampleCheck.py: Adjustment in
accordance with GachReporter. Changed Filter and ReviewSpec module
usage with GachReporter to make existing test and sample test working.
---
BuildRootCheck.py | 18 +++++++++---------
GachReporter.py | 24 ++++++++++++++++++++++++
SampleCheck.py | 11 ++++++-----
3 files changed, 39 insertions(+), 14 deletions(-)
diff --git a/BuildRootCheck.py b/BuildRootCheck.py
index e63a95e..4a6b8a9 100644
--- a/BuildRootCheck.py
+++ b/BuildRootCheck.py
@@ -20,8 +20,8 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import SpecCheck
-import ReviewSpec
-from Filter import *
+from GachReporter import GachReporter
+
import re
# Allowed expressions for the buildroot tag by Fedora:
@@ -34,6 +34,7 @@ buildroot_regex = re.compile(r"""
""", re.VERBOSE)
prep_regex = re.compile(r"^[ \t]*%{?prep}?")
+reporter = GachReporter()
class BuildRootCheck(SpecCheck.SpecCheck):
"""Check the buildroot tag of the spec file to see if it matches
the guidelines."""
@@ -45,7 +46,7 @@ class BuildRootCheck(SpecCheck.SpecCheck):
def check(self, spec):
"""Buildroot Check"""
# Parse the spec file and get the buildroot(s)
- #printInfo(spec, "buildroot-check")
+ #reporter.printInfo(spec, "buildroot-check")
file=open(spec.filename, "r")
result = file.readlines()
file.close()
@@ -58,24 +59,23 @@ class BuildRootCheck(SpecCheck.SpecCheck):
buildroot = buildroot_tag_separator.split(i)[1]
if number_of_specified_buildroots > 1:
- printError(spec, "multiple-buildroots")
+ reporter.printError(spec, "multiple-buildroots")
return
elif number_of_specified_buildroots == 0:
- printError(spec, "no-buildroot")
+ reporter.printError(spec, "no-buildroot")
return
if buildroot_regex.match(buildroot):
- printInfo(spec, "buildroot-check", "passed")
+ reporter.printInfo(spec, "buildroot-check", "passed")
else:
- printError(spec, "bad-buildroot", buildroot)
+ reporter.printError(spec, "bad-buildroot", buildroot)
# An object to autoregister the check
check=BuildRootCheck()
-if ReviewSpec.info:
- addDetails(
+reporter.addDetails(
'buildroot-check',
'''Check the buildroot tag of the spec file to see if it matches the
guidelines.\n
It needs to be one of these three:\n
diff --git a/GachReporter.py b/GachReporter.py
index 87cad4e..68dc50d 100644
--- a/GachReporter.py
+++ b/GachReporter.py
@@ -35,6 +35,30 @@ class GachReporter(object):
"""
"""
self.report = ""
+ self._details = {}
+ self.info = True
+
+ def addDetails(self, *details):
+ """Add test info details
+ """
+ for idx in range(len(details)/2):
+ self._details[details[idx*2]] = details[idx*2+1]
+
+ def setVerbose(self, value):
+ """Set verbose
+ """
+ self.info = value
+
+ def _printDescriptions(self, reason):
+ """Just for debugging
+ """
+ try:
+ d = self._details[reason]
+ if d and d != '' and d != "\n":
+ sys.stdout.write(fill(d, 78))
+ sys.stdout.write("\n\n")
+ except KeyError:
+ pass
def getReport(self):
"""
diff --git a/SampleCheck.py b/SampleCheck.py
index 78307a5..ddf0f61 100644
--- a/SampleCheck.py
+++ b/SampleCheck.py
@@ -17,8 +17,10 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import SpecCheck
-import ReviewSpec
-from Filter import *
+from GachReporter import GachReporter
+
+
+reporter = GachReporter()
class SampleCheck(SpecCheck.SpecCheck):
@@ -30,13 +32,12 @@ class SampleCheck(SpecCheck.SpecCheck):
def check(self, spec):
"""Sample Check"""
- printInfo(spec, "sample-testing")
+ reporter.printInfo(spec, "sample-testing")
# An object to autoregister the check
check=SampleCheck()
-if ReviewSpec.info:
- addDetails(
+reporter.addDetails(
'sample-testing',
'''The is a sample check''')
--
1.6.2.2