ó
r±E^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(   iÿÿÿÿN(   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-4tV8Ix/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-4tV8Ix/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-4tV8Ix/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(   Niÿÿÿÿt   __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-4tV8Ix/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-4tV8Ix/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-4tV8Ix/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-4tV8Ix/django/core/management/commands/shell.pyt   <module>   s   