a
    kh                     @   sR   d dl Zd dlZddlmZ ddlmZ dZG dd deeZdd	 Z	d
d Z
dS )    N   )ReprPrinter)
StrPrinter)AddInfinityZIntegerZMulNegativeInfinityPowc                       s:   e Zd ZdZd fdd	Zdd Zdd Zd	d
 Z  ZS )PythonPrinterzFA printer which converts an expression into its Python interpretation.Nc                    sD   t  | g | _g | _tD ]"}d| }tt|}tt|| qd S )Nz	_print_%s)	super__init__symbols	functionsSTRPRINTgetattrr   setattrr	   )selfsettingsnamef_namef	__class__ C/var/www/auris/lib/python3.9/site-packages/sympy/printing/python.pyr      s    
zPythonPrinter.__init__c                 C   s4   |j j}tt|s(|| jvr(| j| t| |S N)func__name__hasattrsympyr   appendr   _print_Function)r   exprr   r   r   r   r       s    zPythonPrinter._print_Functionc                 C   s,   |  |}|| jvr | j| t| |S r   )_strr   r   r   _print_Symbol)r   r!   symbolr   r   r   r#       s    

zPythonPrinter._print_Symbolc                 C   s   t dd S )Nz*Modules in the expression are unacceptable)
ValueError)r   r!   r   r   r   _print_module&   s    zPythonPrinter._print_module)N)	r   
__module____qualname____doc__r   r    r#   r&   __classcell__r   r   r   r   r	   
   s
   r	   c           
      K   s0  t |}|| }d}i }|jD ]}d|v rP|dddd}||t|< n|}t|r|d7 }||jvr^||jvr^t||t|< qq^||d | d 7 }q |jD ]Z}|}	t|	r|	d7 }	|	|jvr|	|jvrt	|	|t	|< qq||	d | d 7 }q|r| 
|}|d|| 7 }|S )	zvReturn Python interpretation of passed expression
    (can be passed to the exec() function without any modifications) {}_z = Symbol('z')
z = Function('ze = )r	   Zdoprintr   replacer   ZSymbolkw	iskeywordr   ZFunctionsubsr"   )
r!   r   printerZexprpresultZ	renamingsZ
symbolnameZnewsymbolnameZfunctionnameZnewfunctionnamer   r   r   python*   sJ    







r5   c                 K   s   t t| fi | dS )z!Print output of python() functionN)printr5   )r!   r   r   r   r   print_pythonZ   s    r7   )keywordr0   r   reprr   strr   r   r	   r5   r7   r   r   r   r   <module>   s    0