
    df                     ^    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e          Z	dS )    N)BaseCommandCommandError)
OrderedSetc                   <    e Zd ZdZg Zg dZd Zd Zd Zd Z	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                     |                     ddd           |                     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parsers     aD:\Python Project\djangoTemplates\venv\Lib\site-packages\django/core/management/commands/shell.pyadd_argumentszCommand.add_arguments   s    6	 	 	
 	
 	
 	K5 	 	
 	
 	
 		 	 	
 	
 	
 	
 	
    c                 *    ddl m}  |g            d S )Nr   )start_ipython)argv)IPythonr   )r   optionsr   s      r   r   zCommand.ipython/   s-    ))))))2r   c                 6    dd l }|                                 d S )Nr   )r	   embed)r   r   r	   s      r   r	   zCommand.bpython4   s    r   c                 p   dd l }i }|d         st          t          j                            d          t          j                            d          g          D ]}|st          j                            |          s%t          |          5 }|	                                }d d d            n# 1 swxY w Y   	 t          t          ||d          |           # t          $ r t          j                     Y w xY w	 t          j        }	  |             nB# t          $ r% t#          d           t          j                     Y nw xY w# t$          $ r Y nw xY w	 dd l}dd l}	|                    |	                    |          j                   n# t0          $ r Y nw xY w|                    |           d S )Nr   
no_startup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__printAttributeErrorreadlinerlcompleterset_completer	CompletercompleteImportErrorinteract)
r   r   r#   imported_objectspythonrchandlepythonrc_codehookr4   r5   s
             r   r
   zCommand.python9   sL     |$ 	*&00"'2D2DEU2V2VW  * *   w~~h// (^^ 2v$*KKMMM2 2 2 2 2 2 2 2 2 2 2 2 2 2 2*&AACSTTTT  * * *')))))*	&*D& & & & >???#%%%%%&  	 	 	 D	 	OOO"";#8#89I#J#J#STTTT 	 	 	D	 	,-----sZ   B//B3	6B3	;CC;:C;?E	 
D ,EE	
EE5F 
FFc                 N   |d         r$t          |d         t                                 d S t          j        dk    rt          j                                        sbt          j        t          j        gg g d          d         r:t          t          j                                        t                                 d S |d         r	|d         gn| j        }|D ]-}	  t          | |          |          c S # t          $ r Y *w xY wt          d                    |                    )Ncommandwin32r   	interfacezCouldn't import {} interface.)r!   globalsr0   platformstdinisattyselectr+   r   getattrr9   r   format)r   r   available_shellsshells       r   r=   zCommand.handler   s0   9 	#WYY///F
 LG##I$$&& $syk2r155a8 $ !!799---F '.k&:KW[!"" 	 & 	 	E+wtU++G44444   :AA%HHIIIs   C55
DDN)__name__
__module____qualname__r   requires_system_checksr   r   r   r	   r
   r=    r   r   r   r   
   s        	 	  ---F
 
 
6  
  
7. 7. 7.rJ J J J Jr   r   )
r$   rH   r0   r.   django.core.managementr   r   django.utils.datastructuresr   r   rQ   r   r   <module>rT      s    				  



     < < < < < < < < 2 2 2 2 2 2AJ AJ AJ AJ AJk AJ AJ AJ AJ AJr   