Changeset 2276

Show
Ignore:
Timestamp:
06/01/05 10:05:34 (19 years ago)
Author:
jerome
Message:

A positive or negative offset can be added to the special keywords in dumpykota's date filtering options

Location:
pykota/trunk
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • pykota/trunk/NEWS

    r2268 r2276  
    2222PyKota NEWS : 
    2323        
     24    - 1.23alpha6 : 
     25     
     26        - The data dumper's start= and end= date filtering options now 
     27          accept a positive or negative offset to be added to the special 
     28          keywords 'yesterday', 'today', 'now', 'tomorrow'.  
     29          e.g. : dumpykota --data history start=yesterday-5 end=today 
     30           
    2431    - 1.23alpha5 : 
    2532     
  • pykota/trunk/pykota/storage.py

    r2268 r2276  
    601601        now = DateTime.now()     
    602602        nameddates = ('yesterday', 'today', 'now', 'tomorrow') 
    603         if ((startdate.lower() in nameddates) or startdate.isdigit()) and \ 
    604            ((enddate.lower() in nameddates) or enddate.isdigit()) :  
    605             datedict = { "start" : startdate, "end" : enddate }     
    606             for limit in datedict.keys() : 
    607                 dateval = datedict[limit] 
    608                 if dateval in nameddates : 
     603        datedict = { "start" : startdate.lower(), "end" : enddate.lower() }     
     604        for limit in datedict.keys() : 
     605            dateval = datedict[limit] 
     606            for name in nameddates : 
     607                if dateval.startswith(name) : 
     608                    try : 
     609                        offset = int(dateval[len(name):]) 
     610                    except :     
     611                        offset = 0 
     612                    dateval = dateval[:len(name)]     
    609613                    if limit == "start" : 
    610614                        if dateval == "yesterday" : 
    611                             dateval = (now - 1).Format("%Y%m%d000000") 
     615                            dateval = (now - 1 + offset).Format("%Y%m%d000000") 
    612616                        elif dateval == "today" : 
    613                             dateval = now.Format("%Y%m%d000000") 
     617                            dateval = (now + offset).Format("%Y%m%d000000") 
    614618                        elif dateval == "now" : 
    615                             dateval = now.Format("%Y%m%d%H%M%S") 
     619                            dateval = (now + offset).Format("%Y%m%d%H%M%S") 
    616620                        else : # tomorrow 
    617                             dateval = (now + 1).Format("%Y%m%d000000") 
     621                            dateval = (now + 1 + offset).Format("%Y%m%d000000") 
    618622                    else : 
    619623                        if dateval == "yesterday" : 
    620                             dateval = (now - 1).Format("%Y%m%d235959") 
     624                            dateval = (now - 1 + offset).Format("%Y%m%d235959") 
    621625                        elif dateval == "today" : 
    622                             dateval = now.Format("%Y%m%d235959") 
     626                            dateval = (now + offset).Format("%Y%m%d235959") 
    623627                        elif dateval == "now" : 
    624                             dateval = now.Format("%Y%m%d%H%M%S") 
     628                            dateval = (now + offset).Format("%Y%m%d%H%M%S") 
    625629                        else : # tomorrow 
    626                             dateval = (now + 1).Format("%Y%m%d235959") 
    627                          
     630                            dateval = (now + 1 + offset).Format("%Y%m%d235959") 
     631                    break 
     632                     
     633            if not dateval.isdigit() : 
     634                dateval = None 
     635            else :     
    628636                lgdateval = len(dateval) 
    629637                if lgdateval == 4 : 
     
    661669                except :     
    662670                    dateval = None 
    663                 datedict[limit] = dateval     
    664             (start, end) = (datedict["start"], datedict["end"]) 
    665             if start > end : 
    666                 (start, end) = (end, start) 
    667             return (start, end)     
    668         else :             
    669             return (None, None) 
     671            datedict[limit] = dateval     
     672        (start, end) = (datedict["start"], datedict["end"]) 
     673        if start > end : 
     674            (start, end) = (end, start) 
     675        return (start, end)     
    670676         
    671677def openConnection(pykotatool) : 
  • pykota/trunk/pykota/storages/ldapstorage.py

    r2266 r2276  
    13401340        startdate = extractonly.get("start") 
    13411341        enddate = extractonly.get("end") 
    1342         for limit in ("start", "end") : 
    1343             try : 
    1344                 del extractonly[limit] 
    1345             except KeyError :     
    1346                 pass 
    13471342        (startdate, enddate) = self.cleanDates(startdate, enddate) 
    13481343        entries = self.retrieveHistory(user, printer, hostname=extractonly.get("hostname"), billingcode=extractonly.get("billingcode"), limit=None, start=startdate, end=enddate) 
  • pykota/trunk/pykota/version.py

    r2268 r2276  
    2222# 
    2323 
    24 __version__ = "1.23alpha5_unofficial" 
     24__version__ = "1.23alpha6_unofficial" 
    2525 
    2626__doc__ = "PyKota : a complete Printing Quota Solution for CUPS and LPRng."