ó
b=0Yc           @   s5   d  d l  Z  d  d l Z d Z d d d „  ƒ  YZ d S(   iÿÿÿÿNs   Subject:t   ClEmailc           B   s)   e  Z d  „  Z e d d d d „ ƒ Z RS(   c         C   s   d  S(   N(    (   t   self(    (    s4   /usr/lib/python2.7/site-packages/clcommon/clemail.pyt   __init__   s    c         C   s™  d } | p | } t  j j |  | ƒ } | | k rm t  j j t  j j | | ƒ ƒ rm t  j j |  | ƒ } n  t  j j | | ƒ } t | d ƒ } | j ƒ  }	 | j ƒ  t |	 ƒ d k r|	 d j t	 ƒ r|	 d d k r|	 d j
 t	 d ƒ j ƒ  } |	 j d ƒ |	 j d ƒ n  g  |	 D] }
 |
 j d ƒ ^ q}	 i d j |	 ƒ | 6} t j | ƒ } t j d	 | ƒ } | j | ƒ j | ƒ } | | j d ƒ f S(
   s\  
		Generates email message using jinja2 template engine
		:param template_dir: Base templates directory
		:param templ_filename: Template filename
		:param templ_data: Data to fill template using jinja2
		:param locale_name: Locale
		:param subject: Email subject to use if it not found in template
		:return: Cortege (email_subject, email_body)
		t   en_USt   ri   i    i   s   
t    s   utf-8t   loader(   t   ost   patht   joint   isfilet   opent	   readlinest   closet   lent
   startswitht   SUBJECT_LINE_PREFIXt   replacet   stript   popt   decodet   jinja2t
   DictLoadert   Environmentt   get_templatet   rendert   encode(   t   template_dirt   templ_filenamet
   templ_datat   locale_namet   subjectt
   def_localet	   templ_dirt   template_filet
   f_templatet   template_linest   lt
   templ_dictt   templ_loadert   templ_envirt   body_message(    (    s4   /usr/lib/python2.7/site-packages/clcommon/clemail.pyt   generate_mail_jinja2   s(    .
5"N(   t   __name__t
   __module__R   t   staticmethodt   NoneR*   (    (    (    s4   /usr/lib/python2.7/site-packages/clcommon/clemail.pyR    
   s   	(    (   R   R   R   R    (    (    (    s4   /usr/lib/python2.7/site-packages/clcommon/clemail.pyt   <module>   s   