U if @sVddlmZddlmZmZmZmZddlmZm Z m Z ddZ Gdddej Z d S) ) fixer_base)dirnamejoinexistssep) FromImportsymstokenccs|g}|r|}|jtjkr(|jVq|jtjkrNddd|jDVq|jtj krl| |jdq|jtj kr| |jdddqt dqdS)NcSsg|] }|jqS)value).0Zchr r =/opt/alt/python38/lib64/python3.8/lib2to3/fixes/fix_import.py sz$traverse_imports..rzunknown node type)poptyper NAMEr r Z dotted_namerchildrenZdotted_as_nameappendZdotted_as_namesextendAssertionError)namesZpendingnoder r rtraverse_importss     rcs4eZdZdZdZfddZddZddZZS) FixImportTzj import_from< 'from' imp=any 'import' ['('] any [')'] > | import_name< 'import' imp=any > cs"tt|||d|jk|_dS)NZabsolute_import)superr start_treeZfuture_featuresskip)selfZtreename __class__r rr/szFixImport.start_treecCs|jr dS|d}|jtjkrVt|ds4|jd}q||jrd|j|_|nZd}d}t |D]}||rzd}qfd}qf|r|r| |ddSt d|g}|j |_ |SdS)Nimpr r.FTz#absolute and local imports together) rrr Z import_fromhasattrrprobably_a_local_importr ZchangedrZwarningrprefix)r rZresultsr$Z have_localZ have_absoluteZmod_namenewr r r transform3s,          zFixImport.transformcCst|drdS|ddd}t|j}t||}ttt|dsHdSdtddd d fD]}t||rXd SqXdS) Nr%Frz __init__.pyz.pyz.pycz.soz.slz.pydT) startswithsplitrfilenamerrr)r Zimp_name base_pathZextr r rr'Us    z!FixImport.probably_a_local_import) __name__ __module__ __qualname__Z BM_compatibleZPATTERNrr*r' __classcell__r r r"rr&s  "rN)r rZos.pathrrrrZ fixer_utilrr r rZBaseFixrr r r rs