o
    •0¡câ  ã                   @   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| _|  ¡  n|dkr8i | _| jD ]}t	 
| j| ¡| j|< q(d S | jD ]}t	 
| j| ¡| j|< q;d S )NÚErimpÚAbovo)ÚtypeÚ__name__Úset_for_constantsÚrsÚeÚabovoÚ	constantsÚset_the_othersÚssÚreÚcompile)ÚselfÚargÚ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Ú_Úhas_double_dateÚis_shotiz^[a-z]{3,4}-[a-z0-9]+$Ú
is_repcodeÚext_amfÚamf_extz.gzÚ
amf_ext_gzÚis_rifÚ	is_rif_gzz(\s*<variable\s+name="([^"]+)"\s+select="Ú	conf_linez'([^']+)'"/>\s*$|)r   Úescaper   r   )r   Údate_reÚ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&   d| j vrdS | j d  |¡rdS dS )Nr   FT©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#   ;   s
   zRexer.is_rifc                 C   s   | j d  |¡}|d S )Nr   r   )r   Úsearch)r   r+   Úmatchesr   r   r   Úget_issuedateB   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    