o 3a@sPddlZddlZddlZddlZddlmZmZddlmZGdddeZ dS)N) BaseCommand CommandError) OrderedSetc@sDeZdZdZgZgdZddZddZddZd d Z d 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.)ipythonbpythonpythoncCs8|jdddd|jdd|jdd|jd d d d dS) Nz --no-startup store_truezaWhen using plain Python, ignore the PYTHONSTARTUP environment variable and ~/.pythonrc.py script.)actionhelpz-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_argumentshells)selfparserrG/usr/lib/python3/dist-packages/django/core/management/commands/shell.py add_argumentss zCommand.add_argumentscCsddlm}|gddS)Nr) start_ipython)argv)IPythonr)roptionsrrrrr"s zCommand.ipythoncCsddl}|dS)Nr)rembed)rrrrrrr&s zCommand.bpythonc Cs&ddl}i}zddl}Wn tyYn'wddl}|||jt|dd}|dur7d|vr7|dn|d|dst t j dt j d gD]<}|sSqNt j |sZqNt| }|} Wdn1smwYz tt| |d |WqNtytYqNw|j|d dS) Nr__doc__libeditzbind ^I rl_completez tab:complete no_startup PYTHONSTARTUPz~/.pythonrc.pyexec)local)codereadline ImportError rlcompleter set_completer Completercompletegetattrparse_and_bindrosenvirongetpath expanduserisfileopenreadrcompile Exception traceback print_excinteract) rrr imported_objectsr!r# readline_docpythonrchandle pythonrc_coderrrr*s8           zCommand.pythonc Ks|drt|dtdStjdkr/tjs/ttjgggddr/ttjtdS|dr8|dgn|j}|D]}z t |||WSt yRYq=wt d |)Ncommandwin32r interfacezCouldn't import {} interface.) rglobalssysplatformstdinisattyselectr0rr'r"rformat)rravailable_shellsshellrrrr9Ts, zCommand.handleN) __name__ __module__ __qualname__r requires_system_checksrrrrrr9rrrrr s *r) r)rCr?r3django.core.managementrrdjango.utils.datastructuresrrrrrrs