
    $gg3                    (   d dl m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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mZ d dlmZ erd dlmZ  ej        d	          Z ed
          Z  G d dee                    Z! G d de"          Z#ee$e!f         Z%ee%         Z&eee$e"f                  Z'eee$e$f                  Z( G d de          Z) ej*        d          d"d            Z+ G d de)          Z,e
d#d            Z-	 d$ddd%d!Z.dS )&    )annotationsN)UserDict)contextmanager)IOTYPE_CHECKINGAnyGenericIteratorListMappingSequenceTupleTypeVaroverload)
exceptionsutils)weak_propertyMkDocsConfigzmkdocs.configTc                      e Zd ZddZed             Zej        d             Zdd	Zdd
ZddZ	ddZ
ddZd Zeddd            Zeddd            ZddZd dZdS )!BaseConfigOptionreturnNonec                "    g | _         d | _        d S N)warningsdefaultselfs    R/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/mkdocs/config/base.py__init__zBaseConfigOption.__init__&   s    #%    c                d    	 | j                                         S # t          $ r
 | j         cY S w xY wr   )_defaultcopyAttributeErrorr   s    r!   r   zBaseConfigOption.default*   sD    	!=%%''' 	! 	! 	!=   	!s    //c                    || _         d S r   )r%   r    values     r!   r   zBaseConfigOption.default2   s    r#   r*   objectr   c               ,    |                      |          S r   )run_validationr)   s     r!   validatezBaseConfigOption.validate6   s    ""5)))r#   c                    g | _         d S r   )r   r   s    r!   reset_warningszBaseConfigOption.reset_warnings9   s    r#   configConfigkey_namestrc                    dS )z
        Before all options are validated, perform a pre-validation process.

        The pre-validation process method should be implemented by subclasses.
        N r    r1   r3   s      r!   pre_validationzBaseConfigOption.pre_validation<         r#   c                   |S )zy
        Perform validation for a value.

        The run_validation method should be implemented by subclasses.
        r6   r)   s     r!   r-   zBaseConfigOption.run_validationC   s	     r#   c                    dS )z
        After all options have passed validation, perform a post-validation
        process to do any additional changes dependent on other config values.

        The post-validation process method should be implemented by subclasses.
        Nr6   r7   s      r!   post_validationz BaseConfigOption.post_validationK   r9   r#   c                |    |                     d          r|                    d          s
|d d         }|| _        d S )N_)endswith
startswith_name)r    ownernames      r!   __set_name__zBaseConfigOption.__set_name__S   sA    == 	dooc&:&: 	9D


r#   Nobjc                    d S r   r6   r    rF   types      r!   __get__zBaseConfigOption.__get__X       r#   c                    d S r   r6   rH   s      r!   rJ   zBaseConfigOption.__get__\   rK   r#   c                J    t          |t                    s| S || j                 S r   )
isinstancer2   rB   rH   s      r!   rJ   zBaseConfigOption.__get__`   s%    #v&& 	K4:r#   c                    t          |t                    s/t          d| j         dt	          |           dt                     ||| j        <   d S )Nzcan't set attribute (z) because the parent is a z not a )rN   r2   r'   rB   rI   )r    rF   r*   s      r!   __set__zBaseConfigOption.__set__e   s\    #v&& 	 h
hhdSViihh`fhh    DJr#   r   r   )r*   r+   r   r   )r1   r2   r3   r4   r   r   )r*   r+   r   )rF   r2   r   r   )r   r   )r*   r   )__name__
__module____qualname__r"   propertyr   setterr.   r0   r8   r-   r<   rE   r   rJ   rP   r6   r#   r!   r   r   %   sE           ! ! X! ^  ^* * * *              
     X     X   
           r#   r   c                      e Zd ZdZd ZdS )ValidationErrorz=Raised during the validation process of the config on errors.c                ~    t          |           t          |          u ot          |           t          |          k    S r   )rI   r4   )r    others     r!   __eq__zValidationError.__eq__p   s/    DzzT%[[(DSYY#e**-DDr#   N)rR   rS   rT   __doc__r[   r6   r#   r!   rX   rX   m   s.        GGE E E E Er#   rX   c                       e Zd ZU dZded<   ded<   d Zd fdZdd fdZddZddZ	ddZ
ddZddZd dZd!dZed"d            Z xZS )#r2   aT  
    Base class for MkDocs configuration, plugin configuration (and sub-configuration) objects.

    It should be subclassed and have `ConfigOption`s defined as attributes.
    For examples, see mkdocs/contrib/search/__init__.py and mkdocs/config/defaults.py.

    Behavior as it was prior to MkDocs 1.4 is now handled by LegacyConfig.
    PlainConfigSchema_schemar4   config_file_pathc                   t          t          | dd                    }| j                                        D ].\  }}t	          |t
                    r||t          |d|          <   /t          |                                          | _        | j        D ]7\  }}d|_        t          |dd           t          | j
         d| d          8d S )Nr_   r6   rB   T_legacy_required.z: Setting 'required' is unsupported in class-based configs. All values are required, or can be wrapped into config_options.Optional)dictgetattr__dict__itemsrN   r   tupler_   required	TypeErrorrR   )clsschema	attr_nameattrs       r!   __init_subclass__zConfig.__init_subclass__   s    gc9b1122"|1133 	A 	AOIt$ 011 A<@wtWi889FLLNN++"{ 	 	OIt DMt/66B| ^ ^i ^ ^ ^   C	 	r#   r   c                p    | t           u rt          |i |S t                                          |           S )zSCompatibility: allow referring to `LegacyConfig(...)` constructor as `Config(...)`.)r2   LegacyConfigsuper__new__)rk   argskwargs	__class__s      r!   rs   zConfig.__new__   s5    &==0000wws###r#   Nstr | bytes | Nonec                v   t                                                       g | _        |                                  d | j        D             | _        |[t          |t                    sF	 |                    t          j
                              }n# t          $ r t          d          w xY w|pd| _        d S )Nc                    h | ]\  }}|S r6   r6   .0kvs      r!   	<setcomp>z"Config.__init__.<locals>.<setcomp>   s    88841aQ888r#   )encodingz)config_file_path is not a Unicode string. )rr   r"   _Config__user_configsset_defaultsr_   _schema_keysrN   r4   decodesysgetfilesystemencodingUnicodeDecodeErrorrX   r`   )r    r`   rv   s     r!   r"   zConfig.__init__   s    *,884<888'
;KS0Q0Q'S#3#:#:CD]D_D_#:#`#`  % S S S%&QRRRS 0 6Bs   +'B B-r   c                4    | j         D ]\  }}|j        | |<   dS )zt
        Set the base config by going through each validator and getting the
        default if it has one.
        N)r_   r   )r    keyconfig_options      r!   r   zConfig.set_defaults   s2    
 #', 	. 	.C%-DII	. 	.r#   #tuple[ConfigErrors, ConfigWarnings]c                   g }g }| j         D ]\  }	 |                               }|                    |          | <    |j        fd|j        D                        |                                 i# t          $ r"}|                    |f           Y d }~ nd }~ww xY wt          | 	                                          | j
        z
  D ] |j        d f           ||fS )Nc              3      K   | ]}|fV  	d S r   r6   r{   wr   s     r!   	<genexpr>z#Config._validate.<locals>.<genexpr>   '      IIQaIIIIIIr#   z!Unrecognised configuration name: )r_   getr.   extendr   r0   rX   appendsetkeysr   )r    failedr   r   r*   er   s         @r!   	_validatezConfig._validate   s(   !#%"&, 	 	C)22599S	IIII-2HIIIIII,,...."   sAh''' tyy{{##d&77 	N 	NCHOS"Kc"K"KLMMMMxs   A"A66
B" BB"c                $   g }g }| j         D ]\  }	 |                    |             |j        fd|j        D                        |                                 S# t
          $ r!}|                    |f           Y d }~yd }~ww xY w||fS )Nr3   c              3      K   | ]}|fV  	d S r   r6   r   s     r!   r   z'Config._pre_validate.<locals>.<genexpr>   r   r#   )r_   r8   r   r   r0   rX   r   r    r   r   r   r   r   s        @r!   _pre_validatezConfig._pre_validate   s    !#%"&, 	( 	(C(,,TC,@@@IIII-2HIIIIII,,...." ( ( (sAh''''''''( x   AA  
