
    zi                        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	m
Z
 ddlmZ ddlmZ e	rdd	lmZ  G d
 d          ZdS )z,Utilities parsing and analyzing Python code.    )annotationsN)import_module)path)TYPE_CHECKINGAny)PycodeError)Parser)	Signaturec                      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[str, str], Any]cachemodnamestrreturntuple[str | None, str | None]c                   	 t          |           }n&# t          $ r}t          d| z  |          |d}~ww xY wt          |dd          }t          |dd          }|r>t          |dd          r-	 |                    |           }|r||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        t          j	        |                    }|
                                                    d	          r;|dd
         }t          j        |          st          j        |dz             r|dz  }n9|
                                                    d          st          d|z            t          j        |          st          d|z            |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)z.pyoz.pycw)z.pyz.pywzsource is not a .py file: %rzsource file is not present: %r)r   	Exceptionr   getattrr   ImportErrorr   r   normpathabspathlowerendswithisfile)r   moderrloaderfilenamesources         a/var/www/tmov.alphamb/tmov_inventario/venv/lib/python3.11/site-packages/sphinx/pycode/__init__.pyget_module_sourcez ModuleAnalyzer.get_module_source   sM   	L((CC 	L 	L 	L2W<cBBK	LlD113
D11 	gflD99 	**733 ,#V++,    76>4+P+P[!..w77 [ [ [!"AG"KSQQWZZ[=GHHH=h!7!788>>$$%566 	I}H;x((  T[C-H-H  C!!**?;; 	I<xGHHH{8$$ 	K>IJJJ~s:    
505.B
 

BB0C 
C)C$$C)<string>stringsrcnamec                     | |||          S )N )clsr0   r   r1   s       r-   
for_stringzModuleAnalyzer.for_stringG   s     s67G,,,    r+   c                <   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   tokenizeopenreadr    r   )r4   r+   r   fr0   objr)   s          r-   for_filezModuleAnalyzer.for_fileL   s   H**9VX-..	Kx(( "A" " " " " " " " " " " " " " "#fgx00C*-CIfh&'' 	K 	K 	K08;SAAsJ	K
s:   A6 AA6 AA6 AA6 6
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moduler/   )r   
isinstancer   r.   r5   r>   )r4   r   entryr+   r,   r=   r)   s          r-   
for_modulezModuleAnalyzer.for_moduleY   s    g#)++Ih/0E%-- L	"44W==Hf!nnVWh6L*MM%ll8W55 	 	 	+.CIh'(	 (+	(G#$
s   AB 
BBBr,   Nonec                >    || _         || _        || _        d| _        d S )NF)r   r1   code	_analyzed)selfr,   r   r1   s       r-   __init__zModuleAnalyzer.__init__m   s$     	r6   c                   | j         rdS 	 t          | j                  }|                                 i | _        |j                                        D ]3\  }}|r!|                                dgz   | 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: )rG   r	   rF   parser   commentsitems
splitlinesr   r   r   definitionsr   	defordersr   r    r1   r   )rH   parserscopecommentexcmsgs         r-   analyzezModuleAnalyzer.analyzev   s   > 	F	,DI&&FLLNNNDN$*O$9$9$;$; 1 1  1,3,>,>,@,@B4,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.)rW   r   rH   s    r-   find_attr_docszModuleAnalyzer.find_attr_docs   s    ~r6   c                8    |                                   | j        S )z?Find class, function and method definitions and their location.)rW   r   rY   s    r-   	find_tagszModuleAnalyzer.find_tags   s    yr6   N)r   r   r   r   )r/   )r0   r   r   r   r1   r   r   r   )r+   r   r   r   r   r   )r   r   r   r   )r,   r   r   r   r1   r   r   rD   )r   rD   )r   r   )r   r   )__name__
__module____qualname____annotations__r   staticmethodr.   classmethodr5   r>   rC   rI   rW   rZ   r\   r3   r6   r-   r   r      sE        ++++////)))))))) )+E****( ( ( \(T - - - - [- 
 
 
 [
    [&   , , , ,4   
     r6   r   )__doc__
__future__r   r9   	importlibr   osr   typingr   r   sphinx.errorsr   sphinx.pycode.parserr	   inspectr
   r   r3   r6   r-   <module>rk      s    2 2 " " " " " "  # # # # # #       % % % % % % % % % % % % % % ' ' ' ' ' ' "!!!!!!G G G G G G G G G Gr6   