a
    6^i,                     @   s  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Zd dlZd dlZd dlZzd dlZe  W n ey   Y n0 i Zi Zh dZG dd dejZdd Zd	d
 Zdd Z dd Z!dddZ"dd Z#dd Z$dd Z%dddZ&da'dd Z(dS )    )divisionabsolute_importwith_statementprint_functionunicode_literals)PY2
basestringbchrbordchropenpystrrangeroundstrtobytesunicodeN>   compileZmerge_stringsZadd_fromc                   @   s2   e Zd ZdZdddZdd Zdd	 Zd
d ZdS )ArgumentParserz
    Creates an argument parser that is capable of parsing the standard Ren'Py
    arguments, as well as arguments that are specific to a sub-command.
    TNc              	   C   s  | | _ tjj| ddd dtt}|rP| jddd | jdd	| d
 d n,| jddddd | jdd	| d
 ddd | jdddddd | jddddtddd | jddt	j
dd  | jd!d"d#d$d% | jd&d"d'd( | jd)d"d*tjd% | jd+d"d,d( | jd-d.d"dd/d0 | jd1d2d3}|jd4dd5d6d7 |jd8d"dd9d: |jd;d"dd<d: |r| jd=d>d?d@d( t	jjj}| dA||| _ dS )Ba4  
        Creates an argument parser.

        `second_pass`
            True if this is the second pass through argument parsing. (The pass
            that parses sub-commands.)

        `description`
            If supplied, this will be used as a description of the subcommand
            to run.
        zThe Ren'Py visual novel engine.F)descriptionZadd_helpz, basedirzuThe base directory containing of the project to run. This defaults to the directory containing the Ren'Py executable.)helpcommandz0The command to execute. Available commands are: z. Defaults to 'run'. ?)defaultnargsr   run)r   r   r   z	--savedirsavedirNZ	DIRECTORYz9The directory where saves and persistent data are placed.)destr   metavarr   z--tracetracestorer   ZLEVELzIThe level of trace Ren'Py will log to trace.txt. (1=per-call, 2=per-line))r   actionr   typer    r   z	--versionversionz&Displays the version of Ren'Py in use.)r#   r%   r   z	--compile
store_truer   z;Forces all .rpy scripts to be recompiled before proceeding.)r#   r   r   z--keep-orphan-rpycz=Prevents the compile command from deleting orphan rpyc files.)r#   r   z--lintlintz--errors-in-editorz'Causes errors to open in a text editor.z--safe-modeZ	safe_modezOForces Ren'Py to start in safe mode, allowing the player to configure graphics.r   r#   r   r   zJSON dump argumentsz|Ren'Py can dump information about the game to a JSON file. These options let you select the file, and choose what is dumped.r   z--json-dumpZFILEzThe name of the JSON file.)r#   r    r   z--json-dump-privatez0Include private names. (Names beginning with _.))r#   r   r   z--json-dump-commonz.Include names defined in the common directory.z-hz--helpr   z'Displays this help message, then exits.z{0} command arguments)groupargparser   __init__joinsortedcommandsadd_argumentintrenpyr%   ZSUPPRESSZadd_argument_groupgameargsr   format)selfZsecond_passr   require_commandZcommand_namesdumpr    r9   5C:\Users\PahaGest\Downloads\Selene\renpy\arguments.pyr,   >   s    


zArgumentParser.__init__c                 O   s<   | j | u r&tjj| g|R i | n| j j|i | d S )N)r*   r+   r   r0   )r6   r4   kwargsr9   r9   r:   r0      s    
zArgumentParser.add_argumentc                 O   sB   t jj| g|R i |}|jtv r*d|_tjddr>d|_|S NTr   F)	r+   r   
parse_argsr   compile_commandsr   r2   sessionget)r6   r4   r;   rvr9   r9   r:   r=      s    
zArgumentParser.parse_argsc                 O   sJ   t jj| g|R i |\}}|jtv r.d|_tjddrBd|_||fS r<   )	r+   r   parse_known_argsr   r>   r   r2   r?   r@   )r6   r4   r;   restr9   r9   r:   rB      s    
zArgumentParser.parse_known_args)TNT)__name__
__module____qualname____doc__r,   r0   r=   rB   r9   r9   r9   r:   r   8   s
   
