ó
:…6ic           @   s/  d  d l  Z  d  d l Z 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 m Z d „  Z d „  Z d „  Z e
 j Z d „  Z d e f d	 „  ƒ  YZ d
 „  Z d e f d „  ƒ  YZ d e d „ Z e j ƒ  Z e j ƒ  d a d „  Z d „  Z e d „ Z d „  Z  d e d „ Z! d d „ Z# i  Z$ d d „ Z% d „  Z& d „  Z' d „  Z( e d „ Z) d „  Z* d „  Z+ d „  Z, d „  Z- d  „  Z. e
 j j/ d! ƒ Z0 d" e f d# „  ƒ  YZ1 i  Z2 d$ „  Z3 d% „  Z4 d& „  Z5 d Z6 e r+e
 j7 j8 d' ƒ Z6 n  d S((   iÿÿÿÿN(   t   StringIO(   t   dumpsc         C   s?   t  j j r% t j |  | t j ƒ n t j |  | t j ƒ d  S(   N(   t   renpyt   configt   use_cpicklet   cPicklet   dumpt   HIGHEST_PROTOCOLt   pickle(   t   ot   f(    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR   +   s    c         C   s6   t  j j r t j |  t j ƒ St j |  t j ƒ Sd  S(   N(   R   R   R   R   R   R   R   (   R	   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR   2   s    c         C   s*   t  j j r t j |  ƒ St j |  ƒ Sd  S(   N(   R   R   R   R   t   loadsR   (   t   s(    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR   9   s    c            sR   i  ‰ ‡  ‡ ‡ f d †  ‰ t  d d ƒ ‰  ˆ |  d ƒ ˆ | d ƒ ˆ  j ƒ  d S(   s¼   
    Dumps information about the save to save_dump.txt. We dump the size
    of the object (including unique children), the path to the object,
    and the type or repr of the object.
    c            s…  t  |  ƒ } | ˆ k r< ˆ j d j d | ˆ | ƒ ƒ d St |  t t t j t j t j	 f ƒ rr t
 |  ƒ } n&t |  t t f ƒ rÑ t |  ƒ d k r± t
 |  ƒ j d ƒ } q˜t
 |  d  d ƒ j d ƒ } nÇ t |  t t f ƒ rý d |  j j d } n› t |  t ƒ r#d |  j j d } nu t |  t j ƒ rVd j |  j j |  j j ƒ } nB t |  t ƒ r€d	 j t |  ƒ j ƒ } n d
 j t |  ƒ j ƒ } | ˆ | <t |  t t t j t j t j	 f ƒ rÒd } nt |  t t f ƒ rþt |  ƒ d d } nct |  t t f ƒ rbd } xEt |  ƒ D]5 \ } } | d 7} | ˆ | d j | | ƒ ƒ 7} q&Wnÿt |  t ƒ rÀd } xç|  j ƒ  D]5 \ } } | d 7} | ˆ | d j | | ƒ ƒ 7} q„Wn¡t |  t j ƒ rïd ˆ |  j | d ƒ } nry |  j d ƒ ‰  Wn g  ‰  d | } n X‡  f d †  }	 d } |	 d i  ƒ }
 t |
 t ƒ r”xY |
 j ƒ  D]1 \ } } | d 7} | ˆ | | d | ƒ 7} q\Wn | ˆ |
 | d ƒ 7} xL t |	 d g  ƒ ƒ D]5 \ } } | d 7} | ˆ | d j | | ƒ ƒ 7} qÁWxd |	 d g  ƒ D]S } t | ƒ d k r(q
n  | \ } } | d 7} | ˆ | d j | | ƒ ƒ 7} q
Wˆ j d j | | ˆ | ƒ ƒ | S(   Ns   {0: 7d} {1} = alias {2}
i    iP   s   utf-8s   ...t   <t   >s   <method {0}.{1}>s   <{0}>s   BAD TYPE <{0}>i   i(   s
   {0}[{1!r}]i   s   .im_selfs   BAD REDUCTION c            s2   |  t  ˆ  ƒ k  r* ˆ  |  d  k	 r* ˆ  |  S| Sd  S(   N(   t   lent   None(   t   idxt   default(   t	   reduction(    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   get   s    "t   .s   .__getstate__()i   s   {0}[{1}]i   s   {0: 7d} {1} = {2}
(   t   idt   writet   formatt
   isinstancet   intt   floatt   typest   NoneTypet
   ModuleTypet	   ClassTypet   reprt   strt   unicodeR   t   encodet   tuplet   listt	   __class__t   __name__t   dictt
   MethodTypet   im_classt   im_funct   objectt   typet	   enumeratet	   iteritemst   im_selft   __reduce_ex__(   R	   t   patht   idot   o_reprt   sizet   it   oot   kt   vR   t   state(   R
   t   o_repr_cachet   visit(   R   s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR<   M   sx     ' !
'	
&
&
""
#
# s   save_dump.txtt   wt   rootst   logN(   t   filet   close(   R>   R?   (    (   R
   R;   R<   s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt	   save_dumpD   s    dt	   SaveAbortc           B   s   e  Z RS(    (   R'   t
   __module__(    (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRC   À   s   c         C   s6   t  j j | ƒ r" t  j | ƒ n  t  j |  | ƒ d S(   s#   
    Safely rename old to new.
    N(   t   osR2   t   existst   unlinkt   rename(   t   oldt   new(    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   safe_renameÄ   s    t
   SaveRecordc           B   s    e  Z d  Z d „  Z d „  Z RS(   sÒ   
    This is passed to the save locations. It contains the information that
    goes into a save file in uncompressed form, and the logic to save that
    information to a Ren'Py-standard format save file.
    c         C   s1   | |  _  | |  _ | |  _ | |  _ d  |  _ d  S(   N(   t
   screenshott
   extra_infot   jsonR?   R   t   first_filename(   t   selfRM   RN   RO   R?   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   __init__Ö   s
    				c         C   sá   | d } |  j  d k	 r= t j |  j  | ƒ t | | ƒ d St j | d t j ƒ } | j d |  j	 ƒ | j d |  j
 j d ƒ ƒ | j d |  j ƒ | j d t j ƒ | j d	 |  j ƒ | j ƒ  t | | ƒ | |  _  d S(
   sG   
        This writes a standard-format savefile to `filename`.
        s   .newNR=   s   screenshot.pngRN   s   utf-8RO   t   renpy_versionR?   (   RP   R   t   shutilt   copyfileRK   t   zipfilet   ZipFilet   ZIP_DEFLATEDt   writestrRM   RN   R#   RO   R   t   versionR?   RA   (   RQ   t   filenamet   filename_newt   zf(    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt
   write_fileÞ   s    

(   R'   RD   t   __doc__RR   R^   (    (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRL   Ï   s   	t    c   	      C   s  | r t  t j _ n  t j j j d ƒ } t j j	 rL t	 | t j j ƒ n  t
 ƒ  } t | t j j f | ƒ | rŒ t j j rŒ t ƒ  ‚ n  t j j j ƒ  } i | d 6} x t j j D] } | | ƒ q¸ Wt | ƒ } t | | | | j ƒ  ƒ } t j |  | ƒ t j ƒ  t |  ƒ d S(   sÏ  
    :doc: loadsave
    :args: (filename, extra_info='')

    Saves the game state to a save slot.

    `filename`
        A string giving the name of a save slot. Despite the variable name,
        this corresponds only loosely to filenames.

    `extra_info`
        An additional string that should be saved to the save file. Usually,
        this is the value of :var:`save_name`.

    :func:`renpy.take_screenshot` should be called before this function.
    t
   _save_nameN(   t   FalseR   t   pythont   mutate_flagt   gameR?   t   freezeR   R   RB   R    R   RC   t	   interfacet   get_screenshott   save_json_callbackst
   json_dumpsRL   t   getvaluet   locationt   savet   scant
   clear_slot(	   t   slotnameRN   Rd   R>   t   logfRM   RO   R6   t   sr(    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRm     s$    	
i    c         C   s“   z ys t  d t j j ƒ t j j r7 t j j ƒ  } n d } |  rY t j j d t ƒ n  t d d t d | ƒd a	 Wn n XWd  t
 j ƒ  Xd  S(   Ns   auto-R`   t
   backgrounds   auto-1Rd   RN   i    (   t   cycle_savesR   R   t   autosave_slotst   auto_save_extra_infot   exportst   take_screenshott   TrueRm   t   autosave_countert   autosave_not_runningt   set(   Rx   RN   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   autosave_thread;  s    
c           C   sŠ   t  j j s d  St j ƒ  s  d  St  j j r0 d  St t  j j ƒ d k rL d  St	 d 7a	 t	 t  j j k  rl d  St  j
 j r| d  St t ƒ d  S(   Ni   (   R   R   t   autosave_frequencyR{   t   isSett   skippingR   Re   t   contextsRz   t   storet	   main_menut   force_autosaveRy   (    (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   autosaveW  s    
c         C   sl   t  j ƒ  s d St j j r  d St j j r0 d St  j ƒ  t j d t	 d |  f ƒ } t
 | _ | j ƒ  d S(   sÁ   
    :doc: other

    Forces a background autosave to occur.

    `take_screenshot`
        If True, a new screenshot will be taken. If False, the existing
        screenshot will be used.
    Nt   targett   args(   R{   R   R   R‚   Rƒ   t
   _in_replayt   cleart	   threadingt   ThreadR}   Ry   t   daemont   start(   Rx   t   t(    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR„   s  s    
	c         C   s   t  |  ƒ } | j ƒ  } | d  k r( d  S| j ƒ  } | d  k rD d  S| j d d ƒ } | j ƒ  } | d  k rr d  S| | | f S(   NRa   R`   (   t	   get_cachet	   get_mtimeR   t   get_jsonR   Rh   (   Rp   t   ct   mtimeRO   RN   RM   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   scan_saved_game”  s    R   c         C   sô   t  j ƒ  } |  d k	 rF g  | D] } t j |  | ƒ r | ^ q } n  | j ƒ  | rZ | Sg  } x | D]… } t | ƒ } | d k	 rg | j ƒ  } | d k	 r² | j d d ƒ } n d } | j	 ƒ  }	 | j
 ƒ  }
 | j | | |	 |
 f ƒ qg qg W| S(   s3  
    :doc: loadsave

    Lists the save games. For each save game, returns a tuple containing:

    * The filename of the save.
    * The extra_info that was passed in.
    * A displayable that, when displayed, shows the screenshot that was
      used when saving the game.
    * The time the game was stayed at, in seconds since the UNIX epoch.

    `regexp`
        A regular expression that is matched against the start of the
        filename to filter the list.

    `fast`
        If fast is true, the filename is returned instead of the
        tuple.
    Ra   R`   N(   Rl   R%   R   t   ret   matcht   sortR   R‘   R   Rh   R   t   append(   t   regexpt   fastt   slotsR6   t   rvR   R’   RO   RN   RM   R“   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   list_saved_games«  s$    .
 c         C   sT   t  j ƒ  } |  d k	 rF g  | D] } t j |  | ƒ r | ^ q } n  | j ƒ  | S(   s¹   
    :doc: loadsave

    Returns a list of non-empty save slots. If `regexp` exists, only slots
    that begin with `regexp` are returned. The slots are sorted in
    string-order.
    N(   Rl   R%   R   R•   R–   R—   (   R™   R›   R6   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt
   list_slotsà  s
    
.
c         C   s¼   t  j |  t ƒ } | t k r® d } d } t j ƒ  } xu | D]j } |  d k	 rh t j |  | ƒ rh q= n  t | ƒ j	 ƒ  } | d k rŒ q= n  | | k r= | } | } q= q= Wn  | t  |  <| S(   s÷   
    :doc: loadsave

    Returns the name of the newest save slot (the save slot with the most
    recent modification time), or None if there are no (matching) saves.

    If `regexp` exists, only slots that begin with `regexp` are returned.
    i    N(
   t   newest_slot_cacheR   t   unknownR   Rl   R%   R•   R–   R   R   (   R™   Rœ   t	   max_mtimeR›   R6   R“   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   newest_slot÷  s     

c         C   s   t  |  ƒ j ƒ  S(   se   
    :doc: loadsave

    Returns the modification time for `slot`, or None if the slot is empty.
    (   R   R   (   Rp   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt
   slot_mtime  s    c         C   s   t  |  ƒ j ƒ  S(   sl   
    :doc: loadsave

    Returns the json information for `slotname`, or None if the slot is
    empty.
    (   R   R‘   (   Rp   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt	   slot_json$  s    c         C   s   t  |  ƒ j ƒ  S(   s„   
    :doc: loadsave

    Returns a display that can be used as the screenshot for `slotname`,
    or None if the slot is empty.
    (   R   Rh   (   Rp   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   slot_screenshot/  s    c         C   s$   t  |  ƒ } | j ƒ  r t St Sd S(   sd   
    :doc: loadsave

    Returns true if `filename` exists as a save slot, and False otherwise.
    N(   R   R   Ry   Rb   (   R[   t   testR’   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   can_load:  s    c         C   s2   t  t j |  ƒ ƒ \ } } | j | d d ƒd S(   s–   
    :doc: loadsave

    Loads the game state from the save slot `filename`. If the file is loaded
    successfully, this function never returns.
    t   labelt   _after_loadN(   R   Rl   t   loadt   unfreeze(   R[   R>   R?   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRª   I  s    c         C   s   t  j |  ƒ t |  ƒ d S(   sH   
    :doc: loadsave

    Deletes the save slot with the given name.
    N(   Rl   RG   Ro   (   R[   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   unlink_saveU  s    c         C   s(   t  j |  | ƒ t |  ƒ t | ƒ d S(   sm   
    :doc: loadsave

    Renames a save from `old` to `new`. (Does nothing if `old` does not
    exist.)
    N(   Rl   RH   Ro   (   RI   RJ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   rename_save`  s    
c         C   s   t  j |  | ƒ t | ƒ d S(   sl   
    :doc: loadsave

    Copies the save at `old` to `new`. (Does nothing if `old` does not
    exist.)
    N(   Rl   t   copyRo   (   RI   RJ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt	   copy_saven  s    c         C   sJ   xC t  | d d d ƒ D]+ } t |  t | ƒ |  t | d ƒ ƒ q Wd S(   s  
    :doc: loadsave

    Rotates the first `count` saves beginning with `name`.

    For example, if the name is auto- and the count is 10, then
    auto-9 will be renamed to auto-10, auto-8 will be renamed to auto-9,
    and so on until auto-1 is renamed to auto-2.
    i   i    iÿÿÿÿN(   t   rangeR­   R!   (   t   namet   countR6   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRt   z  s    R    t   Cachec           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   s?   
    This represents cached information about a save slot.
    c         C   s   | |  _  |  j ƒ  d  S(   N(   Rp   R‰   (   RQ   Rp   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRR   •  s    	c         C   s   t  |  _ t  |  _ t  |  _ d  S(   N(   R    R“   RO   RM   (   RQ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR‰   ™  s    		c         C   s5   |  j  } | t k r1 t j  |  j ƒ } |  _  n  | S(   N(   R“   R    Rl   Rp   (   RQ   Rœ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR   £  s    	c         C   s5   |  j  } | t k r1 t j  |  j ƒ } |  _  n  | S(   N(   RO   R    Rl   Rp   (   RQ   Rœ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR‘   ¬  s    	c         C   s8   |  j  } | t k r1 t j  |  j ƒ } |  _  n  |  j  S(   N(   RM   R    Rl   Rp   (   RQ   Rœ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRh   µ  s    	(   R'   RD   R_   RR   R‰   R   R‘   Rh   (    (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR³     s   		
				c         C   s9   t  j |  d  ƒ } | d  k r5 t |  ƒ } t  |  <n  | S(   N(   t   cacheR   R   R³   (   Rp   Rœ   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyR   Ã  s    c         C   s+   t  |  ƒ j ƒ  t j ƒ  t j j ƒ  d S(   s,   
    Clears a single slot in the cache.
    N(   R   R‰   RŸ   R   Rw   t   restart_interaction(   Rp   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyRo   Í  s    
c          C   s<   x t  j ƒ  D] }  |  j ƒ  q Wt j ƒ  t j j ƒ  d S(   s"   
    Clears the entire cache.
    N(   R´   t   valuesR‰   RŸ   R   Rw   Rµ   (   R’   (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   clear_cacheÙ  s    
t   blah(9   R   R   t	   cStringIOR    RV   R•   RŠ   R   RT   RE   R   RO   R   Rj   R   R   t   savegame_suffixRB   t	   ExceptionRC   RK   R,   RL   Rb   Rm   t   EventR{   R|   Rz   R}   R…   R„   R”   R   R   Rž   RŸ   R¢   R£   R¤   R¥   R§   Rª   R¬   R­   R¯   Rt   t   SentinelR    R³   R´   R   Ro   R·   Rl   t   savelocationt   FileLocation(    (    (    s]   Z:\home\souce\.local\share\Steam\steamapps\common\Doki Doki Literature Club\renpy\loadsave.pyt   <module>   s`   					|	41
		!	5#	
							0	
		