§
    cÌc˜  ã                   ó|   — d Z ddlZddlmZ ddlmZ  G d„ de¦  «        Z e¦   «         Zd„ Zdd
„Zd„ Z	d„ Z
dd„ZdS )zUI location string handling.é    Né   )Úurlutils)ÚHooksc                   ó   — e Zd ZdZd„ ZdS )ÚLocationHookszLDictionary mapping hook name to a list of callables for location hooks.
    c                 óŽ   — t          j        | dd¦  «         |                      ddd¦  «         |                      ddd¦  «         d S )	Nzbreezy.locationÚhooksÚrewrite_urlzPPossibly rewrite a URL. Called with a URL to rewrite and the purpose of the URL.)é   r   Úrewrite_locationzaPossibly rewrite a location. Called with a location string to rewrite and the purpose of the URL.)r   é   )r   Ú__init__Úadd_hook)Úselfs    ú1/usr/lib/python3/dist-packages/breezy/location.pyr   zLocationHooks.__init__    se   € ÝŒ�tÐ.°Ñ8Ô8Ð8Ø�ŠØð"Ø#)ñ	+ô 	+ð 	+ð 	�ŠØð2Ø39ñ	;ô 	;ð 	;ð 	;ð 	;ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   © r   r   r   r      s-   € € € € € ðð ð	;ð 	;ð 	;ð 	;ð 	;r   r   c                 óv  — t          j        d| ¦  «        }|st          d¦  «        ‚|                     d¦  «                             d¦  «        rt          d¦  «        ‚|                     d¦  «        |                     d¦  «        r|                     d¦  «        dd	…         nd|                     d¦  «        fS )
á   Convert a rcp-style location to a URL.

    :param location: Location to convert, e.g. "foo:bar"
    :param scheme: URL scheme to return, defaults to "ssh"
    :return: A URL, e.g. "ssh://foo/bar"
    :raises ValueError: if this is not a RCP-style URL
    z5^(?P<user>[^@:/]+@)?(?P<host>[^/:]{2,}):(?P<path>.*)$zNot a RCP URLÚpathz//z'Not a RCP URL: already looks like a URLÚhostÚuserNéÿÿÿÿ)ÚreÚmatchÚ
ValueErrorÚgroupÚ
startswith)ÚlocationÚms     r   Úparse_rcp_locationr%   .   s±   € õ 	ŒØ?Øñ	ô 	€Að ð *Ý˜Ñ)Ô)Ð)Ø‡w‚wˆv�„×!Ò! $Ñ'Ô'ð DÝÐBÑCÔCÐCØ�GŠG�F‰OŒOØ$%§G¢G¨F¡O¤OÐ=ˆA�GŠG�F‰OŒO˜C˜R˜CÔ Ð ¸Ø�GŠG�F‰OŒOðð r   Ússhc           
      óò   — t          | ¦  «        \  }}}|rt          j        |¦  «        nd}t          j        ||ddt          j        |¦  «        t          j        |¦  «        ¬¦  «        }t	          |¦  «        S )r   N)ÚschemeÚquoted_userÚportÚquoted_passwordÚquoted_hostÚquoted_path)r%   r   ÚquoteÚURLÚstr)r#   r(   r   r   r   r)   Úurls          r   Úrcp_location_to_urlr2   B   sx   € õ ,¨HÑ5Ô5Ñ€Tˆ4�Ø*.Ð8•(”. Ñ&Ô&Ð&°D€KÝ
Œ,Ø ;Ø 4Ý”N 4Ñ(Ô(Ý”N 4Ñ(Ô(ð	*ñ *ô *€Cõ
 ˆs‰8Œ8€Or   c                 ód  — |                       d¦  «        }|d         s
|d         dvrt          d¦  «        ‚	 |d                               dd¦  «        \  }}n# t          $ r |d         }d }Y nw xY w|d         }|dk    rd	}	 |d
         }n # t          $ r t          d| z  ¦  «        ‚w xY w||||fS )Nú:r   r   )Úpserverr&   Úextsshznot a valid CVS location stringr   ú@r6   r&   r   z"no path element in CVS location %s)Úsplitr    Ú
IndexError)r#   ÚpartsÚusernameÚhostnamer(   r   s         r   Úparse_cvs_locationr=   T   sû   € Ø�NŠN˜3ÑÔ€EØˆQ„xð <�5˜”8Ð#?Ð?Ð?ÝÐ:Ñ;Ô;Ð;ðØ$ QœxŸ~š~¨c°1Ñ5Ô5Ñˆ�8�8øÝð ð ð Ø˜”8ˆØˆˆˆðøøøð �1ŒX€FØ�ÒÐØˆðJØ�QŒxˆˆøÝð Jð Jð JÝÐ=ÀÑHÑIÔIÐIðJøøøà�H˜h¨Ð-Ð-s   ¸A ÁA/Á.A/ÂB ÂB)c                 ó`  — 	 t          | ¦  «        \  }}}}n5# t          $ r(}t          j        | t	          |¦  «        ¬¦  «        ‚d}~ww xY wt	          t          j        d|z   |rt          j        |¦  «        ndt          j        |¦  «        ddt          j        |¦  «        ¬¦  «        ¦  «        S )zuConvert a CVS pserver location string to a URL.

    :param location: pserver URL
    :return: A cvs+pserver URL
    ©r   ÚextraNzcvs+)r(   r)   r,   r+   r*   r-   )r=   r    r   Ú
