U
    —9%e   ã                   @   s>   d dl mZ d dlmZ d dlmZ d dlmZ d	dd„ZdS )
é    )Úchain)ÚModule)ÚDummy)ÚFCodePrinter© Nc           	      C   s¨   |pdddœ}t |ƒ}tƒ }t| tƒr.tdƒ‚t|t||gƒ| ƒ}| |¡}dd dd„ |j 	¡ D ƒ¡ }|d	7 }|d
7 }|dd dd„ | D ƒ¡ 7 }| 
| |¡|¡S )a”   Creates a ``Module`` instance and renders it as a string.

    This generates Fortran source code for a module with the correct ``use`` statements.

    Parameters
    ==========

    definitions : iterable
        Passed to :class:`sympy.codegen.fnodes.Module`.
    name : str
        Passed to :class:`sympy.codegen.fnodes.Module`.
    declarations : iterable
        Passed to :class:`sympy.codegen.fnodes.Module`. It will be extended with
        use statements, 'implicit none' and public list generated from ``definitions``.
    printer_settings : dict
        Passed to ``FCodePrinter`` (default: ``{'standard': 2003, 'source_format': 'free'}``).

    iÓ  Úfree)ÚstandardZsource_formatz7This function expects to construct a module on its own.z   %s
z   
c                 S   s"   g | ]\}}d |d  |¡f ‘qS )zuse %s, only: %sú, )Újoin)Ú.0ÚkÚvr   r   úS/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/sympy/codegen/futils.pyÚ
<listcomp>#   s   ÿz$render_as_module.<locals>.<listcomp>z   implicit none
z   private
z   public %s
r	   c                 S   s"   g | ]}t |d dƒrt|jƒ‘qS )ÚnameN)ÚgetattrÚstrr   )r   Únoder   r   r   r   '   s      )r   r   Ú
isinstancer   Ú
ValueErrorr   Zdoprintr
   Zmodule_usesÚitemsÚreplace)	Zdefinitionsr   ZdeclarationsZprinter_settingsÚprinterÚdummyÚmodZfstrZmodule_use_strr   r   r   Úrender_as_module	   s    

ÿ
r   )r   N)	Ú	itertoolsr   Zsympy.codegen.fnodesr   Zsympy.core.symbolr   Zsympy.printing.fortranr   r   r   r   r   r   Ú<module>   s   