
    7j                     \   d Z ddlZddlZej                  ej
                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                  ej                   ej"                  iZd Zd Zy)zjParse arbitrary math equations in a safe way.

Gratefully copied from https://stackoverflow.com/a/9558001
    Nc                 V    t        t        j                  | d      j                        S )zParse a mathematical expression and return the answer.

    >>> compute('2^6')
    4
    >>> compute('2**6')
    64
    >>> compute('1 + 2*3**(4^5) / (6 + -7)')
    -5.0
    eval)mode)_evalastparsebody)exprs    E/home/hanthebot/chat/keyboard/qmk_firmware/lib/python/qmk/math_ops.pycomputer      s      4f-2233    c                    t        | t        j                        r| j                  S t        | t        j                        rHt        t        | j                           t        | j                        t        | j                              S t        | t        j                        r4t        t        | j                           t        | j                              S t        |       )N)
isinstancer   ConstantvalueBinOp	operatorstypeopr   leftrightUnaryOpoperand	TypeError)nodes    r   r   r      s    $%zz	D#))	$dgg'dii(8%

:KLL	D#++	&dgg'dll(;<<or   )__doc__r   operatorr   AddaddSubsubMultmulDivtruedivPowpowBitXorxorUSubnegr   r   r    r   r   <module>r-      s      WWbffcggrvvsxx"**VYV]V]_a_e_egjgqgqsusysy{~  |D  |D  FH  FL  FL  M	
4r   