o ,º]D ã@sddZddlmZmZmZmZddlmZddlm Z m Z ddlm Z ddl m Z Gdd„deƒZd S) a¶ Fixer for import statements, with a __future__ import line. Based on lib2to3/fixes/fix_import.py, but extended slightly so it also supports Cython modules. If spam is being imported from the local directory, this import: from spam import eggs becomes: from __future__ import absolute_import from .spam import eggs and this import: import spam becomes: from __future__ import absolute_import from . import spam é)ÚdirnameÚjoinÚexistsÚsep)Ú FixImport)Ú FromImportÚsyms)Útraverse_imports)Ú future_importc@s eZdZdZdd„Zdd„ZdS)ÚFixAbsoluteImporté cCsÒ|jrdS|d}|jtjkr7t|dƒs|jd}t|dƒr| |j¡r5d|j|_| ¡t d|ƒdSdSd}d}t |ƒD] }| |¡rId}q?d}q?|rX|rV|  |d ¡dSt d|gƒ}|j |_ t d|ƒ|S) zÅ Copied from FixImport.transform(), but with this line added in any modules that had implicit relative imports changed: from __future__ import absolute_import" NÚimpÚvaluerÚ.Úabsolute_importFTz#absolute and local imports together)ÚskipÚtyperÚ import_fromÚhasattrÚchildrenÚprobably_a_local_importrÚchangedr r ÚwarningrÚprefix)ÚselfÚnodeÚresultsr Ú have_localÚ have_absoluteÚmod_nameÚnew©r!úG/usr/lib/python3/dist-packages/libfuturize/fixes/fix_absolute_import.pyÚ transforms4    ÿ  ý     zFixAbsoluteImport.transformcCsv| d¡rdS| dd¡d}t|jƒ}t||ƒ}ttt|ƒdƒƒs$dSdtddd d d fD] }t||ƒr8d Sq-dS) zq Like the corresponding method in the base class, but this also supports Cython modules. rFérz __init__.pyz.pyz.pycz.soz.slz.pydz.pyxT)Ú startswithÚsplitrÚfilenamerrr)rÚimp_nameÚ base_pathÚextr!r!r"rIs    ÿz)FixAbsoluteImport.probably_a_local_importN)Ú__name__Ú __module__Ú __qualname__Ú run_orderr#rr!r!r!r"r s *r N)Ú__doc__Úos.pathrrrrÚlib2to3.fixes.fix_importrÚlib2to3.fixer_utilrrr Úlibfuturize.fixer_utilr r r!r!r!r"Ús