
    yIf                          U d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZ d	Ze
ed
f         ed<    G d de          Zeddfde	dedee         dedee         f
dZdS )zVFast stream based import identification.
Eventually this will likely replace parse.py
    )partial)Path)Iterator
NamedTupleOptionalTextIOTuple)normalize_line	skip_linestrip_syntax   )parse)DEFAULT_CONFIGConfig)zdef zcdef zcpdef zclass @z	async def.STATEMENT_DECLARATIONSc                       e Zd ZU eed<   eed<   eed<   dZee         ed<   dZ	ee         ed<   dZ
eed<   dZee         ed	<   d
efdZd
efdZdS )Importline_numberindentedmoduleN	attributealiasFcimport	file_pathreturnc                     | j         rdnd}| j        rd| j         d| d| j         }n| d| j         }| j        r|d| j         z  }|S )Nr   importfrom  z as )r   r   r   r   )self
import_cmdimport_strings      B/var/www/piapp/venv/lib/python3.11/site-packages/isort/identify.py	statementzImport.statement   sy    "&,<YYH
> 	:ODKOO*OOt~OOMM)99DK99M: 	10DJ000M    c                 h    | j         pd d| j         d| j        rdnd |                                  S )N :r    z	indented )r   r   r   r%   )r!   s    r$   __str__zImport.__str__#   s[    ~# H Hd&6 H H"m3{{H59^^5E5EH H	
r&   )__name__
__module____qualname__int__annotations__boolstrr   r   r   r   r   r   r%   r*    r&   r$   r   r      s         NNNKKK#Ix}###E8C=GT $Ix~$$$3    
 
 
 
 
 
 
r&   r   NFinput_streamconfigr   top_onlyr   c           
   #     K   d}t          |           }|D ]Z\  }}t          ||||j                  \  }}|r|s|                    t                    r dS |rE|                                                    d          d         }	|	                    d          s|	                    d          r|	dk    ra|	r|	dk    rY	 t          |          \  }}
n# t          $ r Y n9w xY w|
                                                    d          d         }	|	S|	dk    Y|		                    d          rf	 t          |          \  }}
n# t          $ r Y nFw xY w|
                                                    d          d         }	|		                    d          f|                    dd          ^}}d	 |                    d
          D             }|r|d          d|d          |d<   |D ]}t          |          \  }}|                    d          rd}n|                    d          rd}nFt          |          \  }}|                    dd                              dd                              dd          }d|v p|                    d          }t          t          |dz   |                    d          ||          }d|                    dd          d         v r|                    d          d                                         	                    d          s~	 t          |          \  }}
n# t          $ r Y n^w xY wt          |
          \  }}|d|z   z  }|                    d          d                                         	                    d          ~n|                                	                    d          r	 t          |          \  }}
n# t          $ r Y nw xY wt          |
          \  }}d|                    d          d         v rd|                    d          d         vr|d|z   z  }|                    d          d                                         	                    d          s~	 t          |          \  }}
n# t          $ r Y n^w xY wt          |
          \  }}|d|z   z  }|                    d          d                                         	                    d          ~n|                                	                    d          s'|                                                    d          r	|d|z   z  }n?|                                                    d          dz   |                                z   }|                                	                    d          |dk    r|                    dd                              dd                              dd          }|                    |rdnd          }|d                             d          }|rdnd                    |d         dz   d                    |dd                   z   g|dd         z             }d t%          |                                          D             }|dd         }d}d|v ri|                    d          dz   t)          |          k     r?d|v r:d}|                    d          }|dk    r||dz
           }|d         }|dz   |z   }||dz            }|                    |           |                    |           |                    d           ||dd<   ||k    r|j        r |||          V  n ||||           V  n||dz
           }||dz            }|                    |           |                    d           |                    |           ||k    r|j        r ||          V  n |||           V  d|v :|rB|dk    r*|                    d          }|D ]} |||          V  u|D ]} ||          V  \dS )!z9Parses a python file taking out and categorizing imports.r(   )in_quoteindexsection_comments#r   raiseyield\r   c                 6    g | ]}|                                 S r2   )strip).0lines     r$   
