B
    v9a"                 @   sP   d dl Z ddlmZ ddlmZ ddlmZ G dd deZG dd	 d	eZ	dS )
    N   )PatternCompiler)pygram)does_tree_importc               @   s   e Zd ZdZdZdZdZdZe	dZ
e ZdZdZdZdZdZdZejZdd Zdd	 Zd
d Zdd Zdd ZdddZdd ZdddZdd Zdd Zdd Z dS )BaseFixNr   ZpostF   c             C   s   || _ || _|   d S )N)optionslogcompile_pattern)selfr   r	    r    /usr/lib/python3.7/fixer_base.py__init__/   s    zBaseFix.__init__c             C   s,   | j d k	r(t }|j| j dd\| _| _d S )NT)Z	with_tree)PATTERNr   r
   patternpattern_tree)r   ZPCr   r   r   r
   ;   s    
zBaseFix.compile_patternc             C   s
   || _ d S )N)filename)r   r   r   r   r   set_filenameF   s    zBaseFix.set_filenamec             C   s   d|i}| j ||o|S )Nnode)r   match)r   r   resultsr   r   r   r   M   s    	zBaseFix.matchc             C   s
   t  d S )N)NotImplementedError)r   r   r   r   r   r   	transformY   s    zBaseFix.transformxxx_todo_changemec             C   s6   |}x || j kr$|tt| j }qW | j | |S )N)
used_namesstrnextnumbersadd)r   templatenamer   r   r   new_namei   s
    zBaseFix.new_namec             C   s.   | j rd| _ | jd| j  | j| d S )NFz### In file %s ###)	first_logr	   appendr   )r   messager   r   r   log_messaget   s    zBaseFix.log_messagec             C   s>   |  }| }d|_d}| |||f  |r:| | d S )N zLine %d: could not convert: %s)
get_linenoZcloneprefixr%   )r   r   reasonlinenoZ
for_outputmsgr   r   r   cannot_convertz   s    zBaseFix.cannot_convertc             C   s   |  }| d||f  d S )NzLine %d: %s)r'   r%   )r   r   r)   r*   r   r   r   warning   s    zBaseFix.warningc             C   s(   |j | _ | | td| _d| _d S )Nr   T)r   r   	itertoolscountr   r"   )r   treer   r   r   r   
start_tree   s    
zBaseFix.start_treec             C   s   d S )Nr   )r   r0   r   r   r   r   finish_tree   s    zBaseFix.finish_tree)r   )N)!__name__
__module____qualname__r   r   r   r   r   r.   r/   r   setr   orderZexplicitZ	run_orderZ_accept_typeZkeep_line_orderZBM_compatibler   Zpython_symbolsZsymsr   r
   r   r   r   r!   r%   r,   r-   r1   r2   r   r   r   r   r      s2   




r   c                   s(   e Zd ZdZ fddZdd Z  ZS )ConditionalFixNc                s   t t| j|  d | _d S )N)superr8   r1   _should_skip)r   args)	__class__r   r   r1      s    zConditionalFix.start_treec             C   sJ   | j d k	r| j S | jd}|d }d|d d }t|||| _ | j S )N.)r:   skip_onsplitjoinr   )r   r   Zpkgr    r   r   r   should_skip   s    
zConditionalFix.should_skip)r3   r4   r5   r?   r1   rB   __classcell__r   r   )r<   r   r8      s   r8   )
r.   Zpatcompr   r&   r   Z
fixer_utilr   objectr   r8   r   r   r   r   <module>   s    