
    ,h                      N    d dl Z d dlmZ d dlmZ  G d de      Z G d d      Zy)    N)Enum)Optionalc                        e Zd ZdZdZdZdZdZy)UrlTypesz4
    Enum to represent different types of URLS.
    r            N)__name__
__module____qualname____doc__UNKNOWNURLINTERNALEXTERNAL     P/var/www/html/Resume-Scraper/venv/lib/python3.12/site-packages/xlsxwriter/url.pyr   r      s     G
CHHr   r   c                   (   e Zd ZdZdZdZdefdZd Ze	de
ded    fd	       Zedefd
       Zej                  defd       Zedefd       Zej                  defd       Zd Zd Zd ZdefdZdefdZededefd       Zededefd       Zy)Urlz.
    A class to represent URLs in Excel.

    i      linkc                    t         j                  | _        || _        || _        || _        d| _        d| _        d| _        d| _	        d| _
        | j                          t        | j                        | j                  kD  rt        d      t        | j                        | j                  kD  rt        d      t        | j                        | j                  kD  rt        d      | j!                          y )N Fr   z#URL exceeds Excel's maximum length.z5Anchor segment or url exceeds Excel's maximum length.z2Hyperlink tool tip exceeds Excel's maximum length.)r   r   
_link_type_original_url_link_relationship_link_text_tip_anchor_is_object_link
_rel_index
_parse_urllenMAX_URL_LEN
ValueErrorMAX_PARAMETER_LEN_escape_strings)selfr   s     r   __init__zUrl.__init__$   s    $,$4$4"&
'+
	%* tzz?T---BCCt||t///TUUtyy>D222QRRr   c                    d| j                   j                   d| j                   d| j                   d| j                   d| j
                   d| j                   d| j                   d| j                   d	| j                   d
S )zF
        Return a string representation of the Url instance.

        z
Url:
  _link_type         = z
  _original_url      = z
  _link              = z
  _relationship_link = z
  _text              = z
  _tip               = z
  _anchor            = z
  _is_object_link    = z
  _rel_index         = 
)
r   namer   r   r   r   r    r!   r"   r#   r*   s    r   __repr__zUrl.__repr__<   s    &&*oo&:&:%; <&&*&8&8%9 :&&*jj\ 2&&*&=&=%> ?&&*jj\ 2&&*ii[ 1&&*ll^ 4&&*&:&:%; <&&*oo%6b
:	
r   optionsreturnc                     t        |t              st        d      |j                  d      }t        |t              r& | |d         }|j                  d      r
|d   |_        |S )aM  
        For backward compatibility, convert the 'url' key and 'tip' keys in an
        options dictionary to a Url object, or return the Url object if already
        an instance.

        Args:
            options (dict): A dictionary that may contain a 'url' key.

        Returns:
            url: A Url object or None.

        z-The 'options' parameter must be a dictionary.urltip)
isinstancedict	TypeErrorgetstrr    )clsr1   r4   s      r   from_optionszUrl.from_optionsO   s\     '4(KLLkk% c3gen%C{{5!"5>
r   c                     | j                   S )z5Get the alternative, user-friendly, text for the URL.r   r/   s    r   textzUrl.texti   s     zzr   valuec                     || _         y)z5Set the alternative, user-friendly, text for the URL.Nr>   r*   r@   s     r   r?   zUrl.textn   s     
r   c                     | j                   S )zGet the screen tip for the URL.r    r/   s    r   r5   zUrl.tips   s     yyr   c                     || _         y)zSet the screen tip for the URL.NrD   rB   s     r   r5   zUrl.tipx   s     	r   c                    | j                   j                  d      rt        j                  | _        | j
                  s| j                   | _        d| j                   v r)| j                   j                  dd      \  | _         | _        | j                  r| j                  | _
        y| j                   | _
        y| j                   j                  d      rEt        j                  | _        | j
                  s#| j                   j                  ddd      | _        yy| j                   j                  d      rt        j                  | _        | j                   j                  ddd      | _
        | j                   j                  ddd      | _         | j                   | _        | j
                  s| j                  | _        yy| j                   j                  d      s| j                   j                  d      rpt        j                  | _        | j                  j                  dd	d      }|}|j                  d	dd      }|j                  ddd      }|j                  d
