a
    [f                     @   sP   d dl Z d dlZd dlZd dlZd dlmZmZ d dlmZ G dd deZ	dS )    N)BaseCommandCommandError)
OrderedSetc                   @   sD   e Zd ZdZg Zg dZdd Zdd Zdd Zd	d
 Z	dd Z
dS )CommandzRuns a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available. Any standard input is executed as code.)ipythonbpythonpythonc                 C   s8   |j dddd |j dd| jdd |j d	d
dd d S )Nz--no-startup
store_truezaWhen using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.)actionhelpz-iz--interfacezcSpecify an interactive interpreter interface. Available options: "ipython", "bpython", and "python")choicesr   z-cz	--commandzJInstead of opening an interactive shell, run a command as Django and exit.)r   )add_argumentshells)selfparser r   wC:\Users\91910\OneDrive\Desktop\vts_admin_rebuild-master\vts\Lib\site-packages\django/core/management/commands/shell.pyadd_arguments   s     	zCommand.add_argumentsc                 C   s   ddl m} |g d d S )Nr   )start_ipython)argv)ZIPythonr   )r   optionsr   r   r   r   r   /   s    zCommand.ipythonc                 C   s   dd l }|  d S )Nr   )r   embed)r   r   r   r   r   r   r   4   s    zCommand.bpythonc           
   	   C   sD  dd l }i }|d sttjdtjdgD ]z}|s:q0tj|sHq0t|}|	 }W d    n1 sn0    Y  zt
t||d| W q0 ty   t  Y q00 q0z
tj}W n ty   Y n00 z
|  W n" ty   td t  Y n0 z&dd l}dd l}	||	|j W n ty2   Y n0 |j|d d S )Nr   Z
no_startupZPYTHONSTARTUPz~/.pythonrc.pyexecz&Failed calling sys.__interactivehook__)local)coder   osenvirongetpath
expanduserisfileopenreadr   compile	Exception	traceback	print_excsys__interactivehook__AttributeErrorprintreadlinerlcompleterZset_completerZ	CompleterZcompleteImportErrorZinteract)
r   r   r   Zimported_objectsZpythonrchandleZpythonrc_codehookr+   r,   r   r   r   r   9   s@    
&

zCommand.pythonc              	   K   s   |d rt |d t  d S tjdkr^tj s^ttjgg g dd r^t tj t  d S |d rp|d gn| j}|D ],}zt	| ||W   S  t
y   Y qz0 qztd|d S )Ncommandwin32r   Z	interfacezCouldn't import {} interface.)r   globalsr'   platformstdinisattyselectr"   r   getattrr-   r   format)r   r   Zavailable_shellsshellr   r   r   r.   r   s&    zCommand.handleN)__name__
__module____qualname__r   Zrequires_system_checksr   r   r   r   r   r.   r   r   r   r   r   
   s   9r   )
r   r6   r'   r%   Zdjango.core.managementr   r   Zdjango.utils.datastructuresr   r   r   r   r   r   <module>   s   