B*BBc                $   g }g }| j         D ]\  }	 |                    |             |j        fd|j        D                        |                                 S# t
          $ r!}|                    |f           Y d }~yd }~ww xY w||fS )Nr   c              3      K   | ]}|fV  	d S r   r6   r   s     r!   r   z(Config._post_validate.<locals>.<genexpr>   r   r#   )r_   r<   r   r   r0   rX   r   r   s        @r!   _post_validatezConfig._post_validate   s    !#%"&, 	( 	(C(--dS-AAAIIII-2HIIIIII,,...." ( ( (sAh''''''''( xr   c                N   |                                  \  }}|                                 \  }}|                    |            |j        |           t          |          dk    r<|                                 \  }}|                    |            |j        |           ||fS )Nr   )r   r   r   lenr   )r    r   r   
run_failedrun_warningspost_failedpost_warningss          r!   r.   zConfig.validate   s    --//#'>>#3#3 
Lj!!!%%% v;;!)-)<)<)>)>&KMM+&&&HOM***xr#   patchrd   c                    t          |t                    s$t          j        dt	          |                     | j                            |           |                     |           dS )z&Load config options from a dictionary.zPThe configuration is invalid. Expected a key-value mapping (dict) but received: N)rN   rd   r   ConfigurationErrorrI   r   r   update)r    r   s     r!   	load_dictzConfig.load_dict   su    %&& 	/D6:5kkD D  
 	""5)))Er#   config_filer   c                    t          j        dt                     |                     t	          j        |                    S )zALoad config options from the open file descriptor of a YAML file.zjConfig.load_file is not used since MkDocs 1.5 and will be removed soon. Use MkDocsConfig.load_file instead)r   warnDeprecationWarningr   r   	yaml_load)r    r   s     r!   	load_filezConfig.load_file   s<    1	
 	
 	

 ~~eok::;;;r#   Sequence[Mapping[str, Any]]c                D    t          j        dt                     | j        S )Nz>user_configs is never used in MkDocs and will be removed soon.)r   r   r   r   r   s    r!   user_configszConfig.user_configs	  s'    LN`	
 	
 	
 ""r#   )r   r2   r   )r`   rw   rQ   )r   r   )r   rd   r   r   )r   r   r   r   )r   r   )rR   rS   rT   r\   __annotations__ro   rs   r"   r   r   r   r   r.   r   r   r   r   __classcell__rv   s   @r!   r2   r2   {   sA             $ $ $ $ $ $7 7 7 7 7 7 7. . . .       &                     "	 	 	 	< < < < # # # ]# # # # #r#   r2   )maxsizerk   rI   r   r^   c                    t          | t                    r| j        S t          d | j                                        D                       S )zeExtract ConfigOptions defined in a class (used just as a container) and put them into a schema tuple.c              3  N   K   | ] \  }}t          |t                    ||fV  !d S r   )rN   r   rz   s      r!   r   zget_schema.<locals>.<genexpr>  s:      \\DAqJqJZ<[<[\!Q\\\\\\r#   )
