import os
import logging
from lintreview.tools import Tool, run_command, process_quickfix
from lintreview.utils import in_path

log = logging.getLogger(__name__)


class Pep8(Tool):

    name = 'pep8'

    def check_dependencies(self):
        """
        See if pep8 is on the PATH
        """
        return in_path('pep8')

    def match_file(self, filename):
        base = os.path.basename(filename)
        name, ext = os.path.splitext(base)
        return ext == '.py'

    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)
        command = ['pep8', '-r']
        for option, value in self.options.items():
            command += ' --{}={}'.format(option, value)
        command += files
        output = run_command(command, split=True, ignore_error=True)
        if not output:
            log.debug('No pep8 errors found.')
            return False

        process_quickfix(self.problems, output, lambda name: name)

@@ -723,138 +723,451 @@
     
-command = %5B'pep8', '-r'%5D%0A        for option, value in self.options.items():%0A            command += ' --%7B%7D=%7B%7D'.format(option, value
+pep8_options = %5B'exclude',%0A                        'filename',%0A                        'select',%0A                        'ignore',%0A                        'max-line-length'%5D%0A        command = %5B'pep8', '-r'%5D%0A        for option, value in self.options.items():%0A            if option in pep8_options:%0A                command += ' --%7B%7D=%7B%7D'.format(option, value)%0A            else:%0A                log.error('%25s is not a valid option to pep8', option
 )%0A  

Whitelist recognized pep8 options