o
    oÇh   ã                   @   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)ÚstandardÚ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   úh/var/www/html/construction_image-detection-poc/venv/lib/python3.10/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   Údoprintr   Úmodule_usesÚitemsÚreplace)	Údefinitionsr   ÚdeclarationsÚprinter_settingsÚprinterÚdummyÚmodÚfstrÚmodule_use_strr   r   r   Úrender_as_module	   s   


ÿr#   )r   N)	Ú	itertoolsr   Úsympy.codegen.fnodesr   Úsympy.core.symbolr   Úsympy.printing.fortranr   r#   r   r   r   r   Ú<module>   s    