'Replace tab with space within ``line`` while respecting quoted substrings'

def process_line(self, line):

    newline = []
    in_quote = False
    lastchar = None
    for char in line:
        if ((char == self.quotechar) and ((self.escapechar is None) or (lastchar != self.escapechar))):
            in_quote = (not in_quote)
        if ((char == ' DCTB ') and (not in_quote)):
            char = '    '
        lastchar = char
        newline.append(char)
    return ''.join(newline)
