
    VeH                         d dl Z d dlZd dlZd dlmZ d dlmZ ddl d dlm	Z	  ee
      Zd ZddZdd	Zd
edede	fdZd Zy)    N)	getLogger)iter_entry_points   )*)NoReturnc                     i } t        d      D ]n  }|j                         }t        t        t	        j
                  |      j                              dk7  rt        d|j                   d      || |j                  <   p | S )aL  
    Plugins registered by entry points in the current Python env

    :return dict[dict[function(peppy.Project)]]: dict which keys
        are names of all possible hooks and values are dicts mapping
        registered functions names to their values
    :raise EidoFilterError: if any of the filters has an invalid signature.
    zpep.filters   z!Invalid filter plugin signature: zD. Filter functions must take 2 arguments: peppy.Project and **kwargs)	r   loadlenlistinspect	signature
parametersEidoFilterErrorname)pluginsep
plugin_funs      /lib/python3.12/site-packages/eido/conversion.pypep_conversion_pluginsr      s     G. &WWY
tG%%j1<<=>!C!3BGG9 =U V  && N    c                 6    t        | ||xs
 t                     S )aL  
    Convert a `peppy.Project` object to a selected format

    :param peppy.Project prj: a Project object to convert
    :param dict plugin_kwargs: kwargs to pass to the plugin function
    :param str target_format: the format to convert the Project object to
    :raise EidoFilterError: if the requested filter is not defined
    )plugin_kwargs)
run_filterdict)prjtarget_formatr   s      r   convert_projectr   #   s     c=8OPPr   c                 |   |xs
 t               }t               }t        |j                               }|j	                  d      }|j	                  d      }||D ]  }||   t
        j                  |<    ||vr t        d| ddj                  |             t        j                  d|        ||   }	 |	| fi |}
||
D ]  }|j	                  |      }|t        j                  d| d       0t
        j                  j                  |      spt
        j                  j                  t
        j                  j                  |            r4t        j                   t
        j                  j                  |      d	
       t#        ||
|           |r)|
D ]$  }t$        j&                  j)                  |
|          & |
S )a1  
    Run a selected filter on a peppy.Project object

    :param peppy.Project prj: a Project to run filter on
    :param str filter_name: name of the filter to run
    :param dict plugin_kwargs: kwargs to pass to the plugin function
    :raise EidoFilterError: if the requested filter is not defined
    pathsenvzRequested filter (z) not found. Available: z, zRunning plugin zGConversion plugin returned key that doesn't exist in specified paths: 'z'.T)exist_ok)r   r   r   keysgetosenvironr   join_LOGGERinfowarningpathexistsisdirdirnamemakedirssave_resultsysstdoutwrite)r   filter_nameverboser   installed_pluginsinstalled_plugin_namesr    r!   varfuncconv_result
result_keyresult_paths                r   r   r   /   s    "+TVM /0!"3"8"8":;g&E


E
"C  	'C!#hBJJsO	' 00  .))$:;<>
 	
 LL?;-01[)D s,m,K  & 	BJ))J/K"]^h]iikl
 ww~~k2rww}}GGOOK08 KK <tLKZ)@A	B % 	6JJJ[45	6 r   r<   contentreturnc                 h    t        | d      5 }|j                  |       d d d        y # 1 sw Y   y xY w)Nw)openr3   )r<   r=   fs      r   r0   r0   k   s/    	k3	 1	  s   (1c                  D    t        t               j                               S )zd
    Get a list of available target formats

    :return List[str]: a list of available formats
    )r   r   r#    r   r   get_available_pep_filtersrE   p   s     &(--/00r   )N)TN)r   r1   r%   loggingr   pkg_resourcesr   
exceptionstypingr   __name__r(   r   r   r   strr0   rE   rD   r   r   <module>rL      sT     
 	  +  
H
*	Q9xS 3 8 
1r   