3 \"@sPddlZddlmZddlmZddlmZGdddeZGdd d eZ dS) N)PatternCompiler)pygram)does_tree_importc@seZdZdZdZdZdZdZej dZ e Z dZ dZdZdZdZdZejZddZdd Zd d Zd d ZddZdddZddZdddZddZddZddZ dS)BaseFixNrZpostFcCs||_||_|jdS)N)optionslogcompile_pattern)selfrr r */usr/lib64/python3.6/lib2to3/fixer_base.py__init__/szBaseFix.__init__cCs,|jdk r(t}|j|jdd\|_|_dS)NT)Z with_tree)PATTERNrr pattern pattern_tree)r PCr r r r ;s zBaseFix.compile_patterncCs ||_dS)N)filename)r rr r r set_filenameFszBaseFix.set_filenamecCsd|i}|jj||o|S)Nnode)rmatch)r rresultsr r r rMs z BaseFix.matchcCs tdS)N)NotImplementedError)r rrr r r transformYszBaseFix.transformxxx_todo_changemecCs6|}x ||jkr$|tt|j}qW|jj||S)N) used_namesstrnextnumbersadd)r templatenamer r r new_nameis   zBaseFix.new_namecCs.|jrd|_|jjd|j|jj|dS)NFz### In file %s ###) first_logr appendr)r messager r r log_messagetszBaseFix.log_messagecCs>|j}|j}d|_d}|j|||f|r:|j|dS)NzLine %d: could not convert: %s) get_linenoZcloneprefixr&)r rreasonlinenoZ for_outputmsgr r r cannot_convertzszBaseFix.cannot_convertcCs|j}|jd||fdS)Nz Line %d: %s)r(r&)r rr*r+r r r warningszBaseFix.warningcCs(|j|_|j|tjd|_d|_dS)NrT)rr itertoolscountrr#)r treerr r r start_trees  zBaseFix.start_treecCsdS)Nr )r r1rr r r finish_treeszBaseFix.finish_tree)r)N)!__name__ __module__ __qualname__rrrrrr/r0rsetrorderZexplicitZ run_orderZ _accept_typeZkeep_line_orderZ BM_compatiblerZpython_symbolsZsymsrr rrrr"r&r-r.r2r3r r r r rs2         rcs(eZdZdZfddZddZZS)ConditionalFixNcstt|j|d|_dS)N)superr9r2 _should_skip)r args) __class__r r r2szConditionalFix.start_treecCsJ|jdk r|jS|jjd}|d}dj|dd}t||||_|jS)N.rr?)r;skip_onsplitjoinr)r rZpkgr!r r r should_skips  zConditionalFix.should_skip)r4r5r6r@r2rC __classcell__r r )r=r r9s r9) r/Zpatcomprr'rZ fixer_utilrobjectrr9r r r r s