예제 #1
0
def test_python_image():
    eq_('python2', tools.python_image(False))
    eq_('python2', tools.python_image(''))
    eq_('python2', tools.python_image('derp'))
    eq_('python2', tools.python_image({}))
    eq_('python2', tools.python_image([]))
    eq_('python2', tools.python_image({'python': 2}))
    eq_('python2', tools.python_image({'python': '2'}))
    eq_('python3', tools.python_image({'python': '3'}))
    eq_('python3', tools.python_image({'python': 3}))
예제 #2
0
 def test_python_image(self):
     self.assertEqual('python2', tools.python_image(False))
     self.assertEqual('python2', tools.python_image(''))
     self.assertEqual('python2', tools.python_image('derp'))
     self.assertEqual('python2', tools.python_image({}))
     self.assertEqual('python2', tools.python_image([]))
     self.assertEqual('python2', tools.python_image({'python': 2}))
     self.assertEqual('python2', tools.python_image({'python': '2'}))
     self.assertEqual('python3', tools.python_image({'python': '3'}))
     self.assertEqual('python3', tools.python_image({'python': 3}))
예제 #3
0
 def test_python_image(self):
     self.assertEqual('python2', tools.python_image(False))
     self.assertEqual('python2', tools.python_image(''))
     self.assertEqual('python2', tools.python_image('derp'))
     self.assertEqual('python2', tools.python_image({}))
     self.assertEqual('python2', tools.python_image([]))
     self.assertEqual('python2', tools.python_image({'python': 2}))
     self.assertEqual('python2', tools.python_image({'python': '2'}))
     self.assertEqual('python3', tools.python_image({'python': '3'}))
     self.assertEqual('python3', tools.python_image({'python': 3}))
예제 #4
0
    def process_files(self, files):
        """
        Run code checks with pep8.
        Only a single process is made for all files
        to save resources.
        """
        log.debug('Processing %s files with %s', files, self.name)
        pep8_options = ['exclude',
                        'filename',
                        'select',
                        'ignore',
                        'max-line-length']
        command = ['pep8', '-r']
        for option, value in self.options.items():
            if option in pep8_options:
                command += [u'--{}'.format(option), value]
        command += files

        image = python_image(self.options)
        output = docker.run(image, command, source_dir=self.base_path)
        if not output:
            log.debug('No pep8 errors found.')
            return False
        output = output.split("\n")

        process_quickfix(self.problems, output, docker.strip_base)
예제 #5
0
    def get_image_name(self, files):
        """Get the image name based on options

        If the `plugin` option is used a custom image will
        be created.
        """
        image = python_image(self.options)
        plugins = self.options.get('plugins', None)
        if not plugins:
            return image
        if not isinstance(plugins, list):
            plugin_type = plugins.__class__.__name__
            error = IssueComment(
                u'The `flake8.plugins` option must be a list got `{}` instead.'.format(
                    plugin_type
                )
            )
            self.problems.add(error)
            return image

        invalid_plugins = [
            p for p in plugins
            if p not in self.ALLOWED_PLUGINS]
        if invalid_plugins:
            error = IssueComment(
                u'The `flake8.plugins` option contained unsupported plugins {}'.format(
                    u', '.join(invalid_plugins)
                )
            )
            self.problems.add(error)
            return image

        container_name = docker.generate_container_name('flake8', files)
        if self.custom_image is None:
            buildlog.info('Installing flake8 plugins')

            docker.run(
                image,
                ['flake8-install', u','.join(plugins)],
                source_dir=self.base_path,
                name=container_name
            )
            docker.commit(container_name)
            docker.rm_container(container_name)
            self.custom_image = container_name
            buildlog.info('Installed flake8 plugins %s', plugins)

        return container_name
예제 #6
0
    def process_files(self, files):
        """
        Run code checks with flake8.
        Only a single process is made for all files
        to save resources.
        """
        log.debug('Processing %s files with %s', len(files), self.name)
        command = self.make_command(files)
        image = python_image(self.options)
        output = docker.run(image, command, source_dir=self.base_path)
        if not output:
            log.debug('No flake8 errors found.')
            return False

        output = output.split("\n")
        process_quickfix(self.problems, output, docker.strip_base)
예제 #7
0
    def process_files(self, files):
        """
        Run code checks with flake8.
        Only a single process is made for all files
        to save resources.
        """
        log.debug('Processing %s files with %s', len(files), self.name)
        command = self.make_command(files)
        image = python_image(self.options)
        output = docker.run(image, command, source_dir=self.base_path)
        if not output:
            log.debug('No flake8 errors found.')
            return False

        output = output.split("\n")
        process_quickfix(self.problems, output, docker.strip_base)
예제 #8
0
파일: pep8.py 프로젝트: jpos15/lint-review
    def process_files(self, files):
        """
        Run code checks with pep8.
        Only a single process is made for all files
        to save resources.
        """
        pep8_options = [
            'exclude', 'filename', 'select', 'ignore', 'max-line-length'
        ]
        command = ['pep8', '-r']
        for option, value in self.options.items():
            if option in pep8_options:
                command += [u'--{}'.format(option), value]
        command += files

        image = python_image(self.options)
        output = docker.run(image, command, source_dir=self.base_path)
        if not output:
            return False
        output = output.split("\n")

        process_quickfix(self.problems, output, docker.strip_base)
예제 #9
0
 def process_fixer(self, files):
     """Run autopep8, as flake8 has no fixer mode.
     """
     command = self.create_fixer_command(files)
     image = python_image(self.options)
     docker.run(image, command, self.base_path)
예제 #10
0
 def process_fixer(self, files):
     """Run autopep8, as flake8 has no fixer mode.
     """
     command = self.create_fixer_command(files)
     image = python_image(self.options)
     docker.run(image, command, self.base_path)