
    9i/                         S r SSKrSSKJrJrJr  SSKJr  SSKJ	r	J
r
JrJr  S r\R                  " S5      rS rS	 r " S
 S\R$                  5      rg)aL  
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.
    N)LeafNodeComma)
fixer_base)tokenfuture_importtouch_import_topwrap_in_fn_callc                     [         R                  nU R                  U:H  =(       a;    U R                  R                  U:X  + =(       a    U R                  R                  U:X  + $ )zk
__future__.division redefines the meaning of a single slash for division,
so we match that and only that.
)r   SLASHtypenext_siblingprev_sibling)nodeslashs     c/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/libfuturize/fixes/fix_division_safe.pymatch_divisionr      sR    
 KKE99 Fd&7&7&<&<"E F&*&7&7&<&<"EF    z^[0-9]*[.][0-9]*$c                 d    [        U R                  5      =(       d    [        U R                  5      $ )N)
_is_floatyr   r   )r   s    r   	is_floatyr   "   s#    d''(IJt7H7H,IIr   c                 F   [        U [        5      (       a  U S   n [        U [        5      (       a  [        R	                  U R
                  5      $ [        U [        5      (       a>  [        U R                  S   [        5      (       a  U R                  S   R
                  S:H  $ g)Nr   floatF)
isinstancelistr   const_rematchvaluer   children)exprs    r   r   r   &   sx    $Aw$~~djj))	D$		dmmA&--==#))X55r   c                   T   ^  \ rS rSrSr\R                  rSrU 4S jr	S r
S rSrU =r$ )FixDivisionSafe4      z4
    term<(not('/') any)+ '/' ((not('/') any))>
    c                 T   > [         [        U ]  X5        SUR                  ;   U l        g)z?
Skip this fixer if "__future__.division" is already imported.
divisionN)superr"   
start_treefuture_featuresskip)selftreename	__class__s      r   r(   FixDivisionSafe.start_tree>   s&     	ot/;$"6"66	r   c                 H   UR                   U R                  R                  :X  a  SnSn/ nUR                   H  nU(       a  SnM  [	        U5      (       a[  [        U5      (       dK  SnSUS   l        [        SU[        5       UR                  R                  5       /-   UR                  S9/nSnMy  UR                  UR                  5       5        M     U(       aI  [        [        S5      (       a  [        UR                   XAR                  S9$ [        UR                   U5      $ g)	z
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.
FT r   old_div)prefixfixers_applied)r4   )r   symstermr   r   r   r3   r
   r   r   cloneappendhasattrr   r4   )r+   r   matchedr*   r   childs         r   r   FixDivisionSafe.matchE   s    
 99		&GDH D!%((51A1A"G *-HQK& /	08EGUEWEWE]E]E_;`0`7;{{!D  EH  DOOEKKM2 '   4!122		8DWDWXX		844r   c                 \    U R                   (       a  g [        SU5        [        SSU5        U$ )Nr&   z
past.utilsr2   )r*   r   r	   )r+   r   resultss      r   	transformFixDivisionSafe.transformh   s'    99k4(
D9r   )r*   )__name__
__module____qualname____firstlineno__	run_orderr   r   _accept_typePATTERNr(   r   r?   __static_attributes____classcell__)r.   s   @r   r"   r"   4   s-    I;;LG7!F r   r"   )__doc__relib2to3.fixer_utilr   r   r   lib2to3r   libfuturize.fixer_utilr   r   r	   r
   r   compiler   r   r   BaseFixr"    r   r   <module>rR      sV    
 0 0 5 5F ::)*J9j(( 9r   