§
    cÌc  ã                   ó¨  — d Z ddlmZmZ ddlmZmZmZ ddl	m	Z	  e	 e
¦   «         d¦  «          G d„ dej        ¦  «        Z G d	„ d
e¦  «        Z G d„ de¦  «        Z G d„ dej        ¦  «        Z e¦   «         Z G d„ d¦  «        Z G d„ de¦  «        Ze                     ded¦  «          G d„ de¦  «        Ze                     ded¦  «         dS )zÀDirectory service registration and usage.

Directory services are utilities that provide a mapping from URL-like strings
to true URLs.  Examples include lp:urls and per-user location aliases.
é    )ÚCallableÚOptionalé   )ÚbranchÚerrorsÚregistry)Úlazy_importzM
from breezy import (
    controldir as _mod_controldir,
    urlutils,
    )
c                   ó   — e Zd ZdZdS )ÚDirectoryLookupFailurezBase type for lookup errors.N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    ú:/usr/lib/python3/dist-packages/breezy/directory_service.pyr   r   '   s   € € € € € Ø&Ð&Ð&Ð&r   r   c                   ó   — e Zd ZdZd„ ZdS )ÚInvalidLocationAliasz/"%(alias_name)s" is not a valid location alias.c                 ó>   — t                                | |¬¦  «         d S )N©Ú
alias_name©r   Ú__init__©Úselfr   s     r   r   zInvalidLocationAlias.__init__/   s!   € Ý×'Ò'¨¸Ð'ÑDÔDÐDÐDÐDr   N©r   r   r   Ú_fmtr   r   r   r   r   r   +   s-   € € € € € à<€DðEð Eð Eð Eð Er   r   c                   ó   — e Zd ZdZd„ ZdS )ÚUnsetLocationAliasz$No %(alias_name)s location assigned.c                 óN   — t                                | |dd …         ¬¦  «         d S )Nr   r   r   r   s     r   r   zUnsetLocationAlias.__init__7   s)   € Ý×'Ò'¨¸ÀAÀBÀB¼Ð'ÑHÔHÐHÐHÐHr   Nr   r   r   r   r   r   3   s-   € € € € € à1€DðIð Ið Ið Ið Ir   r   c                   ó   — e Zd ZdZdd„ZdS )ÚDirectoryServiceRegistrya—  This object maintains and uses a list of directory services.

    Directory services may be registered via the standard Registry methods.
    They will be invoked if their key is a prefix of the supplied URL.

    Each item registered should be a factory of objects that provide a look_up
    method, as invoked by dereference.  Specifically, look_up should accept a
    name and URL, and return a URL.
    Nc                 óÐ   — |                       |¦  «        }|€|S |\  }} |¦   «         }	 |                     |||¬¦  «        S # t          $ r |                     ||¦  «        cY S w xY w)aú  Dereference a supplied URL if possible.

        URLs that match a registered directory service prefix are looked up in
        it.  Non-matching urls are returned verbatim.

        This is applied only once; the resulting URL must not be one that
        requires further dereferencing.

        :param url: The URL to dereference
        :param purpose: Purpose of the URL ('read', 'write' or None - if not declared)
        :return: The dereferenced URL if applicable, the input URL otherwise.
        N)Úpurpose)Ú
