‡Æ
ÙMö9c       sð    d  Z    d k 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  Z  ) d „  Z! 5 d Z" 6 d Z# 8 d! d  „ Z$ J d! d" „ Z% N d# „  Z& U d$ „  Z' a 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.Ns   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 oL - xB t d - r5 } . | 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    i   s   A_s   TYPE=N(   s   _type_to_name_maps   _namess   names   evals   has_keys   gtype(   s   gtypes   names&   /mit/python/lib/python2.0/gopherlib.pys   type_to_name) s    	#s   
s   	c    s3  8 9 : d k  } ; d k } < | oW = | i | d ƒ } > | d j o. ? | |  | i | | d ƒ f \ } } n n @ | o A t } n3 B t | ƒ t d ƒ j o C | i | ƒ } n D | i  | i	 | i
 ƒ } E | i | | f ƒ F | i |  t ƒ G | i d ƒ H | 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   strings   ports   finds   hosts   is   atois   DEF_PORTs   types   AF_INETs   SOCK_STREAMs   ss   connects   sends   selectors   CRLFs   shutdowns   makefile(   s   selectors   hosts   ports   sockets   strings   is   ss&   /mit/python/lib/python2.0/gopherlib.pys   send_selector8 s    2i    c    s%   J K L 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   ports&   /mit/python/lib/python2.0/gopherlib.pys
   send_queryJ s   c    s0   N O P |  d j o Q d Sn S |  d Sd S(   sJ   Takes a path as returned by urlparse and returns the appropriate selector.s   /i   N(   s   path(   s   paths&   /mit/python/lib/python2.0/gopherlib.pys   path_to_selectorN s   c    s6   U W X |  d j o Z 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   paths&   /mit/python/lib/python2.0/gopherlib.pys   path_to_datatype_nameU s   c    s¾  a b c d k  } d g  } e x’e d o‡f |  i ƒ  } g | o h d GHi Pn j | d t j o k | d  } n( l | d t j o m | d  } n n | d j o o Pn p | o q d GHr q! n s | d } t | i | d t ƒ } u t
 | ƒ d j  o v d	 G| Gd
 GHw q! n x t
 | ƒ d j o6 y | d d g j o z d G{ | 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.Ni   s   (Unexpected EOF from server)i   s   .s   (Empty line from server)i    i   s   (Bad line from server:s   )s   +s   (Extra info from server:s    (   s   strings   lists   fs   readlines   lines   CRLFs   gtypes   splitfieldss   TABs   partss   lens   appends   insert(   s   fs   strings   lists   lines   gtypes   partss&   /mit/python/lib/python2.0/gopherlib.pys   get_directorya 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   lists&   /mit/python/lib/python2.0/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   s   .s   ..N(   s   fs   readlines   lines   CRLFs   func(   s   fs   funcs   lines&   /mit/python/lib/python2.0/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   datas&   /mit/python/lib/python2.0/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   datas&   /mit/python/lib/python2.0/gopherlib.pys   get_alt_binaryž s    
c     sL  ¦ § ¨ d k  }  © d k } ª | i |  i d d ƒ \ } } « t } ¬ | d } ­ t } ® 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 o4 Å t |	 ƒ }
 Æ x |
 d Æ r } Æ | GHq³Wn} Ç | t t f j o4 È t |	 ƒ }
 É x |
 d É r } É | 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   DEF_PORTs   ports   lens   querys   A_INDEXs
   send_querys   fs   send_selectors   A_TEXTs   get_textfiles   lists   items   A_MENUs   get_directorys
   get_binarys   data(   s   syss   getopts   optss   argss   selectors   types   hosts   ports   querys   fs   lists   items   datas&   /mit/python/lib/python2.0/gopherlib.pys   test¦ sN   "			

	
	
 	  	 s   __main__(/   s   __doc__s   strings   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&   /mit/python/lib/python2.0/gopherlib.pys   ? s^   																																!)