3 8Pe@s6ddlmZddlTddlTddlTGdddZdS)) defaultdict)*c@s`eZdZeddZeddZeZdZddZ dddZ d d Z e d d Z e d dZdS) eventlistcCsttS)N)rlistrr/usr/lib/python3.6/eventlist.pyszeventlist.cCsttS)N)rrrrrrr sNc Csddddddg}||_x|jD]}|jj|x||jD]\}}xj|jD]^}xX|D]P}|j|}|snqZt|||} |jr|j ||j | qZ|j ||j | qZWqPWt |j ||ddd |j ||<t |j ||d dd |j ||<q>Wq WdS) NZ SyncPublishZPublishZ SyncDeleteZActivateZInactiveZDeletecSs|jS)N)when)eventrrrr +sz$eventlist.__init__..)keycSs|jS)N)r )r rrrr -s) _kdictZzones_zonesadditemsvaluesZgettimekeyeventsep_Kappend_Zsorted) selfZkdictZ propertieszonealgkeyskZpropterrr__init__s&     zeventlist.__init__c Csdd}|s|}|r |dkr dnd}|r4|dkr4dnd}d}} d} |rb||jkrb|d|dS|rd} |s~|j|d||}|s|j|d||} n`x^|jD]T} | r| |jjkrd} |j| d||}| r| |jjkrd} |j| d||} qW| s|ddS|o| S) Nc_sdS)Nr)argskwargsrrrnoop2sz eventlist.coverage..noopKSKTFZZSKz!ERROR: No key events found for %szERROR: No key events found)r checkzonerrr) rrkeytypeuntiloutputr"Zno_zskZno_kskZkokZzokfoundzrrrcoverage1s6  zeventlist.coveragec Csxd}|dkr|j|}n |j|}xP|jD]D}|d||tj|ftj|||||}|rh|d|on|}q,W|S)NTr#z9Checking scheduled %s events for zone %s, algorithm %s...zNo errors found)rrrdnskeyZalgstrrcheckset) rrr%r&r'ZallokZkzrokrrrr$Ts   zeventlist.checkzonecCsR|sdS|d|djdddx(|D] }|d|jt|jfddq*WdS)Nz r:F)skipz %s: %s)ZshowtimeZwhatreprr )eventsetr'r rrrshowsetfs  zeventlist.showsetc CsNt}t}d}xZ|D]R}d}| s4|dj|jkr>|j||dj|jkr|j|t}|j|qW|rz|j||s|d|dSd}} x|D]}|rtj|dj|kr|dtjdtj|dSx|D]}|j|| \}} qWt j |||s|d|dS| s,|d|dS| j |s|d |dSqWdS) NFTrzERROR: No %s events foundzIgnoring events after %sz%a %b %d %H:%M:%S UTC %Yz*ERROR: No %s's are active after this eventz-ERROR: No %s's are published after this eventz=ERROR: No %s's are both active and published after this event) rr rZcalendarZtimegmZtimeZstrftimeZgmtimeZstatusrr2 intersection) r1r%r&r'groupsgroupZ eventsfoundr ZactiveZ publishedrrrr,nsL          zeventlist.checkset)N)__name__ __module__ __qualname__rrrsetrr rr*r$ staticmethodr2r,rrrrrs   # rN) collectionsrr+Zkeydictrrrrrr s