get_prefixÚlook_upÚ	TypeError)r   Úurlr$   ÚmatchÚserviceÚnameÚ	directorys          r   Údereferencez$DirectoryServiceRegistry.dereferenceF   sŠ   € ð —’ Ñ$Ô$ˆØˆ=ØˆJØ‰ˆ�Ø�G‘I”Iˆ	ð	0Ø×$Ò$ T¨3¸Ð$Ñ@Ô@Ð@øÝð 	0ð 	0ð 	0à×$Ò$ T¨3Ñ/Ô/Ð/Ð/Ð/ð	0øøøs   ªA Á A%Á$A%©N)r   r   r   r   r-   r   r   r   r"   r"   ;   s2   € € € € € ðð ð0ð 0ð 0ð 0ð 0ð 0r   r"   c                   ó   — e Zd ZdZdd„ZdS )Ú	Directoryz Abstract directory lookup class.Nc                 ó*   — t          | j        ¦  «        ‚)a  Look up an entry in a directory.

        :param name: Directory name
        :param url: The URL to dereference
        :param purpose: Purpose of the URL ('read', 'write' or None - if not declared)
        :return: The dereferenced URL if applicable, the input URL otherwise.
        )ÚNotImplementedErrorr&   )r   r+   r(   r$   s       r   r&   zDirectory.look_upe   s   € õ " $¤,Ñ/Ô/Ð/r   r.   ©r   r   r   r   r&   r   r   r   r0   r0   b   s.   € € € € € Ø*Ð*ð0ð 0ð 0ð 0ð 0ð 0r   r0   c                   ó²  — e Zd ZdZ ej        eeej	        ge
e         f         f         ¦   «         Ze                     dd„ d¬¦  «         e                     dd„ d¬¦  «         e                     d	d
„ d¬¦  «         e                     dd„ d¬¦  «         e                     dd„ d¬¦  «         e                     dd„ d¬¦  «         dd„Zed„ ¦   «         ZdS )ÚAliasDirectoryzÓDirectory lookup for locations associated with a branch.

    :parent, :submit, :public, :push, :this, and :bound are currently
    supported.  On error, a subclass of DirectoryLookupFailure will be raised.
    Úparentc                 ó*   — |                       ¦   «         S r.   )Ú
get_parent©Úbs    r   ú<lambda>zAliasDirectory.<lambda>x   s   € °·²±´€ r   zThe parent of this branch.)ÚhelpÚsubmitc                 ó*   — |                       ¦   «         S r.   )Úget_submit_branchr9   s    r   r;   zAliasDirectory.<lambda>z   ó   € °×0CÒ0CÑ0EÔ0E€ r   z"The submit branch for this branch.Úpublicc                 ó*   — |                       ¦   «         S r.   )Úget_public_branchr9   s    r   r;   zAliasDirectory.<lambda>|   r@   r   z#The public location of this branch.Úboundc                 ó*   — |                       ¦   «         S r.   )Úget_bound_locationr9   s    r   r;   zAliasDirectory.<lambda>~   s   € ¨q×/CÒ/CÑ/EÔ/E€ r   z7The branch this branch is bound to, for bound branches.Úpushc                 ó*   — |                       ¦   «         S r.   )Úget_push_locationr9   s    r   r;   zAliasDirectory.<lambda>€   s   € ¨a×.AÒ.AÑ.CÔ.C€ r   z9The saved location used for `brz push` with no arguments.Úthisc                 ó   — | j         S r.   )Úbaser9   s    r   r;   zAliasDirectory.<lambda>‚   s   € ¨a¬f€ r   zThis branch.Nc                 ó®  — t           j                             d¦  «        d         }|                     dd¦  «        }t	          |¦  «        dk    r|\  }}n|\  }d }	 | j                             |dd …         ¦  «        } ||¦  «        }n# t          $ r t          |¦  «        ‚w xY w|€t          |¦  «        ‚|�t                               ||¦  «        }|S )Nú.r   ú/r   é   )Ú_mod_branchÚBranchÚopen_containingÚsplitÚlenÚbranch_aliasesÚgetÚKeyErrorr   r   ÚurlutilsÚjoin)	r   r+   r(   r$   r   ÚpartsÚextraÚmethodÚresults	            r   r&   zAliasDirectory.look_up…   sè   € ÝÔ#×3Ò3°CÑ8Ô8¸Ô;ˆØ—	’	˜#˜qÑ!Ô!ˆÝˆu‰:Œ:˜Š?ˆ?Ø‰KˆD�%�%à‰GˆTØˆEð	$ØÔ(×,Ò,¨T°!°"°"¬XÑ6Ô6ˆFð �V˜F‘^”^ˆFˆFøõ ð 	,ð 	,ð 	,Ý& sÑ+Ô+Ð+ð	,øøøð ˆ>Ý$ SÑ)Ô)Ð)ØÐÝ—]’] 6¨5Ñ1Ô1ˆFØˆs   Á"B
 Â