<listcomp>zimports.<locals>.<listcomp>R   s     ???tdjjll???r&   ;)zimport zcimport straightr   fromzimport(zimport (r    
z	 cimport r   )r    	)r   r   ())z importz cimportz import Nc                 b    g | ],}|                     d d                               dd          -S )z{|z{ z|}z })replace)r@   items     r$   rB   zimports.<locals>.<listcomp>   sF        T4((00t<<  r&   as.)r   )	enumerater   r9   
startswithr   r?   splitnextStopIterationendswithr
   parse_commentsrL   r   r   rstriplstripjoinr   r8   lenremoveremove_redundant_aliasespop)r3   r4   r   r5   r7   indexed_inputr8   raw_lineskipping_linestripped_line	next_linerA   end_of_line_comment
statementsr%   	_raw_linetype_of_importr#   _normalized_import_stringcimportsidentified_importpartsfrom_importjust_importsdirect_importstop_level_moduler   as_indexr   r   s                                  r$   importsrq   *   s	      Hl++M( Z8 Z8x$-xuvG^%
 %
 %
!  	H 	)<)<=S)T)T 	EE 	 ((..s33A6##G,, 	0H0H0Q0Q 	''' D=G+C+C+/+>+>(yy(    %.OO$5$5$;$;C$@$@$CM ( D=G+C+C  ((.. @'+M':':$E99$   E !* 1 1 7 7 < <Q ?  ((.. @ %-^^C%;%;""??tzz#???
 	J *2II1DQ1GIIJrN# x	8 x	8I,Y77OD)677 !+)) !'-d33M1%%i<<DDT3OOWWX\^abb % 77 B+66yAA  !(	##K00 #! ! ! djja((+++**S//!,2244==cBB 1+/+>+>(yy(    -Y77GD!!TD[0M **S//!,2244==cBB 1 jjll++D11 +/+>+>(yy(    -Y77GD! djjooa000S

3PQ@R5R5R%4"&**S//!"4":":"<"<"E"Ec"J"J 9&373F3F 0yy#0 & & & %&&4Y&?&?GD!)TD[8M #'**S//!"4":":"<"<"E"Ec"J"J 9 )..00993  !ZZ\\445LMM *TD[8MM !. 4 4 6 6 = =d C Cc IDKKMM Y *3 jjll++D11 : ''!)))Z@@WT3''WT3'' 
 &++8,SKKTT#AhnnS1108!Hj N N ^c)BGGKO,D,DDEabb	Q! ! (77==??  L
 *!""-N!|##););D)A)AA)E\IZIZ(Z(Zl** $I+11$77H%//$0A$>	+7?(!1C!7)!C ,X\ :&--i888&--e444&--d333+9QRR($--&2Q-"3"34Di"P"PPPPP"3"34DiW\"]"]"]]]]] ".hl!; ,X\ :$++E222$++D111$++F333!U??v/N?"3"3F";";;;;;"3"3F%"H"H"HHHH5 l**8  8!V++)--a00F%1 C C	//	BBBBBBC #/ 8 8//777777qx	8EZ8 Z8sZ   C
C! C!/E
EE$L77
MMO
O-,O-R
R%$R%)__doc__	functoolsr   pathlibr   typingr   r   r   r   r	   isort.parser
   r   r   commentsr   rV   settingsr   r   r   r1   r/   r   r0   rq   r2   r&   r$   <module>ry      s`                 @ @ @ @ @ @ @ @ @ @ @ @ @ @ ? ? ? ? ? ? ? ? ? ? - - - - - - , , , , , , , ,*a c3h a a a
 
 
 
 
Z 
 
 
8 $ $	d8 d8d8d8 ~d8 	d8
 fd8 d8 d8 d8 d8 d8r&   