
    hO                        S SK r S SKr\R                  " S5      r\R                  " S5      r\R                  " S5      rS\4S jr\" 5       qS\4S jr	S r
S	 rS
\SS4S jrS
\S\4S jrS\SS4S jrS rS\S\4S jrS rS rg)    Nz^[a-zA-Z_:][a-zA-Z0-9_:]*$z^[a-zA-Z_][a-zA-Z0-9_]*$z^__.*$returnc                  d    [         R                  R                  SS5      R                  5       S;   $ )z2Retrieve name validation setting from environment.!PROMETHEUS_LEGACY_NAME_VALIDATIONFalse)true1t)osenvirongetlower     oC:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\prometheus_client/validation.py_init_legacy_validationr   	   s'    ::>>=wGMMOSeeer   c                      [         $ )z;Return the current status of the legacy validation setting._legacy_validationr   r   r   get_legacy_validationr      s
     r   c                      Sq g)zEDisable legacy name validation, instead allowing all UTF8 characters.FNr   r   r   r   disable_legacy_validationr      s
     r   c                      Sq g)zFEnable legacy name validation instead of allowing all UTF8 characters.TNr   r   r   r   enable_legacy_validationr      s
     r   namec                     U (       d  [        S5      e[        (       a(  [        R                  U 5      (       d  [        SU -   5      e U R	                  S5        g! [
         a    [        SU -   5      ef = f)zRaises ValueError if the provided name is not a valid metric name.

This check uses the global legacy validation setting to determine the validation scheme.
zmetric name cannot be emptyzinvalid metric name utf-8N)
ValueErrorr   METRIC_NAME_REmatchencodeUnicodeDecodeErrorr   s    r   _validate_metric_namer#   #   sl    
 677##D))3d:;;8G 8/$6778s   A A2c                 0    [         R                  U 5      SL$ )zRReturns true if the provided metric name conforms to the legacy validation scheme.N)r   r   r"   s    r   _is_valid_legacy_metric_namer%   4   s    %T11r   tokc                 .   U (       d  [        SU -   5      eU S   S:H  =(       a    U S   S:H  nU(       a  [        (       a)  [        R                  U 5      (       d  [        SU -   5      eg U R	                  S5        g! [
         a    [        SU -   5      ef = f)zYRaises ValueError if a parsed label name token is invalid. 

UTF-8 names must be quoted.
zinvalid label name token r   "Nr   )r   r   METRIC_LABEL_NAME_REr   r    r!   )r&   quoteds     r   !_validate_metric_label_name_tokenr,   9   s    
 4s:;;Vs]-s2w#~F''#))#..83>??<

7 <4s:;;<s   )A; ;Bc                 p   [        5       (       aQ  [        R                  U 5      (       d  [        SU -   5      e[        R                  U 5      (       a  [        SU -   5      eg U R                  S5        [        R                  U 5      (       a  [        SU -   5      eg! [         a    [        SU -   5      ef = f)zRaises ValueError if the provided name is not a valid label name.

This check uses the global legacy validation setting to determine the validation scheme.
zInvalid label metric name: zReserved label metric name: r   N)r   r*   r   r   RESERVED_METRIC_LABEL_NAME_REr    r!   ls    r   _validate_labelnamer1   L   s    
 #))!,,:Q>??(..q11;a?@@ 2	@HHW )..q11;a?@@ 2 " 	@:Q>??	@s   "B B5r0   c                 ^    [         R                  U 5      c  g[        R                  U 5      SL $ )zQReturns true if the provided label name conforms to the legacy validation scheme.NF)r*   r   r.   r/   s    r   _is_valid_legacy_labelnamer3   _   s,    !!!$,(..q1T99r   c                 ~    [        U5      nU H+  n[        U5        X R                  ;   d  M  [        SU-   5      e   U$ )zRaises ValueError if any of the provided names is not a valid label name.

This check uses the global legacy validation setting to determine the validation scheme.
z Reserved label methe fric name: )tupler1   _reserved_labelnamesr   )cls
labelnamesr0   s      r   _validate_labelnamesr9   f   sE    
 z"JA(((?!CDD  r   c                     SnU R                  5        H,  u  p#[        U5        U[        U5      -  nU[        U5      -  nM.     US:  a  [        S5      eg)z-Raises ValueError if the exemplar is invalid.r      zDExemplar labels have %d UTF-8 characters, exceeding the limit of 128N)itemsr1   lenr   )exemplarruneskvs       r   _validate_exemplarrB   s   sV    E AQQ ! s{_`` r   )r
   recompiler   r*   r.   boolr   r   r   r   r   strr#   r%   r,   r1   r3   r9   rB   r   r   r   <module>rG      s    	 	9:zz"=>  "

9 5 f f
 -. t 8 8 8"2s 2t 2
<3 <4 <&A&:# :$ :
ar   