³ò
OÉcIc        
   @   s  d  Z  d d k l Z d d k Z d d k Z d d k Z d d k Z d d k Z d d k Z d a
 d a d a d a d e f d „  ƒ  YZ d „  Z d „  Z d „  Z d	 „  Z d
 „  Z d „  Z d „  Z d e i f d „  ƒ  YZ d d „ Z d „  Z d „  Z e d d „ Z d S(   s¬  Coordinate corresponding files with different names

For instance, some source filenames may contain characters not allowed
on the mirror end.  These files must be called something different on
the mirror end, so we escape the offending characters with semicolons.

One problem/complication is that all this escaping may put files over
the 256 or whatever limit on the length of file names.  (We just don't
handle that error.)

iÿÿÿÿ(   t
   generatorsNt   QuotingExceptionc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyR   0   s    c          C   s%   x t  i D] }  |  i i ƒ  q
 Wd S(   s+   Set quoting value from Globals on all connsN(   t   Globalst   connectionst   FilenameMappingt   set_init_quote_vals_local(   t   conn(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   set_init_quote_vals2   s    
 c           C   sQ   t  i a t t  i ƒ d j o t i i d t  i f ƒ n t  i a t ƒ  d S(   s1   Set value on local connection, initialize regexpsi   s;   Expected single character for quoting char,got '%s' insteadN(   R   t   chars_to_quotet   lent   quoting_chart   logt   Logt
   FatalErrort   init_quoting_regexps(    (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyR   7   s    		c           C   s¤   t  o t t  ƒ t i j p t d t  f ‚ y< t i d t  t f t i ƒ a	 t i d t t i ƒ a
 Wn3 t i j
 o$ t i i d t i t  f ƒ n Xd S(   s#   Compile quoting regular expressionss   Chars to quote: '%s's   [%s]|%ss
   %s[0-9]{3}s-   Error '%s' when processing char quote list %rN(   R
   t   typet   typest
   StringTypet   AssertionErrort   ret   compileR   t   St   chars_to_quote_regexpt   unquoting_regexpt   errorR   R   R   (    (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyR   A   s     c         C   sæ   t  i t |  ƒ } t i o t i o | Sn t i ok t | ƒ oH | d d j p | d d j o& | d  d t t | d ƒ f } n t i p | Sq¥ n t	 i
 d | t	 i ƒ p | Sn d t t | d ƒ f | d S(   sû   Return quoted version of given path

	Any characters quoted will be replaced by the quoting char and
	the ascii number of the character.  For instance, "10:11:12"
	would go to "10;05811;05812" if ":" were quoted and ";" were
	the quoting character.

	iÿÿÿÿt    t   .s   %s%03dsZ   ^aux(\..*)*$|^prn(\..*)*$|^con(\..*)*$|^nul(\..*)*$|^com[0-9](\..*)*$|^lpt[1-9]{1}(\..*)*$i    i   (   R   t   subt   quote_singleR   t   must_escape_dos_devicest   must_escape_trailing_spacesR   R   t   ordR   t   searcht   I(   t   patht
   QuotedPath(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   quoteN   s    	
/
	c         C   s   d t  t |  i ƒ  ƒ f S(   s)   Return replacement for a single characters   %s%03d(   R   R!   t   group(   t   match(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyR   n   s    c         C   s   t  i t |  ƒ S(   s*   Return original version of quoted filename(   R   R   t   unquote_single(   R$   (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   unquoter   s    c         C   s   t  |  i ƒ  ƒ d j p t d |  i ƒ  ƒ ‚ n y t t |  i ƒ  d ƒ ƒ SWn) t j
 o t d |  i ƒ  ƒ ‚ n Xd S(   s!   Unquote a single quoted characteri   s   Quoted group wrong size: i   s   Quoted out of range: N(   R   R'   R   t   chrt   intt
   ValueError(   R(   (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyR)   v   s     t   QuotedRPathc           B   sA   e  Z d  Z d d d „ Z d „  Z d „  Z d „  Z d „  Z RS(   sß   RPath where the filename is quoted version of index

	We use QuotedRPaths so we don't need to remember to quote RPaths
	derived from this one (via append or new_index).  Note that only
	the index is quoted, not the base.

	c         C   sÂ   t  t t | ƒ ƒ |  _ | |  _ | |  _ | |  _ | d j	 oJ | d j o d d i |  i ƒ |  _	 qŠ d i | f |  i ƒ |  _	 n d |  _
 | p | d j o | |  _ n |  i ƒ  d S(   s   Make new QuotedRPatht   /N(   t   tuplet   mapR&   t   quoted_indexR   t   indext   baset   Nonet   joinR$   t   filet   datat   setdata(   t   selft
   connectionR4   R3   R8   (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   __init__‡   s    			  	 c         C   si   | \ } |  _  |  _ |  _ t i | |  _ t t t |  i ƒ ƒ |  _	 d i
 |  i  f |  i	 ƒ |  _ d S(   s.   Reproduce QuotedRPath from __getstate__ outputR/   N(   R4   R3   R8   R   t   connection_dictR   R0   R1   R&   R2   R6   R$   (   R:   t   rpath_statet   conn_number(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   __setstate__”   s    c         C   s   t  t |  i i i |  i ƒ ƒ S(   s¬   Return list of unquoted filenames in current directory

		We want them unquoted so that the results can be sorted
		correctly and append()ed to the currect QuotedRPath.

		(   R1   R*   R   t   ost   listdirR$   (   R:   (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyRB   ›   s    c         C   s   d |  i  |  i |  i f S(   Ns!   QuotedPath: %s
Index: %s
Data: %s(   R$   R3   R8   (   R:   (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   __str__¤   s    c         C   s¯   |  i  pr |  i ƒ  \ } } t i |  i | t | ƒ f ƒ } | i ƒ  } | o( t | i ƒ |  _ t | i ƒ |  _ q« n0 t i i |  ƒ } | o t |  i ƒ |  _ n | S(   s?   Return true if path indicates increment, sets various variables(	   R3   t   dirsplitt   rpatht   RPathR   R*   t	   isincfilet   inc_basestrt   inc_timestr(   R:   t   dirnamet   basenamet   temp_rpt   result(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyRG   ¨   s    
! (    N(	   R   R   t   __doc__R5   R<   R@   RB   RC   RG   (    (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyR.      s   				i    c         C   sq   |  i  p t ‚ | o8 |  i ƒ  \ } } t |  i | t | ƒ f |  i ƒ Sn t |  i |  i d |  i ƒ Sd S(   s!   Return quoted version of rpath rpN(    (   R3   R   RD   R.   R   R*   R8   R4   (   t   rpt   separate_basenameRJ   RK   (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   get_quotedrpath¶   s
    &c         C   s   t  t i t i |  ƒ d ƒ S(   s9   Get QuotedRPath from filename assuming last bit is quotedi   (   RQ   RE   RF   R   t   local_connection(   t   filename(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   get_quoted_sep_base¾   s    c   
         sü   d „  ‰  ‡  f d †  } |  i  t i j p t ‚ |  i ƒ  } | i } t i d | i d ƒ y t i	 } Wn t
 j
 o t	 } n Xxn | | ƒ D]` \ } } } | i | ƒ } x | D] }	 | | |	 | ƒ q¹ Wx | D] }	 | | |	 d ƒ qÚ Wq” Wd S(   s^   Update the quoting of a repository by renaming any
	files that should be quoted differently.
	c         S   s5   t  |  ƒ } t | ƒ } |  | j o | Sn d  Sd  S(   N(   R*   R&   R5   (   t   namet   unquoted_namet   quoted_name(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   requoteÇ   s
    c            sŽ   ˆ  | ƒ } | ow | o | i  | ƒ | i | ƒ n |  i | ƒ } |  i | ƒ } t i d | i | i f d ƒ t i | | ƒ n d  S(   Ns   Re-quoting %s to %si   (   t   removet   appendR   R   R$   RE   t   move(   t
   dirpath_rpRU   t   listt   new_namet   name_rpt   new_rp(   RX   (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   processÏ   s     s   Re-quoting repository %si   N(   R   R   RR   R   t   get_parent_rpR$   R   R   RA   t   walkt   AttributeErrort   newpathR5   (
   t   rbdirRa   t	   mirror_rpt   mirrort   os_walkt   dirpatht   dirst   filesR\   RU   (    (   RX   sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyt   update_quotingÂ   s&    		     c         c   sT  d d k  l } l } d d k l } l } l } y | |  ƒ } Wn4 | j
 o( }	 | d  j	 o | |	 ƒ n d  Sn Xg  g  }
 } xB | D]: } | | |  | ƒ ƒ o |
 i | ƒ q | i | ƒ q W| o |  |
 | f Vn xP |
 D]H } | |  | ƒ } | | ƒ p& x# t	 | | | ƒ D] } | Vq Wqë që W| p |  |
 | f Vn d  S(   Niÿÿÿÿ(   R   RB   (   R6   t   isdirt   islink(
   RA   R   RB   t   os.pathR6   Rn   Ro   R5   RZ   Rc   (   t   topt   topdownt   onerrorR   RB   R6   Rn   Ro   t   namest   errRk   t   nondirsRU   R$   t   x(    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pyRc   ñ   s2    	   (   RN   t
   __future__R    RA   R   R   R   R   RE   R5   R
   R   R   R   t	   ExceptionR   R	   R   R   R&   R   R*   R)   RF   R.   RQ   RT   Rm   t   TrueRc   (    (    (    sA   /var/lib/python-support/python2.5/rdiff_backup/FilenameMapping.pys   <module>   s(   $$		
		 				7		/