
    \jd                       U d Z ddlmZ g dZddlZddlZddlmZm	Z	m
Z
 ddlmZ ddlmZmZ dd	l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egef   Z dZ!de"d<   ejF                  jI                  d      rddl%mZ! dZ&de"d<   ejF                  jI                  d      rddl'mZ&  e( e)de&e!ef            Z*de"d<   dZ+ G d d      Z,de"d<   	  ejZ                         Z.ddZ/ddZ0ddZ1ddZ2d dZ3y)!a  The package provides top-level helpers which use a lazily initialised
default parser. These are convenience functions, for more control it
is perfectly acceptable to instantiate and call parsers directly.

The default parser does use a cache keyed on the user-agent string,
but its exact behaviour is unspecified, if you require a consistent
behaviour or specific algorithm, set up your own parser (global or
not).

For convenience, direct aliases are also provided for:

- :mod:`core types <.types>`
- :mod:`caching utilities <.caching>`
- :mod:`ua_parser.basic.Parser` as :class:`BasicParser`

This way importing anything but the top-level package should not be
necessary unless you want to *implement* a parser.
    )annotations)OSBasicResolverCacheCachingResolverDefaultedResultDeviceDomainMatchersPartialResultResolverResult	UserAgentload_builtinsload_lazy_builtinsparseparse_deviceparse_osparse_user_agentN)CallableOptionalcast   )r   )r   S3Fifo)	r   r	   r
   r   r   r   r   r   r   )r   r   )IS_GRAALzOptional[_ResolverCtor]Re2Resolverre2RegexResolverua_parser_rs_ResolverCtorBestAvailableResolver)r   r      c                  R    e Zd ZdZed
d       ZddZddZddZddZ	ddZ
ddZy	)Parserz^Wrapper object, provides convenience methods around an
    underlying :class:`Resolver`.

    c               J     | t        t        |      t        d                  S )zfrom_matchers(Matchers) -> Parser

        Instantiates a parser from the provided
        :class:`~ua_parser.core.Matchers` using the default resolver
        stack.

        i  )r   r!   r   )clsms     </root/env/lib/python3.12/site-packages/ua_parser/__init__.pyfrom_matcherszParser.from_matchersT   s      ?#8#;U4[IJJ    c                    || _         y )Nresolver)selfr-   s     r(   __init__zParser.__init___   s	     r*   c               &    | j                  ||      S )zParses the ``ua`` string, returning a parse result with *at least*
        the requested :class:`domains <Domain>` resolved (whether to success or
        failure).
        r,   )r.   uadomainss      r(   __call__zParser.__call__b   s    
 }}R))r*   c                L     | |t         j                        j                         S )z+Convenience method for parsing all domains.)r
   ALLcompleter.   r1   s     r(   r   zParser.parsei   s    B

#,,..r*   c                D     | |t         j                        j                  S )z=Convenience method for parsing the :class:`UserAgent` domain.)r
   
USER_AGENT
user_agentr7   s     r(   r   zParser.parse_user_agentm   s    B))*555r*   c                D     | |t         j                        j                  S )z6Convenience method for parsing the :class:`OS` domain.)r
   r   osr7   s     r(   r   zParser.parse_osq   s    B		"%%%r*   c                D     | |t         j                        j                  S )z:Convenience method for parsing the :class:`Device` domain.)r
   DEVICEdevicer7   s     r(   r   zParser.parse_deviceu   s    B&---r*   N)r'   r   returnr$   )r-   r   r@   None)r1   strr2   r
   r@   r   )r.   r   r1   rB   r@   r   )r.   r   r1   rB   r@   Optional[UserAgent])r.   r   r1   rB   r@   Optional[OS])r.   r   r1   rB   r@   Optional[Device])__name__
__module____qualname____doc__classmethodr)   r/   r3   r   r   r   r    r*   r(   r$   r$   N   s;    
 K K!*/6&.r*   r$   parserc                l   t         5  | dk(  rt               j                  d      x}rt        t        |      cd d d        S t
        st        st        rt               }n
t               }t        j                  |      at        cd d d        S 	 d d d        t        dt        d|       # 1 sw Y   xY w)NrL   zmodule z has no attribute )_lazy_globals_lockglobalsgetr   r$   r   r   r   r   r   r)   rL   AttributeErrorrF   )namepmatcherss      r(   __getattr__rU      s    	 8
 IMM(++q+FA  x-/(?))(3F   78,.@I
JJ! s   0B*AB**B3c                X    ddl m}  || t        j                        j	                         S )a  Parses the :class:`.UserAgent`, :class:`.OS`, and :class:`.Device`
    information using the :data:`global parser <parser>`.

    Equivalent to calling each of :func:`parse_user_agent`,
    :func:`parse_os`, and :func:`parse_device` but *may* be more
    efficient than calling them separately depending on the underlying
    parser.

    Even in the best case, prefer the domain-specific helpers if
    you're not going to use *all* of them.
    r   rL   ) rL   r
   r5   r6   r1   rL   s     r(   r   r      s!     "fjj!**,,r*   c                P    ddl m}  || t        j                        j                  S )zgParses the :class:`browser <.UserAgent>` information using the
    :data:`global parser <parser>`.
    r   rW   )rX   rL   r
   r9   r:   rY   s     r(   r   r      s      "f''(333r*   c                P    ddl m}  || t        j                        j                  S )zVParses the :class:`.OS` information using the :data:`global parser
    <parser>`.
    r   rW   )rX   rL   r
   r   r<   rY   s     r(   r   r      s     "fii ###r*   c                P    ddl m}  || t        j                        j                  S )zZParses the :class:`.Device` information using the :data:`global
    parser <parser>`.
    r   rW   )rX   rL   r
   r>   r?   rY   s     r(   r   r      s     "fmm$+++r*   )rR   rB   r@   r$   )r1   rB   r@   r   )r1   rB   r@   rC   )r1   rB   r@   rD   )r1   rB   r@   rE   )4rI   
__future__r   __all__importlib.util	importlib	threadingtypingr   r   r   basicr   r   cachingr   r   r   corer   r	   r
   r   r   r   r   r   loadersr   r   utilsr   r    r   __annotations__util	find_specr   r   regexnextfilterr!   VERSIONr$   LockrN   rU   r   r   r   r   rK   r*   r(   <module>rp      s   & #*   + + , 5
 
 
 7 (X-.'+$ +>>E",)-& ->>N+0'+
4-m<=( } 
 ). ).X 	 $Y^^% K*-&4$,r*   