Ë
    Ìi5F  ã                  ó  — U d Z ddlmZ ddlmZ ddlmZ ddlm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mZ dd	lmZ erdd
lmZ  ed«      Z ed«      ZdZ G d„ de«      Zej@                  Z!d d„Z"d!d„Z#e	jH                  e	jJ                  e	jL                  e	jN                  e	jP                  dœZ)d"d„Z*d#d„Z+d$d„Z,d$d„Z-e,e-dœZ.de/d<   ed%d„«       Z0 G d„ deeef   «      Z1 G d„ d«      Z2 e2«       Z3de/d<   y)&zIProvide access to settings for globally used Azure configuration values.
é    )Úannotations)Ú
namedtuple)ÚEnum)ÚcacheN)ÚTypeÚOptionalÚCallableÚUnionÚDictÚAnyÚTypeVarÚTupleÚGenericÚMappingÚListÚTYPE_CHECKINGé   )ÚAzureClouds)ÚAbstractSpanÚValidInputTypeÚ	ValueType)ÚsettingsÚSettingsc                  ó   — e Zd ZdZy)Ú_Unsetr   N)Ú__name__Ú
__module__Ú__qualname__Útoken© ó    úT/var/www/html/strategist-ai/venv/lib/python3.12/site-packages/azure/core/settings.pyr   r   =   s   „ Ø�Er!   r   c                óŽ   — t        | t        «      r| S | j                  «       }|dv ry|dv ryt        dj	                  | «      «      ‚)a¬  Convert a string to True or False

    If a boolean is passed in, it is returned as-is. Otherwise the function
    maps the following strings, ignoring case:

    * "yes", "1", "on" -> True
    " "no", "0", "off" -> False

    :param value: the value to convert
    :type value: str or bool
    :returns: A boolean value matching the intent of the input
    :rtype: bool
    :raises ValueError: If conversion to bool fails

    )ÚyesÚ1ÚonÚtrueÚTrueT)ÚnoÚ0ÚoffÚfalseÚFalseFz"Cannot convert {} to boolean value)Ú
isinstanceÚboolÚlowerÚ
ValueErrorÚformat)ÚvalueÚvals     r"   Úconvert_boolr5   D   sM   € ô  �%œÔØˆØ
�+‰+‹-€CØ
Ð0Ñ0ØØ
Ð2Ñ2ØÜ
Ð9×@Ñ@ÀÓGÓ
HÐHr!   c                óH   — | €t         j                  «       ryyt        | «      S )a  Convert tracing value to bool with regard to tracing implementation.

    :param value: the value to convert
    :type value: str or bool or None
    :returns: A boolean value matching the intent of the input
    :rtype: bool
    :raises ValueError: If conversion to bool fails
    TF)r   Útracing_implementationr5   )r3   s    r"   Úconvert_tracing_enabledr8   ^   s(   € ð €}ô ×*Ñ*Ô,ØØÜ˜ÓÐr!   )ÚCRITICALÚERRORÚWARNINGÚINFOÚDEBUGc                óÔ   — t        | t        «      r| S | j                  «       }t        j	                  |«      }|s.t        dj                  | dj                  t        «      «      «      ‚|S )aÖ  Convert a string to a Python logging level

    If a log level is passed in, it is returned as-is. Otherwise the function
    understands the following strings, ignoring case:

    * "critical"
    * "error"
    * "warning"
    * "info"
    * "debug"

    :param value: the value to convert
    :type value: str or int
    :returns: A log level as an int. See the logging module for details.
    :rtype: int
    :raises ValueError: If conversion to log level fails

    z4Cannot convert {} to log level, valid values are: {}ú, )r.   ÚintÚupperÚ_levelsÚgetr1   r2   Újoin)r3   r4   Úlevels      r"   Úconvert_loggingrF   y   s]   € ô& �%œÔð ˆØ
�+‰+‹-€CÜ�K‰K˜Ó€EÙÜÐO×VÑVÐW\Ð^b×^gÑ^gÔhoÓ^pÓqÓrÐrØ€Lr!   c           	     óB  — t        | t        «      r| S t        | t        «      r_t        D �ci c]  }|j                  |“Œ }}| |v r||    S t	        dj                  | dj                  |j                  «       «      «      «      ‚t	        dj                  | «      «      ‚c c}w )zãConvert a string to an Azure Cloud

    :param value: the value to convert
    :type value: string
    :returns: An AzureClouds enum value
    :rtype: AzureClouds
    :raises ValueError: If conversion to AzureClouds fails

    z6Cannot convert {} to Azure Cloud, valid values are: {}r?   z Cannot convert {} to Azure Cloud)r.   r   ÚstrÚnamer1   r2   rD   Úkeys)r3   ÚcloudÚazure_cloudss      r"   Úconvert_azure_cloudrM   —   sž   € ô �%œÔ%ØˆÜ�%œÔÜ7BÖC¨e˜Ÿ
