
    $gV                        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Zd dl	Z	d dl
mZmZ d dlmZmZ d dlmZ d dlmZ d dlmZ d dlmZmZ d dlmZ d d	lmZmZ d
dlmZ d
dl m!Z!  G d dee                   Z"ddZ#d de$de$de$fdZ%de$fdZ&d!de$de'fdZ(de$fdZ)d!de$de'de'fdZ* ej+        d          Z,dS )"    N)ForeStyle)distributionsversion)BytesIO)slugify)MkDocsConfig)
BasePluginevent_priority)get_yaml_loader)ZipFileZIP_DEFLATED   )
InfoConfig)get_exclusion_patternsc                   n     e Zd Z fdZd Z ed          d             Zd Zd Zd Z	de
d	efd
Z xZS )
InfoPluginc                 d     t                      j        |i | d| _        g | _        g | _        d S )NF)super__init__is_serveexclusion_patternsexcluded_entries)selfargskwargs	__class__s      \/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/material/plugins/info/plugin.pyr   zInfoPlugin.__init__4   s@    $)&)))  #% "    c                    |dk    | _         d S )Nserve)r   )r   commanddirtys      r   
on_startupzInfoPlugin.on_startup?   s    7*r   d   c                    | j         j        sd S | j         j        s	| j        rd S d}t	          j        |d          }|j                            d                              dd          \  }}t          d          }|	                    |          s0t                              d           |                     ||           | j         j        st          j        d           t                              d	           |j        j        r.t                              d
           |                                  |j        r.t                              d           |                                  t+          |j                  |_        t.          j                            |j                  }|j        j        rt+          |j        j        |          }nd}|j                            d          }	|	rt+          |	j         j        |          }
nd}
t9          |j                  }t;          |t<                    s|g}|j        |j        ||
gd |D             }|j        D ](}t+          ||          }|                     |           )t=          |          D ]?}|r&|	                    t/          j!                              r|"                    |           @|r/t                              d           | #                    |           tI                      }tK          d          }t.          j        &                    |          \  }}d'                    |tQ          |d          g          }tS                      | _*        g | _+        |j,        	                    t/          j!                              r,| j*                             t[          |j,                             t\          j/        D ]O}|	                    t/          j!                              r'| j*                             t[          |                     P|	rta          j1        |	j         j2        |
d          D ]_}t.          j        '                    |
|          }tg          |          }t[          |j,                  }| j*                             |           `d}g }ti          |dtj          d          5 }t/          j6        t/          j!                              D ]a\  }}}d| }to          |dd           t=          |          D ]`}t.          j        '                    ||          }| 8                    |          r|"                    |           Mts          |d          rd}a|D ]}t.          j        '                    ||          }| 8                    |          r8ts          |d          rd}t.          j        :                    |t.          j        j;                  }|<                    |t.          j        '                    ||                     to          dt{          |          z  dd           c|>                    t.          j        '                    |d          d'                    t          d t                      D                                            |>                    t.          j        '                    |d          t          jB        t          jC                    t          jD                    t          jE                    t/          j!                    d'                    t          jF        d                             t.          jG        d          d          gt          jF        dd                    t/          jH        d!d          t          j        | j+        d"t          d#$                     |jJ        D ]f}d%|jK        v rt          jM        nt          jN        }|                     d'                    ||jK        dt          |jP                  g                     g	 d d d            n# 1 swxY w Y   |Q                                }t          | d&d'          5 }|<                    |S                                           d d d            n# 1 swxY w Y   t                              d(           to          t          jU                   |V                                 |D ]}to          d)|            to          t          jW                   to          d'                    d)|jX        dt          |jY        d*          g                     to          t          jW                   |jY        d+k    rt          Z                    d,           |rt          Z                    d-           t          j        d           d S ).Nz<https://github.com/squidfunk/mkdocs-material/releases/latestF)allow_redirectslocation/r   zmkdocs-materialz%Please upgrade to the latest version.z'Started archive creation for bug reportz#Please remove 'custom_dir' setting.zPlease remove 'hooks' setting.
abs_prefix zmaterial/projectsc                 :    g | ]}|                     d d          S )INHERITr,   )get).0cfgs     r   
<listcomp>z(InfoPlugin.on_config.<locals>.<listcomp>   s&    ???cggi$$???r   z)One or more paths aren't children of rootz*
Please name your bug report (2-4 words): -T)pathnameroot_dir	recursiveazProcessing: )endflush)log_warning zrequirements.lock.txt
c                 P    g | ]#}d                      |j        |j        g          $S )z==)joinnamer   )r0   packages     r   r2   z(InfoPlugin.on_config.<locals>.<listcomp>  s=     " " "# IIw|W_=>>" " "r   zplatform.jsonr   
PYTHONPATH)systemarchitecturepythoncwdr"   zenv:$PYTHONPATHzsys.pathr      )defaultindentz/.z.zipwbzArchive successfully created:z  
   i@B z0Archive exceeds recommended maximum size of 1 MBzArchive contains dotpaths, which could contain sensitive information.
