def fixline(): if self.use_spaces: for line in lines: yield line.rstrip().expandtabs(self.tab_size) else: for line in lines: match = re.match(r'^(\t*( \t*)+)[^ \t]', line) if match: ws = match.group(1) text = line[len(ws):] yield ws.expandtabs(self.tab_size).replace(' ' * self.tab_size, '\t') + text.rstrip() else: yield line.rstrip()
def fixline(): if self.use_spaces: for line in lines: yield line.rstrip().expandtabs(self.tab_size) else: for line in lines: match = re.match(r'^(\t*( \t*)+)[^ \t]', line) if match: ws = match.group(1) text = line[len(ws):] yield ws.expandtabs(self.tab_size).replace( ' ' * self.tab_size, '\t') + text.rstrip() else: yield line.rstrip()
def detect_ws_before_text(self, file, num, line, indicator, state): if self.use_spaces: if self.is_ws_before_text(line): state.found_ws_begin() self.ui.note('%s (%i): tab character(s)\n' % (file, num)) line_show = ''.join(indicator if c == '\t' else ' ' for c in line) line = line.expandtabs(self.tab_size) self.ui.note(' %s\n %s\n' % (line, line_show)) else: match = self.match_spaces_before_text(line) if match: state.found_ws_begin() self.ui.note('%s (%i): space(s) before text\n' % (file, num)) line = line.expandtabs(self.tab_size) line_show = match.group()[0:-1].replace(' ', indicator).expandtabs(self.tab_size) self.ui.note(' %s\n %s\n' % (line, line_show))
def detect_ws_before_text(self, file, num, line, indicator, state): if self.use_spaces: if self.is_ws_before_text(line): state.found_ws_begin() self.ui.note('%s (%i): tab character(s)\n' % (file, num)) line_show = ''.join(indicator if c == '\t' else ' ' for c in line) line = line.expandtabs(self.tab_size) self.ui.note(' %s\n %s\n' % (line, line_show)) else: match = self.match_spaces_before_text(line) if match: state.found_ws_begin() self.ui.note('%s (%i): space(s) before text\n' % (file, num)) line = line.expandtabs(self.tab_size) line_show = match.group()[0:-1].replace( ' ', indicator).expandtabs(self.tab_size) self.ui.note(' %s\n %s\n' % (line, line_show))