d      }| j                  |      r|| _         n
d	|z   | _         | j
                  s|| _        d| j                   v r)| j                   j                  dd      \  | _         | _        | j                  r;| j                  |      r"| j                   j                  dd
      | _
        n|| _
        n| j                   | _
        | j                  j                  d      r#| j                  j                  ddd      | _
        yyt        d| j                         )z%Parse the URL and determine its type.)zhttp://zhttps://zftp://zftps://#r   zmailto:r   z	internal:zfile://z	external:zfile:////\z.\zUnknown URL type: N)r   
startswithr   r   r   r   splitr!   r"   r   r   replacer   r   _is_relative_pathr'   )r*   file_url	link_paths      r   r$   zUrl._parse_url}   s    ::  !MN&llDO::!ZZ
djj +/::+;+;C+C(
DL ##*.*<*<'*.**' ZZ""9-&llDO::!ZZ//	2qA
  ZZ"";/&//DO&*jj&8&8c1&MD#++KQ?DJ::DL::!\\
  ZZ""9-1F1F{1S&//DO ))11+z1MH I!))*b!<I!)))R;I!))#t4I%%i0&
')3
::&
djj +/::+;+;C+C(
DL ##)))4.2jj.@.@s.KD+.6D+ +/**' &&11%8*.*A*A*I*I%QSUV*W' 9 1$2D2D1EFGGr   c                 t    d| _         | j                  | _        | j                          | j	                          y)z
        Set the _is_object_link flag and re-parse the URL since the relationship
        link is different for object links.

        TN)r"   r   r   r$   r)   r/   s    r   _set_object_linkzUrl._set_object_link   s/      $''
r   c                 <   | j                   t        j                  k7  r@| j                  | j                        | _        | j                  | j
                        | _        | j                   t        j                  k(  r"| j
                  j                  dd      | _        yy)z-Escape special characters in the URL strings.rG   z%23N)r   r   r   _escape_urlr   r   r   rL   r/   s    r   r)   zUrl._escape_strings   sy     ??h///))$**5DJ&*&6&6t7N7N&OD# ??h///&*&=&=&E&Ec5&QD# 0r   c                     | j                   S )z$Get the target for relationship IDs.)r   r/   s    r   _targetzUrl._target   s    &&&r   c                 @    | j                   t        j                  k(  ryy)z)Get the target mode for relationship IDs.r   External)r   r   r   r/   s    r   _target_modezUrl._target_mode   s    ??h///r   r4   c                 `    | j                  d      ry| d   j                         r	| d   dk(  ryy)z"Check if a URL is a relative path.z\\Fr   r   :T)rJ   isalphar4   s    r   rM   zUrl._is_relative_path   s1     >>% q6>>A#r   c                    t        j                  d|       r| S | j                  dd      j                  dd      j                  dd      j                  dd	      j                  d
d      j                  dd      j                  dd      j                  dd      j                  dd      j                  dd      j                  dd      S )z#Escape special characters in a URL.z%[0-9a-fA-F]{2}%z%25"z%22 z%20<z%3c>z%3e[z%5b]z%5d^z%5e`z%60{z%7b}z%7d)researchrL   r\   s    r   rS   zUrl._escape_url   s     99&,J KKU#WS% WS% WS% WS% WS% WS% WS% WS% WS% WS% 	
r   N)r
   r   r   r   r&   r(   r:   r+   r0   classmethodr7   r   r<   propertyr?   setterr5   r$   rQ   r)   rU   rX   staticmethodboolrM   rS   r   r   r   r   r      s.   
 KS 0
& 4 HUO  2 c   
[[#   S   	ZZ  LH\		R' 'c  s t   
 
 
 
r   r   )ri   enumr   typingr   r   r   r   r   r   <module>rr      s(    
  t p
 p
r   