Link:
http://rakesh.fedorapeople.org/misc/0001--RomReporter.py-New-file.patch
--
rakesh
From 6c4836def543c13774fb29b0974262d474280332 Mon Sep 17 00:00:00 2001
From: Rakesh Pandit <rakesh(a)fedoraproject.org>
Date: Tue, 23 Dec 2008 21:40:21 +0530
Subject: [PATCH] * RomReporter.py: New file.
---
RomReporter.py | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 112 insertions(+), 0 deletions(-)
create mode 100644 RomReporter.py
diff --git a/RomReporter.py b/RomReporter.py
new file mode 100644
index 0000000..f9dfb31
--- /dev/null
+++ b/RomReporter.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python
+#
+# Copyright 2008 Rakesh Pandit <rakesh(a)fedoraproject.org>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with translate; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+class RomReporter(object):
+ """
+ Reporter interface. Part of functionality to be implemented by
+ derived classes.
+ """
+
+ def __new__(cls, *args, **kwargs):
+ """
+ Make reporter singleton class.
+ """
+ if '_one_inst' not in vars(cls):
+ cls._one_inst = object.__new__(cls, *args, **kwargs)
+ return cls._one_inst
+
+ def __init__(self):
+ """
+ """
+ self.report = ""
+
+ def getReport(self):
+ """
+ Return report.
+ """
+ return self.report
+
+ def __print(self, type, reason, details):
+ """
+ type: Type of message e.g, M, S, E, W etc
+ spec: Spec object
+ reason: Main message
+ details: dictionary for other arguments if any
+ """
+ line_num = None
+
+ if 'spec' in details.keys():
+ spec = details['spec']
+ if spec.getLineNum() is not None:
+ line_num = "%s:" % spec.getLineNum()
+
+ if 'spec' in details.keys():
+ spec = details['spec']
+ self.report += "%s:%s %s: %s" % (spec.getSpecname(),
line_num, type, reason)
+ else:
+ self.report += "%s: %s" % (type, reason)
+
+ for d in details:
+ self.report += " %s" %d
+
+ self.report +="\n"
+
+ def printInfo(self, reason, **details):
+ """
+ spec: Spec object
+ reason: message
+ details: additional messages
+ """
+ # I => Info
+ self.__print("I", reason, details)
+
+
+ def printMust(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # M => Must
+ self.__print("M", reason, details)
+
+
+ def printShould(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # S => Should
+ self.__print("S", reason, details)
+
+
+ def printError(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # E => Error
+ self.__print("E", reason, details)
+
+
+ def printWarning(self, reason, **details):
+ """
+ Same as printInfo.
+ """
+ # W => Warning
+ self.__print("W", reason, details)
+
+
+# Abstract reporter interface ends here
--
1.6.0.6
Comments ?