o
    DDi^                     @   sD   d dl mZmZ d dlmZ d dlmZ eddG dd dZdS )	    )	dataclassreplace)Optional) get_absolute_module_from_packageT)frozenc                   @   sx   e Zd ZU dZeed< dZee ed< dZee ed< dZ	e
ed< dd	d
ZedefddZdee dd fddZdS )
ImportItemz7Representation of individual import items for codemods.module_nameNobj_namealiasr   relativereturnc                 C   sp   | j d u rt| dd d S | j dr6| j d}| jt| j  t| }t| d| t| d| d S d S )Nr    .r   )r   object__setattr__
startswithlstripr   len)selfmodrel r   Y/var/www/Datamplify/venv/lib/python3.10/site-packages/libcst/codemod/visitors/_imports.py__post_init__   s   
zImportItem.__post_init__c                 C   s   d| j  | j S )Nr   )r   r   )r   r   r   r   module   s   zImportItem.modulepackage_namec                 C   s^   | }|j r|jdu rt|d|jd}|du r|S t||jpd| j }|du r(|S t||ddS )z>Return an ImportItem with an absolute module name if possible.Nr   )r   r	   r   )r   r   )r   r	   r   r   r   )r   r   r   mr   r   r   resolve_relative"   s   zImportItem.resolve_relative)r   N)__name__
__module____qualname____doc__str__annotations__r	   r   r
   r   intr   propertyr   r   r   r   r   r   r      s   
 
	r   N)dataclassesr   r   typingr   libcst.helpersr   r   r   r   r   r   <module>   s
   