Ñò
~^cDc           @   sƒ   d  d k  Z  d  d k Z d  d k Z d  d k Z e i d e i e i Bƒ Z d „  Z d „  Z	 d d „ Z
 d d „ Z d „  Z d S(	   iÿÿÿÿNs   <TITLE>(.*?)</TITLE>c         C   s#   t  i |  ƒ } | o	 | d Sd  S(   Ni    (   t   titleret   findallt   None(   t   ct   x(    (    s*   /var/www/www.aaronsw.com/2002/feeds/rss.pyt   gettitle   s     	c         C   s(   |  i  d d ƒ i  d d ƒ i  d d ƒ S(   Nt   &s   &amp;t   <s   &lt;t   >s   &gt;(   t   replace(   t   text(    (    s*   /var/www/www.aaronsw.com/2002/feeds/rss.pyt
   htmlencode   s    t   utf8c         C   s  t  i i d ƒ o d | GHHn | d j o d | d GHn d t |  ƒ d t | ƒ d d	 d
 GHx | D]ˆ } d GHt | ƒ t h  ƒ j	 o h | d 6} n | i ƒ  } | i ƒ  x5 | D]- } d | d t | | ƒ d | d GHqÁ Wd GHqo Wd GHd  S(   Nt   QUERY_STRINGs'   Content-Type: application/xml; charset=R   s   <?xml version="1.0" encoding="s   "?>s‹   <rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel>
  <title>s   </title>
  <link>s   </link>
  <description>s$   Scraped feed provided by aaronsw.coms   </description>s     <item>t   descriptions       <R   s   </s	     </item>s   </channel></rss>(   t   ost   environt   has_keyR   t   typet   keyst   sort(   t   titlet   linkt   itemst   encodingt   itemR   t   k(    (    s*   /var/www/www.aaronsw.com/2002/feeds/rss.pyt   rssify   s$    	)   
 +	c         C   sq   t  i |  ƒ i ƒ  } | o6 t | ƒ } | o h | d 6| d 6|  d 6} q^ n t | ƒ } t | |  | g ƒ S(   NR   R   R   (   t   urllibt   urlopent   readR   R   (   t   urlR   t   contentR   (    (    s*   /var/www/www.aaronsw.com/2002/feeds/rss.pyt   fromurl    s     #c         C   s‚   g  } xi | D]a } t  i | ƒ i ƒ  } t | ƒ } | o& | i h | d 6| d 6| d 6ƒ q | i | ƒ q Wt |  | | ƒ S(   NR   R   R   (   R   R   R   R   t   appendR   (   R   R   t   itemlistR   t   lR    t   ntitle(    (    s*   /var/www/www.aaronsw.com/2002/feeds/rss.pyt   fromlist*   s      &(   R   t   reR   t   syst   compilet   It   SR    R   R   R   R   R!   R&   (    (    (    s*   /var/www/www.aaronsw.com/2002/feeds/rss.pyt   <module>   s   $		