B$c                 óÚ   — g }| j                              ¦   «         D ]8}| j                              |¦  «        }|                     d|d›|›d�¦  «         Œ9dd                     |¦  «        z  S )Nz  :Ú10ú
a  Location aliases
================

Bazaar defines several aliases for locations associated with a branch.  These
can be used with most commands that expect a location, such as `brz push`.

The aliases are::

%s
For example, to push to the parent location::

    brz push :parent
Ú )rV   ÚkeysÚget_helpÚappendrZ   )ÚclsÚtopicÚalias_linesÚkeyr<   s        r   Ú	help_textzAliasDirectory.help_text™   s‚   € àˆØÔ%×*Ò*Ñ,Ô,ð 	=ð 	=ˆCØÔ%×.Ò.¨sÑ3Ô3ˆDØ×ÒÐ°°°°d°d°dÐ;Ñ<Ô<Ð<Ð<ðð 	‡g‚gˆkÑÔñð 	r   r.   )r   r   r   r   r   ÚRegistryÚstrr   rQ   rR   r   rV   Úregisterr&   Úclassmethodrj   r   r   r   r5   r5   p   s{  € € € € € ðð ð [�XÔ& s¨H°kÔ6HÐ5IÈ8ÐTWÌ=Ð5XÔ,YÐ'YÔZÑ\Ô\€NØ×Ò˜HÐ&>Ð&>Ø!=ð ñ ?ô ?ð ?à×Ò˜HÐ&EÐ&EØ!Eð ñ Gô Gð Gà×Ò˜HÐ&EÐ&EØ!Fð ñ Hô Hð Hà×Ò˜GÐ%EÐ%EØ!Zð ñ \ô \ð \à×Ò˜FÐ$CÐ$CØ!\ð ñ ^ô ^ð ^à×Ò˜FÐ$4Ð$4Ø!/ð ñ 1ô 1ð 1ðð ð ð ð( ðð ñ „[ðð ð r   r5   ú:z*Easy access to remembered branch locationsc                   ó   — e Zd ZdZdd„ZdS )ÚColocatedDirectoryz‘Directory lookup for colocated branches.

    co:somename will resolve to the colocated branch with "somename" in
    the current directory.
    Nc                 óÀ   — t           j                             d¦  «        d         }t                               |j        dt                               |¦  «        i¦  «        S )NrN   r   r   )Ú_mod_controldirÚ
ControlDirrS   rY   Újoin_segment_parametersÚuser_urlÚescape)r   r+   r(   r$   Údirs        r   r&   zColocatedDirectory.look_upº   sM   € ÝÔ(×8Ò8¸Ñ=Ô=¸aÔ@ˆÝ×/Ò/ØŒL˜8¥X§_¢_°TÑ%:Ô%:Ð;ñ=ô =ð 	=r   r.   r3   r   r   r   rq   rq   ³   s2   € € € € € ðð ð=ð =ð =ð =ð =ð =r   rq   zco:z!Easy access to colocated branchesN)r   Útypingr   r   rb   r   rQ   r   r   r	   ÚglobalsÚBzrErrorr   r   r   rk   r"   Údirectoriesr0   r5   rm   rq   r   r   r   ú<module>r}      s-  ðð"ð ð &Ð %Ð %Ð %Ð %Ð %Ð %Ð %ðð ð ð ð ð ð ð ð ð ð
 %Ð $Ð $Ð $Ð $Ð $Ø €ˆGˆG‰IŒIð ñ ô ð ð'ð 'ð 'ð 'ð '˜Vœ_ñ 'ô 'ð 'ðEð Eð Eð Eð EÐ1ñ Eô Eð EðIð Ið Ið Ið IÐ/ñ Iô Ið Ið!0ð !0ð !0ð !0ð !0˜xÔ0ñ !0ô !0ð !0ðH 'Ð&Ñ(Ô(€ð0ð 0ð 0ð 0ð 0ñ 0ô 0ð 0ð<ð <ð <ð <ð <�Yñ <ô <ð <ð~ × Ò �S˜.ØAñCô Cð Cð
=ð 
=ð 
=ð 
=ð 
=˜ñ 
=ô 
=ð 
=ð × Ò �UÐ.Ø8ñ:ô :ð :ð :ð :r   