ó
3…6ic           @  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 e	 f d „  ƒ  YZ
 d „  Z e j j d	 e ƒ d S(
   iÿÿÿÿ(   t   print_functionN(   t   quote_unicode(   t   scan_stringsc           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   firstt   rvt   i(    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   tag_pass"   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   (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   square_passB   s4    		

(    (   R   R   (    (   R   si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   notags_filter    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   normpatht   renpyt   configt	   commondirt
   startswitht   tdft   notagst   escapet   stringst   opent   ft   write_dialoguet   close(   t   selfR   t   outputR   R!   R   R    R   (    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   __init__s   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 | ƒ } n  |  j r÷ | j | j | | | j t | j ƒ g ƒ q
| j | g ƒ qQ qQ Wq& W|  j rP| j |  j ƒ  ƒ |  j rP| j d d „  ƒ qPn  x4 | D], } |  j j d j | ƒ j d ƒ d ƒ qWWd S(   s2   
        Writes the dialogue to the file.
        R   t   keyc         S  s   t  |  d ƒ S(   Ni   (   t   int(   t   x(    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   <lambda>Ê   s    s   	s   utf-8s   
N(   R   t   gamet   scriptt
   translatort   file_translatesR   t   Nonet   blockt
   isinstancet   astt   Sayt   whot   whatR   R   R    R   R   t   appendt
   identifiert   strt
   linenumberR!   t   extendt   get_stringst   sortR#   t   writet   joint   encode(	   R&   t   linesR/   t   labelt   tt   nR6   R7   t   line(    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyR$   ˜   s:    										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 | ƒ } n  |  j rÍ | j d d | | t | ƒ g ƒ q+ | j | g ƒ q+ W| S(   s0   
        Finds the strings in the file.
        R   N(   R   t   parsert   elide_filenameR   R   R-   R.   R/   R!   R1   t   translationsR   R   R    R   R   R8   R:   (   R&   RB   R   RF   R   t   stl(    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyR=   Ï   s    			%(   t   __name__t
   __module__R   R   R(   R$   R=   (    (    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyR   q   s   %	7c          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.R!   s   --notagss"   Strip text tags from the dialogue.R   s   --escapes+   Escape quotes and other special characters.R    s   dialogue.tabs   dialogue.txtt   wt
   Identifiert	   Charactert   Dialoguet   Filenames   Line Numbers   	s   utf-8s   
Ns   .rpys   .rpymR   (   R   t	   argumentst   ArgumentParsert   add_argumentt
   parse_argsRP   R   R   R@   R   t   basedirR"   R?   RA   t   loadert   listdirfilesR1   t   endswithR   R   R!   R   R    R   (   t   apt   argsR   R'   R#   RF   t   dirnameR   (    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   dialogue_commandð   s6    
	,2t   dialogue(   t
   __future__R    R   R   t   renpy.translationR   t   renpy.translation.generationR   R   t   objectR   Rc   RX   t   register_command(    (    (    si   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\translation\dialogue.pyt   <module>   s   	Q	-