issubclassr2   r_   rh   rf   rg   )rk   s    r!   
get_schemar     sI     #v {\\CL$6$6$8$8\\\\\\r#   c                  &     e Zd ZdZdd	 fdZ xZS )
rq   zVA configuration object for plugins, as just a dict without type-safe attribute access.Nrl   r^   r`   
str | Nonec                    t          d |D                       | _        t                                          |           d S )Nc              3  $   K   | ]\  }}||fV  d S r   r6   rz   s      r!   r   z(LegacyConfig.__init__.<locals>.<genexpr>  s*      771aV777777r#   )rh   r_   rr   r"   )r    rl   r`   rv   s      r!   r"   zLegacyConfig.__init__  s@    7777777)*****r#   r   )rl   r^   r`   r   )rR   rS   rT   r\   r"   r   r   s   @r!   rq   rq     sH        ``+ + + + + + + + + + +r#   rq   r   str | IO | NoneIterator[IO]c              #    K   | ddg}n7t          | t                    r| g}nt          | dd          r	| j        g}n| }d}|r|D ]`}t          j                            |          }t                              d|            	 t          |d          } n.# t          $ r Y ]w xY wt          j        d|d	          d
          nDt                              d|            	 |                    d	           n# t          $ r Y nw xY w	 |V  t          |d          r|                                 dS dS # t          |d          r|                                 w w xY w)a  
    A context manager which yields an open file descriptor ready to be read.

    Accepts a filename as a string, an open or closed file descriptor, or None.
    When None, it defaults to `mkdocs.yml` in the CWD. If a closed file descriptor
    is received, a new file descriptor is opened for the same file.

    The file descriptor is automatically closed when the context manager block is existed.
    Nz