Please review them at the bottom of the list and share only necessary data to reproduce the issue.)[configenabledenabled_on_server   requestsr/   headersrsplitr   
startswithlogerror_help_on_versions_and_exitarchivesysexitinfotheme
custom_dir _help_on_customizations_and_exithooks_convert_to_absconfig_file_pathospathdirnamepluginsprojects_dir
_load_yaml
isinstancelistdocs_dirappendgetcwdremove_help_on_not_in_cwdr   inputsplitextr?   r   r   r   r   site_dir_resolve_patternsitePREFIXESglobiglobprojects_config_files_get_project_configr   r   walkprint_is_excluded_is_dotpathrelpathcurdirwritelenwritestrsortedr   jsondumpsplatformrE   python_versionargvsepgetenvstrfilelistfilenamer   LIGHTYELLOW_EXLIGHTBLACK_EX_sizecompress_size	getbufferopengetvaluer   NORMALsort	RESET_ALLr@   nbyteswarning) r   rM   urlres_currentpresentconfig_file_parentabs_custom_dirprojects_pluginabs_projects_dirloaded_configspaths_to_validatehookrb   rW   examplecurrent_config_fileproject_configpatterncontains_dotpathfilesfabs_rootdirnames	filenames	indicatorr@   r7   colorbufferfiles                                    r   	on_configzInfoPlugin.on_configF   s7
   {" 	F
 {+ 	 	F Ml3%888 [__Z0077Q??
7+,,!!'** 	>II=>>>++GW=== {" 	HQKKK 	:;;; <" 	4II;<<<11333 < 	4II677711333
 #2&2I"J"JW__V-DEE <" 	 ,'/  NN
  N !.,,-@AA 	".&3/     
  " $F$;<<.$// 	.,-N #O	

 @????
 L 	+ 	+D"46HIIID$$T**** *++ 	/ 	/D /4??29;;77 /!((...  	8IIBCCC$$%6777 ))EFFW%%g..
((GWWc%:%:;<< #9":": " ?%%bikk22 	N#**+;FO+L+LMMM
 M 	G 	GDry{{++ G'../?/E/EFFF  		8
*1G+    8 8
 ')gll3CT&J&J#!45H!I!I*>+BCC'..w7777 "' Wc<77 O	1131E1E %B %B-(I5855	iT6666 !NN 0 0D7<<$77D ((.. ! ---  #4t<<< 0+/( & ? ?D7<<$77D ((.. !  #4t<<< 0+/( 7??4@@DGGD"',,w"="=>>>> cC	NN*DAAAAA JJW&=>>		& " "'4" " "       JJWo66
"*"3"5"5(0(=(?(?"*"9";";!y{{#&88HQK..rvq99"=- Xabb\- $ $ ,.9\2+F+F$'H,0,A  "    , Z  04
0B0B,,"0 RWW1:s!/**&      	QO	 O	 O	 O	 O	 O	 O	 O	 O	 O	 O	 O	 O	 O	 O	d ""$$W"""D)) 	(QGGG$$&&'''	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	( 	0111el 	

 	 	D+t++ 	eobgg!&#&-$$
   	 	 	 	eo=7""KKJKKK  	KKH   	s%   M:aa a(b??ccc                    t          t          j                   t          d           t          d           t          d           t          d           t          t          j                   t          d| d| d           t          t          j                   t          d           t          t          j                   | j        j        rt          j	        d	           d S d S )
Nz;  When reporting issues, please first upgrade to the latestz>  version of Material for MkDocs, as the problem might alreadyz=  be fixed in the latest version. This helps reduce duplicatez(  efforts and saves us maintainers time.z  Please update from z to .z9  pip install --upgrade --force-reinstall mkdocs-materialr   )
ry   r   REDr   r   r   rM   archive_stop_on_violationrX   rY   )r   haveneeds      r   rV   z%InfoPlugin._help_on_versions_and_exitU  s    dhKLLLNOOOMNNN8999el7d77777888eoJKKKel ;0 	HQKKKKK	 	r   c                    t          t          j                   t          d           t          d           t          d           t          d           t          t          j                   t          d           t          d           t          t          j                   t          d           t          d           t          t          j                   t          d	           t          d
           t          t          j                   t          d           t          d           t          d           t          d           t          t          j                   | j        j        rt          j
        d           d S d S )Nz;  When reporting issues, you must remove all customizationsz;  and check if the problem persists. If not, the problem isz;  caused by your overrides. Please understand that we can'tz4  help you debug your customizations. Please remove:z  - theme.custom_dirz	  - hooksz;  Additionally, please remove all third-party JavaScript orz4  CSS not explicitly mentioned in our documentation:z  - extra_cssz  - extra_javascriptz?  If you're using customizations from the theme's documentationz?  and you want to report a bug specific to those customizationsz?  then set the 'archive_stop_on_violation: false' option in thez  info plugin config.r   )ry   r   r   r   r   YELLOWr   rM   r   rX   rY   )r   s    r   r]   z+InfoPlugin._help_on_customizations_and_exitf  sY   dhKLLLKLLLKLLLDEEEel$%%%kdkKLLLDEEEelo$%%%dkOPPPOPPPOPPP%&&&eo ;0 	HQKKKKK	 	r   c                 (   t          t          j                   t          d           t          dt          j                     d           t          d           t          t
          j                   |D ]}t          d|            t          d           t          d           t          d           t          d           t          d           t          t
          j                   | j        j	        rt          j        d	           d S d S )
Nz(  The current working (root) directory:
z    r=   z)  is not a parent of the following paths:z;
  To assure that all project files are found please adjustz=  your config or file structure and put everything within thez   root directory of the project.z<
  Please also make sure `mkdocs build` is run in the actualr   )ry   r   r   ra   rk   r   r   r   rM   r   rX   rY   )r   outside_rootrb   s      r   rm   zInfoPlugin._help_on_not_in_cwd  s   dh9:::$RY[[$$$%%%9:::el  	! 	!D---    LMMMMNNN0111MNNN0111eo ;0 	HQKKKKK	 	r   abspathreturnc                 "   t          |d          }| j        D ]Y}t          j        ||          rBt                              d| d|            | j                            | d|             dS Zt          j	        
                    |          rdS t          j	                            |d          }t          j	                            |          r<t                              d|            | j                            d	|            dS dS )
NTreturn_pathzExcluded pattern 'z': z - Fzsitemap.xml.gzzExcluded site_dir: zsitemap.xml.gz - )rq   r   regexsearchrT   debugr   rj   ra   rb   isfiler?   exists)r   r   pattern_pathr   
sitemap_gzs        r   rz   zInfoPlugin._is_excluded  s     (tDDD. 	 	G|G\22 		DwDD7DDEEE%,,-J-JL-J-JKKKtt 7>>'"" 	5 W\\'+;<<
7>>*%% 	II5G55666!(()K\)K)KLLL4ur   )__name__
__module____qualname__r   r$   r   r   rV   r]   rm   r   boolrz   __classcell__)r   s   @r   r   r   1   s        # # # # #+ + + ^CI I I\  "  6  ,C D        r   r   c                     t           j        }| d|z  k    rt           j        }n| d|z  k    rt           j        }dD ]&}t	          |           dk     r| | dd| c S | dz  } 'd S )Ni ia  )BkBMBGBTBPBEBZBg     @@z3.1fr<   )r   GREENr   r   abs)valuefactorr   units       r   r   r     s    JE	&	 	 $(%%	%&.	 	 $+%?  u::0U000$00000 r   rb   r+   r   c                     t           j                            |           r| S |t          j                    }t           j                            t           j                            ||                     S N)ra   rb   isabsrk   normpathr?   )rb   r+   s     r   r_   r_     sP    	w}}T'4K	:7BGLLT::;;;r   abs_src_pathc                    t          | d          5 }|                                }d d d            n# 1 swxY w Y   	 t          j        |t	                                pi }n# t          j        $ r i }Y nw xY wd|v r|                    d          }t          j        	                    |           }t          ||          }t          j                            |          re||d<   t                              d|            t          |          }t          |t                     r|g|}nt          |t"                    r||g}|S )N	utf-8-sigencoding)Loaderr.   r*   z&Loading inherited configuration file: )r   readyamlloadr   	YAMLErrorr/   ra   rb   rc   r_   r   rT   r   rf   rg   rh   dict)r   r   sourceresultr|   parent_pathr   parents           r   rf   rf     s   	lk	2	2	2 d              6O,=,=>>>D">    F**Y''gool33!'DDD7>>'"" 	* 'F9IIHwHHIII((F&$'' * *6*FD)) * &)Ms   377$A$ $A87A8Fr   r   c                    |                      t          j                    dd          }|                     t          j        d                              d          }|sdS t          j                            |           s|dz   }|r|nd| S )Nr,   r   r)   ^)replacera   rk   r   rstriprb   r   )r   r   rb   s      r   rq   rq     s    ??29;;A..D<<$$++C00D s 7>>'"" cz.44JJJ.r   project_config_filec                     t          | d          5 }t          |           }|                    |           |                                 |cd d d            S # 1 swxY w Y   d S )Nr   r   )r`   )r   r	   	load_filevalidate)r   r   rM   s      r   rw   rw     s    	!K	8	8	8 D1DEEE 	                 s   ;AA!Ar;   c                     t          | d          }|                    d                              dd          d         }|                    d          r!|rt                              d|             dS dS )	NTr   r)   r   rB   r   z)The following .dotpath will be included: F)rq   r   rR   rS   rT   r   )rb   r;   
posix_pathr@   s       r   r{   r{     s~    !$d;;;JS!!((a004Ds  	LKKJDJJKKKt5r   zmkdocs.material.info)r   r   )F)-rt   r   loggingra   r   r   rP   rr   rX   r   coloramar   r   importlib.metadatar   r   ior   markdown.extensions.tocr   mkdocs.config.defaultsr	   mkdocs.pluginsr
   r   mkdocs.utilsr   zipfiler   r   rM   r   patternsr   r   r   r   r_   rf   r   rq   rw   r{   	getLoggerrT    r   r   <module>r     sK  *    				     



                  5 5 5 5 5 5 5 5       + + + + + + / / / / / / 5 5 5 5 5 5 5 5 ( ( ( ( ( ( ) ) ) ) ) ) ) )       , , , , , ,    J'   L   < <# <3 <# < < < <S    :/ /c / / / / /S     c       g.//r   