™
 EÑ)ÐCˆÐCØ�LÑ Ø Ñ&Ð&ÜØD×KÑKÈEÐSW×S\ÑS\Ð]i×]nÑ]nÓ]pÓSqÓró
ð 	
ô Ð7×>Ñ>¸uÓEÓ
FÐFùò Ds   «Bc                 ó2   — 	 ddl m}  | S # t        $ r Y yw xY w)z²Returns the OpenCensusSpan if the opencensus tracing plugin is installed else returns None.

    :rtype: type[AbstractSpan] or None
    :returns: OpenCensusSpan type or None
    r   ©ÚOpenCensusSpanN)Ú&azure.core.tracing.ext.opencensus_spanrP   ÚImportErrorrO   s    r"   Ú_get_opencensus_spanrS   ­   s&   € ðõ	
ð ÐøÜò Ùðúó   ‚
 Š	•c                 ó2   — 	 ddl m}  | S # t        $ r Y yw xY w)z»Returns the OpenTelemetrySpan if the opentelemetry tracing plugin is installed else returns None.

    :rtype: type[AbstractSpan] or None
    :returns: OpenTelemetrySpan type or None
    r   ©ÚOpenTelemetrySpanN)Ú)azure.core.tracing.ext.opentelemetry_spanrW   rR   rV   s    r"   Ú_get_opentelemetry_spanrY   ½   s&   € ðõ	
ð !Ð øÜò ÙðúrT   )Ú
opencensusÚopentelemetryz5Dict[str, Callable[[], Optional[Type[AbstractSpan]]]]Ú_tracing_implementation_dictc                óø   — | €yt        | t        «      s| S | j                  «       } t        j	                  | d„ «      } |«       }|t
        u r.t        dj                  | dj                  t        «      «      «      ‚|S )ao  Convert a string to AbstractSpan

    If a AbstractSpan is passed in, it is returned as-is. Otherwise the function
    understands the following strings, ignoring case:

    * "opencensus"
    * "opentelemetry"

    :param value: the value to convert
    :type value: string
    :returns: AbstractSpan
    :raises ValueError: If conversion to AbstractSpan fails

    Nc                 ó   — t         S ©N)Ú_unsetr    r!   r"   ú<lambda>z&convert_tracing_impl.<locals>.<lambda>ê   s   € Ì€ r!   z7Cannot convert {} to AbstractSpan, valid values are: {}r?   )	r.   rH   r0   r\   rC   r`   r1   r2   rD   )r3   Úget_wrapper_classÚwrapper_classs      r"   Úconvert_tracing_implrd   Ó   s{   € ð  €}Øä�eœSÔ!Øˆà�K‰K‹M€EÜ4×8Ñ8¸ÁÓOÐÙARÓAT€MØœÑÜØE×LÑLØ�t—y‘yÔ!=Ó>óó
ð 	
ð
 Ðr!   c                  óŒ   — e Zd ZdZddedf	 	 	 	 	 	 	 	 	 dd„Zdd„Zddd„Zddd„Zdd„Z	dd„Z