Vr   c                  C   s   t ddd} | jdddddd | jd	d
dddd | jddddd |   }tj_|jrf|jtj_|jrtdtj	_
|jrdtj	_dS )zO
    The default command, that (when called) leads to normal game startup.
    z"Runs the current project normally.F)r   r7   z--profile-displayprofile_displayr&   zNIf present, Ren'Py will report the amount of time it takes to draw the screen.r(   z--debug-image-cachedebug_image_cachezRIf present, Ren'Py will log information regarding the contents of the image cache.z--warpwarpNzqThis takes as an argument a filename:linenumber pair, and tries to warp to the statement before that line number.)r   r   r   T)r   r0   r=   r2   r3   r4   rJ   Z	warp_specrH   configprofilerI   )apr4   r9   r9   r:   r      s*    
r   c                   C   s   t d dS )z?
    This command forces the game script to be recompiled.
    Recompiles the game script.Ftakes_no_argumentsr9   r9   r9   r:   r      s    r   c                   C   s   t d dS )z>
    This command is used to quit without doing anything.
    rN   FrO   r9   r9   r9   r:   quit   s    rQ   c                   C   s    t d tjj  dtj_dS )z=
    This command is used to delete the persistent data.
    zDeletes the persistent data.F)rP   r2   ZloadsavelocationZunlink_persistentZ
persistentZshould_save_persistentr9   r9   r9   r:   rmpersistent   s    rS   Fc                 C   s   |t | < |t| < dS )a  
    Registers a command that can be invoked when Ren'Py is run on the command
    line. When the command is run, `function` is called with no arguments.

    If `function` needs to take additional command-line arguments, it should
    instantiate a renpy.arguments.ArgumentParser(), and then call parse_args
    on it. Otherwise, it should call renpy.arguments.takes_no_arguments().

    If `function` returns true, Ren'Py startup proceeds normally. Otherwise,
    Ren'Py will terminate when function() returns.

    `uses_display`
        If true, Ren'Py will initialize the display. If False, Ren'Py will
        use dummy video and audio drivers.
    N)r/   display)namefunctionZuses_displayr9   r9   r:   register_command   s    rW   c                  C   s"   t   tddd} |  \}}|S )z
    Called during bootstrap to perform an initial parse of the arguments, ignoring
    unknown arguments. Returns the parsed arguments, and a list of unknown arguments.
    F)r7   )clean_epic_argumentsr   rB   )rM   r4   Z_restr9   r9   r:   	bootstrap  s    rY   c                   C   s<   t dtd t dtjj t dt t dt t dt dS )z9
    Called before init, to set up argument parsing.
    r   Tr'   r   rS   rQ   N)rW   r   r2   r'   r   rS   rQ   r9   r9   r9   r:   pre_init  s
    

rZ   c                  C   sh   t jjj} | dkr t jjjr d} | tvr:t d|  t	|  s^t
jdd t
jdd t|   S )z
    Called after init, but before the game starts. This parses a command
    and its arguments. It then runs the command function, and returns True
    if execution should continue and False otherwise.
    r   r'   zCommand {0} is unknown.ZSDL_AUDIODRIVERdummySDL_VIDEODRIVER)r2   r3   r4   r   r'   r/   r   errorr5   rT   osenviron
setdefault)r   r9   r9   r:   	post_init"  s    
ra   c                 C   s   t | d  dS )z;
    Used to report that a command takes no arguments.
    r)   N)r   r=   r)   r9   r9   r:   rP   8  s    rP   c                  C   sJ   t jdd  D ]} |  dr q*qd S t jdd  at jd gt _d S )N   z	-epicapp=r   )sysargvlower
startswithepic_arguments)ir9   r9   r:   rX   F  s    rX   )F)N))
__future__r   r   r   r   r   renpy.compatr   r   r	   r
   r   r   r   r   r   r   r   r   r+   r^   rc   r2   site_renpy_argv_emulation	Exceptionr/   rT   r>   r   r   r   rQ   rS   rW   rY   rZ   ra   rP   rg   rX   r9   r9   r9   r:   <module>   s2   8y!



