<s> from base import * <EOL> from bucket import * <EOL> from distribution import * <EOL> class StatGroup ( Stat ) : <EOL> def __init__ ( self ) : <EOL> Stat . __init__ ( self ) <EOL> self . _stats = [ ] <EOL> def _AddStat ( self , stat ) : <EOL> self . _stats . append ( stat ) <EOL> def ProcessMessageInfos ( self , message_infos , threads ) : <EOL> for stat in self . _stats : <EOL> if stat : <EOL> stat . ProcessMessageInfos ( message_infos , threads ) <EOL> class StatCollection ( StatGroup ) : <EOL> def __init__ ( self , title ) : <EOL> StatGroup . __init__ ( self ) <EOL> self . title = title <EOL> self . __stat_titles = [ ] <EOL> def _AddStatRef ( self , stat , title ) : <EOL> self . _AddStat ( stat ) <EOL> self . __stat_titles . append ( title ) <EOL> def _AddStatDivider ( self ) : <EOL> self . _AddStat ( None ) <EOL> self . __stat_titles . append ( None ) <EOL> def GetHtml ( self ) : <EOL> all_empty = True <EOL> for stat in self . _stats : <EOL> if not stat . IsEmpty ( ) : <EOL> all_empty = False <EOL> break <EOL> if all_empty : return "<STR_LIT>" <EOL> t = Template ( <EOL> file = "<STR_LIT>" , <EOL> searchList = { <EOL> "<STR_LIT>" : self , <EOL> "<STR_LIT>" : self . _stats , <EOL> "<STR_LIT>" : self . __stat_titles <EOL> } ) <EOL> return unicode ( t ) <EOL> class MonthStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> for year in GetYearRange ( date_range ) : <EOL> self . _AddStatRef ( MonthStat ( year ) , "<STR_LIT:%s>" % year ) <EOL> class DayStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> start , end = [ time . localtime ( d ) for d in date_range ] <EOL> for year in range ( start . tm_year , end . tm_year + <NUM_LIT:1> ) : <EOL> for month in range ( <NUM_LIT:1> , <NUM_LIT> ) : <EOL> if year == start . tm_year and month < start . tm_mon : continue <EOL> if year == end . tm_year and month > end . tm_mon : continue <EOL> if month == <NUM_LIT:1> and year != start . tm_year : self . _AddStatDivider ( ) <EOL> self . _AddStatRef ( <EOL> DayStat ( year , month ) , <EOL> "<STR_LIT>" % ( year , MONTH_NAMES [ month - <NUM_LIT:1> ] ) ) <EOL> class SenderDistributionStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> for year in GetYearRange ( date_range ) : <EOL> self . _AddStatRef ( SenderDistribution ( year ) , "<STR_LIT:%s>" % year ) <EOL> class RecipientDistributionStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> for year in GetYearRange ( date_range ) : <EOL> self . _AddStatRef ( RecipientDistribution ( year ) , "<STR_LIT:%s>" % year ) <EOL> class ListDistributionStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> for year in GetYearRange ( date_range ) : <EOL> self . _AddStatRef ( ListDistribution ( year ) , "<STR_LIT:%s>" % year ) <EOL> class MeRecipientDistributionStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> for year in GetYearRange ( date_range ) : <EOL> self . _AddStatRef ( MeRecipientDistribution ( year ) , "<STR_LIT:%s>" % year ) <EOL> class MeSenderDistributionStatCollection ( StatCollection ) : <EOL> def __init__ ( self , date_range ) : <EOL> StatCollection . __init__ ( self , "<STR_LIT>" ) <EOL> for year in GetYearRange ( date_range ) : <EOL> self . _AddStatRef ( MeSenderDistribution ( year ) , "<STR_LIT:%s>" % year ) <EOL> class StatColumnGroup ( StatGroup ) : <EOL> def __init__ ( self , * args ) : <EOL> StatGroup . __init__ ( self ) <EOL> for stat in args : <EOL> self . _AddStat ( stat ) <EOL> def GetHtml ( self ) : <EOL> t = Template ( <EOL> file = "<STR_LIT>" , <EOL> searchList = { "<STR_LIT>" : self . _stats } ) <EOL> return unicode ( t ) <EOL> class StatTabGroup ( StatGroup ) : <EOL> def __init__ ( self , * tabs ) : <EOL> StatGroup . __init__ ( self ) <EOL> self . __tabs = [ ] <EOL> for tab in tabs : <EOL> title = tab [ <NUM_LIT:0> ] <EOL> stats = tab [ <NUM_LIT:1> : ] <EOL> for stat in stats : <EOL> self . _AddStat ( stat ) <EOL> self . __tabs . append ( StatTab ( title , stats ) ) <EOL> def GetHtml ( self ) : <EOL> t = Template ( <EOL> file = "<STR_LIT>" , <EOL> searchList = { <EOL> "<STR_LIT:id>" : self . id , <EOL> "<STR_LIT>" : self . __tabs , <EOL> } ) <EOL> return unicode ( t ) <EOL> class StatTab ( object ) : <EOL> _IdIndex = <NUM_LIT:0> <EOL> def __init__ ( self , title , stats ) : <EOL> self . title = title <EOL> self . stats = stats <EOL> self . id = "<STR_LIT>" % StatTab . _IdIndex <EOL> StatTab . _IdIndex += <NUM_LIT:1> </s>
