
    2yi\                       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Zd dlZd dl	m
Z
 d dlmZmZ d dlmZmZmZmZmZmZmZ d dlmZ d dlZd dlZd dlZd dlmZ erd dlZd dl m!Z! d d	l"m#Z#  ejH                  e%      Z& G d
 dejN                        Z( G d d      Z) G d d      Z*ejV                  jX                  j[                  ddg      Z.ddZ/ddZ0ddZ1ddZ2ddZ3ddZ4y)    )annotationsN)cached_property)PurePathPurePosixPath)TYPE_CHECKINGCallableIterableIteratorMappingSequenceoverload)quote)utils)MkDocsConfig)Pagec                  N    e Zd ZdZ	 dZ	 dZ	 dZ	 dZ	 d Zd Z	d Z
d	 Zd
 Zd Zy)InclusionLevelr      c                     yNT selfs    X/var/www/html/content_weaver/venv/lib/python3.12/site-packages/mkdocs/structure/files.pyallzInclusionLevel.all+   s        c                H    | j                   | j                  j                   kD  S NvalueDRAFTr   s    r   is_includedzInclusionLevel.is_included.   s    zzDJJ,,,,r   c                H    | j                   | j                  j                   k  S r!   r"   r   s    r   is_excludedzInclusionLevel.is_excluded1       zzTZZ----r   c                H    | j                   | j                  j                   k\  S r!   r"   r   s    r   is_in_servezInclusionLevel.is_in_serve4   r(   r   c                H    | j                   | j                  j                   kD  S r!   r#   
NOT_IN_NAVr   s    r   	is_in_navzInclusionLevel.is_in_nav7   s    zzDOO1111r   c                H    | j                   | j                  j                   k  S r!   r,   r   s    r   is_not_in_navzInclusionLevel.is_not_in_nav:   s    zzT__2222r   N)__name__
__module____qualname__EXCLUDEDr$   r-   	UNDEFINEDINCLUDEDr   r%   r'   r*   r.   r0   r   r   r   r   r      sH    H9EfJIIuHp-..23r   r   c                  $   e Zd ZdZddZddZddZddZedd       Z	edd       Z
ddZdd	Zdd
Z	 dej                  d	 	 	 	 	 ddZej                  d	 	 	 d dZd!dZd!dZd!dZd!dZd"dZed#d       Zej0                  d$d       Zy)%Filesz<A collection of [File][mkdocs.structure.files.File] objects.c                N    |D ci c]  }|j                   | c}| _        y c c}w r!   )src_uri	_src_uris)r   filesfs      r   __init__zFiles.__init__A   s    0561!))Q,66s   "c                H    t        | j                  j                               S )zIterate over the files within.)iterr;   valuesr   s    r   __iter__zFiles.__iter__D   s    DNN))+,,r   c                ,    t        | j                        S )zThe number of files within.)lenr;   r   s    r   __len__zFiles.__len__H   s    4>>""r   c                L    t        |      j                         | j                  v S )z?Soft-deprecated, prefer `get_file_from_path(path) is not None`.)r   as_posixr;   r   paths     r   __contains__zFiles.__contains__L   s    ~&&(DNN::r   c                B    | D ci c]  }|j                   | c}S c c}w )z#Soft-deprecated, prefer `src_uris`.)src_pathr   files     r   	src_pathszFiles.src_pathsP   s!     155t#555s   c                    | j                   S )z
        A mapping containing every file, with the keys being their
        [`src_uri`][mkdocs.structure.files.File.src_uri].
        )r;   r   s    r   src_uriszFiles.src_urisU   s     ~~r   c                f    | j                   j                  t        |      j                               S )z7Return a File instance with File.src_uri equal to path.)r;   getr   rG   rH   s     r   get_file_from_pathzFiles.get_file_from_path]   s$    ~~!!(4."9"9";<<r   c                    |j                   | j                  v r1t        j                  dt               | j                  |j                   = || j                  |j                   <   y)z!Add file to the Files collection.z;To replace an existing file, call `remove` before `append`.N)r:   r;   warningswarnDeprecationWarningrM   s     r   appendzFiles.appenda   sH    <<4>>)MMMOa t||,'+t||$r   c                ~    	 | j                   |j                  = y# t        $ r t        |j                  d      w xY w)z"Remove file from Files collection.z not in collectionN)r;   r:   KeyError
