
    d                         d Z ddlZddlmZmZ ddlmZmZ ddlm	Z	m
Z
 deded	efd
Zdeded	efdZde	dee         d	ee
         fdZdS )zaSupport for git credential helpers

https://git-scm.com/book/en/v2/Git-Tools-Credential-Storage

    N)IteratorOptional)ParseResulturlparse   )
ConfigDictSectionLikeurl
url_prefixreturnc                 (   | j         |j         k    o| j        |j        k    o| j        |j        k    }|j        r| j        |j        k    nd}| j                            d                              |j                                                  }|o|o|S )NT/)schemehostnameportusernamepathrstrip
startswith)r
   r   
base_match
user_match
path_matchs        W/home/feoh/.local/pipx/venvs/poetry/lib/python3.11/site-packages/dulwich/credentials.py
match_urlsr   "   s    
j'' 	(LJ//	(H
' 
 9C8KU!444QUJ%%001G1G1I1IJJJ3*33    	valid_urlpartial_urlc           	         d|vrt          d|z             }n!t          |          }| j        |j        k    rdS t          |j        o| j        |j        k    |j        o| j        |j        k    |j        o| j        |j        k    |j        o5|j                            d          | j                            d          k    f          rdS dS )z:matches a parsed url with a partial url (no scheme/netloc)z://z	scheme://Fr   T)r   r   anyr   r   r   r   r   )r   r   parseds      r   match_partial_urlr!   -   s    K+344+&&v},,5
_F!3v!F_F!3v!F[:Y^v{:[RV[//44	8M8Mc8R8RR		
   u4r   configc              #     K   | j         pt          j                    }t          |pd          }|                                 D ]}|d         dk    rt          |          dk     r|V  '|d                             |          }t          |          }|j        r|j        rt          ||          }nt          ||          }|r|V  dS )zEReturns credential sections from the config which match the given URL r   s
   credential   r   N)encodingsysgetdefaultencodingr   sectionslendecoder   netlocr   r!   )r"   r
   r&   
parsed_urlconfig_section
config_urlparsed_config_urlis_matchs           r   urlmatch_credential_sectionsr2   C   s       :#"8":":H#)$$J //++ ! !!--~""    #A&--h77
$Z00# 	A(9(@ 	A!*.?@@HH(Z@@H 	!    !! !r   )__doc__r'   typingr   r   urllib.parser   r   r"   r   r	   boolr   strr!   r2    r   r   <module>r9      s   , 
 


 % % % % % % % % . . . . . . . . + + + + + + + +4K 4[ 4T 4 4 4 4 3 4    ,!!%c]!k! ! ! ! ! !r   