
    ce!                    p   U d Z ddlmZ ddgZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddlmZ ddlmZ ddlZddlmZ ej        rdd	lmZ  ej        d
          ZddZ G d dej                  ZddddZded<   dZded<    ej         de!e!e!e!e!e!e!e!e!e!e"e"d          Z# G d d          Z$dS )z!Utility components for telemetry.    )annotations	ApiClientStatsN)QtCore)	QtWidgets)	__about__anaconda_apiTvaluestrreturnc                >   t           j                            |           \  }}}}}|                    d          s|dz  }|s7|dd         dv rt	          | d          |                    dd          \  }}t           j                            |pd||ddf          S )z
    Make sure that path is normalized to be used as a root URL.

    It strips down all query params, fragment and ensures that URL ends with a :code:`/`. The latter is required for the
    :func:`~urllib.parse.urljoin`.
    /N   z is not a valid root urlhttps )urllibparseurlsplitendswith
ValueErrorsplit
urlunsplit)r   schemenetlocpath_s        Llib/python3.11/site-packages/anaconda_navigator/utils/telemetry/utilities.pynormalize_root_urlr       s     "(!6!6u!=!=FFD!Q==  *8s??AAABBBzz#q))<""F$5gvtR#LMMM    c                  \    e Zd ZdZdZddZedd	            Zedd            ZddddZ	dS )r   zR
    Base for API client classes.

    :param root_url: Base URL for the API.
    )	__session__urlsroot_urlr   r   Nonec                b    t          j                    | _        dt          |          i| _        dS )z0Initialize new instance of a :class:`ApiClient`.r   N)requestsSession_ApiClient__sessionr    _ApiClient__urls)selfr%   s     r   __init__zApiClient.__init__?   s,    9A9I9K9K<>@RS[@\@\;]r!   "requests.cookies.RequestsCookieJarc                    | j         j        S )z!Cookies attached to each request.)r*   cookiesr,   s    r   _cookieszApiClient._cookiesD        ~%%r!   4typing.MutableMapping[str, typing.Union[bytes, str]]c                    | j         j        S )z!Headers attached to each request.)r*   headersr1   s    r   _headerszApiClient._headersI   r3   r!   F)ignore_statusmethodurlargs
