Changeset 2285

Show
Ignore:
Timestamp:
06/08/05 08:45:46 (19 years ago)
Author:
jerome
Message:

More work done on the --sum command line option, still not finished though...

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/pykota/dumper.py

    r2266 r2285  
    9797            raise PyKotaToolError, _("XML output is disabled because the jaxml module is not available.") 
    9898             
     99        if options["sum"] and datatype not in ("payments", "history") :  
     100            raise PyKotaToolError, _("Invalid datatype [%s] for --sum command line option, see help.") % datatype 
     101             
    99102        entries = getattr(self.storage, "extract%s" % datatype.title())(extractonly) 
    100103        if entries : 
     
    106109                mustclose = 1 
    107110                 
    108             retcode = getattr(self, "dump%s" % format.title())(entries, datatype) 
     111            retcode = getattr(self, "dump%s" % format.title())(self.summarizeDatas(entries, datatype, options["sum"]), datatype) 
    109112             
    110113            if mustclose : 
     
    114117        return 0 
    115118         
     119    def summarizeDatas(self, entries, datatype, sum=0) :     
     120        """Transforms the datas into a summarized view (with totals). 
     121         
     122           If sum is false, returns the entries unchanged. 
     123        """    
     124        if not sum : 
     125            return entries 
     126        else :     
     127            # TODO : really transform the datas. 
     128            sys.stderr.write("WARNING : --sum command line option is not implemented yet !\n") 
     129            return entries 
     130             
    116131    def dumpWithSeparator(self, separator, entries) :     
    117132        """Dumps datas with a separator."""