ó
i4Vdc           @   s6   d  d l  Z  d  d l m Z d e f d     YZ d S(   i˙˙˙˙N(   t   BaseCommandt   Commandc           B   sk   e  Z d  Z e Z d d g Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d d	  Z d
   Z RS(   sd   Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available.t   ipythont   bpythonc      	   C   sg   | j  d d d d d d d | j  d d d d d	 d d
 | j  d d d |  j d d d d d  S(   Ns   --plaint   actiont
   store_truet   destt   plaint   helps9   Tells Django to use plain Python, not IPython or bpython.s   --no-startupt
   no_startupsa   When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.s   -is   --interfacet   choicest	   interfacesX   Specify an interactive interpreter interface. Available options: "ipython" and "bpython"(   t   add_argumentt   shells(   t   selft   parser(    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyt   add_arguments   s    c         C   s-   d d l  m } | d g   } | j   d S(   s   Start IPython pre-0.11i˙˙˙˙(   t   IPShellt   argvN(   t   IPython.ShellR   t   mainloop(   R   R   t   shell(    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyt   _ipython_pre_011   s    c         C   s:   d d l  m } | j   } | j d g   | j   d S(   s   Start IPython pre-1.0.0i˙˙˙˙(   t   TerminalIPythonAppR   N(   t   IPython.frontend.terminal.ipappR   t   instancet
   initializet   start(   R   R   t   app(    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyt   _ipython_pre_100   s    c         C   s!   d d l  m } | d g   d S(   s   Start IPython >= 1.0i˙˙˙˙(   t   start_ipythonR   N(   t   IPythonR   (   R   R   (    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyt   _ipython    s    c         C   sV   xC |  j  |  j |  j f D]) } y |   Wn t k
 r= q Xd Sq Wt d   d S(   s   Start any version of IPythonNs
   No IPython(   R    R   R   t   ImportError(   R   t   ip(    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyR   %   s    c         C   s   d d  l  } | j   d  S(   Ni˙˙˙˙(   R   t   embed(   R   R   (    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyR   1   s    c         C   s[   | r | g n |  j  } x6 | D]. } y t |  |    SWq t k
 rL q Xq Wt  d  S(   N(   R   t   getattrR!   (   R   R   t   available_shells(    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyt	   run_shell5   s    c      	   J   sh  y+ | d r e   n  |  j d | d  Wn6e  k
 rcd d  l } i  } y d d  l } Wn e  k
 rp n3 Xd d  l } | j | j |  j  | j d  | d sPx  e	 j
 j d  d f D] } | sŘ qĆ n  e	 j j |  } e	 j j |  sqĆ n  y3 e |  ! } e | j   | d	  | UWd  QXWqĆ e k
 rHqĆ XqĆ Wn  | j d
 |  n Xd  S(   NR   R   R   i˙˙˙˙s   tab:completeR	   t   PYTHONSTARTUPs   ~/.pythonrc.pyt   exect   local(   R!   R&   t   codet   readlinet   rlcompletert   set_completert	   Completert   completet   parse_and_bindt   ost   environt   gett   patht
   expandusert   isfilet   opent   compilet   readt	   NameErrort   interact(   R   t   optionsR*   t   imported_objectsR+   R,   t   pythonrct   handle(    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyR?   ?   s6    
	
$N(   t   __name__t
   __module__R   t   Falset   requires_system_checksR   R   R   R   R    R   R   t   NoneR&   R?   (    (    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyR      s   						
(   R1   t   django.core.management.baseR    R   (    (    (    ss   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/django/core/management/commands/shell.pyt   <module>   s   