ó
ø¢TQc           @   sF   d  d l  Z  d  d l m Z d  d l m Z d e f d „  ƒ  YZ d S(   iÿÿÿÿN(   t   NoArgsCommand(   t   make_optiont   Commandc           B   s™   e  Z d  d g Z e j e d d d d d d d ƒe d	 d
 d d d d d e d d d d ƒf Z d Z e Z d „  Z	 d „  Z
 d d „ Z d „  Z RS(   t   ipythont   bpythons   --plaint   actiont
   store_truet   destt   plaint   helps9   Tells Django to use plain Python, not IPython or bpython.s   -is   --interfacet   storet   typet   choicet   choicest	   interfacesX   Specify an interactive interpreter interface. Available options: "ipython" and "bpython"sd   Runs a Python interactive interpreter. Tries to use IPython or bpython, if one of them is available.c         C   sw   y d d l  m } | ƒ  WnU t k
 rr y- d d l m } | d g  ƒ } | j ƒ  Wqs t k
 rn ‚  qs Xn Xd  S(   Niÿÿÿÿ(   t   embed(   t   IPShellt   argv(   t   IPythonR   t   ImportErrort   IPython.ShellR   t   mainloop(   t   selfR   R   t   shell(    (    s>   ../Django//lib/python/django/core/management/commands/shell.pyR      s    c         C   s   d d  l  } | j ƒ  d  S(   Niÿÿÿÿ(   R   R   (   R   R   (    (    s>   ../Django//lib/python/django/core/management/commands/shell.pyR   $   s    c         C   s[   | r | g n |  j  } x6 | D]. } y t |  | ƒ ƒ  SWq t k
 rL q Xq Wt ‚ d  S(   N(   t   shellst   getattrR   (   R   R   t   available_shells(    (    s>   ../Django//lib/python/django/core/management/commands/shell.pyt	   run_shell(   s    c      
   J   sˆ  d d l  m } | ƒ  | j d e ƒ } | j d d  ƒ } y# | rM e ‚ n  |  j d | ƒ Wn#e k
 rƒd d  l } i  } y d d  l } Wn e k
 r£ n3 Xd d  l	 } | j
 | j | ƒ j ƒ | j d ƒ | spx‘ e j j d ƒ e j j d ƒ f D]h }	 |	 re j j |	 ƒ ry3 e |	 ƒ ! }
 e |
 j ƒ  |	 d	 ƒ d  UWd  QXWqie k
 reqiXqqWn  | j d
 | ƒ n Xd  S(   Niÿÿÿÿ(   t
   get_modelsR   R   R   s   tab:completet   PYTHONSTARTUPs   ~/.pythonrc.pyt   exect   local(   t   django.db.models.loadingR   t   gett   Falset   NoneR   R   t   codet   readlinet   rlcompletert   set_completert	   Completert   completet   parse_and_bindt   ost   environt   patht
   expandusert   isfilet   opent   compilet   readt	   NameErrort   interact(   R   t   optionsR   t	   use_plainR   R$   t   imported_objectsR%   R&   t   pythonrct   handle(    (    s>   ../Django//lib/python/django/core/management/commands/shell.pyt   handle_noargs2   s8    	$N(   t   __name__t
   __module__R   R    t   option_listR   R	   R"   t   requires_model_validationR   R   R#   R   R:   (    (    (    s>   ../Django//lib/python/django/core/management/commands/shell.pyR      s   		
(   R+   t   django.core.management.baseR    t   optparseR   R   (    (    (    s>   ../Django//lib/python/django/core/management/commands/shell.pyt   <module>   s   