typing.Anyr8   boolkwargsrequests.Responsec                  | j                             |d          }|5t          j                            | j         d         |          x}| j         |<    | j        j        ||g|R i |}|s|                                 |S )a  
        Send request to the service.

        :param method: HTTP method for the request.
        :param url: Path to the API endpoint. It should be a URL relative to the :code:`root_url`.
        :param args: Extra positional arguments to :func:`requests.request`.
        :param ignore_status: Do not raise an error if server responds with non-200 status code.
        :param kwargs: Extra keyword arguments to :func:`requests.request`.
        :return: Server response.
        Nr   )r+   getr   r   urljoinr*   requestraise_for_status)r,   r9   r:   r8   r;   r>   targetresponses           r   _requestzApiClient._requestN   s    $ (,{sD'A'A>(.(<(<T[_c(R(RRFT[%&<dn&<VV&]d&]&]&]V\&]&] 	(%%'''r!   N)r%   r   r   r&   )r   r.   )r   r4   )r9   r   r:   r   r;   r<   r8   r=   r>   r<   r   r?   )
__name__
__module____qualname____doc__	__slots__r-   propertyr2   r7   rG    r!   r   r   r   6   s          (I^ ^ ^ ^
 & & & X& & & & X& #(       r!   )	metaclass6432)amd64x86x86_64z/typing.Final[collections.abc.Mapping[str, str]]MACHINE_CLARIFICATION))darwinosx)win32winz)typing.Final[tuple[tuple[str, str], ...]]PLATFORM_CLARIFICATIONStatsDetailszconda-versionzlocale-encodingzlocale-languageznavigator-versionzos-longzos-shortplatformzpython-longzpython-shortz
qt-versionzscreen-heightzscreen-widthc                  T   e Zd ZdZej        dd            Zej        dd            Zej        dd            Zej        dd            Z	ej        dd	            Z
ej        dd
            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        dd            Zej        d d            ZdS )!r   zFHelper class to collect basic details about the execution environment.r   r   c                >    | j                             dd          pdS )z(Conda version that Navigator works with.condarootpkgnameunknown_apiconda_package_versionr1   s    r   conda_versionzStats.conda_version   s$     y..7.HHUIUr!   r[   c                    | j         | j        | j        | j        | j        | j        | j        | j        | j        | j	        | j
        | j        dS )zr
        Collected details in a dictionary format.

        Can be used to send statistics to the server.
        r\   )ri   locale_encodinglocale_languagenavigator_versionos_longos_shortr]   python_longpython_short
qt_versionscreen_heightscreen_widthr1   s    r   detailszStats.details   sW     "/#3#3!%!7|+ -/!/ -
 
 	
r!   c                     | j         d         pdS )z%Encoding used for the current locale.r   re   _localer1   s    r   rk   zStats.locale_encoding        |A+)+r!   c                     | j         d         pdS )zLanguage of the current locale.r   re   rw   r1   s    r   rl   zStats.locale_language   ry   r!   c                    t           j        S )zVersion of the Navigator.)r   __version__r1   s    r   rm   zStats.navigator_version   s     $$r!   c                <    | j          dt          j                     S )z2Name of the OS in a long form (including version). )ro   r]   releaser1   s    r   rn   zStats.os_long   s#     -66("2"4"4666r!   c                (    t          j                    S )z1Name of the OS in a short form (without version).)r]   systemr1   s    r   ro   zStats.os_short   s        r!   c                   t          j                                                    }t                              ||          }t
          j                                         }t          D ]\  }}|                    |          r|} n| d| S )z Platform that Navigator runs in.-)r]   machinelowerrU   rA   sysrZ   
startswith)r,   architecturer   leftrights        r   r]   zStats.platform   s     %,..4466,00|LL l((**1 	 	KD%  &&  ))<)))r!   c                    | j                             dd          p9| j                             dd          p| j                             dd          pdS )z.Version of the PyQt used to display Navigator.pyqt5ra   rb   pyqt4pyqtre   rf   r1   s    r   pyqt_versionzStats.pyqt_version   se     	//G&/II 	//G&/II	//F/HH 		
r!   c                V    t          j                     dt          j                     dS )z1Current version of the python with extra details.z ())r]   python_versionpython_implementationr1   s    r   rp   zStats.python_long   s-     )++RRx/M/O/ORRRRr!   c                ^    d                     t          j                    dd                   S )z>Short version of the python (without patch and extra details)..N   )joinr]   python_version_tupler1   s    r   rq   zStats.python_short   s(     xx577;<<<r!   c                >    	 t           j        S # t          $ r Y dS w xY w)z/Version of the Qt that Navigator is running in.re   )r   r|   AttributeErrorr1   s    r   rr   zStats.qt_version   s2    	%% 	 	 	99	s    
intc                    | j         d         S )zHeight of the primary screen.r   _screenr1   s    r   rs   zStats.screen_height        |Ar!   c                    | j         d         S )zWidth of the primary screen.r   r   r1   s    r   rt   zStats.screen_width   r   r!   anaconda_api._AnacondaAPIc                ,    ddl m}  |j                    S )z Shortcut to :code:`AnacondaAPI`.r   r	   )anaconda_navigator.apir
   AnacondaAPI)r,   r
   s     r   rg   z
Stats._api   s'     	877777'|')))r!   tuple[str | None, str | None]c                (    t          j                    S )z$Collected details on current locale.)locale	getlocaler1   s    r   rx   zStats._locale   s     !!!r!   tuple[int, int]c                    	 t          j                    }|                    |                                          }|                                |                                fS # t          $ r Y dS w xY w)z'Collected details on screen dimensions.)r   r   )r   QDesktopWidgetscreenGeometryprimaryScreenwidthheight	Exception)r,   widgetgeometrys      r   r   zStats._screen   su    	/8/G/I/IF%+%:%:6;O;O;Q;Q%R%RH>>##X__%6%666 	 	 	44	s   A!A$ $
A21A2N)r   r   )r   r[   )r   r   )r   r   )r   r   )r   r   )rH   rI   rJ   rK   	functoolscached_propertyri   ru   rk   rl   rm   rn   ro   r]   r   rp   rq   rr   rs   rt   rg   rx   r   rN   r!   r   r   r      s       PPV V V V 
 
 
 
* , , , , , , , , % % % % 7 7 7 7 ! ! ! ! * * * * 
 
 
 
 S S S S = = = =             * * * *
 " " " "      r!   )r   r   r   r   )%rK   
__future__r   __all__abccollections.abccollectionsr   r   r]   r   typingurllib.parser   qtpyr   r   requests.cookiesr(   anaconda_navigatorr   TYPE_CHECKINGr   r
   TypeVarr   r    ABCMetar   rU   __annotations__rZ   	TypedDictr   r   r[   r   rN   r!   r   <module>r      s   ( ' ' " " " " " "
  



           



                      ( ( ( ( ( (	 4333333 FN3N N N N.1 1 1 1 1#+ 1 1 1 1j J J     
E       v1 1   @ @ @ @ @ @ @ @ @ @r!   