ó
ÔŒ\c           @  s€   d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z g  Z g  Z g  Z	 i  Z
 d „  Z e a d „  Z d S(   iÿÿÿÿ(   t   print_functionNc         C  sS   t  j |  d  ƒ } | d  k rO t j j |  ƒ } t j j | ƒ } | t  |  <n  | S(   N(	   t   file_exists_cachet   gett   Nonet   renpyt   parsert   unelide_filenamet   ost   patht   exists(   t   fnt   rvt   fullfn(    (    s   renpy/dump.pyt   file_exists/   s    c           s¸  t  j j ‰  t r d St a ˆ  j s) d S‡  f d †  } i  } |  | d <t  j j t  j j g | d <t  j j	 | d <t  j j
 | d <i  } | | d <i  } | d <xo t  j j j j ƒ  D]X \ } } | j } | j } t | t ƒ së q¸ n  | | | ƒ s q¸ n  | | g | | <q¸ Wi  }	 | d	 <x< t D]4 \ } } } | | | ƒ sMq)n  | | g |	 | <q)Wi  }
 | d
 <x< t D]4 \ } } } | | | ƒ sšqvn  | | g |
 | <qvWi  } | d <x< t D]4 \ } } } | | | ƒ sçqÃn  | | g | | <qÃW‡ f d †  ‰ i  } | d <xÚt j j ƒ  D]É\ } } | d k rFq(n  | d k r[d } n# | j d ƒ r(| d d } n q(xp| j j ƒ  D]_\ } } t j | ƒ r%yl t j | ƒ | k rÇwŽn  ˆ | ƒ \ } } | d k rëwŽn  | | | ƒ s wŽn  | | g | | | <Wq%qŽq%Xn  t j | ƒ rŽx¶ | j j ƒ  D]¢ \ } } y‰ t j | ƒ | k rnwDn  ˆ | ƒ \ } } | d k r’wDn  | | | ƒ s§wDn  | | | ƒ s¼wDn  | | g | | | d | <WqDqDqDXqDWqŽqŽWq(Wy t  j j  j! ƒ  | d <Wn n Xˆ  j d k r›ˆ  j d } t" | d ƒ  } t# j! | | ƒ Wd QXt$ j% j& ˆ  j ƒ r…t$ j' ˆ  j ƒ n  t$ j( | ˆ  j ƒ n t# j! | t j) d d ƒd S(   s”   
    Causes a JSON dump file to be written, if the user has requested it.

    `error`
        An error flag that is added to the written file.
    Nc           sŸ   | j  d d ƒ } |  j d ƒ rS ˆ  j rS |  j d ƒ rL |  j d ƒ rL qS t Sn  t | ƒ sc t S| j d ƒ s | j d ƒ rˆ ˆ  j S| j d ƒ s› t St S(   sa   
        Returns true if the name is included by the filter, or false if it is excluded.
        s   \t   /t   _t   __s   common/s   renpy/common/s   game/(   t   replacet
   startswitht   json_dump_privatet   endswitht   FalseR   t   json_dump_commont   True(   t   namet   filename(   t   args(    s   renpy/dump.pyt   filterS   s    t   errort   sizeR   t   versiont   locationt   labelt   definet   screent	   transformc           sH   t  j |  ƒ r( t  j |  ƒ |  j j f St  j |  ƒ rD ˆ  |  j ƒ Sd S(   s"  
        Returns the filename and the first line number of the class or function o. Returns
        None, None if unknown.

        For a class, this doesn't return the first line number of the class, but rather
        the line number of the first method in the class - hopefully.
        N(   NN(   t   inspectt
   isfunctiont   getfilet	   func_codet   co_firstlinenot   ismethodt   im_funcR   (   t   o(   t   get_line(    s   renpy/dump.pyR,   §   s
    	t   callablet   storet    s   store.i   t   .t   buildt   -s   .newt   wt   indenti   (*   R   t   gameR   t   completed_dumpR   t	   json_dumpt   configt   screen_widtht   screen_heightR   R   t   scriptt   namemapt	   iteritemsR   t
   linenumbert
   isinstancet
   basestringt   definitionst   screenst
   transformst   syst   modulest   itemsR   R   t   __dict__R$   R%   t	   getmodulet   isclassR.   R1   t   dumpt   filet   jsonR   R   R	   t   unlinkt   renamet   stdout(   R   R   t   resultR   R    R   t   nR   t   lineR!   R"   R#   t   codet   modnamet   modt   prefixR+   t   methnamet   methodt   newt   f(    (   R   R,   s   renpy/dump.pyRJ   ?   s°    
	

"			
 (   t
   __future__R    R$   RL   RD   R   R   RA   RC   RB   R   R   R   R6   RJ   (    (    (    s   renpy/dump.pyt   <module>   s   	