o
    ¹i»  ã                   @   s0   d Z ddlZG dd„ deƒZG dd„ deƒZdS )a  
    werkzeug.useragents
    ~~~~~~~~~~~~~~~~~~~

    This module provides a helper to inspect user agent strings.  This module
    is far from complete but should work for most of the currently available
    browsers.


    :copyright: 2007 Pallets
    :license: BSD-3-Clause
é    Nc                   @   s6   e Zd ZdZdZdZdZe d¡Z	dd„ Z
dd	„ Zd
S )ÚUserAgentParserz5A simple user agent parser.  Used by the `UserAgent`.))z cros Úchromeos)z
iphone|iosÚiphone)Úipadr   )zdarwin|mac|os\s*xÚmacos)ÚwinÚwindows)Úandroidr	   )Únetbsdr
   )Úopenbsdr   )Úfreebsdr   )Ú	dragonflyÚdragonflybsd)z(sun|i86)osÚsolaris)zx11|lin(\b|ux)?Úlinux)znintendo\s+wiiÚwii)Úirixr   )zhp-?uxÚhpux)Úaixr   )zsco|unix_svÚsco)Úbsdr   )Úamigar   )zblackberry|playbookÚ
blackberry)Úsymbianr   ))Ú	googlebotÚgoogle)ÚmsnbotÚmsn)Úyahoor   )z
ask jeevesÚask)zaol|america\s+online\s+browserÚaol)z	opera|oprÚopera)Úedger"   )zchrome|criosÚchrome)Ú	seamonkeyr$   )z"firefox|firebird|phoenix|iceweaselÚfirefox)Úgaleonr&   )zsafari|versionÚsafari)Úwebkitr(   )Úcaminor)   )Ú	konquerorr*   )zk-meleonÚkmeleon)Únetscaper,   )z4msie|microsoft\s+internet\s+explorer|trident/.+? rv:Úmsie)Úlynxr.   )Úlinksr/   )ÚBaiduspiderÚbaidu)ÚbingbotÚbing)Úmozillar4   z(?:%s)[/\sa-z(]*(\d+[.\da-z]+)?za(?:;\s*|\s+)(\b\w{2}\b(?:-\b\w{2}\b)?)\s*;|(?:\(|\[|;)\s*(\b\w{2}\b(?:-\b\w{2}\b)?)\s*(?:\]|\)|;)c                    s,   dd„ ˆ j D ƒˆ _ ‡ fdd„ˆ jD ƒˆ _d S )Nc                 S   s"   g | ]\}}|t  |t j¡f‘qS © )ÚreÚcompileÚI©Ú.0ÚaÚbr5   r5   úN/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/werkzeug/useragents.pyÚ
<listcomp>L   s   " z,UserAgentParser.__init__.<locals>.<listcomp>c                    s(   g | ]\}}|t  ˆ j| t j¡f‘qS r5   )r6   r7   Ú_browser_version_rer8   r9   ©Úselfr5   r=   r>   M   s    ÿÿ)Ú	platformsÚbrowsersr@   r5   r@   r=   Ú__init__K   s   
þzUserAgentParser.__init__c                 C   sœ   | j D ]\}}| |¡}|d ur nqd }| jD ]\}}| |¡}|d ur,| d¡} nqd  }}| j |¡}|d urF| d¡pD| d¡}nd }||||fS )Né   é   )rB   ÚsearchrC   ÚgroupÚ_language_re)rA   Ú
user_agentÚplatformÚregexÚmatchÚbrowserÚversionÚlanguager5   r5   r=   Ú__call__R   s$   
ÿ

þzUserAgentParser.__call__N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rB   rC   r?   r6   r7   rI   rD   rQ   r5   r5   r5   r=   r      s    ÿr   c                   @   sB   e Zd ZdZeƒ Zdd„ Zdd„ Zdd„ Zdd	„ Z	e	Z
d
d„ ZdS )Ú	UserAgenta±  Represents a user agent.  Pass it a WSGI environment or a user agent
    string and you can inspect some of the details from the user agent
    string via the attributes.  The following attributes exist:

    .. attribute:: string

       the raw user agent string

    .. attribute:: platform

       the browser platform. ``None`` if not recognized.
       The following platforms are currently recognized:

       -   `aix`
       -   `amiga`
       -   `android`
       -   `blackberry`
       -   `bsd`
       -   `chromeos`
       -   `dragonflybsd`
       -   `freebsd`
       -   `hpux`
       -   `ipad`
       -   `iphone`
       -   `irix`
       -   `linux`
       -   `macos`
       -   `netbsd`
       -   `openbsd`
       -   `sco`
       -   `solaris`
       -   `symbian`
       -   `wii`
       -   `windows`

    .. attribute:: browser

        the name of the browser. ``None`` if not recognized.
        The following browsers are currently recognized:

        -   `aol` *
        -   `ask` *
        -   `baidu` *
        -   `bing` *
        -   `camino`
        -   `chrome`
        -   `edge`
        -   `firefox`
        -   `galeon`
        -   `google` *
        -   `kmeleon`
        -   `konqueror`
        -   `links`
        -   `lynx`
        -   `mozilla`
        -   `msie`
        -   `msn`
        -   `netscape`
        -   `opera`
        -   `safari`
        -   `seamonkey`
        -   `webkit`
        -   `yahoo` *

        (Browsers marked with a star (``*``) are crawlers.)

    .. attribute:: version

        the version of the browser. ``None`` if not recognized.

    .. attribute:: language

        the language of the browser. ``None`` if not recognized.
    c                 C   s:   t |tƒr| dd¡}|| _|  |¡\| _| _| _| _d S )NÚHTTP_USER_AGENTÚ )	Ú
isinstanceÚdictÚgetÚstringÚ_parserrK   rN   rO   rP   )rA   Úenviron_or_stringr5   r5   r=   rD   ¶   s   
ÿzUserAgent.__init__c                 C   ó   | j S ©N©r\   r@   r5   r5   r=   Ú	to_header¾   ó   zUserAgent.to_headerc                 C   r_   r`   ra   r@   r5   r5   r=   Ú__str__Á   rc   zUserAgent.__str__c                 C   s
   t | jƒS r`   )ÚboolrN   r@   r5   r5   r=   Ú__nonzero__Ä   s   
zUserAgent.__nonzero__c                 C   s   d| j j| j| jf S )Nz
<%s %r/%s>)Ú	__class__rR   rN   rO   r@   r5   r5   r=   Ú__repr__É   s   zUserAgent.__repr__N)rR   rS   rT   rU   r   r]   rD   rb   rd   rf   Ú__bool__rh   r5   r5   r5   r=   rV   h   s    KrV   )rU   r6   Úobjectr   rV   r5   r5   r5   r=   Ú<module>   s   W