a
    Gkz`¡  ã                   @   s   d dl Z G dd„ dƒZdS )é    Nc                   @   sD   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ Zdd„ Z	dS )ÚRexerc                 C   s–   t |ƒj}|  ¡  i | _|dkr<|| _| jjj| _|  ¡  n4|dkrpi | _| jD ]}t	 
| j| ¡| j|< qPd S | jD ]}t	 
| j| ¡| j|< qvd S )NÚErimpÚAbovo)ÚtypeÚ__name__Úset_for_constantsÚrsÚeÚabovoÚ	constantsÚset_the_othersÚssÚreÚcompile)ÚselfÚargZargtypeÚs© r   ú!/home/ernad/ernad/python/rexer.pyÚ__init__   s    



zRexer.__init__c                 C   s&   i | _ d| j d< | j d  d7  < d S )Nz&\s{2}<variable name="([^"]+)" select="Úis_constants_linez'([^"]+)'"/>)r   )r   r   r   r   r      s    
zRexer.set_for_constantsc                 C   sà   d}d}i }d| d |d< d|d< |d d |d  |d	< d| d |d
< d|d< t  | jd ¡|d< |d t  d¡ |d< d| d | |d  d |d< d| d | |d  d |d< d|d< |d  d7  < || _d S )Nz\d{4}-\d{2}-\d{2}z[a-z0-9]{6}ú^ú$Úis_datez(\d{4}-\d{2}-\d{2})Úhas_dateÚ_Zhas_double_dateZis_shotiz^[a-z]{3,4}-[a-z0-9]+$Ú
is_repcodeZext_amfZamf_extz.gzZ
amf_ext_gzÚis_rifÚ	is_rif_gzz(\s*<variable\s+name="([^"]+)"\s+select="Ú	conf_linez'([^']+)'"/>\s*$|)r   Úescaper   r   )r   Zdate_reZshoti_rer   r   r   r   r      s*    
ÿ ÿÿzRexer.set_the_othersc                 C   s   | j  | jd ¡rdS dS )Nr   TF)r   Úmatchr   ©r   Ústringr   r   r   r   /   s    zRexer.is_datec                 C   s   | j d  |¡rdS dS )Nr   TF©r   r!   r"   r   r   r   r   4   s    zRexer.is_repcodec                 C   s,   | j d  |¡rdS | j d  |¡r(dS dS )Nr   Tr   Fr$   r"   r   r   r   r   9   s
    zRexer.is_rifc                 C   s   | j d  |¡}|d S )Nr   r   )r   Úsearch)r   r#   Úmatchesr   r   r   Úget_issuedate@   s    zRexer.get_issuedateN)
r   Ú
__module__Ú__qualname__r   r   r   r   r   r   r'   r   r   r   r   r      s   r   )r   r   r   r   r   r   Ú<module>   s   