ó
Ä‚Œ\c           @  s   d  d l  m Z d  d l Z d  d l Z d  d l m Z d  d l m Z d „  Z d „  Z	 d e
 f d „  ƒ  YZ d	 „  Z e j j d
 e ƒ d S(   iÿÿÿÿ(   t   print_functionN(   t   quote_unicode(   t   scan_stringsc   
      C  s´   i  } d „  } t  j j j } x | j j ƒ  D]~ } xu | D]m \ } } | j j | j |  f d ƒ } | d k rw q; n  | | ƒ } | | ƒ }	 | r; |	 r; |	 | | <q; q; Wq. W| S(   sØ   
    :undocumented:

    Creates a map from a dialogue string to a potential translation of the
    the dialogue. This is meant for the Ren'Py tutorial, as a way of translating
    strings found in the examples.
    c         S  s4   x- |  j  D]" } t | t j j ƒ r
 | j Sq
 Wd  S(   N(   t   blockt
   isinstancet   renpyt   astt   Sayt   whatt   None(   t   tt   i(    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   get_text+   s    N(
   R   t   gamet   scriptt
   translatort   file_translatest   valuest   language_translatest   gett
   identifierR	   (
   t   languaget   rvR   R   t   vt   _R
   t   ltt   t_textt   lt_text(    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   create_dialogue_map    s    		c           s"   d „  ‰  ‡  f d †  } | |  ƒ S(   Nc         S  sŽ   t  } t  } d } xu |  D]m } | d k rI | r: t  } q† t } t } q | d k rm t  } | r† t  } q† q t  } | r| q | | 7} q W| S(   Nt    t   {t   }(   t   Falset   True(   t   st   bracet   firstR   R   (    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   tag_passH   s$    		c           s  d } t  } d } d } xÊ |  D]Â } | d k r‚ | r@ d } n5 | ˆ  | ƒ 7} d } | d k rk t } n  | d 7} | d 7} q | d k rÄ t  } | d 8} | d k  r· | d 7} n  | d 7} q | r× | | 7} q | | 7} q W| rþ | ˆ  | ƒ 7} n  | S(   Ni    R   t   [i   t   ](   R    R!   (   R"   t   squaresR$   R   t   bufR   (   R%   (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   square_passi   s4    		

(    (   R"   R*   (    (   R%   ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   notags_filterF   s    	!,t   DialogueFilec           B  s/   e  Z e e e e d  „ Z d „  Z d „  Z RS(   c         C  s…   | |  _  t j j t j j ƒ } | j | ƒ r4 d S| |  _ | |  _	 | |  _
 | |  _ t | d ƒ |  _ |  j ƒ  |  j j ƒ  d S(   sÞ  
        `filename`
            The file we're extracting dialogue from.

        `tdf`
            If true, dialogue is extracted in tab-delimited format. If false,
            dialogue is extracted by itself.

        `strings`
            If true, extract all translatable strings, not just dialogue.

        `notags`
            If true, strip text tags from the extracted dialogue.

        `escape`
            If true, escape special characters in the dialogue.
        Nt   a(   t   filenamet   ost   patht   normpathR   t   configt	   commondirt
   startswitht   tdft   notagst   escapet   stringst   opent   ft   write_dialoguet   close(   t   selfR.   t   outputR5   R8   R6   R7   R3   (    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   __init__š   s    					
c   	   	   C  sÍ  g  } t  j j j } x<| j |  j D]*\ } } | d k rG d } n  x| j D]û } t | t  j	 j
 ƒ rQ | j s~ d } n	 | j } | j } |  j r¨ t | ƒ } n  |  j rÀ t | ƒ } nB |  j r| j d d ƒ } | j d d ƒ } | j d d ƒ } n  |  j r9| j | j | | | j t | j ƒ g ƒ qL| j | g ƒ qQ qQ Wq& W|  j r’| j |  j ƒ  ƒ |  j r’| j d d	 „  ƒ q’n  x4 | D], } |  j j d j | ƒ j d
 ƒ d ƒ q™Wd S(   s2   
        Writes the dialogue to the file.
        R   s   \s   \\s   	s   \ts   
s   \nt   keyc         S  s   t  |  d ƒ S(   Ni   (   t   int(   t   x(    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   <lambda>õ   s    s   utf-8N(   R   R   R   R   R   R.   R	   R   R   R   R   t   whoR   R6   R+   R7   R   R5   t   replacet   appendR   t   strt
   linenumberR8   t   extendt   get_stringst   sortR:   t   writet   joint   encode(	   R=   t   linesR   t   labelR
   t   nRD   R   t   line(    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyR;   ¿   sB    											c         C  s'  g  } t  j j |  j ƒ } xt |  j ƒ D]ô \ } } t  j j j j d } | | j
 k rb q+ n  | | j
 | <|  j r‡ t | ƒ } n  |  j rŸ t | ƒ } nB |  j rá | j d d ƒ } | j d d ƒ } | j d d ƒ } n  |  j r| j d d | | t | ƒ g ƒ q+ | j | g ƒ q+ W| S(	   s0   
        Finds the strings in the file.
        s   \s   \\s   	s   \ts   
s   \nR   N(   R   t   parsert   elide_filenameR.   R   R   R   R   R8   R	   t   translationsR6   R+   R7   R   R5   RE   RF   RG   (   R=   RO   R.   RR   R"   t   stl(    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyRJ   ú   s&    				%(   t   __name__t
   __module__R!   R    R?   R;   RJ   (    (    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyR,   ˜   s   %	;c          C  sî  t  j j d d ƒ }  |  j d d d d d d d	 ƒ|  j d
 d d d d d d	 ƒ|  j d d d d d d d	 ƒ|  j d d d d d d d	 ƒ|  j ƒ  } | j } | rË t j j t  j	 j
 d ƒ } n t j j t  j	 j
 d ƒ } t | d ƒ H } | r9d d d d d g } | j d j | ƒ j d ƒ d ƒ n  Wd QXx¨ t  j j ƒ  D]— \ } } | d k rmqOn  t j j | | ƒ } | j d ƒ p| j d  ƒ s¦qOn  t j j | ƒ } t | | d! | d | j d | j d | j ƒqOWt S("   sj   
    The dialogue command. This updates dialogue.txt, a file giving all the dialogue
    in the game.
    t   descriptions"   Generates or updates translations.s   --textt   helpsC   Output the dialogue as plain text, instead of a tab-delimited file.t   destt   textt   actiont
   store_trues	   --stringss3   Output all translatable strings, not just dialogue.R8   s   --notagss"   Strip text tags from the dialogue.R6   s   --escapes+   Escape quotes and other special characters.R7   s   dialogue.tabs   dialogue.txtt   wt
   Identifiert	   Charactert   Dialoguet   Filenames   Line Numbers   	s   utf-8s   
Ns   .rpys   .rpymR5   (   R   t	   argumentst   ArgumentParsert   add_argumentt
   parse_argsR\   R/   R0   RM   R2   t   basedirR9   RL   RN   t   loadert   listdirfilesR	   t   endswithR1   R,   R8   R6   R7   R    (   t   apt   argsR5   R>   R:   RR   t   dirnameR.   (    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   dialogue_command   s6    
	,2t   dialogue(   t
   __future__R    R   R/   t   renpy.translationR   t   renpy.translation.generationR   R   R+   t   objectR,   Ro   Rd   t   register_command(    (    (    ss   C:\Users\romet\Desktop\TwistedScarlett Patreon Pack #13\FriendshipwithBenefits-0.1-pc\renpy\translation\dialogue.pyt   <module>   s   	&	Rˆ	.