o
    bhm                     @  s  U d dl mZ g dZd dlZd dlZd dlZd dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZ ddlmZmZ ddlmZ erPeeeje ejf Zded	< z
d d
lmZmZ W n! e y{   z
d dlmZmZ W n e yx   d ZZY nw Y nw d.ddZ!d.ddZ"G dd deZ#G dd de#ddZ$G dd de#ddZ%G dd de#ddZ&ee	e$ e	e% e	e& f Z'ee'gef Z(d/ddZ)d/d d!Z*G d"d# d#eZ+e)fd0d(d)Z,d*ed+< edu rdZ-dS e)fd1d-d+Z-dS )2    )annotations)

DeviceDictMatchersDataOSDictUserAgentDictload_builtins	load_data	load_json	load_lazyload_lazy_builtins	load_yamlN)TYPE_CHECKINGCallableListLiteralOptionalProtocolTupleType	TypedDictUnioncast   )lazymatchers)MatcherszOptional[Type[object]]
SafeLoader)CSafeLoaderload)r   r   returnr   c                  C     ddl m}  tt| S )zLoads the pre-compiled matcher data into eager matchers.

    The matchers data is imported lazily, and cached after imports,
    further imports simply reference the existing datas.

    r   MATCHERS)ua_parser_builtins.matchersr"   r   r   r!    r$   ]/var/www/html/Testing_prj/Navya-Bakers/venv/lib/python3.10/site-packages/ua_parser/loaders.pyr   0   s   
r   c                  C  r    )zLoads the pre-compiled matcher data into lazy matchers.

    The matchers data is imported lazily, and cached after imports,
    further imports simply reference the existing datas.

    r   r!   )ua_parser_builtins.lazyr"   r   r   r!   r$   r$   r%   r   >   s   
r   c                   @  s   e Zd ZU ded< dS )
_RegexDictstrregexN__name__
__module____qualname____annotations__r$   r$   r$   r%   r'   L   s   
 r'   c                   @  6   e Zd ZU ded< ded< ded< ded< ded< dS )r   r(   family_replacementv1_replacementv2_replacementv3_replacementv4_replacementNr*   r$   r$   r$   r%   r   P      
 r   F)totalc                   @  r/   )r   r(   os_replacementos_v1_replacementos_v2_replacementos_v3_replacementos_v4_replacementNr*   r$   r$   r$   r%   r   X   r5   r   c                   @  s.   e Zd ZU ded< ded< ded< ded< dS )r   zLiteral['i']
regex_flagr(   device_replacementbrand_replacementmodel_replacementNr*   r$   r$   r$   r%   r   `   s
   
 r   dr   c                 C  4   dd | d D dd | d D dd | d D fS )z-Loads the input data set into eager matchers.c                 S  B   g | ]}t |d  |d|d|d|d|dqS r)   r0   r1   r2   r3   r4   )r   UserAgentMatcherget.0pr$   r$   r%   
<listcomp>n       	zload_data.<locals>.<listcomp>r   c                 S  rB   r)   r7   r8   r9   r:   r;   )r   	OSMatcherrE   rF   r$   r$   r%   rI   y   rJ   r   c                 S  :   g | ]}t |d  |d|d|d|dqS r)   r<   r=   r>   r?   )r   DeviceMatcherrE   rF   r$   r$   r%   rI             r$   r@   r$   r$   r%   r   k      		r   c                 C  rA   )z,Loads the input data set into lazy matchers.c                 S  rB   rC   )r   rD   rE   rF   r$   r$   r%   rI      rJ   zload_lazy.<locals>.<listcomp>r   c                 S  rB   rK   )r   rL   rE   rF   r$   r$   r%   rI      rJ   r   c                 S  rM   rN   )r   rO   rE   rF   r$   r$   r%   rI      rP   rQ   r$   rR   r$   r$   r%   r
      rS   r
   c                   @  s   e Zd Zefd
ddZd	S )
FileLoaderpath
PathOrFileloader
DataLoaderr   r   c                 C  s   d S )Nr$   )selfrU   rW   r$   r$   r%   __call__   s   zFileLoader.__call__NrU   rV   rW   rX   r   r   )r+   r,   r-   r   rZ   r$   r$   r$   r%   rT      s    rT   frV   rW   rX   c                 C  sh   t | ttjfr"t| }t|}W d   n1 sw   Y  nt| }||d |d |d fS )a  Loads JSON data following the ``regexes.yaml`` structure.

    The ``loader`` parameter customises which matcher variant is
    generated, by default :func:`load_data` is used to generate eager
    matchers, :func:`load_lazy` can be used to generate lazy matchers
    instead.

    Nuser_agent_parsers
os_parsersdevice_parsers)
isinstancer(   osPathLikeopenjsonr   )r\   rW   fpregexesr$   r$   r%   r	      s   	

r	   zOptional[FileLoader]r   rU   c                 C  sl   t | ttjfr#t| }t|td}W d   n1 sw   Y  nt| td}t|d |d |d fS )a-  Loads YAML data following the ``regexes.yaml`` structure.

        The ``loader`` parameter customises which matcher variant is
        generated, by default :func:`load_data` is used to generate eager
        matchers, :func:`load_lazy` cab be used to generate lazy matchers
        instead.
        )LoaderNr]   r^   r_   )r`   r(   ra   rb   rc   r   r   r   )rU   rW   re   rf   r$   r$   r%   r      s   
)r   r   )r@   r   r   r   )r\   rV   rW   rX   r   r   r[   ).
__future__r   __all__iord   ra   typingr   r   r   r   r   r   r   r   r   r   r    r   r   corer   r(   rb   IOBaserV   r.   yamlr   r   r   ImportErrorr   r   r'   r   r   r   r   rX   r   r
   rT   r	   r   r$   r$   r$   r%   <module>   sJ    4



&&