environment/lib/python2.7/site-packages/IPython/frontend/qt/console/ansi_code_processor.py
def split_string(self, string):
        """ Yields substrings for which the same escape code applies.
        """
        self.actions = []
        start = 0

        # strings ending with \r are assumed to be ending in \r\n since
        # \n is appended to output strings automatically.  Accounting
        # for that, here.
        last_char = '\n' if len(string) > 0 and string[-1] == '\n' else None
        string = string[:-1] if last_char is not None else string

        for match in ANSI_OR_SPECIAL_PATTERN.finditer(string):
            raw = string[start:match.start()]
            substring = SPECIAL_PATTERN.sub(self._replace_special, raw)
            if substring or self.actions:
                yield substring
                self.actions = []
            start = match.end()

            groups = filter(lambda x: x is not None, match.groups())
            g0 = groups[0]
            if g0 == '\a':
                self.actions.append(BeepAction('beep'))
                yield None
                self.actions = []
            elif g0 == '\r':
                self.actions.append(CarriageReturnAction('carriage-return'))
                yield None
                self.actions = []
            elif g0 == '\b':
                self.actions.append(BackSpaceAction('backspace'))
                yield None
                self.actions = []
            elif g0 == '\n' or g0 == '\r\n':
                self.actions.append(NewLineAction('newline'))
                yield g0
                self.actions = []
            else:
                params = [ param for param in groups[1].split(';') if param ]
                if g0.startswith('['):
                    # Case 1: CSI code.
                    try:
                        params = map(int, params)
                    except ValueError:
                        # Silently discard badly formed codes.
                        pass
                    else:
                        self.set_csi_code(groups[2], params)

                elif g0.startswith(']'):
                    # Case 2: OSC code.
                    self.set_osc_code(params)

        raw = string[start:]
        substring = SPECIAL_PATTERN.sub(self._replace_special, raw)
        if substring or self.actions:
            yield substring

        if last_char is not None:
            self.actions.append(NewLineAction('newline'))
            yield last_char
def split_string(self, string):
        self.actions = []
        start = 0

        # strings ending with \r are assumed to be ending in \r\n since
        # \n is appended to output strings automatically.  Accounting
        # for that, here.
        last_char = '\n' if len(string) > 0 and string[-1] == '\n' else None
        string = string[:-1] if last_char is not None else string

        for match in ANSI_OR_SPECIAL_PATTERN.finditer(string):
            raw = string[start:match.start()]
            substring = SPECIAL_PATTERN.sub(self._replace_special, raw)
            if substring or self.actions:
                yield substring
                self.actions = []
            start = match.end()

            groups = filter(lambda x: x is not None, match.groups())
            g0 = groups[0]
            if g0 == '\a':
                self.actions.append(BeepAction('beep'))
                yield None
                self.actions = []
            elif g0 == '\r':
                self.actions.append(CarriageReturnAction('carriage-return'))
                yield None
                self.actions = []
            elif g0 == '\b':
                self.actions.append(BackSpaceAction('backspace'))
                yield None
                self.actions = []
            elif g0 == '\n' or g0 == '\r\n':
                self.actions.append(NewLineAction('newline'))
                yield g0
                self.actions = []
            else:
                params = [ param for param in groups[1].split(';') if param ]
                if g0.startswith('['):
                    # Case 1: CSI code.
                    try:
                        params = map(int, params)
                    except ValueError:
                        # Silently discard badly formed codes.
                        pass
                    else:
                        self.set_csi_code(groups[2], params)

                elif g0.startswith(']'):
                    # Case 2: OSC code.
                    self.set_osc_code(params)

        raw = string[start:]
        substring = SPECIAL_PATTERN.sub(self._replace_special, raw)
        if substring or self.actions:
            yield substring

        if last_char is not None:
            self.actions.append(NewLineAction('newline'))
            yield last_char
def split_string ( self , string ) : self . actions = [ ] start = 0 # strings ending with \r are assumed to be ending in \r\n since # \n is appended to output strings automatically.  Accounting # for that, here. last_char = '\n' if len ( string ) > 0 and string [ - 1 ] == '\n' else None string = string [ : - 1 ] if last_char is not None else string for match in ANSI_OR_SPECIAL_PATTERN . finditer ( string ) : raw = string [ start : match . start ( ) ] substring = SPECIAL_PATTERN . sub ( self . _replace_special , raw ) if substring or self . actions : yield substring self . actions = [ ] start = match . end ( ) groups = filter ( lambda x : x is not None , match . groups ( ) ) g0 = groups [ 0 ] if g0 == '\a' : self . actions . append ( BeepAction ( 'beep' ) ) yield None self . actions = [ ] elif g0 == '\r' : self . actions . append ( CarriageReturnAction ( 'carriage-return' ) ) yield None self . actions = [ ] elif g0 == '\b' : self . actions . append ( BackSpaceAction ( 'backspace' ) ) yield None self . actions = [ ] elif g0 == '\n' or g0 == '\r\n' : self . actions . append ( NewLineAction ( 'newline' ) ) yield g0 self . actions = [ ] else : params = [ param for param in groups [ 1 ] . split ( ';' ) if param ] if g0 . startswith ( '[' ) : # Case 1: CSI code. try : params = map ( int , params ) except ValueError : # Silently discard badly formed codes. pass else : self . set_csi_code ( groups [ 2 ] , params ) elif g0 . startswith ( ']' ) : # Case 2: OSC code. self . set_osc_code ( params ) raw = string [ start : ] substring = SPECIAL_PATTERN . sub ( self . _replace_special , raw ) if substring or self . actions : yield substring if last_char is not None : self . actions . append ( NewLineAction ( 'newline' ) ) yield last_char
Yields substrings for which the same escape code applies.
Yields substrings for which the same escape code applies .