
66ic           @  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 d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l Z e e e   Z e   Z d a d a d   Z i  Z d   Z d d  Z d d  Z e   Z d   Z e   Z d   Z e d	  Z i  Z d
   Z d   Z  d   Z! d   Z" d   Z# d   Z$ d   Z% d   Z& d   Z' d   Z( d   Z) d   Z* d   Z+ d   Z, d   Z- d   Z. d   Z/ d   Z0 d   Z1 d   Z2 d   Z3 d   Z4 d    Z5 d! e6 f d"     YZ7 d#   Z8 d$   Z9 d S(%   i(   t   print_functionNc         G  s]   t  r+ d t j j t  j  t  j f } n d } | |  | 7} t   t | j d   d  S(   Nu   %s:%d t    s   utf-8(   t   report_nodet   renpyt   parsert   unicode_filenamet   filenamet
   linenumbert   printt   encode(   t   msgt   argst   out(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   report9   s    %c         C  s6   |  t  k r2 t t  |  <t t |   j d   n  d  S(   Ns   utf-8(   t   addedt   TrueR   t   unicodeR	   (   R
   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   addI   s    
c         C  s   t  |  |  t j d |  } | s) d  St t j | j d   rH d  S| j d  t k ra d  St d | |   | r t	 |  n  d  S(   Ns   \s*([a-zA-Z_]\w*)i   s   Could not evaluate '%s', in %s.(
   t   try_compilet   ret   matcht   hasattrR   t   storet   groupt   __builtins__R   R   (   t   wheret   exprt
   additionalt   m(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   try_evalP   s    c         C  sE   y t  j j |  Wn* t d | |   | rA t |  qA n Xd  S(   Ns6   '%s' could not be compiled as a python expression, %s.(   R   t   pythont   py_compile_eval_bytecodeR   R   (   R   R   R   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyR   j   s    c         C  s  |  t  k r t S|  d } t   } t   } xC |  d D]7 } | d d k ra | j | d  q7 | j |  q7 Wx t j j j D] } | d | k r q n  t | d  } g  | D] } | | k r | ^ q r q n  g  | D] } | | k r | ^ q rq n  t  j |   t SWt S(   s   
    Returns true if the image is a plausible image that can be used in a show
    statement. This returns true if at least one image exists with the same
    tag and containing all of the attributes (and none of the removed attributes).
    i    i   t   -(	   t   imprecise_cacheR   t   setR   R   t   displayt   imaget   imagest   False(   t   namet   nametagt   requiredt   bannedt   it   imt   attrs(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   image_exists_imprecisex   s(    
		%%c         C  s   |  t  k r t S|  d } t |  d  } xZ t j j j D]I } | d | k rV q: n  t | d  } | | k r: t  j |   t Sq: Wt S(   s   
    Returns true if an image exists with the same tag and attributes as
    `name`. (The attributes are allowed to occur in any order.)
    i    i   (	   t   precise_cacheR   R"   R   R#   R$   R%   R   R&   (   R'   R(   R)   R,   R-   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   image_exists_precise   s    
c         C  s   | p |  d } t  t | <| r$ d St |   } d j |  } x3 | rt t |  t j j j k rg d S| j	   qB W| r t
 |   r d Sn t |   r d St d |  d S(   s?   
    Checks a scene or show statement for image existence.
    i    Nt    s&   The image named '%s' was not declared.(   R   t   image_prefixest   listt   joint   tupleR   R#   R$   R%   t   popR0   R.   R   (   R'   t
   expressiont   tagt   preciset   namelistt   names(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   image_exists   s     
	c         C  s   t  j | d   } | t k r" d  S| t k rH t d |  j   |  d  St j j	 |  s~ t d |  j   |  t t  | <d  St t  | <d  S(   Ns)   %s uses file '%s', which is not loadable.(
   t   check_file_cachet   gett   NoneR   R&   R   t
   capitalizeR   t   loadert   loadable(   t   whatt   fnt   present(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_file   s    
c           s     f d   } | t  j j _ g    y/ t | t  j j j  rR | j d    n  Wn n Xx   D] } t |  |  qd Wd  S(   Nc           s     j  |  j    d  S(   N(   t   extendt   predict_files(   t   img(   t   files(    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   predict_image   s    c         S  s
   |  j    S(   N(   t   predict_one(   t   a(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   <lambda>  s    (	   R   R#   t   predictR$   t
   isinstancet   coret   Displayablet	   visit_allRF   (   RC   t   dRK   RD   (    (   RJ   sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_displayable   s    c         C  s7   d j  |  j  } t d | t j j j |  j  d  S(   NR1   s   image %s(   R4   t   imgnameRU   R   R#   R$   R%   (   t   nodeR'   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_image
  s    c         C  s   t  |   d k r4 |  d d  d  |  d |  d d f St  |   d k rw |  d |  d |  d |  d |  d |  d d  f S|  Sd  S(   Ni   i    i   i   i   i   i   (   t   lenR?   (   t   t(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   imspec  s
    "1c   
      C  s   |  j  s d  St  |  j   \ } } } } } } } t j j | | pF |  } | t j j k r | t j j k r t d |  n  t | | | d | x | D] }	 t	 d |	 d  q Wd  S(   Ns/   Uses layer '%s', which is not in config.layers.R9   s'   the at list of a scene or show statments7   Perhaps you forgot to define or misspelled a transform.(
   R[   R   t   exportst   default_layert   configt   layerst
   top_layersR   R<   R   (
   RW   R9   R'   R7   R8   t   at_listt   layert   _zordert   _behindR+   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_show  s    	$$c         C  s.   |  j  s d  St  |  j   d } t t | <d  S(   Ni   (   R[   R   R2   (   RW   R8   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   precheck_show.  s    	c         C  s   t  |  j   \ } } } } } } } | p1 | d } t j j | |  } | t j j k r} | t j j k r} t d |  n  | t k r t d |  n  d  S(   Ni    s/   Uses layer '%s', which is not in config.layers.sy   The image tag '%s' is not the prefix of a declared image, nor was it used in a show statement before this hide statement.(	   R[   R   R\   R]   R^   R_   R`   R   R2   (   RW   R'   t   _expressionR8   t   _at_listRb   Rc   Rd   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_hide9  s    $$c         C  s   t  d |  j d  d  S(   Ns   a with statement or clauses;   Perhaps you forgot to declare, or misspelled, a transition?(   R   R   (   RW   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_withH  s    c         C  sa   d   } t  j j |  z |  j d  Wd  t  j j   Xy |  j   Wn t d  n Xd  S(   Nc         S  s   t  d |   d  S(   Ns   %s(   R   (   R
   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   errorN  s    t   lints9   Didn't properly report what the next statement should be.(   R   R\   t   push_error_handlert   callt   pop_error_handlert   get_nextR   (   RW   Rk   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_userL  s    	c         C  s  t  j j j |   } | r8 t d | t |   d  n  d |  k rt  j j rd } d } d } x | t |   k  r^|  | } | d 7} | d k r | d k r[d } d } q[qe | d k r-| | 7} | d k r d } q[| d k r d } q[| d	 k r
d } q[t d
 | t |   d  d } qe | d k re | | 7} | d k r[d } q[qe qe W| d k rt d | t |   d  qn  d  S(   Ns
   %s (in %s)i   t   %i    R   t   (i   s   #0123456780- +hlLs   diouxXeEfFgGcrs%s'   Unknown string format code '%s' (in %s)t   )s,   Unterminated string format code '%s' (in %s)(	   R   t   textt   extrast   check_text_tagsR   t   reprR^   t   old_substitutionsRY   (   t   sR
   t   statet   post   fmtt   c(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   text_checks]  s<    


				
c         C  s+  |  j  rO y t j j |  j   } WqO t d |  j   t d  d  } qO Xn  |  j rn t d |  j d  n  t	 |  j
  |  j s d  S|  j  d  k r d  St | t j j  s d  S|  j d  k r d  S| j d  k r d  S| j f |  j } t |  r d  St d |  rd  St d d j |   d  S(	   Ns;   Could not evaluate '%s' in the who part of a say statement.s)   Perhaps you forgot to define a character?s"   the with clause of a say statements;   Perhaps you forgot to declare, or misspelled, a transition?t   sidesG   Could not find image (%s) corresponding to attributes on say statement.R1   (   s   side(   t   whoR   t   astt   eval_whoR   R   R?   t   with_R   R   RC   t   who_fastRP   t	   charactert   ADVCharactert
   attributest	   image_tagR.   R4   (   RW   t   charR'   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt	   check_say  s4    	
		c         C  s   |  j  r t d |  j  d  n  g  |  j D]$ \ } } } | r) | | | f ^ q) s` t d  n  x: |  j D]/ \ } } } | r t d |  n  t |  qj Wd  S(   Ns#   the with clause of a menu statements;   Perhaps you forgot to declare, or misspelled, a transition?s1   The menu does not contain any selectable choices.s   in the if clause of a menuitem(   R   R   t   itemsR   R   R   (   RW   t   lR~   t   b(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_menu  s    	4c         C  s<   |  j  r d  St j j j |  j  s8 t d |  j  n  d  S(   Ns&   The jump is to nonexistent label '%s'.(   R7   R   t   gamet   scriptt	   has_labelt   targetR   (   RW   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_jump  s    	c         C  s<   |  j  r d  St j j j |  j  s8 t d |  j  n  d  S(   Ns&   The call is to nonexistent label '%s'.(   R7   R   R   R   R   t   labelR   (   RW   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   check_call  s    	c         C  s   t  d |  j  d  S(   Ns'   in the condition of the while statement(   R   t	   condition(   RW   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_while  s    c         C  s+   x$ |  j  D] \ } } t d |  q
 Wd  S(   Ns"   in a condition of the if statement(   t   entriesR   (   RW   R   t   _block(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_if  s    c         C  sz   |  j  d k r d  S|  j t j j k r, d  S|  j t k rQ t d | |  j  n  |  j t k rv t d | |  j  n  d  S(   NR   sB   '%s %s' replaces a python built-in name, which may cause problems.sB   '%s %s' replaces a Ren'Py built-in name, which may cause problems.(   R   t   varnameR   R^   t   lint_ignore_replacest   python_builtinsR   t   renpy_builtins(   RW   t   kind(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_define  s    c   
      C  s   | j  s& t d j |  |  |  d  St j j   d   } | t j j  } x | t j j j | g    D] } x | D]w } | t	 |  } | t j j
 k rz | j j d |  } | j |  }	 |	 j   t d j |  | |  |	  Pqz qz Wqm Wd  S(   Ns   {}, property {}c         S  s#   t  |   }  |  j d d    |  S(   Nt   keyc         S  s
   t  |   S(   N(   RY   (   RM   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyRN     s    (   R3   t   sort(   R   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt
   sort_short  s    t   prefix(   t   _duplicatableRU   t   formatR   t   stylet   init_inspectt   prefix_altst   affectsR>   RY   t   all_propertiest   _argst   copyt
   _duplicatet   _unique(
   R'   t   propertyRT   R   t   altst   pR   t   restR   t   dd(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt    check_style_property_displayable  s&    		%
c         C  s   x | j  D] } x | j   D] \ } } | j d  r t | t j j j  rt x. | j D] } t	 |  |  qZ Wq t	 |  |  n  t | t j
 j j  r t |  | |  q q Wq
 Wd  S(   Nt   font(   t
   propertiest	   iteritemst   endswithRP   R   Ru   R   t	   FontGroupt   fontsRF   R#   RQ   RR   R   (   R'   Rz   R   t   kt   vt   f(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_style  s    c         C  s]   d   } |  j  } | d  k	 rY x | j D] } | |  q( W| | j  | | j  n  d  S(   Nc         S  s<   |  d  k r d  St t j |   s8 t t j |  d   n  d  S(   N(   R?   R   R   R   t   setattr(   t   n(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   add_arg!  s    (   t
   parametersR?   t
   positionalt   extrapost   extrakw(   RW   R   t   piR+   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_label  s    		c          C  sn   xg t  j j j   D]S \ }  } d |  d } x% |  d D] } | d j |  7} q8 Wt d | |  q Wd  S(   Ns   style.i    i   s   [{!r}]s   Style (   R   R   t   stylesR   R   R   (   t	   full_nameRz   R'   R+   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_styles2  s
    c         C  sv   t  |   } g  } xT t t |   D]@ \ } } | rU | d rU | j d d  n  | j d |  q% Wd j |  S(   Ni   i    t   ,R   (   t   strt	   enumeratet   reversedt   insertR4   (   R   Rz   t   rvR+   R~   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   humanize;  s    c          C  sY   xR t  j j   D]A \ }  } y | j d  w Wn n Xt d |  t d  q Wd S(   sF   
    Checks files to ensure that they are displayable in unicode.
    t   asciis1   %s contains non-ASCII characters in its filename.sC   (ZIP file distributions can only reliably include ASCII filenames.)N(   R   RA   t   listdirfilesR	   R   R   (   t   _dirnameR   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   check_filename_encodingsI  s    t   Countc           B  s    e  Z d  Z d   Z d   Z RS(   s2   
    Stores information about the word count.
    c         C  s   d |  _  d |  _ d |  _ d  S(   Ni    (   t   blockst   wordst
   characters(   t   self(    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   __init__^  s    		c         C  sC   |  j  d 7_  |  j t | j    7_ |  j t |  7_ d  S(   Ni   (   R   R   RY   t   splitR   (   R   Rz   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyR   h  s    (   t   __name__t
   __module__t   __doc__R   R   (    (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyR   Y  s   	
c         C  s?   |  j  j d d  } | j d  s3 | j d  r7 t St Sd S(   s>   
    Returns true if the node is in the common directory.
    s   \t   /s   common/s   renpy/common/N(   R   t   replacet
   startswithR   R&   (   R   R   (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   commonn  s    c            s  t  j j d d d t  }  |  j d d d d d d	 d
 |  j   } | j rm t | j d  } | t _	 n  t
 t  j _ t t j  t t t  j d t j    j d   i  a x% t  j j j D] } t
 t | d <q Wg  t  j j j D] } | j | j | f ^ q } | j   t j t    d } d } d } d }	 xE | D]= \ }
 } } t! | t  j" j# t  j" j$ f  rGt% |  qGqGWx| D]\ }
 } } t& |  rqn  | a' t! | t  j" j(  r|	 d 7}	 t) |  qt! | t  j" j#  rt* | t  qt! | t  j" j$  r,t* | t
  qt! | t  j" j+  rNt, |  qt! | t  j" j-  rpt. |  qt! | t  j" j/  rt0 |    | j1 | j2  qt! | t  j" j3  rt4 |  | d 7} qt! | t  j" j5  rt6 |  qt! | t  j" j7  rt8 |  qt! | t  j" j9  r8t: |  qt! | t  j" j;  rZt< |  qt! | t  j" j=  r|t> |  qt! | t  j" j?  rt@ |  qt! | t  j" jA  r| jB } qt! | t  j" jC  rd } qt! | t  j" jD  r| d 7} qt! | t  j" jE  r$tF | d  qt! | t  j" jG  rtF | d  qqWd a' tH   tI   x t  jJ jK D] } |   qnWg      f d   } t   t   t d  t   tL    } | j   x | D] } | |  qW jM d jN tO |  tO |	  tO |    xE  D]= } x- tP jQ | d  D] } t | j d   q5Wt   qWt   t  jJ jR rt  jJ jS d k rt d  t   n  t d  t d  t S(   s_   
    The master lint function, that's responsible for staging all of the
    other checks.
    t   descriptions:   Checks the script for errors and prints script statistics.t   require_commandR   t   nargst   ?t   actionR   t   helps   The file to write to.t   ws    lint report, generated at: s   utf-8i    i   t   definet   defaultc           s     |  } | j  d k r d  S|  d  k r2 d } n d j |   } | d j t | j   t | j  t | j  d | j | j  d | j | j   7}  j |  d  S(   Ni    s   The games   The {0} translations    contains {0} dialogue blocks, containing {1} words
and {2} characters, for an average of {3:.1f} words and {4:.0f}
characters per block. g      ?(   R   R?   R   R   R   R   t   append(   t   languaget   countRz   (   t   countst   lines(    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   report_language  s    
	s   Statistics:s9   The game contains {0} menus, {1} images, and {2} screens.iN   t   autos;   Remember to set config.developer to False before releasing.sH   Lint is not a substitute for thorough testing. Remember to update Ren'PysB   before releasing. New releases fix bugs and improve compatibility.N(T   R   t	   argumentst   ArgumentParserR&   t   add_argumentt
   parse_argsR   t   opent   syst   stdoutR   R   Rl   R   t   codecst   BOM_UTF8R   t   versiont   timet   ctimeR	   R2   R#   R$   R%   R   t	   all_stmtsR   R   t   collectionst   defaultdictR   R?   RP   R   t   Showt   SceneRf   R   R   t   ImageRX   Re   t   HideRi   t   WithRj   t   SayR   R   RC   t   MenuR   t   JumpR   t   CallR   t   WhileR   t   IfR   t   UserStatementRq   t   LabelR   t	   TranslateR   t   EndTranslatet   Screent   DefineR   t   DefaultR   R   R^   t
   lint_hooksR3   R   R   R   t   textwrapt   wrapt	   developert   original_developer(   t   apR   R   R   R+   R  R   t
   menu_countt   screen_countt   image_countt   _fnt   _lnRW   R   t	   languagesR   t   ll(    (   R   R   sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyRl   {  s    	*1
!


	

"



(:   t
   __future__R    t   renpy.displayR   t
   renpy.textR   R   R   R   R  R  t   __builtin__R"   t   dirR   R   R?   R2   R   R   R   R   R   R   R!   R.   R/   R0   R   R<   R=   RF   RU   RX   R[   Re   Rf   Ri   Rj   Rq   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   objectR   R   Rl   (    (    (    sY   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\lint.pyt   <module>   sd   		
			(		"				
						+	*									"							