Ñò
mÈKc           @   s²  d  Z  d d k Z d d k Z d d k Z d d k Z d d d g Z d e f d „  ƒ  YZ e d ƒ \ Z	 Z
 Z d Z d	 Z e d
 ƒ Z y< d d k l Z l Z d d k l Z d „  Z d „  Z WnB e j
 o6 d d$ d „  ƒ  YZ d „  Z d d% d „  ƒ  YZ n Xd d& d „  ƒ  YZ d d' d „  ƒ  YZ d d( d „  ƒ  YZ d „  Z d d) d „  ƒ  YZ d d* d „  ƒ  YZ d d+ d  „  ƒ  YZ d! „  Z d" „  Z  e! d# j o e  ƒ  n d S(,   s‰   Macintosh binhex compression/decompression.

easy interface:
binhex(inputfilename, outputfilename)
hexbin(inputfilename, outputfilename)
iÿÿÿÿNt   binhext   hexbint   Errorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s   /usr/lib/python2.6/binhex.pyR      s   i   i €  i@   i   (   t   FSSpect   FInfo(   t   openrfc         C   s   t  |  ƒ i ƒ  } t i i |  ƒ \ } } t |  d ƒ } | i d d ƒ | i ƒ  } t |  d ƒ } | i d d ƒ | i ƒ  } | | | | f S(   Nt   rbi    i   s   *rb(	   R   t   FSpGetFInfot   ost   patht   splitt   opent   seekt   tellR   (   t   namet   finfot   dirt   filet   fpt   dlent   rlen(    (    s   /usr/lib/python2.6/binhex.pyt   getfileinfo3   s    c         G   s,   | p
 d } n d | d } t  |  | ƒ S(   Ns   *rbt   *i    (   R   (   R   t   mode(    (    s   /usr/lib/python2.6/binhex.pyt   openrsrc?   s    
R   c           B   s   e  Z d  „  Z RS(   c         C   s   d |  _  d |  _ d |  _ d  S(   Ns   ????i    (   t   Typet   Creatort   Flags(   t   self(    (    s   /usr/lib/python2.6/binhex.pyt   __init__L   s    		(   R   R   R   (    (    (    s   /usr/lib/python2.6/binhex.pyR   K   s   c         C   sÚ   t  ƒ  } t |  ƒ } t |  ƒ i d ƒ } xJ | D]9 } | i ƒ  o% | d j  p t | ƒ d j o Pq1 q1 Wd | _ | i d d ƒ | i ƒ  } | i ƒ  t	 i
 i |  ƒ \ } } | i d d d	 ƒ } | | | d f S(
   Ni   t    i   t   TEXTi    i   t   :t   -i   (   R   R   t   readt   isspacet   ordR   R   R   t   closeR
   R   R   t   replace(   R   R   R   t   datat   ct   dsizeR   R   (    (    s   /usr/lib/python2.6/binhex.pyR   Q   s    	 .		
R   c           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         G   s   d  S(   N(    (   R   t   args(    (    s   /usr/lib/python2.6/binhex.pyR   c   s    c         G   s   d S(   Nt    (    (   R   R,   (    (    s   /usr/lib/python2.6/binhex.pyR$   f   s    c         G   s   d  S(   N(    (   R   R,   (    (    s   /usr/lib/python2.6/binhex.pyt   writei   s    c         C   s   d  S(   N(    (   R   (    (    s   /usr/lib/python2.6/binhex.pyR'   l   s    (   R   R   R   R$   R.   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyR   b   s   			t   _Hqxcoderenginec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s(   Write data to the coder in 3-byte chunksc         C   s,   | |  _  d |  _ d |  _ t d |  _ d  S(   NR-   i   (   t   ofpR)   t   hqxdatat   LINELENt   linelen(   R   R0   (    (    s   /usr/lib/python2.6/binhex.pyR   r   s    			c         C   s€   |  i  | |  _  t |  i  ƒ } | d d } |  i  |  } |  i  | |  _  | p d  S|  i t i | ƒ |  _ |  i d ƒ d  S(   Ni   i    (   R)   t   lenR1   t   binasciit   b2a_hqxt   _flush(   R   R)   t   datalent   todo(    (    s   /usr/lib/python2.6/binhex.pyR.   x   s    c         C   s›   d } x\ | t  |  i ƒ |  i j o> | |  i } |  i i |  i | | !d ƒ t |  _ | } q	 W|  i | |  _ | o |  i i |  i d ƒ n d  S(   Ni    s   
s   :
(   R4   R1   R3   R0   R.   R2   (   R   t   forcet   firstt   last(    (    s   /usr/lib/python2.6/binhex.pyR7   ƒ   s     	c         C   sN   |  i  o  |  i t i |  i  ƒ |  _ n |  i d ƒ |  i i ƒ  |  ` d  S(   Ni   (   R)   R1   R5   R6   R7   R0   R'   (   R   (    (    s   /usr/lib/python2.6/binhex.pyR'   Ž   s
    
 (   R   R   t   __doc__R   R.   R7   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyR/   o   s
   			t   _Rlecoderenginec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s4   Write data to the RLE-coder in suitably large chunksc         C   s   | |  _  d |  _ d  S(   NR-   (   R0   R)   (   R   R0   (    (    s   /usr/lib/python2.6/binhex.pyR   ™   s    	c         C   sZ   |  i  | |  _  t |  i  ƒ t j  o d  St i |  i  ƒ } |  i i | ƒ d |  _  d  S(   NR-   (   R)   R4   t   REASONABLY_LARGER5   t   rlecode_hqxR0   R.   (   R   R)   t   rledata(    (    s   /usr/lib/python2.6/binhex.pyR.      s    c         C   sG   |  i  o& t i |  i  ƒ } |  i i | ƒ n |  i i ƒ  |  ` d  S(   N(   R)   R5   R@   R0   R.   R'   (   R   RA   (    (    s   /usr/lib/python2.6/binhex.pyR'   ¥   s
    
(   R   R   R=   R   R.   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyR>   –   s   		t   BinHexc           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c   
      C   sî   | \ } } } } t  | ƒ t  d ƒ j oI | } t | d ƒ } t i d j o  t | ƒ } | i d d ƒ qt n | i d ƒ t | ƒ }	 t |	 ƒ |  _	 d |  _
 | d  j o t ƒ  } n | |  _ | |  _ |  i | | ƒ t |  _ d  S(   NR-   t   wt   mact   BnHqR!   s0   (This file must be converted with BinHex 4.0)

:i    (   t   typeR   R
   R   R   t   SetCreatorTypeR.   R/   R>   R0   t   crct   NoneR   R   R   t
   _writeinfot   _DID_HEADERt   state(
   R   t   .1R0   R   R   R   R   t   ofnamet   fsst   hqxer(    (    s   /usr/lib/python2.6/binhex.pyR   ­   s"    			c   	      C   s§   t  | ƒ } | d j o t d ‚ n t | ƒ | d } | i | i } t i d | i ƒ } t i d |  i |  i	 ƒ } | | | | } |  i
 | ƒ |  i ƒ  d  S(   Ni?   s   Filename too longt    s   >hs   >ii(   R4   R   t   chrR   R   t   structt   packR   R   R   t   _writet	   _writecrc(	   R   R   R   t   nlt   dt   d2t   d3t   d4t   info(    (    s   /usr/lib/python2.6/binhex.pyRJ   ¿   s    c         C   s,   t  i | |  i ƒ |  _ |  i i | ƒ d  S(   N(   R5   t   crc_hqxRH   R0   R.   (   R   R)   (    (    s   /usr/lib/python2.6/binhex.pyRU   Í   s    c         C   sL   |  i  d j  o
 d } n d } |  i i t i | |  i  ƒ ƒ d |  _  d  S(   Ni    s   >hs   >H(   RH   R0   R.   RS   RT   (   R   t   fmt(    (    s   /usr/lib/python2.6/binhex.pyRV   Ñ   s
    
c         C   sD   |  i  t j o t d ‚ n |  i t | ƒ |  _ |  i | ƒ d  S(   Ns   Writing data at the wrong time(   RL   RK   R   R   R4   RU   (   R   R)   (    (    s   /usr/lib/python2.6/binhex.pyR.   Û   s    c         C   s>   |  i  d j o t d |  i f ‚ n |  i ƒ  t |  _ d  S(   Ni    s   Incorrect data size, diff=%r(   R   R   R   RV   t	   _DID_DATARL   (   R   (    (    s   /usr/lib/python2.6/binhex.pyt
   close_dataá   s    
c         C   sb   |  i  t j  o |  i ƒ  n |  i  t j o t d ‚ n |  i t | ƒ |  _ |  i | ƒ d  S(   Ns'   Writing resource data at the wrong time(   RL   R_   R`   R   R   R4   RU   (   R   R)   (    (    s   /usr/lib/python2.6/binhex.pyt
   write_rsrcç   s    c         C   sŒ   |  i  t j  o |  i ƒ  n |  i  t j o t d ‚ n |  i d j o t d |  i f ‚ n |  i ƒ  |  i i ƒ  d  |  _  |  ` d  S(   Ns   Close at the wrong timei    s$   Incorrect resource-datasize, diff=%r(	   RL   R_   R`   R   R   RV   R0   R'   RI   (   R   (    (    s   /usr/lib/python2.6/binhex.pyR'   ï   s    
	(
   R   R   R   RJ   RU   RV   R.   R`   Ra   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyRB   ¬   s   				
			c         C   sÁ   t  |  ƒ } t | | ƒ } t |  d ƒ } x+ | i d ƒ } | p Pn | i | ƒ q- | i ƒ  | i ƒ  t |  d ƒ } x+ | i d ƒ } | p Pn | i | ƒ q~ | i ƒ  | i ƒ  d S(   s@   (infilename, outfilename) - Create binhex-encoded copy of a fileR   i ô N(	   R   RB   R   R$   R.   R`   R'   R   Ra   (   t   inpt   outR   R0   t   ifpRX   (    (    s   /usr/lib/python2.6/binhex.pyR    ü   s$     

 
t   _Hqxdecoderenginec           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s*   Read data via the decoder in 4-byte chunksc         C   s   | |  _  d |  _ d  S(   Ni    (   Rd   t   eof(   R   Rd   (    (    s   /usr/lib/python2.6/binhex.pyR     s    	c         C   sþ   d } | } xë | d j oÝ |  i  o | S| d d d } |  i i | ƒ } xi y t i | ƒ \ } |  _  PWn t i j
 o n X|  i i d ƒ } | p t d ‚ n | | } qR | | } | t | ƒ } | o |  i  o t d ‚ q q W| S(   s&   Read at least wtd bytes (or until EOF)R-   i    i   i   i   i   s   Premature EOF on binhex file(   Rf   Rd   R$   R5   t   a2b_hqxt
   IncompleteR   R4   (   R   t   totalwtdt   decdatat   wtdR)   t
   decdatacurt   newdata(    (    s   /usr/lib/python2.6/binhex.pyR$     s0     
 

c         C   s   |  i  i ƒ  d  S(   N(   Rd   R'   (   R   (    (    s   /usr/lib/python2.6/binhex.pyR'   ;  s    (   R   R   R=   R   R$   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyRe     s   		"t   _Rledecoderenginec           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   s   Read data via the RLE-coderc         C   s(   | |  _  d |  _ d |  _ d |  _ d  S(   NR-   i    (   Rd   t
   pre_buffert   post_bufferRf   (   R   Rd   (    (    s   /usr/lib/python2.6/binhex.pyR   A  s    			c         C   sU   | t  |  i ƒ j o |  i | t  |  i ƒ ƒ n |  i |  } |  i | |  _ | S(   N(   R4   Rp   t   _fill(   R   Rk   t   rv(    (    s   /usr/lib/python2.6/binhex.pyR$   G  s
    c         C   s.  |  i  |  i i | d ƒ |  _  |  i i o* |  i t i |  i  ƒ |  _ d |  _  d  St |  i  ƒ } |  i  d t d t j o | d } nk |  i  d t j o | d } nI |  i  d t d j o | d } n# |  i  d t j o n | d	 } |  i t i |  i  |  ƒ |  _ |  i  | |  _  d  S(
   Ni   R-   iýÿÿÿRQ   i   iÿÿÿÿi   iþÿÿÿi   (	   Ro   Rd   R$   Rf   Rp   R5   t   rledecode_hqxR4   t   RUNCHAR(   R   Rk   t   mark(    (    s   /usr/lib/python2.6/binhex.pyRq   N  s&     	
c         C   s   |  i  i ƒ  d  S(   N(   Rd   R'   (   R   (    (    s   /usr/lib/python2.6/binhex.pyR'   q  s    (   R   R   R=   R   R$   Rq   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyRn   >  s
   			#t   HexBinc           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   sÇ   t  | ƒ t  d ƒ j o t | ƒ } n xi | i d ƒ } | p t d ‚ n | d j o q, n | d j o Pn | d j o | i ƒ  } q, q, t | ƒ } t | ƒ |  _ d |  _ |  i	 ƒ  d  S(   NR-   i   s   No binhex data founds   R"   s   
i    (
   RF   R   R$   R   t   readlineRe   Rn   Rd   RH   t   _readheader(   R   Rd   t   cht   dummyt   hqxifp(    (    s   /usr/lib/python2.6/binhex.pyR   u  s     	c         C   s.   |  i  i | ƒ } t i | |  i ƒ |  _ | S(   N(   Rd   R$   R5   R]   RH   (   R   R4   R)   (    (    s   /usr/lib/python2.6/binhex.pyt   _read  s    c         C   sm   t  i d |  i i d ƒ ƒ d d @} |  i d @|  _ | |  i j o t d |  i | f ‚ n d |  _ d  S(   Ns   >hi   i    iÿÿ  s   CRC error, computed %x, read %x(   RS   t   unpackRd   R$   RH   R   (   R   t   filecrc(    (    s   /usr/lib/python2.6/binhex.pyt	   _checkcrc’  s    &c      	   C   sú   |  i  d ƒ } |  i  t | ƒ ƒ } |  i  d ƒ } |  i ƒ  | d d !} | d d !} t i d | d d !ƒ d } t i d	 | d d
 !ƒ d |  _ t i d	 | d
 d !ƒ d |  _ | |  _ t ƒ  |  _ | |  i _	 | |  i _
 | |  i _ t |  _ d  S(   Ni   i   i   i   i	   s   >hi   i    s   >li   i   i   i	   i   i   i   (   R|   R&   R   RS   R}   R   R   t   FNameR   R   R   R   RK   RL   (   R   R4   t   fnamet   restRF   t   creatort   flags(    (    s   /usr/lib/python2.6/binhex.pyRx   œ  s    
  	c         G   sŸ   |  i  t j o t d ‚ n | o  | d } t | |  i ƒ } n
 |  i } d } x5 t | ƒ | j  o! | |  i | t | ƒ ƒ } qV W|  i | |  _ | S(   Ns   Read data at wrong timei    R-   (   RL   RK   R   t   minR   R4   R|   (   R   t   nRr   (    (    s   /usr/lib/python2.6/binhex.pyR$   °  s    
	 "c         C   sT   |  i  t j o t d ‚ n |  i o |  i |  i ƒ } n |  i ƒ  t |  _  d  S(   Ns   close_data at wrong time(   RL   RK   R   R   R|   R   R_   (   R   Rz   (    (    s   /usr/lib/python2.6/binhex.pyR`   ¾  s    

c         G   sˆ   |  i  t j o |  i ƒ  n |  i  t j o t d ‚ n | o  | d } t | |  i ƒ } n
 |  i } |  i | |  _ |  i | ƒ S(   Ns    Read resource data at wrong timei    (   RL   RK   R`   R_   R   R…   R   R|   (   R   R†   (    (    s   /usr/lib/python2.6/binhex.pyt	   read_rsrcÆ  s    
	c         C   sD   |  i  o |  i |  i  ƒ } n |  i ƒ  t |  _ |  i i ƒ  d  S(   N(   R   R‡   R   t	   _DID_RSRCRL   Rd   R'   (   R   Rz   (    (    s   /usr/lib/python2.6/binhex.pyR'   Ó  s
    

	(
   R   R   R   R|   R   Rx   R$   R`   R‡   R'   (    (    (    s   /usr/lib/python2.6/binhex.pyRv   t  s   			
				c         C   ss  t  |  ƒ } | i } | p | i } n t i d j o t | ƒ } | i ƒ  } n t | d ƒ } x+ | i d ƒ } | p Pn | i	 | ƒ qg | i
 ƒ  | i ƒ  | i d ƒ } | oX t | d ƒ } | i	 | ƒ x+ | i d ƒ } | p Pn | i	 | ƒ qÛ | i
 ƒ  n t i d j oA | i ƒ  } | i | _ | i | _ | i | _ | i | ƒ n | i
 ƒ  d S(   s0   (infilename, outfilename) - Decode binhexed fileRD   t   wbi ô N(   Rv   R   R€   R
   R   R   t   as_pathnameR   R$   R.   R'   R`   R‡   R   t   GetFInfoR   R   R   t   SetFInfo(   Rb   Rc   Rd   R   t   ofssR0   RX   t   nfinfo(    (    s   /usr/lib/python2.6/binhex.pyR   Ú  s@    	 

 c          C   sD   t  i d }  t |  |  d ƒ t |  d |  d ƒ t  i d ƒ d  S(   Ni   s   .hqxs   .viahqx(   t   syst   argvR    R   t   exit(   R   (    (    s   /usr/lib/python2.6/binhex.pyt   _test   s    t   __main__(    (    (    (    (    (    (    (    ("   R=   R   R
   RS   R5   t   __all__t	   ExceptionR   t   rangeRK   R_   Rˆ   R?   R2   RR   Rt   t   Carbon.FileR   R   t   MacOSR   R   R   t   ImportErrorR/   R>   RB   R    Re   Rn   Rv   R   R’   R   (    (    (    s   /usr/lib/python2.6/binhex.pyt   <module>   s<   		'P	,6f	&	