
    -Ph                        d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ erddlZdd	lmZ dd
lmZmZ  G d d          ZdS )z,Utilities parsing and analyzing Python code.    )annotationsN)import_module)TYPE_CHECKING)PycodeError)Parser)_StrPath)	Signature)AnyLiteralc                      e Zd ZU ded<   ded<   ded<   ded<   d	ed
<   ded<   i Zded<   ed%d            Ze	 d&d'd            Zed(d            Z	ed)d            Z
d*d Zd+d!Zd,d"Zd-d#Zd$S ).ModuleAnalyzerzdict[tuple[str, str], str]r    dict[tuple[str, str], list[str]]	attr_docsz	list[str]finalszdict[str, list[Signature]]	overloadszdict[str, int]tagorderdict[str, tuple[str, int, int]]tagsz;dict[tuple[Literal['file', 'module'], str | _StrPath], Any]cachemodnamestrreturn"tuple[_StrPath | None, str | None]c                   	 t          |           }n&# t          $ r}t          d| z  |          |d}~ww xY wt          |dd          }t          |dd          }|rQt          |dd          r@	 |                    |           }|r|dnt          |          }||fS n# t          $ r Y nw xY w|P|rNt          |dd          r=	 |                    |           }n&# t          $ r}t          d| z  |          |d}~ww xY w|t          d| z            t          |                                          }|j	        d	v rV|
                    d
          }|                                s|                                r|}n3|
                    d          }n|j	        dvrd|}t          |          |                                sd|}t          |          |dfS )zTry to find the source code for a module.

        Returns ('filename', 'source'). One of it can be None if
        no filename or source found
        zerror importing %rN
__loader____file__
get_sourceget_filenamezerror getting filename for %rzno source found for module %r>   .pyc.pyo.pyw.py>   r"   r!   zsource is not a .py file: zsource file is not present: )r   	Exceptionr   getattrr   r   ImportErrorr   resolvesuffixwith_suffixis_file)	r   moderrloaderfilenamesourcemod_pathmod_path_pywmsgs	            V/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx/pycode/__init__.pyget_module_sourcez ModuleAnalyzer.get_module_source   se   	L((CC 	L 	L 	L2W<cBBK	LlD11&sJ== 		gflD99 		**733 ,'/'7ttXh=O=OH#V++,    76>4+P+P!..w77   !3g=s  =GHHHH%%--//?...#//77L##%% 7,*>*>*@*@ 7'#//66_O33;x;;Cc"""!! 	#===Cc"""~s:    
505.-B 
B*)B*C 
C<#C77C<<string>clstype[ModuleAnalyzer]stringsrcnamestr | os.PathLike[str]c                     | |||          S )N )r5   r7   r   r8   s       r2   
for_stringzModuleAnalyzer.for_stringP   s     s67G,,,    r-   c                Z   t          |          }d|f| j        v r| j        d|f         S 	 t          j        |          5 }|                                }d d d            n# 1 swxY w Y    | |||          }|| j        d|f<   n&# t
          $ r}t          d|z  |          |d }~ww xY w|S )Nfilezerror opening %r)r   r   tokenizeopenreadr#   r   )r5   r-   r   fr7   objr+   s          r2   for_filezModuleAnalyzer.for_fileY   s    H%%H**9VX-..	Kx(( "A" " " " " " " " " " " " " " "#fgx00C*-CIfh&'' 	K 	K 	K08;SAAsJ	K
s:   B A B  A$$B 'A$(B 
B(B##B(c                ^   d|f| j         v r(| j         d|f         }t          |t                    r||S 	 |                     |          \  }}||                     |||pd          }n||                     ||          }n# t          $ r}|| j         d|f<    d }~ww xY w|| j         d|f<   |S )Nmoduler4   )r   
isinstancer   r3   r<   rE   )r5   r   entryr-   r.   rD   r+   s          r2   
for_modulezModuleAnalyzer.for_modulei   s    g#)++Ih/0E%-- L	"44W==Hf!nnVWh6L*MM%ll8W55 	 	 	+.CIh'(	 (+	(G#$
s   AB 
BBBr.   Nonec                X    || _         t          |          | _        || _        d| _        d S )NF)r   r   r8   code	_analyzed)selfr.   r   r8   s       r2   __init__zModuleAnalyzer.__init__}   s,     7|| 	r=   c                   | j         rdS 	 t          | j                  }|                                 i | _        |j                                        D ]3\  }}|r!g |                                d| j        |<   (dg| j        |<   4|j        | _        |j	        | _	        |j
        | _
        |j        | _        |j        | _        d| _         dS # t          $ r"}d| j        d|}t#          |          |d}~ww xY w)zAnalyze the source code.N Tzparsing z	 failed: )rN   r   rM   parser   commentsitems
splitlinesr   r   r   definitionsr   	defordersr   r#   r8   r   )rO   parserscopecommentexcr1   s         r2   analyzezModuleAnalyzer.analyze   s   > 	F	,DI&&FLLNNNDN"(/"7"7"9"9 1 1w 1,Gg.@.@.B.B,GB,GDN5))-/DDN5))%1D -DK#-DN*DI",DM!DNNN 	, 	, 	,=T\==c==Cc""+	,s   B?C 
C8C33C8c                8    |                                   | j        S )z?Find class and module-level attributes and their documentation.)r]   r   rO   s    r2   find_attr_docszModuleAnalyzer.find_attr_docs   s    ~r=   c                8    |                                   | j        S )z?Find class, function and method definitions and their location.)r]   r   r_   s    r2   	find_tagszModuleAnalyzer.find_tags   s    yr=   N)r   r   r   r   )r4   )
r5   r6   r7   r   r   r   r8   r9   r   r   )r5   r6   r-   r9   r   r   r   r   )r5   r6   r   r   r   r   )r.   r   r   r   r8   r9   r   rK   )r   rK   )r   r   )r   r   )__name__
__module____qualname____annotations__r   staticmethodr3   classmethodr<   rE   rJ   rP   r]   r`   rb   r;   r=   r2   r   r      sL        ++++////)))))))) JLEKKKK/ / / \/b 
 +5	- - - - [-    [    [&	 	 	 	, , , ,4   
     r=   r   )__doc__
__future__r   r@   	importlibr   typingr   sphinx.errorsr   sphinx.pycode.parserr   sphinx.util._pathlibr   osinspectr	   r
   r   r   r;   r=   r2   <module>rr      s    2 2 " " " " " "  # # # # # #             % % % % % % ' ' ' ' ' ' ) ) ) ) ) ) $III!!!!!!########W W W W W W W W W Wr=   