run_pep8.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:flask-ci 作者: vicenteneto 项目源码 文件源码
def run(self, settings, **options):
        output = open(os.path.join(options[CI.OUTPUT_DIR], Reports.PEP8_REPORT), 'w')

        class JenkinsReport(pep8.BaseReport):
            def error(self, line_number, offset, text, check):
                code = super(JenkinsReport, self).error(line_number, offset, text, check)
                if code:
                    source_line = self.line_offset + line_number
                    output.write('%s:%s:%s: %s\n' % (self.filename, source_line, offset + 1, text))

        pep8_options = {}
        config_file = self.get_config_path(settings, options)
        if config_file is not None:
            pep8_options[Pep8.CONFIG_FILE] = config_file

        pep8_options[Pep8.MAX_LINE_LENGTH] = options[Pep8.PEP8_MAX_LINE_LENGTH]

        pep8style = pep8.StyleGuide(
            parse_argv=False,
            reporter=JenkinsReport,
            **pep8_options)

        pep8style.options.report.start()
        for location in getattr(settings, Settings.PROJECT_APPS, []):
            pep8style.input_dir(os.path.relpath(location))
        pep8style.options.report.stop()

        output.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号