ValueErrorrM   s     r   removezFiles.removej   sA    	Dt||, 	D//ABCC	Ds    "<	inclusionc               |    | D ]7  }|j                         r ||j                        s'|j                  |       9 y)z-Copy static files from source to destination.N)is_documentation_pager_   	copy_file)r   dirtyr_   rN   s       r   copy_static_fileszFiles.copy_static_filesq   s6      	&D--/Idnn4Mu%	&r   c               t    | D cg c](  }|j                         s ||j                        s'|* c}S c c}w )z2Return iterable of all Markdown page file objects.)ra   r_   )r   r_   rN   s      r   documentation_pageszFiles.documentation_pages|   s1     "&d)C)C)E)TXTbTbJcddds   555c                N    | D cg c]  }|j                         s| c}S c c}w )z0Return iterable of all static page file objects.)is_static_pagerM   s     r   static_pageszFiles.static_pages   s!    !%?)<)<)>???   ""c                N    | D cg c]  }|j                         s| c}S c c}w )zPReturn iterable of all file objects which are not documentation or static pages.)is_media_filerM   s     r   media_fileszFiles.media_files   !    !%>););)=>>>rj   c                N    | D cg c]  }|j                         s| c}S c c}w )z/Return iterable of all javascript file objects.)is_javascriptrM   s     r   javascript_fileszFiles.javascript_files   rn   rj   c                N    | D cg c]  }|j                         s| c}S c c}w )z(Return iterable of all CSS file objects.)is_cssrM   s     r   	css_fileszFiles.css_files   s    !%7777rj   c           
     x   fd}|j                  |      D ]  }| j                  |      j                  j                  D ]r  }t        j
                  j                  t        j
                  j                  ||            sA| j                  t        ||j                  j                                  y)zCRetrieve static files from Jinja environment and add to collection.c                    g d}|j                  d       |j                  d t        j                  D               |j                  j                  j
                         |D ](  }t        j                  | j                         |      s( y y)N).*z*/.*z*.pyz*.pycz*.htmlz*readme*zmkdocs_theme.ymlz	locales/*c              3  &   K   | ]	  }d |   yw)*Nr   ).0xs     r   	<genexpr>z=Files.add_files_from_theme.<locals>.filter.<locals>.<genexpr>   s     GasGGs   FT)rY   extendr   markdown_extensionsthemestatic_templatesfnmatchlower)namepatternspatternconfigs      r   filterz*Files.add_files_from_theme.<locals>.filter   sm    `HOOK(OOGU-F-FGGOOFLL99:# !??4::<9 ! r   )filter_funcN)list_templatesrT   r   dirsosrI   isfilejoinrY   Filesite_diruse_directory_urls)r   envr   r   rI   dirs     `   r   add_files_from_themezFiles.add_files_from_theme   s    
	 &&6&: 	D&&t,4!<<,, Cww~~bggll3&=>DsFOOVE^E^$_`		r   c                :    t        j                  dt               | S NzDo not access Files._files.)rV   rW   rX   r   s    r   _fileszFiles._files   s    35GHr   c                    t        j                  dt               |D ci c]  }|j                  | c}| _        y c c}w r   )rV   rW   rX   r:   r;   )r   r#   r=   s      r   r   zFiles._files   s/    35GH0561!))Q,66s   <N)r<   Iterable[File]returnNone)r   zIterator[File])r   int)rI   strr   bool)r   zdict[str, File])r   zMapping[str, File])rI   r   r   zFile | None)rN   r   r   r   F)rc   r   r_    Callable[[InclusionLevel], bool]r   r   )r_   r   r   Sequence[File])r   r   )r   zjinja2.Environmentr   r   r   r   )r   r   )r#   r   )r1   r2   r3   __doc__r>   rB   rE   rJ   propertyrO   rQ   rT   rY   r]   r   r%   rd   rf   ri   rm   rq   rt   r   r   setterr   r   r   r8   r8   >   s    F7-#; 6 6  =,D 	& 7E6P6P		&	& 4		&
 
	& @N?Y?Ye<e	e@??80   ]]7 7r   r8   c                  l   e Zd ZU dZded<   	 ded<   	 ded<   	 ded<   	 ej                  Zd	ed
<   	 dZded<   	 dZ	ded<   	 e
d/d       Zej                  d0d       Ze
d/d       Zej                  d0d       ZdZded<   eeej                  d	 	 	 	 	 	 	 	 	 d1d              Zeeej                  d	 	 	 	 	 	 	 	 	 d2d              Zeddej                  d	 	 	 	 	 	 	 	 	 	 	 d3d       Zdej                  d	 	 	 	 	 	 	 	 	 	 	 	 	 d4dZd Zej*                  d5d       Zd/dZ ee      Z	 d6d7dZ ee      Z	 d6d7d Z ee      Z	 ed5d!       Zed/d"       Zd8d#Z e
d9d$       Z!e!j                  d:d%       Z!e
d/d&       Z"e"j                  d0d'       Z"d;d<d(Z#d=d)Z$d=d*Z%d=d+Z&d=d,Z'd=d-Z(d=d.Z)y)>r   aj  
    A MkDocs File object.

    It represents how the contents of one file should be populated in the destination site.

    A file always has its `abs_dest_path` (obtained by joining `dest_dir` and `dest_path`),
    where the `dest_dir` is understood to be the *site* directory.

    `content_bytes`/`content_string` (new in MkDocs 1.6) can always be used to obtain the file's
    content. But it may be backed by one of the two sources:

    *   A physical source file at `abs_src_path` (by default obtained by joining `src_dir` and
        `src_uri`). `src_dir` is understood to be the *docs* directory.

        Then `content_bytes`/`content_string` will read the file at `abs_src_path`.

        `src_dir` *should* be populated for real files and should be `None` for generated files.

    *   Since MkDocs 1.6 a file may alternatively be stored in memory - `content_string`/`content_bytes`.

        Then `src_dir` and `abs_src_path` will remain `None`. `content_bytes`/`content_string` need
        to be written to, or populated through the `content` argument in the constructor.

        But `src_uri` is still populated for such files as well! The virtual file pretends as if it
        originated from that path in the `docs` directory, and other values are derived.

    For static files the file is just copied to the destination, and `dest_uri` equals `src_uri`.

    For Markdown files (determined by the file extension in `src_uri`) the destination content
    will be the rendered content, and `dest_uri` will have the `.html` extension and some
    additional transformations to the path, based on `use_directory_urls`.
    r   r:   r   r   
str | Nonesrc_dirdest_dirr   r_   Ngenerated_bystr | bytes | None_contentc                T    t         j                  j                  | j                        S )z^Same as `src_uri` (and synchronized with it) but will use backslashes on Windows. Discouraged.)r   rI   normpathr:   r   s    r   rL   zFile.src_path   s     ww--r   c                @    t        |      j                         | _        y r!   )r   rG   r:   r   r#   s     r   rL   zFile.src_path   s    //1r   c                T    t         j                  j                  | j                        S )z_Same as `dest_uri` (and synchronized with it) but will use backslashes on Windows. Discouraged.)r   rI   r   dest_urir   s    r   	dest_pathzFile.dest_path  s     ww..r   c                @    t        |      j                         | _        y r!   )r   rG   r   r   s     r   r   zFile.dest_path  s     002r   zPage | Nonepager^   c                    y)z
        Create a virtual file backed by in-memory content.

        It will pretend to be a file in the docs dir at `src_uri`.
        Nr   )clsr   r:   contentr_   s        r   	generatedzFile.generated      r   c                    y)z
        Create a virtual file backed by a physical temporary file at `abs_src_path`.

        It will pretend to be a file in the docs dir at `src_uri`.
        Nr   )r   r   r:   abs_src_pathr_   s        r   r   zFile.generated  r   r   )r   r   r_   c                   |du |du k(  rt        d       | |d|j                  |j                  |      }|j                  j                  xs d|_        ||_        ||_        |S )z
        Create a virtual file, backed either by in-memory `content` or by a file at `abs_src_path`.

        It will pretend to be a file in the docs dir at `src_uri`.
        Nz9File must have exactly one of 'content' or 'abs_src_path')r   r   r   r_   z	<unknown>)	TypeErrorr   r   plugins_current_pluginr   r   r   )r   r   r:   r   r   r_   r=   s          r   r   zFile.generated-  so     tO!56WXX__%88
  77F;%
r   )r   r_   c               \    || _         || _        || _        || _        ||| _        || _        y r!   )rL   r   r   r   r   r_   )r   rI   r   r   r   r   r_   s          r   r>   zFile.__init__J  s5      "4$DM"r   c                    t        |       j                   d| j                  d| j                  d| j                  d| j
                  d| j                  d| j                   dS )N(z
, src_dir=z, dest_dir=z, use_directory_urls=z, dest_uri=z, inclusion=))typer1   r:   r   r   r   r   r_   r   s    r   __repr__zFile.__repr__\  sn    Dz""#1T\\$4Jt||>N O((=d>U>U=X Y(T^^4DAG	
r   c                6    | j                   | j                  S dS )z
        A path relative to the source repository to use for the "edit" button.

        Defaults to `src_uri` and can be overwritten.
        For generated files this should be set to `None`.
        N)r   r:   r   s    r   edit_urizFile.edit_uric  s      $008t||BdBr   c                    t        j                  | j                        }t        j                  |      \  }}|dk(  rdS |S )Soft-deprecated, do not use.READMEindex)	posixpathbasenamer:   splitext)r   filenamestemexts       r   	_get_stemzFile._get_stemm  s<    %%dll3&&x0	c(*w44r   c                D   | j                         rt        j                  | j                        \  }}|| j                  }|r| j
                  dk(  r#t        j                  || j
                  dz         S t        j                  || j
                  d      S | j                  S )r   r   .html
index.html)ra   r   splitr:   r   r   r   )r   r   parentr   s       r   _get_dest_pathzFile._get_dest_pathv  s    %%'(t||<FH!)%)%<%<"%g)= !~~fdii'.ABB !~~fdiiFF||r   c                    | j                   }t        j                  |      \  }}|| j                  }|r|dk(  r	|xs ddz   }t	        |      S )r   r   ./)r   r   r   r   urlquote)r   r   urldirnamer   s        r   _get_urlzFile._get_url  sR    mm%OOC0%!%!8!8(l":>cS(C}r   c                    | j                   yt        j                  j                  t        j                  j	                  | j                   | j
                              S )z
        The absolute concrete path of the source file. Will use backslashes on Windows.

        Note: do not use this path to read the file, prefer `content_bytes`/`content_string`.
        N)r   r   rI   r   r   r:   r   s    r   r   zFile.abs_src_path  s=     <<wwT\\4<< HIIr   c                    t         j                  j                  t         j                  j                  | j                  | j
                              S )zTThe absolute concrete path of the destination file. Will use backslashes on Windows.)r   rI   r   r   r   r   r   s    r   abs_dest_pathzFile.abs_dest_path  s0     wwT]]DMM JKKr   c                    t        j                  | j                  t        |t              r|j                        S |      S )z+Return url for file relative to other file.)r   get_relative_urlr   
isinstancer   )r   others     r   url_relative_tozFile.url_relative_to  s/    %%dhhZt=T		``Z_``r   c                    | j                   }|>| j                  J t        | j                  d      5 }|j                         cddd       S t	        |t
              s|j                         }|S # 1 sw Y   +xY w)z
        Get the content of this file as a bytestring.

        May raise if backed by a real file (`abs_src_path`) if it cannot be read.

        If used as a setter, it defines the content of the file, and `abs_src_path` becomes unset.
        Nrb)r   r   openreadr   bytesencoder   r   r=   s      r   content_byteszFile.content_bytes  st     --?$$000d''.  !vvx   '5)nn&G	   s   A//A8c                D    t        |t              sJ || _        d | _        y r!   )r   r   r   r   r   s     r   r   zFile.content_bytes  s!    %''' r   c                    | j                   }|@| j                  J t        | j                  dd      5 }|j                         cddd       S t	        |t
              s|j                  dd      }|S # 1 sw Y   .xY w)a  
        Get the content of this file as a string. Assumes UTF-8 encoding, may raise.

        May also raise if backed by a real file (`abs_src_path`) if it cannot be read.

        If used as a setter, it defines the content of the file, and `abs_src_path` becomes unset.
        Nz	utf-8-sigstrict)encodingerrors)r   )r   r   r   r   r   r   decoder   s      r   content_stringzFile.content_string  s}     --?$$000d''+hO  STvvx   '3'nn[nBG	   s   A44A=c                D    t        |t              sJ || _        d | _        y r!   )r   r   r   r   r   s     r   r   zFile.content_string  s!    %%%% r   c                   |r4| j                         s$t        j                  d| j                   d       yt        j                  d| j                   d       | j                  }t        j                  t
        j                  j                  |      d       | j                  }|0| j                  J 	 t        j                  | j                  |       yt        |t               r)t#        |dd	      5 }|j%                  |       ddd       yt#        |d
      5 }|j%                  |       ddd       y# t        j                  $ r Y yw xY w# 1 sw Y   yxY w# 1 sw Y   yxY w)zCCopy source file to destination, ensuring parent directories exist.zSkip copying unmodified file: ''NzCopying media file: 'T)exist_okwzutf-8)r   wb)is_modifiedlogdebugr:   r   r   makedirsrI   r   r   r   r   rb   shutilSameFileErrorr   r   r   write)r   rc   output_pathr   output_files        r   rb   zFile.copy_file  s8   ))+II7~QGH		)$,,q9:((
BGGOOK04@--?$$000 1 1;? %k39 +[!!'*+ + k4( +K!!'*+ + '' + ++ +s*   7 D8 6EE8EEEE&c                2   | j                   y| j                  J t        j                  j	                  | j
                        rSt        j                  j                  | j
                        t        j                  j                  | j                        k  S yr   )r   r   r   rI   r   r   getmtimer   s    r   r   zFile.is_modified  so    ==$  ,,,77>>$,,-77##D$6$67"'':J:J4K\K\:]]]r   c                @    t        j                  | j                        S )z'Return True if file is a Markdown page.)r   is_markdown_filer:   r   s    r   ra   zFile.is_documentation_page  s    %%dll33r   c                8    | j                   j                  d      S )z7Return True if file is a static page (HTML, XML, JSON).)r   z.htmz.xmlz.jsonr:   endswithr   s    r   rh   zFile.is_static_page  s    ||$$%GHHr   c                H    | j                         xs | j                          S )z:Return True if file is not a documentation or static page.)ra   rh   r   s    r   rl   zFile.is_media_file  s"    ..0ID4G4G4IJJr   c                8    | j                   j                  d      S )z)Return True if file is a JavaScript file.)z.jsz.javascriptz.mjsr
  r   s    r   rp   zFile.is_javascript  s    ||$$%CDDr   c                8    | j                   j                  d      S )z"Return True if file is a CSS file.z.cssr
  r   s    r   rs   zFile.is_css  s    ||$$V,,r   )r   r   )r#   r   )
r   r   r:   r   r   zstr | bytesr_   r   r   r   )
r   r   r:   r   r   r   r_   r   r   r   )r   r   r:   r   r   r   r   r   r_   r   r   r   )rI   r   r   r   r   r   r   r   r   r   r_   r   r   r   )r   r   r!   )r   zbool | Noner   r   )r   z
File | strr   r   )r   r   )r#   r   r   )rc   r   r   r   )r   r   )*r1   r2   r3   r   __annotations__r   r5   r_   r   r   r   rL   r   r   r   r   classmethodr   r>   r   r   weak_propertyr   r   r   r   r   r   r   r   r   r   r   r   r   rb   r   ra   rh   rl   rp   rs   r   r   r   r   r      sB   B Lc H Mj . 8 8I~8@#L*#t $(H '!
 . . __2 2 / / 3 3 D+ %3$<$< 
  " 
    %3$<$< 
  " 
    '+#'$2$<$< 
 $ ! " 
 F  $$2$<$<## # 	#
 !# # "# 
#$
 C C5 9%D< ~.Hm (
#C\J J L La  " ! !
  " ! !
+,4IKE-r   r   rw   z/templates/c                .   |j                  d      }|r	t        |z   nt        }|j                  d      }|j                  d      }| D ]  }|j                  t        j                  k(  s!|j                  |j                        rt        j                  |_        R|r1|j                  |j                        rt        j                  |_        |r1|j                  |j                        rt        j                  |_        t        j                  |_         y)zKRe-calculate which files are excluded, based on the patterns in the config.exclude_docs
draft_docs
not_in_navN)rS   _default_excluder_   r   r5   
match_filer:   r4   r$   r-   r6   )r<   r   excludedraftsnav_excluderN   s         r   set_exclusionsr    s    7=zz.7QG,3(9IG6<jj6NF;A::l;SK 	9>>^555!!$,,/!/!8!8F--dll;!/!5!5!7!7!E!/!:!:!/!8!8	9r   c           	     z   g }g }t        j                  | d   d      D ]  \  }}}t         j                  j                  || d         }|j	                          |j	                  t
               i }|D ]}  }t        t         j                  j                  ||      | d   | d   | d         }	|j                  |	j                  |	      }
|
|	ur|j                  |
|	f       |j                  |	       |	}
  t        ||        |D ]  \  }}|j                  j                         r]|j                  j                         r0t        j                  d|j                    d|j                    d	       	 |j#                  |       }	 |j#                  |        t'        |      S # t$        $ r Y w xY w# t$        $ r Y w xY w)
z2Walk the `docs_dir` and return a Files collection.docs_dirT)followlinkskeyr   r   zExcluding 'z+' from the site because it conflicts with 'z'.)r   walkrI   relpathsort_file_sort_keyr   r   
setdefaultr   rY   r  r_   r%   r   warningr:   r]   r\   r8   )r   r<   conflicting_files
source_dirdirnames	filenamesrelative_dirfiles_by_destr   rN   	prev_fileabs                r   	get_filesr0  "  s   E13+-776*3ESW+X '
Hiwwz6*3EF>*)+! 	H\84z"z"+,	D &00EI$!(()T):;LLI	( 5&!! 1;;""${{&&(!!)),WXYXaXaWbbdeQQ  <  
  s$   .FF.	F+*F+.	F:9F:c               v    t        | j                        j                  }|sy|dd | j                  dk7  |d   fS )z
    Replicates the sort order how `get_files` produces it - index first, directories last.

    To sort a list of `File`, pass as the `key` argument to `sort`.
    r   Nr   r   )r   r:   partsr   )r=   r2  s     r   file_sort_keyr3  O  s>     !))$**E#2J')5955r   c                N    t         j                  j                  |       d   dv| fS )zaAlways sort `index` or `README` as first filename in list. This works only on basenames of files.r   )r   r   )r   rI   r   )r=   s    r   r$  r$  [  s'    GGQ"*==qAAr   c                $    t        | t              S )r   r  )sortedr$  )r*  s    r   _sort_filesr7  `  s    )00r   c                    t        j                  dt               |D ]R  }|j                  d      r|s|j	                  d      r|n| }t        j
                  ||j                  d            sR y y)NzD_filter_paths is not used since MkDocs 1.5 and will be removed soon.r   TF)rV   rW   rX   r  
startswithr   strip)r   rI   is_dirr  itemmatchs         r   _filter_pathsr>  e  sh    MMNPb  ==f ,(??5$**S/2 r   )r<   r   r   r   r   r   )r   r   r   r8   )r=   r   )r=   r   )r*  Iterable[str]r   z	list[str])
r   r   rI   r   r;  r   r  r?  r   r   )5
__future__r   enumr   loggingr   r   r   rV   	functoolsr   pathlibr   r   typingr   r   r	   r
   r   r   r   urllib.parser   r   pathspecpathspec.gitignorepathspec.utilmkdocsr   jinja2.environmentjinja2mkdocs.config.defaultsr   mkdocs.structure.pagesr   	getLoggerr1   r   Enumr   r8   r   	gitignoreGitIgnoreSpec
from_linesr  r  r0  r3  r$  r7  r>  r   r   r   <module>rT     s    "    	    % + [ [ [ *    3+ g!3TYY 3>t7 t7nT- T-n
 %%33>>m?TU 9&*Z	6B
1
r   