dd	„Zedd
„«       Zedd„«       Zy)ÚPrioritizedSettinga¹  Return a value for a global setting according to configuration precedence.

    The following methods are searched in order for the setting:

    4. immediate values
    3. previously user-set value
    2. environment variable
    1. system setting
    0. implicit default

    If a value cannot be determined, a RuntimeError is raised.

    The ``env_var`` argument specifies the name of an environment to check for
    setting values, e.g. ``"AZURE_LOG_LEVEL"``.
    If a ``convert`` function is provided, the result will be converted before being used.

    The optional ``system_hook`` can be used to specify a function that will
    attempt to look up a value for the setting from system-wide configurations.
    If a ``convert`` function is provided, the hook result will be converted before being used.

    The optional ``default`` argument specified an implicit default value for
    the setting that is returned if no other methods provide a value. If a ``convert`` function is provided,
    ``default`` will be converted before being used.

    A ``convert`` argument may be provided to convert values before they are
    returned. For instance to concert log levels in environment variables
    to ``logging`` module values. If a ``convert`` function is provided, it must support
    str as valid input type.

    :param str name: the name of the setting
    :param str env_var: the name of an environment variable to check for the setting
    :param callable system_hook: a function that will attempt to look up a value for the setting
    :param default: an implicit default value for the setting
    :type default: any
    :param callable convert: a function to convert values before they are returned
    Nc                ón   — || _         || _        || _        || _        d„ }|r|n|| _        t
        | _        y )Nc                ó   — | S r_   r    )Úxs    r"   ra   z-PrioritizedSetting.__init__.<locals>.<lambda>(  s   € °q€ r!   )Ú_nameÚ_env_varÚ_system_hookÚ_defaultÚ_convertr`   Ú_user_value)ÚselfrI   Úenv_varÚsystem_hookÚdefaultÚconvertÚnoop_converts          r"   Ú__init__zPrioritizedSetting.__init__  s:   € ð ˆŒ
ØˆŒØ'ˆÔØˆŒÙ-8ˆÙV]É7ÐcoˆŒÜ:@ˆÕr!   c                ó    — d| j                   z  S )NzPrioritizedSetting(%r))rj   ©rp   s    r"   Ú__repr__zPrioritizedSetting.__repr__,  s   € Ø'¨$¯*©*Ñ4Ð4r!   c                ó*  — |�| j                  |«      S t        | j                  t        «      s| j                  | j                  «      S | j                  rH| j                  t
        j                  v r,| j                  t
        j                  | j                     «      S | j                  r| j                  | j                  «       «      S t        | j                  t        «      s| j                  | j                  «      S t        d| j                  z  «      ‚)a   Return the setting value according to the standard precedence.

        :param value: value
        :type value: str or int or float or None
        :returns: the value of the setting
        :rtype: str or int or float
        :raises RuntimeError: if no value can be determined
        z(No configured value found for setting %r)rn   r.   ro   r   rk   ÚosÚenvironrl   rm   ÚRuntimeErrorrj   ©rp   r3   s     r"   Ú__call__zPrioritizedSetting.__call__/  sÏ   € ð ÐØ—=‘= Ó'Ð'ô ˜$×*Ñ*¬FÔ3Ø—=‘= ×!1Ñ!1Ó2Ð2ð �=Š=˜TŸ]™]¬b¯j©jÑ8Ø—=‘=¤§¡¨D¯M©MÑ!:Ó;Ð;ð ×ÒØ—=‘= ×!2Ñ!2Ó!4Ó5Ð5ô ˜$Ÿ-™-¬Ô0Ø—=‘= §¡Ó/Ð/äÐEÈÏ
É
ÑRÓSÐSr!   c                ó   — | S r_   r    )rp   ÚinstanceÚowners      r"   Ú__get__zPrioritizedSetting.__get__O  s   € Øˆr!   c                ó&   — | j                  |«       y r_   )Ú	set_value)rp   r�   r3   s      r"   Ú__set__zPrioritizedSetting.__set__R  s   € Ø�‰�uÕr!   c                ó   — || _         y)a  Specify a value for this setting programmatically.

        A value set this way takes precedence over all other methods except
        immediate values.

        :param value: a user-set value for this setting
        :type value: str or int or float
        N)ro   r~   s     r"   r…   zPrioritizedSetting.set_valueU  s   € ð !ˆÕr!   c                ó   — t         | _        y)z>Unset the previous user value such that the priority is reset.N)r`   ro   rx   s    r"   Úunset_valuezPrioritizedSetting.unset_value`  s
   € ä!ˆÕr!   c                ó   — | j                   S r_   )rk   rx   s    r"   rq   zPrioritizedSetting.env_vard  ó   € à�}‰}Ðr!   c                ó   — | j                   S r_   )rm   rx   s    r"   rs   zPrioritizedSetting.defaulth  r‹   r!   )
rI   rH   rq   úOptional[str]rr   z&Optional[Callable[[], ValidInputType]]rs   úUnion[ValidInputType, _Unset]rt   z;Optional[Callable[[Union[ValidInputType, str]], ValueType]])ÚreturnrH   r_   )r3   zOptional[ValidInputType]r�   r   )r�   r   r‚   zOptional[Any]r�   z-PrioritizedSetting[ValidInputType, ValueType])r�   r   r3   r   r�   ÚNone)r3   r   r�   r�   ©r�   r�   )r�   r�   )r�   rŽ   )r   r   r   Ú__doc__r`   rv   ry   r   rƒ   r†   r…   r‰   Úpropertyrq   rs   r    r!   r"   rf   rf   õ   sš   „ ñ#ðP "&Ø>BØ17ØOSðAàðAð ðAð <ð	Að
 /ðAð MóAó"5ôTô@óó	!ó"ð òó ðð òó ñr!   rf   c                  ó6  — e Zd ZU dZdd„Zedd„«       Zej                  dd„«       Zedd„«       Zedd„«       Z	dd„Z
