Files
PowerToys/PythonHome/Lib/lib2to3/fixes/fix_import.pyc

36 lines
3.1 KiB
Plaintext
Raw Normal View History

2014-07-09 18:15:23 +08:00
<03>
<EFBFBD>W`Sc@szdZddlmZddlmZmZmZmZddlm Z m
Z
m Z d<00>Z dej fd<00><00>YZd S(
s<>Fixer for import statements.
If spam is being imported from the local directory, this import:
from spam import eggs
Becomes:
from .spam import eggs
And this import:
import spam
Becomes:
from . import spam
i(t
fixer_basei<65><69><EFBFBD><EFBFBD>(tdirnametjointexiststsep(t
FromImporttsymsttokenccs<>|g}x<>|r<>|j<00>}|jtjkr;|jVq |jtjkrwdjg|jD]}|j^q]<00>Vq |jtj kr<>|j
|jd<19>q |jtj kr<>|j |jddd<00><19>q t d<00><00>q WdS(sF
Walks over all the names imported in a dotted_as_names node.
tiNi<4E><69><EFBFBD><EFBFBD>sunknown node type(tpopttypeRtNAMEtvalueRt dotted_nameRtchildrentdotted_as_nametappendtdotted_as_namestextendtAssertionError(tnamestpendingtnodetch((s!.\Lib\lib2to3\fixes\fix_import.pyttraverse_importss    * t FixImportcBs/eZeZdZd<00>Zd<00>Zd<00>ZRS(sj
import_from< 'from' imp=any 'import' ['('] any [')'] >
|
import_name< 'import' imp=any >
cCs/tt|<00>j||<00>d|jk|_dS(Ntabsolute_import(tsuperRt
start_treetfuture_featurestskip(tselfttreetname((s!.\Lib\lib2to3\fixes\fix_import.pyR/scCs|jr dS|d}|jtjkr~x t|d<00>sK|jd}q,W|j|j<00>rd|j|_|j<00>qn<>t }t }x2t
|<00>D]$}|j|<00>r<>t }q<>t }q<>W|r<>|r<>|j |d<00>ndSt d|g<00>}|j|_|SdS(NtimpR iu.s#absolute and local imports together(RR
Rt import_fromthasattrRtprobably_a_local_importR tchangedtFalseRtTruetwarningRtprefix(RRtresultsR"t
have_localt have_absolutetmod_nametnew((s!.\Lib\lib2to3\fixes\fix_import.pyt transform3s, 
 
 cCs<>|jd<00>rtS|jdd<00>d}t|j<00>}t||<00>}ttt|<00>d<00><00>sftSx4dtdddd gD]}t||<17>rtSqWtS(
Nu.iis __init__.pys.pys.pycs.sos.sls.pyd( t
startswithR'tsplitRtfilenameRRRR((Rtimp_namet base_pathtext((s!.\Lib\lib2to3\fixes\fix_import.pyR%Us(t__name__t
__module__R(t BM_compatibletPATTERNRR0R%(((s!.\Lib\lib2to3\fixes\fix_import.pyR&s
  "N(t__doc__RRtos.pathRRRRt
fixer_utilRRRRtBaseFixR(((s!.\Lib\lib2to3\fixes\fix_import.pyt<module> s
"