³ò
Jé¬Fc           @   sN  d  d k  l Z l Z l Z d  d k l Z d  d k l Z d  d k l	 Z	 d  d k
 l
 Z
 d  d k l Z d  d k Z d d „ Z d	 e e f d
 „  ƒ  YZ h  e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d ƒ <e d ƒ e d  ƒ <e d! ƒ e d" ƒ <e d# ƒ e d$ ƒ <e d% ƒ e d& ƒ <e d' ƒ e d( ƒ <e d) ƒ e d* ƒ <e d+ ƒ e d, ƒ <e d- ƒ e d. ƒ <e d/ ƒ e d0 ƒ <e d1 ƒ e d2 ƒ <e d3 ƒ e d4 ƒ <e d5 ƒ e d6 ƒ <e d7 ƒ e d8 ƒ <e d9 ƒ e d: ƒ <e d; ƒ e d< ƒ <e d= ƒ e d> ƒ <e d? ƒ e d@ ƒ <Z e dA j oc d  d k Z d  d k Z e
 ƒ  Z x+ e i dB D] Z e e i e ƒ e ƒ qWe i e i ƒ n d S(C   iÿÿÿÿ(   t   ContentHandlert   make_parsert   SAXParseException(   t   InputSource(   t
   SGMLParser(   t   StringIO(   t   ConfigParser(   t
   entitydefsNc         C   sª   t  |  d ƒ o |  i ƒ  }  n | p t ƒ  } n t | ƒ } yC t ƒ  } | i t |  ƒ ƒ t ƒ  } | i | ƒ | i	 | ƒ Wn  t
 j
 o | i |  ƒ n X| S(   Nt   read(   t   hasattrR   R   t
   OpmlParserR   t   setByteStreamR   R   t   setContentHandlert   parseR   t   feed(   t   opmlt   configt
   opmlParsert   sourcet   parser(    (    s1   /home/sgala/public_html/code/venus/planet/opml.pyt   opml2config
   s    		R
   c           B   s;   e  Z e i d  ƒ Z d „  Z d „  Z d „  Z d „  Z RS(   s	   &(#?\w+);c         C   s'   t  i |  ƒ t i |  ƒ | |  _ d  S(   N(   R    t   __init__R   R   (   t   selfR   (    (    s1   /home/sgala/public_html/code/venus/planet/opml.pyR   %   s    c         C   sß  | d j o d  Sn | i  d ƒ oe | d d j o1 | i  d ƒ o  t | i ƒ  ƒ } d | d <n | d i ƒ  d j o d  SqŠ n | i  d ƒ p | d i ƒ  oh xe | i ƒ  D]O } | i ƒ  d j o6 | | i ƒ  o% t | i ƒ  ƒ } | | | d <Pqº qº Wd  Sn | i  d	 ƒ p | d	 i ƒ  oO | i  d
 ƒ p | d
 i ƒ  o d  Sn t | i ƒ  ƒ } | d
 | d	 <n | d } |  i i | ƒ p7 |  i i | ƒ |  i i	 | d |  i
 | d	 ƒ ƒ n d  S(   Nt   outlinet   typet   linkt   urlt   rsst   atomt   xmlUrlt   xmlurlt   textt   titlet   name(   s   rsss   atom(   t   has_keyt   dictt   itemst   lowert   stript   keysR   t   has_sectiont   add_sectiont   sett   unescape(   R   R!   t   attrst	   attributeR   (    (    s1   /home/sgala/public_html/code/venus/planet/opml.pyt   startElement*   s,    "## $	#+
c         C   s)  |  i  i | ƒ } xþ t d t | ƒ d ƒ D]ä } | | t i ƒ  j oÇ t | | } |  i  i | ƒ } | o | i d ƒ | | <n t t	 | ƒ ƒ | | <| | i
 d ƒ o[ | | i
 d ƒ o% t t | | d d ƒ ƒ | | <qt t | | d ƒ ƒ | | <qq+ q+ Wd i | ƒ i d ƒ S(   Ni   i   t   #s   #xi   u    s   utf-8(   t   entitiest   splitt   ranget   lenR   R'   t   matcht   groupt   unichrt   ordt
   startswitht   intt   joint   encode(   R   R   t   parsedt   it	   codepointR4   (    (    s1   /home/sgala/public_html/code/venus/planet/opml.pyR+   T   s     %*c         C   sµ   t  | ƒ } x’ | D]Š } y | | i d ƒ | | <Wq | | i d ƒ } d i g  } | D]% } | | t j o t | p | q^ ~ ƒ } | | | <q Xq W|  i | | ƒ d  S(   Ns   utf-8s
   iso-8859-1u    (   R#   t   decodeR:   t   cp1252R.   (   R   R!   R,   R-   t   workt   _[1]t   c(    (    s1   /home/sgala/public_html/code/venus/planet/opml.pyt   unknown_starttagk   s     B(	   t   __name__t
   __module__t   ret   compileR0   R   R.   R+   RD   (    (    (    s1   /home/sgala/public_html/code/venus/planet/opml.pyR
   "   s
   		*	i¬   i€   i   i‚   i’  iƒ   i   i„   i&   i…   i    i†   i!   i‡   iÆ  iˆ   i0   i‰   i`  iŠ   i9   i‹   iR  iŒ   i}  iŽ   i   i‘   i   i’   i   i“   i   i”   i"   i•   i   i–   i   i—   iÜ  i˜   i"!  i™   ia  iš   i:   i›   iS  iœ   i~  iž   ix  iŸ   t   __main__i   (   t   xml.saxR    R   R   t   xml.sax.xmlreaderR   t   sgmllibR   t	   cStringIOR   R   t   htmlentitydefsR   RG   t   NoneR   R
   R6   R@   RE   t   syst   urllibR   t   argvR   t   urlopent   writet   stdout(    (    (    s1   /home/sgala/public_html/code/venus/planet/opml.pys   <module>   sV   U	 
