environment/lib/python2.7/site-packages/IPython/core/interactiveshell.py
def init_readline(self):
        """Command history completion/saving/reloading."""

        if self.readline_use:
            import IPython.utils.rlineimpl as readline

        self.rl_next_input = None
        self.rl_do_indent = False

        if not self.readline_use or not readline.have_readline:
            self.has_readline = False
            self.readline = None
            # Set a number of methods that depend on readline to be no-op
            self.readline_no_record = no_op_context
            self.set_readline_completer = no_op
            self.set_custom_completer = no_op
            if self.readline_use:
                warn('Readline services not available or not loaded.')
        else:
            self.has_readline = True
            self.readline = readline
            sys.modules['readline'] = readline

            # Platform-specific configuration
            if os.name == 'nt':
                # FIXME - check with Frederick to see if we can harmonize
                # naming conventions with pyreadline to avoid this
                # platform-dependent check
                self.readline_startup_hook = readline.set_pre_input_hook
            else:
                self.readline_startup_hook = readline.set_startup_hook

            # Load user's initrc file (readline config)
            # Or if libedit is used, load editrc.
            inputrc_name = os.environ.get('INPUTRC')
            if inputrc_name is None:
                inputrc_name = '.inputrc'
                if readline.uses_libedit:
                    inputrc_name = '.editrc'
                inputrc_name = os.path.join(self.home_dir, inputrc_name)
            if os.path.isfile(inputrc_name):
                try:
                    readline.read_init_file(inputrc_name)
                except:
                    warn('Problems reading readline initialization file <%s>'
                         % inputrc_name)

            # Configure readline according to user's prefs
            # This is only done if GNU readline is being used.  If libedit
            # is being used (as on Leopard) the readline config is
            # not run as the syntax for libedit is different.
            if not readline.uses_libedit:
                for rlcommand in self.readline_parse_and_bind:
                    #print "loading rl:",rlcommand  # dbg
                    readline.parse_and_bind(rlcommand)

            # Remove some chars from the delimiters list.  If we encounter
            # unicode chars, discard them.
            delims = readline.get_completer_delims()
            if not py3compat.PY3:
                delims = delims.encode("ascii", "ignore")
            for d in self.readline_remove_delims:
                delims = delims.replace(d, "")
            delims = delims.replace(ESC_MAGIC, '')
            readline.set_completer_delims(delims)
            # otherwise we end up with a monster history after a while:
            readline.set_history_length(self.history_length)

            self.refill_readline_hist()
            self.readline_no_record = ReadlineNoRecord(self)

        # Configure auto-indent for all platforms
        self.set_autoindent(self.autoindent)
def init_readline(self):
        """Command history completion/saving/reloading."""

        if self.readline_use:
            import IPython.utils.rlineimpl as readline

        self.rl_next_input = None
        self.rl_do_indent = False

        if not self.readline_use or not readline.have_readline:
            self.has_readline = False
            self.readline = None
            # Set a number of methods that depend on readline to be no-op
            self.readline_no_record = no_op_context
            self.set_readline_completer = no_op
            self.set_custom_completer = no_op
            if self.readline_use:
                warn('Readline services not available or not loaded.')
        else:
            self.has_readline = True
            self.readline = readline
            sys.modules['readline'] = readline

            # Platform-specific configuration
            if os.name == 'nt':
                # FIXME - check with Frederick to see if we can harmonize
                # naming conventions with pyreadline to avoid this
                # platform-dependent check
                self.readline_startup_hook = readline.set_pre_input_hook
            else:
                self.readline_startup_hook = readline.set_startup_hook

            # Load user's initrc file (readline config)
            # Or if libedit is used, load editrc.
            inputrc_name = os.environ.get('INPUTRC')
            if inputrc_name is None:
                inputrc_name = '.inputrc'
                if readline.uses_libedit:
                    inputrc_name = '.editrc'
                inputrc_name = os.path.join(self.home_dir, inputrc_name)
            if os.path.isfile(inputrc_name):
                try:
                    readline.read_init_file(inputrc_name)
                except:
                    warn('Problems reading readline initialization file <%s>'
                         % inputrc_name)

            # Configure readline according to user's prefs
            # This is only done if GNU readline is being used.  If libedit
            # is being used (as on Leopard) the readline config is
            # not run as the syntax for libedit is different.
            if not readline.uses_libedit:
                for rlcommand in self.readline_parse_and_bind:
                    #print "loading rl:",rlcommand  # dbg
                    readline.parse_and_bind(rlcommand)

            # Remove some chars from the delimiters list.  If we encounter
            # unicode chars, discard them.
            delims = readline.get_completer_delims()
            if not py3compat.PY3:
                delims = delims.encode("ascii", "ignore")
            for d in self.readline_remove_delims:
                delims = delims.replace(d, "")
            delims = delims.replace(ESC_MAGIC, '')
            readline.set_completer_delims(delims)
            # otherwise we end up with a monster history after a while:
            readline.set_history_length(self.history_length)

            self.refill_readline_hist()
            self.readline_no_record = ReadlineNoRecord(self)

        # Configure auto-indent for all platforms
        self.set_autoindent(self.autoindent)
def init_readline ( self ) : if self . readline_use : import IPython . utils . rlineimpl as readline self . rl_next_input = None self . rl_do_indent = False if not self . readline_use or not readline . have_readline : self . has_readline = False self . readline = None # Set a number of methods that depend on readline to be no-op self . readline_no_record = no_op_context self . set_readline_completer = no_op self . set_custom_completer = no_op if self . readline_use : warn ( 'Readline services not available or not loaded.' ) else : self . has_readline = True self . readline = readline sys . modules [ 'readline' ] = readline # Platform-specific configuration if os . name == 'nt' : # FIXME - check with Frederick to see if we can harmonize # naming conventions with pyreadline to avoid this # platform-dependent check self . readline_startup_hook = readline . set_pre_input_hook else : self . readline_startup_hook = readline . set_startup_hook # Load user's initrc file (readline config) # Or if libedit is used, load editrc. inputrc_name = os . environ . get ( 'INPUTRC' ) if inputrc_name is None : inputrc_name = '.inputrc' if readline . uses_libedit : inputrc_name = '.editrc' inputrc_name = os . path . join ( self . home_dir , inputrc_name ) if os . path . isfile ( inputrc_name ) : try : readline . read_init_file ( inputrc_name ) except : warn ( 'Problems reading readline initialization file <%s>' % inputrc_name ) # Configure readline according to user's prefs # This is only done if GNU readline is being used.  If libedit # is being used (as on Leopard) the readline config is # not run as the syntax for libedit is different. if not readline . uses_libedit : for rlcommand in self . readline_parse_and_bind : #print "loading rl:",rlcommand  # dbg readline . parse_and_bind ( rlcommand ) # Remove some chars from the delimiters list.  If we encounter # unicode chars, discard them. delims = readline . get_completer_delims ( ) if not py3compat . PY3 : delims = delims . encode ( "ascii" , "ignore" ) for d in self . readline_remove_delims : delims = delims . replace ( d , "" ) delims = delims . replace ( ESC_MAGIC , '' ) readline . set_completer_delims ( delims ) # otherwise we end up with a monster history after a while: readline . set_history_length ( self . history_length ) self . refill_readline_hist ( ) self . readline_no_record = ReadlineNoRecord ( self ) # Configure auto-indent for all platforms self . set_autoindent ( self . autoindent )
Command history completion/saving/reloading.
Command history completion / saving / reloading .