
0_c           @   s   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 d  d l	 m
 Z
 d e f d     YZ d S(   iN(   t   BaseCommandt   CommandError(   t
   OrderedSet(   t   RemovedInDjango20Warningt   Commandc           B   sP   e  Z d  Z e Z d d d g Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   s   Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available. Any standard input is executed as code.t   ipythont   bpythont   pythonc      	   C   s   | 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 | j  d d d d d d d  S(   Ns   --plaint   actiont
   store_truet   destt   plaint   helps   Tells Django to use plain Python, not IPython or bpython. Deprecated, use the `-i python` or `--interface python` option instead.s   --no-startupt
   no_startupsa   When using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.s   -is   --interfacet   choicest	   interfacesc   Specify an interactive interpreter interface. Available options: "ipython", "bpython", and "python"s   -cs	   --commandt   commandsJ   Instead of opening an interactive shell, run a command as Django and exit.(   t   add_argumentt   shells(   t   selft   parser(    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyt   add_arguments   s    c         C   s!   d d l  m } | d g   d  S(   Ni(   t   start_ipythont   argv(   t   IPythonR   (   R   t   optionsR   (    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyR   (   s    c         C   s   d d  l  } | j   d  S(   Ni(   R   t   embed(   R   R   R   (    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyR   ,   s    c   	   	   B   sc  d d  l  } i  } y d d  l } Wn e k
 r5 nm Xd d  l } | j | j |  j  e | d d  } | d  k	 r d | k r | j	 d  n | j	 d  | d sOx e
 e j j d  e j j d	  g  D]q } | s q n  e j j |  sq n  y3 e |  ! } e | j   | d
  | UWd  QXWq e k
 rGq Xq Wn  | j d |  d  S(   Nit   __doc__t    t   libedits   bind ^I rl_completes   tab:completeR   t   PYTHONSTARTUPs   ~/.pythonrc.pyt   exect   local(   t   codet   readlinet   ImportErrort   rlcompletert   set_completert	   Completert   completet   getattrt   Nonet   parse_and_bindR   t   ost   environt   gett   patht
   expandusert   isfilet   opent   compilet   readt	   NameErrort   interact(	   R   R   R!   t   imported_objectsR"   R$   t   readline_doct   pythonrct   handle(    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyR   0   s0    
1$c         J   s   | d r' e  j d e  d | d <n  | d rA | d d  Ud  Se j d k r e j e j g g  g  d  d r e j j   d  Ud  S| d r | d g n |  j } x9 | D]1 } y e	 |  |  |  SWq e
 k
 r q Xq We d j |    d  S(	   NR   sX   The --plain option is deprecated in favor of the -i python or --interface python option.R   R   R   t   win32i    s   Couldn't import {} interface.(   t   warningst   warnR   t   syst   platformt   selectt   stdinR3   R   R(   R#   R   t   format(   R   R   t   available_shellst   shell(    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyR9   U   s$    

1 (   t   __name__t
   __module__R   t   Falset   requires_system_checksR   R   R   R   R   R9   (    (    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyR      s   				%(   R+   R?   R=   R;   t   django.core.managementR    R   t   django.utils.datastructuresR   t   django.utils.deprecationR   R   (    (    (    sG   /tmp/pip-unpacked-wheel-BAJOf3/django/core/management/commands/shell.pyt   <module>   s   