
    ZQd                     n    d Z ddlmZ ddlmZmZmZmZ ddlm	Z	m
Z
mZ d Z G d dej                  Zd	S )
zFixer for import statements.
If spam is being imported from the local directory, this import:
    from spam import eggs
Becomes:
    from .spam import eggs

And this import:
    import spam
Becomes:
    from . import spam
   )
fixer_base    )dirnamejoinexistssep)
FromImportsymstokenc              #     K   | g}|r|                                 }|j        t          j        k    r
|j        V  n|j        t
          j        k    r'd                    d |j        D                       V  n~|j        t
          j	        k    r!|
                    |j        d                    nH|j        t
          j        k    r$|                    |j        ddd                    nt          d          |dS dS )zF
    Walks over all the names imported in a dotted_as_names node.
     c                     g | ]	}|j         
S  )value).0chs     //usr/lib/python3.11/lib2to3/fixes/fix_import.py
<listcomp>z$traverse_imports.<locals>.<listcomp>   s    <<<28<<<    r   Nzunknown node type)poptyper   NAMEr   r
   dotted_namer   childrendotted_as_nameappenddotted_as_namesextendAssertionError)namespendingnodes      r   traverse_importsr$      s      gG
 6{{}}9
""*Y$***''<<dm<<<======Y$---NN4=+,,,,Y$...NN4=2.//// !4555  6 6 6 6 6r   c                   2     e Zd ZdZdZ fdZd Zd Z xZS )	FixImportTzj
    import_from< 'from' imp=any 'import' ['('] any [')'] >
    |
    import_name< 'import' imp=any >
    c                 v    t          t          |                               ||           d|j        v | _        d S )Nabsolute_import)superr&   
start_treefuture_featuresskip)selftreename	__class__s      r   r*   zFixImport.start_tree/   s6    i))$555%)==			r   c                     | j         rd S |d         }|j        t          j        k    rnt	          |d          s|j        d         }t	          |d          |                     |j                  r%d|j        z   |_        |                                 d S d S d}d}t          |          D ]}|                     |          rd}d}|r|r| 
                    |d           d S t          d|g          }|j        |_        |S )Nimpr   r   .FTz#absolute and local imports together)r,   r   r
   import_fromhasattrr   probably_a_local_importr   changedr$   warningr	   prefix)r-   r#   resultsr2   
have_localhave_absolutemod_namenews           r   	transformzFixImport.transform3   s0   9 	Fen9(((
 c7++ &l1o c7++ &++CI66 #)O	  J!M,S11 ) )//99 )!%JJ$(MM  N LL'LMMMS3%((CCJJr   c                 V   |                     d          rdS |                    dd          d         }t          | j                  }t	          ||          }t          t	          t          |          d                    sdS dt          ddd	d
fD ]}t          ||z             r dS dS )Nr3   F   r   z__init__.pyz.pyz.pycz.soz.slz.pydT)
startswithsplitr   filenamer   r   r   )r-   imp_name	base_pathexts       r   r6   z!FixImport.probably_a_local_importU   s    s## 	5>>#q))!,DM**	H--	 d79--}==>> 	53uf= 	 	Ci#o&& ttur   )	__name__
__module____qualname__BM_compatiblePATTERNr*   r?   r6   __classcell__)r0   s   @r   r&   r&   &   sc        MG> > > > >     D      r   r&   N)__doc__r   r   os.pathr   r   r   r   
fixer_utilr	   r
   r   r$   BaseFixr&   r   r   r   <module>rR      s   
 
       . . . . . . . . . . . . 0 0 0 0 0 0 0 0 0 06 6 6&= = = = =
" = = = = =r   