-ķ
ē¶<c       só    d  Z    d d g Z  d Z  d Z  d Z  d Z  d Z  d Z  d	 Z  d
 Z	  d Z
  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z  d Z   d Z ! d Z " d Z # d Z $ d Z ' e   Z ( h  a  ) d   Z! 5 d Z" 6 d  Z# 8 d! d"  Z$ I d! d#  Z% M d$   Z& T d%   Z' ` d&   Z(  d'   Z)  d(   Z*  d)   Z+  d*   Z, ¤ d+   Z- Ģ e. d, j o Ķ e-   n d- S(.   s!   Gopher protocol client interface.s   send_selectors
   send_querys   1/s   gopher.micro.umn.eduiF   s   0s   1s   2s   3s   4s   5s   6s   7s   8s   9s   +s   ss   es   cs   hs   Ts   Ms   Is   ws   qs   gs   :s   ;s   <c    s   ) * + , t  h  j oJ - x@ t D- ]5 } . | d  d j o / | d t  t |  <n q# Wn 0 t  i |   o 1 t  |  Sn 2 d |  Sd S(   s=   Map all file types to strings; unknown types become TYPE='x'.i   s   A_s   TYPE=N(   s   _type_to_name_maps   _namess   names   evals   has_keys   gtype(   s   gtypes   name(    (    s   /usr/lib/python2.2/gopherlib.pys   type_to_name) s   
 	#s   