InvalidURLr0   r/   r.   )r#   r(   r   r   r   Úes         r   Ú
cvs_to_urlrC   g   s½   € ð?Ý%7¸Ñ%AÔ%AÑ"ˆ��t˜T˜TøÝð ?ð ?ð ?ÝÔ! xµs¸1±v´vÐ>Ñ>Ô>Ð>øøøøð?øøøå�xŒ|Ø˜‰Ø,0Ð:•H”N 4Ñ(Ô(Ð(°dÝ”N 4Ñ(Ô(ØØÝ”N 4Ñ(Ô(ð*ñ *ô *ñ +ô +ð +s   ‚ —
A	¡#AÁA	c                 óª  — t          | t          ¦  «        st          d¦  «        ‚t          d         D ]} || |¬¦  «        } Œ|                      d¦  «        s|                      d¦  «        rt          | ¦  «        S ddlm} |                     | |¦  «        } 	 |  	                    d¦  «        } |  
                    d¦  «        } nN# t          $ rA t          j        | ¦  «        rt          j        | d	¬
¦  «        ‚t          j        | ¦  «        } Y nw xY w|                      d¦  «        rD|                      d¦  «        s/t          j        t          j        d¦  «        | dd…         ¦  «        S 	 t#          | d¬¦  «        }|S # t$          $ r Y nw xY wt          j        | ¦  «        st          j        | ¦  «        S t          d         D ]} || |¬¦  «        } Œ| S )a¾  Determine a fully qualified URL from a location string.

    This will try to interpret location as both a URL and a directory path. It
    will also lookup the location in directories.

    :param location: Unicode or byte string object with a location
    :param purpose: Intended method of access (None, 'read' or 'write')
    :raise InvalidURL: If the location is already a URL, but not valid.
    :return: Byte string with resulting URL
    z%location not a byte or unicode stringr   )Úpurposez	:pserver:z:extssh:r   )ÚdirectoriesÚasciizURLs must be properly escapedr?   zfile:zfile://ú.é   Nr&   )r(   r
   )Ú
isinstancer0   ÚAssertionErrorr	   r"   rC   Údirectory_servicerF   ÚdereferenceÚencodeÚdecodeÚUnicodeErrorr   Úis_urlrA   Úlocal_path_to_urlÚjoinr2   r    )r#   rE   ÚhookrF   r1   s        r   Úlocation_to_urlrU   z   s,  € õ �h¥Ñ$Ô$ð FÝÐDÑEÔEÐEåÐ(Ô)ð 3ð 3ˆØ�4˜¨'Ð2Ñ2Ô2ˆˆà×Ò˜;Ñ'Ô'ð $¨8×+>Ò+>¸zÑ+JÔ+Jð $Ý˜(Ñ#Ô#Ð#à.Ð.Ð.Ð.Ð.Ð.Ø×&Ò& x°Ñ9Ô9€Hð,Ø—?’? 7Ñ+Ô+ˆð —?’? 7Ñ+Ô+ˆˆøõ ð 8ð 8ð 8ÝŒ?˜8Ñ$Ô$ð 	FÝÔ%ØÐ%DðFñ Fô Fð FåÔ-¨hÑ7Ô7ˆˆˆð	8øøøð ×Ò˜7Ñ#Ô#ð L¨H×,?Ò,?À	Ñ,JÔ,Jð LÝŒ}�XÔ7¸Ñ<Ô<¸hÀqÀrÀr¼lÑKÔKÐKðÝ! (°5Ð9Ñ9Ô9ˆð ˆ
øõ ð ð ð Øˆðøøøõ
 Œ?˜8Ñ$Ô$ð 4ÝÔ)¨(Ñ3Ô3Ð3å�mÔ$ð 3ð 3ˆØ�4˜¨'Ð2Ñ2Ô2ˆˆà€Os%   ÂC ÃADÄDÅ+E> Å>
FÆ
F)r&   )N)r   r   Ú r   r	   r   r   r%   r2   r=   rC   rU   r   r   r   ú<module>rW      sÞ   ðð$ #Ð "à 	€	€	€	ðð ð ð ð ð ð Ð Ð Ð Ð Ð ð;ð ;ð ;ð ;ð ;�Eñ ;ô ;ð ;ð  	ˆ‰Œ€ðð ð ð(ð ð ð ð$.ð .ð .ð&+ð +ð +ð&2ð 2ð 2ð 2ð 2ð 2r   