HEX
Server: LiteSpeed
System: Linux baran.dnsprotection.me 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ddir12 (3618)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/libfuturize/fixes/__pycache__/fix_division_safe.cpython-36.pyc
3

�c/�@s|dZddlZddlmZmZmZddlmZddlm	Z	m
Z
mZmZdd�Z
ejd�Zd	d
�Zdd�ZGd
d�dej�ZdS)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_callcCs,tj}|j|ko*|jj|ko*|jj|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)�nodeZslash�r�'/usr/lib/python3.6/fix_division_safe.py�match_divisionsrz^[0-9]*[.][0-9]*$cCst|j�pt|j�S)N)�
_is_floatyr
r)rrrr�	is_floaty"srcCsVt|t�r|d}t|t�r(tj|j�St|t�rRt|jdt�rR|jdjdkSdS)Nr�floatF)�
isinstance�listr�const_re�match�valuer�children)�exprrrrr&s


rcs:eZdZdZejZdZ�fdd�Zdd�Z	dd�Z
�ZS)	�FixDivisionSafe�z4
    term<(not('/') any)+ '/' ((not('/') any))>
    cs"tt|�j||�d|jk|_dS)zO
        Skip this fixer if "__future__.division" is already imported.
        �divisionN)�superr�
start_treeZfuture_features�skip)�selfZtree�name)�	__class__rrr >szFixDivisionSafe.start_treecCs�|j|jjkr�d}d}g}xn|jD]d}|r0d}q"t|�rxt|�rxd}d|d_td|t�|j	j
�g|jd�g}d}q"|j|j
��q"W|r�tt
d�r�t
|j||jd�St
|j|�SdS)	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)r()rZsymsZtermrrrr'r	rrZclone�append�hasattrrr()r"rZmatchedr!rZchildrrrrEs*

zFixDivisionSafe.matchcCs$|jr
dStd|�tdd|�|S)Nrz
past.utilsr&)r!rr)r"r�resultsrrr�	transformhs

zFixDivisionSafe.transform)�__name__�
__module__�__qualname__Z	run_orderrr
Z_accept_typeZPATTERNr rr,�
__classcell__rr)r$rr4s#r)�__doc__�reZlib2to3.fixer_utilrrrZlib2to3rZlibfuturize.fixer_utilrrrr	r�compilerrrZBaseFixrrrrr�<module>s