mkdocs.ymlzmkdocs.yamlclosedFzLoading configuration file: rbzConfig file 'r   z' does not exist.close)rN   r4   re   rD   ospathabspathlogdebugopenFileNotFoundErrorr   r   seekOSErrorhasattrr   )r   paths_to_tryresult_config_filer   s       r!   _open_config_filer   !  s      $m4	K	%	% #}	h	.	. #()(   		d 		dD7??4((DII;T;;<<<%)$%5%5"$    /0bQ0b0b0bccc	  			E1CEEFFF	##A&&&& 	 	 	D	'    %w// 	'$$&&&&&	' 	'7%w// 	'$$&&&&	's0   B
B#"B##C9 9
DD
D6 6'Er`   r`   r   r   c                  |                                 }|                                                                 D ]\  }}||                    |           t          |           5 }ddlm} |0t          j        r$|t          j        j        urt          |dd          } ||          }|
                    |           ddd           n# 1 swxY w Y   |                    |           |                                \  }	}
|
D ]%\  }}t                              d| d|            &|	D ]%\  }}t                              d| d|            &|                                D ]%\  }}t                              d| d|           &t#          |	          dk    rt%          j        d	          |j        r8t#          |
          dk    r%t%          j        d
t#          |
           d          |S )a9  
    Load the configuration for a given file object or name.

    The config_file can either be a file object, string or None. If it is None
    the default `mkdocs.yml` filename will loaded.

    Extra kwargs are passed to the configuration to replace any default values
    unless they themselves are None.
    Nr   r   rD   r   zConfig value 'z': z' = z#Aborted with a configuration error!zAborted with z) configuration warnings in 'strict' mode!)r&   rg   popr   mkdocs.config.defaultsr   r   stdinbufferre   r   r   r.   r   warningerrorr   r   r   Abortstrict)r   r`   ru   optionsr   r*   fdr   cfgerrorsr   config_namer   r   s                 r!   load_configr   T  sb    kkmmG llnn**,,  
U=KK	;	'	' 	2777777#y =Rsy'777#*2vt#<#< l,<===b	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 MM'||~~FH ( @ @W>[>>W>>????$ < <U		:;::5::;;;;iikk 7 7
U		5355E556666
6{{QDEEE	 
H))TCMMTTT
 
 	
 Js   'ACCC)rk   rI   r   r^   )r   r   r   r   r   )r   r   r`   r   r   r   )/
__future__r   	functoolsloggingr   r   r   collectionsr   
contextlibr   typingr   r   r   r	   r
   r   r   r   r   r   r   mkdocsr   r   mkdocs.utilsr   r   r   	getLoggerr   r   r   	ExceptionrX   r4   PlainConfigSchemaItemr^   ConfigErrorsConfigWarningsr2   	lru_cacher   rq   r   r   r6   r#   r!   <module>r      s   " " " " " "      				 



              % % % % % %                          % $ $ $ $ $ $ $ & & & & & & 4333333 g(( GCLLE  E  E  E  E wqz E  E  E PE E E E Ei E E E c#334 23 E#y.)*eCHo&S# S# S# S# S#X S# S# S#l T"""] ] ] #"]+ + + + +6 + + + /' /' /' /'f $(4KO4 4 4 4 4 4 4 4r#   