
    4pf/                         d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	m
Z
mZmZ d Z ej        d          Zd Zd	 Z G d
 dej                  ZdS )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                 t    t           j        }| j        |k    o!| j        j        |k     o| j        j        |k     S )zw
    __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/nettyfy-visnx/env/lib/python3.11/site-packages/libfuturize/fixes/fix_division_safe.pymatch_divisionr      sH    
 KE9 Fd&7&<&E"E F&*&7&<&E"EF    z^[0-9]*[.][0-9]*$c                 R    t          | j                  pt          | j                  S )N)
_is_floatyr   r   )r   s    r   	is_floatyr   "   s#    d'((IJt7H,I,IIr   c                 >   t          | t                    r| d         } t          | t                    rt                              | j                  S t          | t                    r6t          | j        d         t                    r| j        d         j        dk    S dS )Nr   floatF)
isinstancelistr   const_rematchvaluer   children)exprs    r   r   r   &   s    $ Aw$ 6~~dj)))	D$		 6dmA&-- 	6=#)X555r   c                   @     e Zd ZdZej        ZdZ fdZd Z	d Z
 xZS )FixDivisionSafe   z4
    term<(not('/') any)+ '/' ((not('/') any))>
    c                 v    t          t          |                               ||           d|j        v | _        dS )zO
        Skip this fixer if "__future__.division" is already imported.
        divisionN)superr"   
start_treefuture_featuresskip)selftreename	__class__s      r   r'   zFixDivisionSafe.start_tree>   s8     	ot$$//d;;;$"66			r   c                    |j         | j        j        k    rd}d}g }|j        D ]}|rd}t	          |          rat          |          sRd}d|d         _        t          d|t                      |j	        
                                gz   |j                  g}d}w|                    |
                                           |rFt          t          d          rt          |j         ||j                  S t          |j         |          S dS )	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)r2   )r   symstermr   r   r   r1   r
   r   r   cloneappendhasattrr   r2   )r*   r   matchedr)   r   childs         r   r   zFixDivisionSafe.matchE   s/   
 9	&&GDH 3 3  D!%(( 351A1A 3"G *-HQK& /	08EGGUEWE]E]E_E_;`0`7;{!D !D !D  EH  DDOOEKKMM2222 5 4!122 5	8DDWXXXX	8444ur   c                 Z    | j         rd S t          d|           t          dd|           |S )Nr%   z
past.utilsr0   )r)   r   r	   )r*   r   resultss      r   	transformzFixDivisionSafe.transformh   s8    9 	Fk4(((
D999r   )__name__
__module____qualname__	run_orderr   r   _accept_typePATTERNr'   r   r<   __classcell__)r-   s   @r   r"   r"   4   sj        I;LG7 7 7 7 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>rL      s    
			 0 0 0 0 0 0 0 0 0 0      5 5 5 5 5 5 5 5 5 5 5 5F F F 2:)**J J J  9 9 9 9 9j( 9 9 9 9 9r   