'Run code analysis'

def run_code_analysis(self, run_pyflakes, run_pep8):

    run_pyflakes = (run_pyflakes and codeanalysis.is_pyflakes_installed())
    run_pep8 = (run_pep8 and (codeanalysis.get_checker_executable('pycodestyle') is not None))
    self.pyflakes_results = []
    self.pep8_results = []
    if self.editor.is_python():
        enc = self.encoding.replace('-guessed', '').replace('-bom', '')
        (source_code, enc) = encoding.encode(self.get_source_code(), enc)
        if run_pyflakes:
            self.pyflakes_results = None
        if run_pep8:
            self.pep8_results = None
        if run_pyflakes:
            self.threadmanager.add_thread(codeanalysis.check_with_pyflakes, self.pyflakes_analysis_finished, source_code, self)
        if run_pep8:
            self.threadmanager.add_thread(codeanalysis.check_with_pep8, self.pep8_analysis_finished, source_code, self)
