Package inca :: Module UsageReporter :: Class UsageReporter
[hide private]
[frames] | no frames]

Class UsageReporter

source code

Reporter.Reporter --+
                    |
                   UsageReporter

Usage - Module for creating simple usage reports:

 from inca.UsageReporter import UsageReporter
 reporter = new UsageReporter(
   name = 'My Reporter',
   version = 0.1,
   description = 'What my reporter does',
   url = 'http://some.where/'
 )

This module is a subclass of inca.Reporter that provides a simple schema for reporting usage data. The reporter will return the following body if the reporter is successful:

 <usage>
   <entry>
     <type>type1</type>
     <name>foo</name>
     <statistics>
       <statistic>
         <name>count</name>
         <value>9</value>
       </statistic>
     </statistics>
   </entry>
   <entry>

   .
   .
   .

 </usage>
Instance Methods [hide private]
 
__init__(self, **attributes)
Class constructor that returns a new Usage object.
source code
 
addEntry(self, entry)
This method is used to add an entry to the usage report.
source code
 
fail(self, error_msg)
This method is used to indicate that the reporter failed.
source code
 
getEntries(self)
Returns a list of all entries that have been added to the reporter.
source code
 
reportBody(self)
Constructs the body and returns it.
source code
 
success(self)
This method is called to indicate that the reporter has succeeded.
source code
 
_reportStatistics(self, stats) source code
 
_reportEntry(self, entry) source code

Inherited from Reporter.Reporter: __del__, addArg, addDependency, argValue, argValues, compiledProgramOutput, compiledProgramStatusOutput, failPrintAndExit, getBody, getCompleted, getCwd, getDescription, getFailMessage, getName, getUrl, getVersion, log, loggedCommandOutput, loggedCommandStatusOutput, printReport, processArgv, report, setBody, setCompleted, setCwd, setDescription, setFailMessage, setName, setResult, setUrl, setVersion, tempFile, xmlElement

Method Details [hide private]

__init__(self, **attributes)
(Constructor)

source code 

Class constructor that returns a new Usage object. The constructor accepts the parameters supported by inca.Reporter.

Overrides: Reporter.Reporter.__init__

addEntry(self, entry)

source code 

This method is used to add an entry to the usage report. It takes a dict containing the type and name of the entry as well as a dict of statistics. For example:

 addEntry({
   'type' : 'foo',
   'name' : 'bar',
   'stats' : {
     'count' : 1,
     'blort' : 'baz'
   }
 })

Will create an entry of type 'foo', with a name of 'bar' and two statistics, count with a value of 1 and 'blort' with a value of 'baz'.

fail(self, error_msg)

source code 

This method is used to indicate that the reporter failed. It takes a single arguement which is the error message which will be returned.

reportBody(self)

source code 

Constructs the body and returns it.

Overrides: Reporter.Reporter.reportBody