ó
¡¼™\c           @   sS   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(   iÿÿÿÿ(   t   chain(   t   Module(   t   Dummy(   t   FCodePrinterc      	   C   s4  | p i d d 6d d 6} t  | ƒ } t ƒ  } t |  t ƒ rM t d ƒ ‚ n  t | t | | g ƒ |  ƒ } | j | ƒ } d d j g  | j j	 ƒ  D]% \ } }	 d | d	 j |	 ƒ f ^ q“ ƒ }
 |
 d
 7}
 |
 d 7}
 |
 d d	 j g  |  D]' } t
 | d d ƒ ré t | j ƒ ^ qé ƒ 7}
 | j | j | ƒ |
 ƒ S(   s”   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Ó  t   standardt   freet   source_formats7   This function expects to construct a module on its own.s      %s
s      
s   use %s, only: %ss   , s      implicit none
s      private
s      public %s
t   nameN(   R   R   t
   isinstanceR   t
   ValueErrorR    t   doprintt   joint   module_usest   itemst   getattrt   Nonet   strR   t   replace(   t   definitionsR   t   declarationst   printer_settingst   printert   dummyt   modt   fstrt   kt   vt   module_use_strt   node(    (    s3   lib/python2.7/site-packages/sympy/codegen/futils.pyt   render_as_module	   s    	<

EN(    (
   t	   itertoolsR    t   sympy.codegen.fnodesR   t   sympy.core.symbolR   t   sympy.printing.fcodeR   R   R   (    (    (    s3   lib/python2.7/site-packages/sympy/codegen/futils.pyt   <module>   s   