ó
ì'Gc           @   so   d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l m	 Z	 d   Z
 d S(   s-    Expunge old entries from a cache of entries iÿÿÿÿN(   t   minidom(   t   filenamec          C   sÅ  t  j }  |  j d  i  } t j   } x t j   D] } t j t | |   } | j	 j
 d  sk q5 n  t j |  j
 d  r© t t j |  d  | | j	 j <q5 t j   | | j	 j <q5 W|  j d  t j   } g  t j | d  D]0 } t j j |  sð t j |  j | f ^ qð } | j   | j   x| D]|\ } } yVt j |  }	 |	 j   |	 j d  } | s|  j d |  wAn  | d j d  }
 |
 sÃ|  j d	 |  wAn  |
 d j d j | k rt| |
 d j d j d
 | |
 d j d j <| |
 d j d j d k rP|  j d | |
 d j d j  wAq|  j d | |
 d j d j  n! |  j d | |
 d j d j  t j |  WqA|  j d |  qAXqAWd S(   s-    Expunge old entries from a cache of entries s   Determining feed subscriptionst   idt   cache_keep_entriess   Listing cached entriess   /*t   sources   No source found for %si    s   No source feed id found for %si   s"   Maximum not reached for %s from %ss#   Removing %s, maximum reached for %ss!   Removing %s, not subscribed to %ss   Error parsing %sN(    t   planett   loggert   infot   configt   cache_sources_directoryt   subscriptionst
   feedparsert   parseR   t   feedt   has_keyt   feed_optionst   intR   R   t   cache_directoryt   globt   ost   patht   isdirt   statt   st_mtimet   sortt   reverseR    t	   normalizet   getElementsByTagNamet   debugt
   childNodest	   nodeValuet   unlinkt   error(   t   logt   entry_countt   sourcest   subt   datat   cachet   filet   dirt   mtimet   entryt   ids(    (    s?   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/expunge.pyt   expungeCache   sV    	 &0


+			(   t   __doc__R   R   R   R   R   t   xml.domR    t   spiderR   R,   (    (    (    s?   /home/sa3ruby/intertwingly.net/code/venus-bzr/planet/expunge.pyt   <module>   s   <