s   	i    c    s  8 9 : d k  } ; | oQ < | i d  } = | d j o+ > | |  t | | d  f \ } } n n ? | o @ t } n0 A t |  t d  j o B t |  } n C | i  | i | i	  } D | i | | f  E | i |  t  F | i d  G | i d  Sd S(   sG   Send a selector to a given host and port, return a file with the reply.Ns   :i    i   s    s   rb(   s   sockets   ports   hosts   finds   is   ints   DEF_PORTs   types   AF_INETs   SOCK_STREAMs   ss   connects   sendalls   selectors   CRLFs   shutdowns   makefile(   s   selectors   hosts   ports   sockets   is   s(    (    s   /usr/lib/python2.2/gopherlib.pys   send_selector8 s   /c    s%   I J K t  |  d | | |  Sd S(   s#   Send a selector and a query string.s   	N(   s   send_selectors   selectors   querys   hosts   port(   s   selectors   querys   hosts   port(    (    s   /usr/lib/python2.2/gopherlib.pys
   send_queryI s   c    s0   M N O |  d j o P d Sn R |  d Sd S(   sJ   Takes a path as returned by urlparse and returns the appropriate selector.s   /i   N(   s   path(   s   path(    (    s   /usr/lib/python2.2/gopherlib.pys   path_to_selectorM s   c    s6   T V W |  d j o Y d Sn [ t |  d  Sd S(   sj   Takes a path as returned by urlparse and maps it to a string.
    See section 3.4 of RFC 1738 for details.s   /s   TYPE='unknown'i   N(   s   paths   type_to_name(   s   path(    (    s   /usr/lib/python2.2/gopherlib.pys   path_to_datatype_nameT s   c    s«  ` a b g  } c xc d od |  i   } e | o f d GHg Pn h | d t j o i | d  } n& j | d t j o k | d  } n l | d j o m Pn n | o o d GHp q n q | d } r | d i t  } s t	 |  d j  o t d	 G| Gd
 GHu q n v t	 |  d j o6 w | d d g j o x d Gy | d Gd
 GHn n { | i
 d  | | i d |  } | i
 |  q W~ | Sd S(   s1   Get a directory in the form of a list of entries.i   s   (Unexpected EOF from server)iž’’’i’’’’s   .s   (Empty line from server)i    i   s   (Bad line from server:s   )s   +s   (Extra info from server:s    N(   s   lists   fs   readlines   lines   CRLFs   gtypes   splits   TABs   partss   lens   appends   insert(   s   fs   partss   gtypes   lists   line(    (    s   /usr/lib/python2.2/gopherlib.pys   get_directory` s<   	 


c    s-      g  }  t |  | i   | Sd S(   s@   Get a text file as a list of lines, with trailing CRLF stripped.N(   s   lists   get_alt_textfiles   fs   append(   s   fs   list(    (    s   /usr/lib/python2.2/gopherlib.pys   get_textfile s   	c    sŻ      xĶ  d oĀ  |  i   }  | o  d GH Pn  | d t j o  | d  } n&  | d t j o  | d  } n  | d j o  Pn  | d  d j o  | d } n  | |  q Wd S(	   sN   Get a text file and pass each line to a function, with trailing CRLF stripped.i   s   (Unexpected EOF from server)iž’’’i’’’’s   .i   s   ..N(   s   fs   readlines   lines   CRLFs   func(   s   fs   funcs   line(    (    s   /usr/lib/python2.2/gopherlib.pys   get_alt_textfile s     
c    s       |  i   }  | Sd S(   s*   Get a binary file as one solid data block.N(   s   fs   reads   data(   s   fs   data(    (    s   /usr/lib/python2.2/gopherlib.pys
   get_binary s   c    sQ      xA  d o6  |  i |  }   | o ” Pn ¢ | |  q Wd S(   s4   Get a binary file and pass each block to a function.i   N(   s   fs   reads	   blocksizes   datas   func(   s   fs   funcs	   blocksizes   data(    (    s   /usr/lib/python2.2/gopherlib.pys   get_alt_binary s    
c     s?  ¤ „ ¦ d k  } § d k }	 Ø |	 i | i d d  \ } } © t } Ŗ | d }
 « t } ¬ | o ­ | d } ® | d } n Æ | o³ ° | d }
 ± | d } ² t
 |
  d j o ³ |
 d |
 f \ }
 } n2 µ d } ¶ | o · | d } ø | d } n ¹ d } ŗ | o » | d } ¼ | d } n n ½ |
 t j o ¾ t | | |  } n Ą t | |  } Į |
 t j o2 Ā t |  } Ć x | DĆ ] }  Ć |  GHqØWn{ Ä |
 t t f j o2 Å t |  } Ę x | DĘ ] }  Ę |  GHqšWn3 Č t |  } É d Gt
 |  Gd G| d  d  GHd S(	   s   Trivial test program.Ni   s    i    s   binary data:s   bytes:id   i(   (   s   syss   getopts   argvs   optss   argss   DEF_SELECTORs   selectors   types   DEF_HOSTs   hosts   lens   querys   A_INDEXs
   send_querys   fs   send_selectors   A_TEXTs   get_textfiles   lists   items   A_MENUs   get_directorys
   get_binarys   data(   s   items   argss   selectors   syss   hosts   querys   datas   fs   lists   getopts   types   opts(    (    s   /usr/lib/python2.2/gopherlib.pys   test¤ sL   "		

	
	

 	 
 	 s   __main__N(/   s   __doc__s   __all__s   DEF_SELECTORs   DEF_HOSTs   DEF_PORTs   A_TEXTs   A_MENUs   A_CSOs   A_ERRORs   A_MACBINHEXs
   A_PCBINHEXs   A_UUENCODEDs   A_INDEXs   A_TELNETs   A_BINARYs   A_DUPLICATEs   A_SOUNDs   A_EVENTs
   A_CALENDARs   A_HTMLs   A_TN3270s   A_MIMEs   A_IMAGEs   A_WHOISs   A_QUERYs   A_GIFs   A_WWWs   A_PLUS_IMAGEs   A_PLUS_MOVIEs   A_PLUS_SOUNDs   dirs   _namess   _type_to_name_maps   type_to_names   CRLFs   TABs   send_selectors
   send_querys   path_to_selectors   path_to_datatype_names   get_directorys   get_textfiles   get_alt_textfiles
   get_binarys   get_alt_binarys   tests   __name__(+   s   A_ERRORs   get_textfiles   A_PLUS_IMAGEs
   send_querys   DEF_HOSTs   A_UUENCODEDs   A_PLUS_MOVIEs   A_WHOISs   __all__s   get_directorys   get_alt_binarys   send_selectors   A_TN3270s   A_HTMLs   A_MACBINHEXs   A_CSOs   type_to_names   A_BINARYs   TABs   tests   A_IMAGEs   A_EVENTs   A_QUERYs   A_WWWs   get_alt_textfiles   _namess
   A_CALENDARs   CRLFs   A_TEXTs   DEF_PORTs   A_SOUNDs
   A_PCBINHEXs   path_to_datatype_names   A_MIMEs   DEF_SELECTORs   A_PLUS_SOUNDs   path_to_selectors   A_INDEXs   A_TELNETs
   get_binarys   A_GIFs   A_DUPLICATEs   A_MENU(    (    s   /usr/lib/python2.2/gopherlib.pys   ? s^   																																 (