a
    V$c%                     @   s8  d dl mZmZmZmZmZ d dlmZmZm	Z	m
Z
mZmZmZmZmZmZmZm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e pdZejZejZerej Z!e"e e#d e!e_ dd Z$e$e_#ee_ee_d dl%a&G dd	 d	ej'Z(d
d Z)e)  da*da+dd Z,dd Z-dd Z.dd Z/dd Z0dS )    )divisionabsolute_importwith_statementprint_functionunicode_literals)PY2
basestringbchrbordchropenpystrrangeroundstrtobytesunicode)OptionalNutf-8c                 C   s   dS )za
    This is install in sys to prevent games from trying to change the default
    encoding.
    N )namer   r   renpy/bootstrap.py_setdefaultencoding0   s    r   c                   @   s*   e Zd ZdZdd Zd	ddZdd ZdS )
NullFilezB
    This file raises an error on input, and IOError on read.
    c                 C   s   d S Nr   )selfsr   r   r   writeD   s    zNullFile.writeNc                 C   s   t dd S )NzNot implemented.)IOError)r   lengthr   r   r   readG   s    zNullFile.readc                 C   s   d S r   r   )r   r   r   r   flushJ   s    zNullFile.flush)N)__name__
__module____qualname____doc__r   r    r!   r   r   r   r   r   ?   s   
r   c                   C   s\   zDt jd u st j dk r"t t _t jd u s:t j dk rBt t _W n tyV   Y n0 d S )Nr   )sysstderrfilenor   stdout	Exceptionr   r   r   r   
null_filesN   s    r+   c                 C   s0   t j| jj}td|| j| jj	| t
S )Nz{} {} {} {}
)ospathbasenamef_codeco_filename
trace_filer   formatf_linenoco_nametrace_local)frameeventargfnr   r   r   trace_functiona   s    r:   c                 C   s0   t ddddda| dkrtand att d S )Nz	trace.txtw   r   )	bufferingencoding)r   r1   r:   r5   r&   settrace)levelr   r   r   enable_traceg   s
    rA   c                 C   s   t d|   dS )z)
    os.start compatibility for mac.
    zopen N)r,   system)r9   r   r   r   	mac_startu   s    rC   c                 O   s   dS )zE
    Fix an issue where the __del__ method of popen doesn't wor,
    Nr   )r   argskwargsr   r   r   	popen_del|   s    rF   c              
   C   s  dd l add latjdddkr*tjd= t| ts>t| t} tj	
| d ri }t| d d.}t| | d d}t|| W d    n1 s0    Y  | D ] \}}|tjvrt|tj|< qtj	d}d	|v r|d |d	d
  }tj	
|d ri }t|d d.}t| |d d}t|| W d    n1 sN0    Y  | D ]$\}}|tjvr`t|tj|< q`tj	tjd }|ddkr|d |d }dd latj }|jrt|j |jrtj	|j}	t|	ts|	t}	n| }	tj	
|	s:tjd|	f  td tjrdtj	
|	d sdt |	d d t!"|	|}
tj	#d|	 tj$rt%t_&|	'drdt_(z dd l)}dtj*vr|+  W n* t,y   t-d.|tjd  Y n0 |j/dkrtj0sdd l1atj2j34|	|
 zdd l5}W n* t,yL   t-d.|tjd  Y n0 dd lat6  tj78  d }z|d u rd}z~|tj9_:| tj;_<|	tj;_|
tj;_=g tj;_:tjrtjd tj;_>n|	tj;_>tj	
tj;j>st?tj;j>d tj@@  d}W qp tAy    Y n tj9jBy4   tC  d }Y n tj9jDy } zv|jE}|jFrtGtdrtHItjJgtjdd    n2tKrtHItjLdgtj  ntHItjLgtj  W Y d }~nPd }~0  tj9jMy   Y n2 t,y } ztjNO| W Y d }~n
d }~0 0 qpt| W dtjv r<ttPtjd  tj2jQQd  tj2jRjST  tj2jUrntj2jUT  tjVjVT  tjWstXtHjI_Ynndtjv rttPtjd  tj2jQQd  tj2jRjST  tj2jUrtj2jUT  tjVjVT  tjWstXtHjI_Y0 d S )Nr   SDL_VIDEODRIVER windibz/environment.txtrexec
renpy_basez.app   rb.z-Base directory %r does not exist. Giving up.
r<   z/gamei  zContents/Resources/autorunTpygamea%  Could not import pygame_sdl2. Please ensure that this program has been built
and unpacked properly. Also, make sure that the directories containing
this program do not contain : or ; in their names.

You may be using a system install of python. Please run {0}.sh,
{0}.exe, or {0}.app instead.
)filerunzCould not import _renpy. Please ensure that this program has been built
and unpacked properly.

You may be using a system install of python. Please run {0}.sh,
{0}.exe, or {0}.app instead.
ANDROID_PUBLICrenpy_executablez-EORENPY_SHUTDOWN_TRACE)Zrenpy.configrenpy	renpy.logr,   environget
isinstancer   
FSENCODINGr-   existsr   compiler    rK   itemsabspathfindr.   r&   argvrenpy.arguments	arguments	bootstraptracerA   basedirdecoder'   r   exitandroidmkdir__main__path_to_gamedirinsert	macintoshrC   	startfileendswithmacapppygame_sdl2modulesimport_as_pygamer*   printr2   commandmobilerenpy.display.presplashdisplay	presplashstart_renpy
import_allloaderinit_importergamerD   configrL   gamedirlogdirmakedirsmainKeyboardInterruptUtterRestartException
reload_allQuitExceptionstatusrelaunchhasattr
subprocessPopenrU   r   
executableParseErrorExceptionerrorreport_exceptionintttsimcachequitdrawaudio
emscriptenrF   __del__)rL   evarsfcodekvalt_pathr   rD   rh   r   rt   r~   exit_statuser   r   r   rf      s   

(

*


	



(


rf   )1
__future__r   r   r   r   r   renpy.compatr   r   r	   r
   r   r   r   r   r   r   r   r   typingr   r,   r&   r   iorm   getfilesystemencodingr]   r)   
old_stdoutr'   
old_stderrr   Zsys_executablereloadsetdefaultencodingr   renpy.errorrX   IOBaser   r+   r1   r5   r:   rA   rC   rF   rf   r   r   r   r   <module>   s<   8