dd„Z ed	d
eej                  ¬«      Zded	<    edded¬«      Zded<    edded¬«      Zded<    eddeej0                  ¬«      Zded<   y)r   a]
  Settings for globally used Azure configuration values.

    You probably don't want to create an instance of this class, but call the singleton instance:

    .. code-block:: python

        from azure.core.settings import settings
        settings.log_level = log_level = logging.DEBUG

    The following methods are searched in order for a setting:

    4. immediate values
    3. previously user-set value
    2. environment variable
    1. system setting
    0. implicit default

    An implicit default is (optionally) defined by the setting attribute itself.

    A system setting value can be obtained from registries or other OS configuration
    for settings that support that method.

    An environment variable value is obtained from ``os.environ``

    User-set values many be specified by assigning to the attribute:

    .. code-block:: python

        settings.log_level = log_level = logging.DEBUG

    Immediate values are (optionally) provided when the setting is retrieved:

    .. code-block:: python

        settings.log_level(logging.DEBUG())

    Immediate values are most often useful to provide from optional arguments
    to client functions. If the argument value is not None, it will be returned
    as-is. Otherwise, the setting searches other methods according to the
    precedence rules.

    Immutable configuration snapshots can be created with the following methods:

    * settings.defaults returns the base defaultsvalues , ignoring any environment or system
      or user settings

    * settings.current returns the current computation of settings including prioritization
      of configuration sources, unless defaults_only is set to True (in which case the result
      is identical to settings.defaults)

    * settings.config can be called with specific values to override what settings.current
      would provide

    .. code-block:: python

        # return current settings with log level overridden
        settings.config(log_level=logging.DEBUG)

    :cvar log_level: a log level to use across all Azure client SDKs (AZURE_LOG_LEVEL)
    :type log_level: PrioritizedSetting
    :cvar tracing_enabled: Whether tracing should be enabled across Azure SDKs (AZURE_TRACING_ENABLED)
    :type tracing_enabled: PrioritizedSetting
    :cvar tracing_implementation: The tracing implementation to use (AZURE_SDK_TRACING_IMPLEMENTATION)
    :type tracing_implementation: PrioritizedSetting

    :Example:

    >>> import logging
    >>> from azure.core.settings import settings
    >>> settings.log_level = logging.DEBUG
    >>> settings.log_level()
    10

    >>> settings.log_level(logging.WARN)
    30

    c                ó   — d| _         y )NF©Ú_defaults_onlyrx   s    r"   rv   zSettings.__init__¼  s
   € Ø$)ˆÕr!   c                ó   — | j                   S )zÞWhether to ignore environment and system settings and return only base default values.

        :rtype: bool
        :returns: Whether to ignore environment and system settings and return only base default values.
        r–   rx   s    r"   Údefaults_onlyzSettings.defaults_only¿  s   € ð ×"Ñ"Ð"r!   c                ó   — || _         y r_   r–   r~   s     r"   r™   zSettings.defaults_onlyÈ  s
   € à#ˆÕr!   c                óÔ   — | j                   j                  j                  «       D ��ci c]#  \  }}t        |t        «      sŒ||j
                  “Œ% }}}| j                  |«      S c c}}w )zµReturn implicit default values for all settings, ignoring environment and system.

        :rtype: namedtuple
        :returns: The implicit default values for all settings
        )Ú	__class__Ú__dict__Úitemsr.   rf   rs   Ú_config)rp   ÚkÚvÚpropss       r"   ÚdefaultszSettings.defaultsÌ  sV   € ð -1¯N©N×,CÑ,C×,IÑ,IÓ,K×q¡& 1 aÌzÐZ[Ô]oÕOp��A—I‘I‘ÐqˆÑqØ�|‰|˜EÓ"Ð"ùó rs   ¨A$ÁA$c                óR   — | j                   r| j                  S | j                  «       S )z†Return the current values for all settings.

        :rtype: namedtuple
        :returns: The current values for all settings
        )r™   r£   Úconfigrx   s    r"   ÚcurrentzSettings.currentÖ  s#   € ð ×ÒØ—=‘=Ð Ø�{‰{‹}Ðr!   c                óì   — | j                   j                  j                  «       D ��ci c]  \  }}t        |t        «      sŒ| |«       “Œ  }}}|j                  |«       | j                  |«      S c c}}w )a‚  Return the currently computed settings, with values overridden by parameter values.

        :rtype: namedtuple
        :returns: The current values for all settings, with values overridden by parameter values

        Examples:

        .. code-block:: python

           # return current settings with log level overridden
           settings.config(log_level=logging.DEBUG)

        )rœ   r�   rž   r.   rf   ÚupdaterŸ   )rp   Úkwargsr    r¡   r¢   s        r"   r¥   zSettings.configá  s`   € ð '+§n¡n×&=Ñ&=×&CÑ&CÓ&E×k™F˜Q ÌÐTUÔWiÕIj�‘A“C‘ÐkˆÑkØ�‰�VÔØ�|‰|˜EÓ"Ð"ùó ls   ¨A0Á
