Spade
Mini Shell
| Directory:~$ /proc/self/root/usr/lib/python2.7/site-packages/libfuturize/fixes/ |
| [Home] [System Details] [Kill Me] |
�
,�]c@s�dZddlZddlmZmZmZddlmZddlm Z m
Z
mZmZd�Z
ejd�Zd�Zd �Zd
ejfd��YZdS(sL
For the ``future`` package.
Adds this import line:
from __future__ import division
at the top and changes any old-style divisions to be calls to
past.utils.old_div so the code runs as before on Py2.6/2.7 and has the same
behaviour on Py3.
If "from __future__ import division" is already in effect, this
fixer does
nothing.
i����N(tLeaftNodetComma(t
fixer_base(ttokent
future_importttouch_import_toptwrap_in_fn_callcCs<tj}|j|ko;|jj|ko;|jj|kS(uw
__future__.division redefines the meaning of a single slash for
division,
so we match that and only that.
(RtSLASHttypetnext_siblingtprev_sibling(tnodetslash((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pytmatch_divisions "s^[0-9]*[.][0-9]*$cCst|j�pt|j�S(N(t
_is_floatyRR
(R((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyt is_floaty"scCs{t|t�r|d}nt|t�r;tj|j�St|t�rwt|jdt�rw|jdjdkSntS(Niufloat( t
isinstancetlistRtconst_retmatchtvalueRtchildrentFalse(texpr((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyR&s
tFixDivisionSafecBs8eZdZejZdZd�Zd�Zd�Z RS(is4
term<(not('/') any)+ '/' ((not('/')
any))>
cCs/tt|�j||�d|jk|_dS(sO
Skip this fixer if "__future__.division" is already
imported.
tdivisionN(tsuperRt
start_treetfuture_featurestskip(tselfttreetname((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyR>scCs�|j|jjkr�t}t}g}x�|jD]�}|rIt}q1nt|�r�t|�r�t}d|d_t d|t
�|jj�gd|j�g}t}q1|j
|j��q1W|r�t|j|d|j�SntS(u�
Since the tree needs to be fixed once and only once if and only if
it
matches, we can start discarding matches after the first.
uitold_divtprefixtfixers_applied(R tsymsttermRRRRtTrueR#RRR
tclonetappendRR$(RRtmatchedRRtchild((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyREs&
cCs.|jr
dStd|�tdd|�|S(Nudivisionu
past.utilsuold_div(RRR(RRtresults((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyt transformcs
(
t__name__t
__module__t run_orderRRt_accept_typetPATTERNRRR-(((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyR4s (t__doc__tretlib2to3.fixer_utilRRRtlib2to3Rtlibfuturize.fixer_utilRRRRRtcompileRRRtBaseFixR(((sG/usr/lib/python2.7/site-packages/libfuturize/fixes/fix_division_safe.pyt<module>s"