
    i8                         d dl Z d dlZd dlmZmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZmZ e j        dk     rd dlmZ nd dlmZ  G d d          Zd	eez  ez  ez  d
efdZdS )    N)Anycast)ParseResultSplitResultquoteunquoteurlparse
urlunparse)to_normal_str
to_unicode)      )Selfc                       e Zd ZdZdeez  ez  ddfdZdefdZ	de
defdZde
defd	Zdefd
Zedeez  ez  ez  dd fd            ZdefdZdefdZdefdZdefdZddZdefdZddZddZdedd fdZdS )URLa  
    This class is for wrapping URLs into objects.  It's used
    internally in the library, end users should not need to know
    anything about this class.  All methods that accept URLs can be
    fed either with a URL object, a string or a urlparse.ParsedURL
    object.

    Addresses may be one out of three:

    1) a path relative to the DAV-root, i.e. "someuser/calendar" may
    refer to
    "http://my.davical-server.example.com/caldav.php/someuser/calendar".

    2) an absolute path, i.e. "/caldav.php/someuser/calendar"

    3) a fully qualified URL, i.e.
    "http://someuser:somepass@my.davical-server.example.com/caldav.php/someuser/calendar".
    Remark that hostname, port, user, pass is typically given when
    instantiating the DAVClient object and cannot be overridden later.

    As of 2013-11, some methods in the caldav library expected strings
    and some expected urlParseResult objects, some expected
    fully qualified URLs and most expected absolute paths.  The purpose
    of this class is to ensure consistency and at the same time
    maintaining backward compatibility.  Basically, all methods should
    accept any kind of URL.

    urlreturnNc                     t          |t                    st          |t                    r|| _        d | _        d S || _        d | _        d S N)
isinstancer   r   
url_parsedurl_rawselfr   s     I/root/projects/butler/venv/lib/python3.11/site-packages/caldav/lib/url.py__init__zURL.__init__-   sI    c;'' 	#:c;+G+G 	#@CDODLLLDL"DOOO    c                 &    | j         s| j        rdS dS )NTF)r   r   r   s    r   __bool__zURL.__bool__5   s    < 	4? 	45r   otherc                     | |k     S r    )r   r!   s     r   __ne__z
URL.__ne__;   s    5=  r   c                     t          |           t          |          k    rdS |                                 }t          |d          r|                                }t          |          t          |          k    S )NT	canonical)strr&   hasattr)r   r!   mes      r   __eq__z
URL.__eq__>   se    t99E

""4^^5+&& 	&OO%%E2ww#e**$$r   c                 ^    t          t          |                                                     S r   )hashr'   r&   r   s    r   __hash__zURL.__hash__G   s"    C(())***r   c                 R    |t          |t                    r|S t          |          S r   )r   r   r   s     r   	objectifyzURL.objectifyM   s%    ;*S#..;Js88Or   attrc                 D   dt          |           vrt          | j        6t          t          j        j        t          | j                            | _        t          | j        |          rt          | j        |          S t          |                                 |          S )Nr   )varsAttributeErrorr   r   urllibparser   r	   r   r(   getattr__unicode__)r   r0   s     r   __getattr__zURL.__getattr__V   s    tDzz))  ?""6<#;Xdl=S=STTDO4?D)) 	54?D1114++--t444r   c                 D    t          |                                           S r   )r   r7   r   s    r   __str__zURL.__str__a   s    T--//000r   c                     | j         4| j        t          d          | j                                        | _         t	          | j                   S )Nz)Unexpected value None for self.url_parsed)r   r   
ValueErrorgeturlr   r   s    r   r7   zURL.__unicode__e   sF    <& !LMMM?1133DL$,'''r   c                 &    dt          |           z  S )NzURL(%s))r'   r   s    r   __repr__zURL.__repr__m   s    3t99$$r   c                     t          |           d         dk    r/t                              t          |           d d                   S | S )N/)r'   r   r/   r   s    r   strip_trailing_slashzURL.strip_trailing_slashp   s<    t99R=C==T3B3000Kr   c                     | j         d uS r   )usernamer   s    r   is_authzURL.is_authv   s    }D((r   c           
         |                                  s| S t                              t          | j        | j        d| j        pddd| j                 | j                            dd          | j	        | j
        | j                            S )N:i  P   )httpshttp//rB   )rF   r   r/   r   schemehostnameportpathreplaceparamsqueryfragmentr   s    r   unauthz
URL.unauthy   s    ||~~ 	K}}===$)*^b7Q7QRVR]7^*^_	!!$,,
 	
 	
 		
r   c                    |                                  }t          t          t          j        j        | j                            }t          t          |j	        
                    dd                              |d<   |d         sd|d<   |d         r:d|d         vr0|d         dk    rd}n|d         d	k    rd
}nd}|dxx         |z  cc<   t          |          |_        d|_        |S )z
        a canonical URL ... remove authentication details, make sure there
        are no double slashes, and to make sure the URL is always the same,
        run it through the urlparser, and make sure path is properly quoted
        rL   rB      r   rJ      rH   z:443rK   z:80 N)rU   listr   r4   r5   r   r   r   r   rP   rQ   r
   r   )r   r   arrportparts       r   r&   zURL.canonical   s     kkmm40$/BBCCwsx//c::;;<<A1v 	CFq6 	cQ''1v  !Q6!! FFFhFFF !oo
r   rP   c           
      l   t          |          }|r|s| S t                              |          }|j        r| j        r|j        | j        k    s<|j        r| j        r|j        | j        k    s|j        r+| j        r$|j        | j        k    rt          | d|          |j        r|j        d         dk    r|j        }n0d}| j                            d          rd}| j        ||j        }t          t          | j        p|j        | j
        p|j
        ||j        |j        |j                            S )a^  
        assumes this object is the base URL or base path.  If the path
        is relative, it should be appended to the base.  If the path
        is absolute, it should be added to the connection details of
        self.  If the path already contains connection details and the
        connection details differ from self, raise an error.
        z can't be joined with r   rB   rY   )r'   r   r/   rM   rN   rO   r<   rP   endswithr   netlocrR   rS   rT   )r   rP   pathAsStringret_pathseps        r   joinzURL.join   s`    4yy 	< 	K}}T""[	J![	J-1[DK-G-G .H"&- .H48MT]4R4R	 5S"i 5S,0I,B,BTTT44HIII9 	>1,,yHHCy!!#&& #'99cc499=H*t{*t{
 	
 	
 		
r   )r   r   )__name__
__module____qualname____doc__r'   r   r   r   boolr    objectr$   r*   intr-   classmethodr   r/   r8   r:   r7   r?   rC   rF   rU   r&   r   rc   r#   r   r   r   r      s        :#C+-; # # # # #$    !F !t ! ! ! !%F %t % % % %+# + + + + TCZ+5C     [5 5 5 5 51 1 1 1 1(S ( ( ( (%# % % % %   ) ) ) ) )
 
 
 
   :#
 #
 #
 #
 #
 #
 #
 #
r   r   r   r   c                 6    t                               |           S )zBackward compatibility)r   r/   )r   s    r   makerm      s    ==r   )sysurllib.parser4   typingr   r   r   r   r   r   r	   r
   caldav.lib.python_utilitiesr   r   version_infotyping_extensionsr   r   r'   rm   r#   r   r   <module>rt      s   



             W W W W W W W W W W W W W W W W A A A A A A A Ag&&&&&&&x
 x
 x
 x
 x
 x
 x
 x
vcCi+%3       r   