A0c                ó\   — t        |j                  «       «      }t        d|«      } |di |¤ŽS )NÚConfigr    )ÚlistrJ   r   )rp   r¢   rJ   r«   s       r"   rŸ   zSettings._configó  s*   € Ü˜uŸz™z›|Ó,ˆä˜H dÓ+ˆÙ‰˜‰Ðr!   Ú	log_levelÚAZURE_LOG_LEVEL)rq   rt   rs   z(PrioritizedSetting[Union[str, int], int]Útracing_enabledÚAZURE_TRACING_ENABLEDNz4PrioritizedSetting[Optional[Union[str, bool]], bool]r7   Ú AZURE_SDK_TRACING_IMPLEMENTATIONzZPrioritizedSetting[Optional[Union[str, Type[AbstractSpan]]], Optional[Type[AbstractSpan]]]Úazure_cloudÚAZURE_SDK_CLOUD_CONFz8PrioritizedSetting[Union[str, AzureClouds], AzureClouds]r‘   )r�   r/   )r3   r/   r�   r�   )r�   úTuple[Any, ...])r©   r   r�   r´   )r¢   zMapping[str, Any]r�   r´   )r   r   r   r’   rv   r“   r™   Úsetterr£   r¦   r¥   rŸ   rf   rF   Úloggingr<   r­   Ú__annotations__r8   r¯   rd   r7   rM   r   ÚAZURE_PUBLIC_CLOUDr²   r    r!   r"   r   r   m  s  … ñLó\*ð ò#ó ð#ð ×Ñò$ó ð$ð ò#ó ð#ð òó ðó#ó$ñ ;MØØ!ØØ—‘ô	;€IÐ7ó ñ M_ØØ'Ø'Øô	M€OÐIó ñ 	Ø Ø2Ø$Øô		ð ð ó ñ M_ØØ&Ø#Ø×.Ñ.ô	M€KÐIô r!   r   r   )r3   zUnion[str, bool]r�   r/   )r3   zOptional[Union[str, bool]]r�   r/   )r3   zUnion[str, int]r�   r@   )r3   zUnion[str, AzureClouds]r�   r   )r�   úOptional[Type[AbstractSpan]])r3   z(Optional[Union[str, Type[AbstractSpan]]]r�   r¹   )4r’   Ú
__future__r   Úcollectionsr   Úenumr   Ú	functoolsr   r¶   r{   Útypingr   r   r	   r
   r   r   r   r   r   r   r   r   Ú_azure_cloudsr   Úazure.core.tracingr   r   r   Ú__all__r   r   r`   r5   r8   r9   r:   r;   r<   r=   rB   rF   rM   rS   rY   r\   r·   rd   rf   r   r   r    r!   r"   ú<module>rÂ      s#  ðò4å "Ý "Ý Ý Û Û 	÷÷ ÷ ó õ 'áÝ/áÐ)Ó*€Ù�KÓ €	ð #€ôˆTô ð 
�‰€óIó4ð& × Ñ Ø�]‰]Ø�‰Ø�L‰LØ�]‰]ñ€óó<Gó,ó ð" 'Ø,ñWÐ ÐSó ð òó ðôBu˜ °Ð!:Ñ;ô u÷phñ hñV “Z€ˆ(Ó ðr!   