U
    Kb
                     @   s^   d dl Z d dlZd dlZdddddddgZddd	d
dddddddddddddgZdddZdS )    NZ	load_dataZmodify_networkZinvert_networkderampvelocityZgeocodeZgoogle_earthZreference_pointZquick_overviewZcorrect_unwrap_errorZcorrect_LODZcorrect_SETZcorrect_troposphereZcorrect_topographyZresidual_RMSZreference_datehdfeos5   Tc           	         s
  | t krtd| t |dkr8tjtjtjd}t	|d
 dd D d|  fddD }t|d	kr|d	 d
 }ntd|d}t|d
 tD ]}| dr|} qqd fdd|| D }| }|rd| d }|S )a  Grab the related template content for each step
    To avoid duplication in each utility script.
    
    Parameters: step_name     - str, step name
                template_file - str, path of the template file
    Returns:    step_content  - str, comments and options of the step
    z,input step name "{}" not found! STEP_LIST={}Nzdefaults/smallbaselineApp.cfgrc                 S   s   g | ]}| d qS ) )strip.0line r   O/home/exouser/operations/rsmas_insar/sources/MintPy/mintpy/defaults/template.py
<listcomp>?   s     z(get_template_content.<locals>.<listcomp>z!^##########[ ]?\d{0,2}\.*\d{0,2} c                    s"   g | ]}t |r |qS r   )rematchindexr	   )linespatternr   r   r   C   s      r      z&pattern "{}" is not found in file: {}!z##########  c                 3   s   | ]}d   | V  qdS )r   Nr   r	   )indentationr   r   	<genexpr>Q   s     z'get_template_content.<locals>.<genexpr>ztemplate options:

)	STEP_LIST
ValueErrorformatospathjoindirnamemintpy__file__open	readlineslenrange
startswithrstrip)	Z	step_nametemplate_filer   Zheader_footerindsind0ind1iZstep_contentr   )r   r   r   r   get_template_content/   s*    	 r.   )Nr   T)r   r   r!   ZSTEP_LIST4OFFSETr   r.   r   r   r   r   <module>   s:   