コード例 #1
0
ファイル: checkfiles.py プロジェクト: SeanTAllen/dotfiles
                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()
コード例 #2
0
ファイル: checkfiles.py プロジェクト: conner/dotfiles
                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()
コード例 #3
0
ファイル: checkfiles.py プロジェクト: SeanTAllen/dotfiles
    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))
コード例 #4
0
ファイル: checkfiles.py プロジェクト: conner/dotfiles
    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))