
    FwgD                     j    d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ ddlmZ  G d de      Zy	)
a  
Fixer for import statements, with a __future__ import line.

Based on lib2to3/fixes/fix_import.py, but extended slightly so it also
supports Cython modules.

If spam is being imported from the local directory, this import:
    from spam import eggs
becomes:
    from __future__ import absolute_import
    from .spam import eggs

and this import:
    import spam
becomes:
    from __future__ import absolute_import
    from . import spam
    )dirnamejoinexistssep)	FixImport)
FromImportsyms)traverse_imports)future_importc                       e Zd ZdZd Zd Zy)FixAbsoluteImport	   c                 $   | j                   ry|d   }|j                  t        j                  k(  rut	        |d      s|j
                  d   }t	        |d      s| j                  |j                        r1d|j                  z   |_        |j                          t        d|       yyd}d}t        |      D ]  }| j                  |      rd}d} |r|r| j                  |d	       yt        d|g      }|j                  |_        t        d|       |S )
z
        Copied from FixImport.transform(), but with this line added in
        any modules that had implicit relative imports changed:

            from __future__ import absolute_import"
        Nimpvaluer   .absolute_importFTz#absolute and local imports together)skiptyper	   import_fromhasattrchildrenprobably_a_local_importr   changedr   r
   warningr   prefix)selfnoderesultsr   
have_localhave_absolutemod_namenews           \/var/www/horilla/myenv/lib/python3.12/site-packages/libfuturize/fixes/fix_absolute_import.py	transformzFixAbsoluteImport.transform   s    99en99(((
 c7+ll1o c7+++CII6 399,	0$7 7
 J!M,S1 )//9!%J$(M	)
  LL'LMTC5)CCJ,d3J    c                    |j                  d      ry|j                  dd      d   }t        | j                        }t	        ||      }t        t	        t        |      d            sydt        ddd	d
dfD ]  }t        ||z         s y y)zq
        Like the corresponding method in the base class, but this also
        supports Cython modules.
        r   F   r   z__init__.pyz.pyz.pycz.soz.slz.pydz.pyxT)
startswithsplitr   filenamer   r   r   )r   imp_name	base_pathexts       r$   r   z)FixAbsoluteImport.probably_a_local_importI   s    
 t$>>$*1-DMM*	H-	 d79-}=>3uffE 	Ci#o&	 r&   N)__name__
__module____qualname__	run_orderr%   r    r&   r$   r   r      s    I(Tr&   r   N)__doc__os.pathr   r   r   r   lib2to3.fixes.fix_importr   lib2to3.fixer_utilr   r	   r
   libfuturize.fixer_utilr   r   r3   r&   r$   <module>r9      s*   & / . . / 5 0?	 ?r&   