#! /usr/bin/env python """ Takes WAM_Result objects from the BWAM assessments and wraps them in a pretty data-structure. """ # Copyright 2008-2010 eGovMon # This program is distributed under the terms of the GNU General # Public License. # # This file is part of the eGovernment Monitoring # (eGovMon) # # eGovMon 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. # # eGovMon 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 eGovMon; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, # MA 02110-1301 USA __author__ = "Christian Amble" __updated__ = "$LastChangedDate$" __version__ = "$Id: $" from WAM_Results import * import version import urllib class Report: """ Class for generating datastructure from WAM_Results objects. """ def __init__(self): self.reports = {} def testSubject(self, *args, **kargs): pass def assertor(self, wamid, wamname, description, version): pass def assertion(self, bresult,codeExtracts=0): id = bresult.earlRequirementId() try: self.reports[id] except: self.reports[id] = [] struc = {} struc["type"] = "assertion" struc["line"] = bresult.eiaoLine() struc["column"] = bresult.eiaoColumn() struc["mode"] = bresult.earlMode().split("#")[1] struc["result"] = float(bresult.result) if codeExtracts: struc["xhtml"] = bresult.xhtml if bresult.mode == HEURISTIC: struc["resultProb"] = float(bresult.prob) if bresult.message: struc["message"] = bresult.earlMessage() self.reports[id].append(struc) def metaData(self, bresult): id = bresult.earlRequirementId() try: self.reports[id] except: self.reports[id] = [] struc = {} struc["type"] = "metadata" struc["line"] = bresult.eiaoLine() struc["column"] = bresult.eiaoColumn() struc["what"] = bresult.eiaoType().split("#")[1] struc["value"] = bresult.eiaoValue() self.reports[id].append(struc) def getReport(self): return self.reports