U
    b;d	                     @   s(   G d d de ZG dd deedZdS )c                       s    e Zd Zi Z fddZ  ZS )	Singletonc                    s,   | | j kr"tt| j||| j | < | j |  S N)
_instancessuperr   __call__)clsargskwargs	__class__ ./cmf/import_table.pyr      s    
zSingleton.__call__)__name__
__module____qualname__r   r   __classcell__r   r   r	   r   r      s   r   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
ImportTablec                 C   s   t d i | _d S )NZINIT)printimport_tableselfr   r   r   __init__
   s    zImportTable.__init__c                 C   s   d S r   r   r   r   r   r   init   s    zImportTable.initc                 C   s   d}i t d< tt | d S ]p\}}}|td}|D ]}t| ttj|| q4|D ]}t| ttj|| qXd|kr|	d qd S )N/T)followlinks.z.git)
ZGLOBAL_IMPORT_TABLEmake_import_configoswalkPROJECT_DIRreplacer   pathjoinremove)r   import_prefixdirnamedirnames	filenamesZ
subdirnamefilenamer   r   r   make_import_table   s    

zImportTable.make_import_tablec           
      C   s,  |dkrnt jdd d}i }tjtjtddr@t jdd d}|j D ]\}}t	||| qJ||| d< ndd	d
 |
dD }t j|d d d}i }tjtjt|ddrt j|d d d}|j D ]\}}t	||| q|d d  }	|j D ]\}}t	|	|| q|	|| d< d S )Nr   zcommon.config)packageZcustomz	config.pyzcustom.configZconfigr   c                 s   s   | ]}|r|V  qd S r   r   ).0vr   r   r   	<genexpr>5   s      z1ImportTable.make_import_config.<locals>.<genexpr>z.config)	importlibimport_moduler   r    existsr!   r   __dict__itemssetattrsplitcopy)
r   r   r#   Zconfig_moduleZcustom_config_moduleZcustom_import_modulekr+   Zmodule_pathZglobal_configr   r   r   r   *   s&    zImportTable.make_import_configN)r   r   r   r   r   r(   r   r   r   r   r   r   	   s   r   )	metaclassN)typer   objectr   r   r   r   r   <module>   s   