HEX
Server: Apache
System: Linux infong-uk86 4.4.400-icpu-106 #2 SMP Mon Sep 15 08:23:40 UTC 2025 x86_64
User: u44115835 (4976590)
PHP: 8.4.17
Disabled: NONE
Upload Files
File: //kunden/lib/python3/dist-packages/breezy/__pycache__/location.cpython-39.pyc
a

���_�@s�dZddlmZddlZddlmZddlmZddlm	Z	m
Z
Gdd	�d	e�Ze�Zd
d�Zdd
d�Z
dd�Zdd�Zddd�ZdS)zUI location string handling.�)�absolute_importN�)�urlutils)�Hooks)�PY3�string_typesc@seZdZdZdd�ZdS)�
LocationHookszLDictionary mapping hook name to a list of callables for location hooks.
    cCs t�|dd�|�ddd�dS)Nzbreezy.location�hooks�rewrite_urlzPPossibly rewrite a URL. Called with a URL to rewrite and the purpose of the URL.)�r)r�__init__Zadd_hook)�self�r�1/usr/lib/python3/dist-packages/breezy/location.pyr&s�zLocationHooks.__init__N)�__name__�
__module__�__qualname__�__doc__rrrrrr"srcCsbt�d|�}|std��|�d��d�r0td��|�d�|�d�rT|�d�dd	�nd|�d�fS)
�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
    z2^(?P<user>[^@:/]+@)?(?P<host>[^/:]+):(?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�mrrr�parse_rcp_location0s�r �sshc	CsJt|�\}}}|rt�|�nd}tj||ddt�|�t�|�d�}t|�S)rN)�scheme�quoted_user�port�quoted_password�quoted_host�quoted_path)r r�quote�URL�str)rr"rrrr#�urlrrr�rcp_location_to_urlBs�r,cCs�|�d�}|ds|ddvr&td��z|d�dd�\}}Wnty\|d}d}Yn0|d}|dkrrd	}|d
}||||fS)N�:rr)Zpserverr!�extsshznot a valid CVS location string��@r.r!r)�splitr�
IndexError)r�partsZusernameZhostnamer"rrrr�parse_cvs_locationTs

r4c
CsHt|�\}}}}ttjd||r*t�|�ndt�|�ddt�|�d��S)zuConvert a CVS pserver location string to a URL.

    :param location: pserver URL
    :return: A cvs+pserver URL
    zcvs+N)r"r#r&r%r$r')r4r*rr)r()rr"rrrrrr�
cvs_to_urlds�r5cCs$t|t�std��|�d�s&|�d�r.t|�Sddlm}|�||�}z|�d�}Wn4t	y�t
�|�rzt
j|dd��t
�
|�}Yn0tr�|�d�}|�d	�r�|�d
�s�t
�t
�
d�|dd
��Szt|dd�}Wnty�Yn0|St
�|��st
�
|�StdD]}|||d�}�q|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 stringz	:pserver:z:extssh:r)�directories�asciizURLs must be properly escaped)rZextrazfile:zfile://�.�Nr!)r"r
)�purpose)�
isinstancer�AssertionErrorrr5Zdirectory_servicer6Zdereference�encode�UnicodeErrorrZis_urlZ
InvalidURLZlocal_path_to_urlr�decode�joinr,rr	)rr:r6r+�hookrrr�location_to_urlts8

�

rB)r!)N)rZ
__future__rr�rr	rZsixishrrrr r,r4r5rBrrrr�<module>s