Exemplo n.º 1
0
 def report_error(instance, line_number, offset, text, check):
     code = text[:4]
     if pep8.ignore_code(code):
         return
     message = re.sub(r'([WE]\d+)', r'[\1] PEP8:', text)
     sourceline = instance.line_offset + line_number
     self.output.write('%s:%s: %s\n' % (instance.filename, sourceline, message))
Exemplo n.º 2
0
 def report_error(self, line_number, offset, text, check):
     """Collect errors."""
     code = text[:4]
     if not pep8.ignore_code(code):
         self.__results.append(
             dict(id=text.split()[0], line=line_number,
                  column=offset + 1, info=text))
Exemplo n.º 3
0
 def report_error(self, line_number, offset, text, check):
     """
     Store the error
     """
     self.file_errors += 1
     error_code = text[0:4]
     if not pep8.ignore_code(error_code):
         self.error_list.append([line_number, offset, error_code, text])
Exemplo n.º 4
0
 def report_error(instance, line_number, offset, text, check):
     code = text[:4]
     if pep8.ignore_code(code):
         return
     sourceline = instance.line_offset + line_number
     self.output.write(
         '%s:%s:%s: %s\n' %
         (instance.filename, sourceline, offset + 1, text))
Exemplo n.º 5
0
 def report_error(instance, line_number, offset, text, check):
     code = text[:4]
     if pep8.ignore_code(code):
         return
     filepath = relpath(instance.filename)
     message = re.sub(r'([WE]\d+)', r'[\1] PEP8:', text)
     sourceline = instance.line_offset + line_number
     self.output.write('%s:%s: %s\n' % (filepath, sourceline, message))
Exemplo n.º 6
0
 def report_error(instance, line_number, offset, text, check):
     code = text[:4]
     if pep8.ignore_code(code):
         return
     filepath = relpath(instance.filename)
     message = re.sub(r"([WE]\d+)", r"[\1] PEP8:", text)
     sourceline = instance.line_offset + line_number
     self.output.write("%s:%s: %s\n" % (filepath, sourceline, message))
Exemplo n.º 7
0
 def report_error(self, line_number, offset, text, check):
     """
     Store the error
     """
     self.file_errors += 1
     error_code = text[0:4]
     if not pep8.ignore_code(error_code):
         self.error_list.append([line_number, offset, error_code, text])
Exemplo n.º 8
0
 def report_error(self, line_number, offset, text, check):
     code = text[:4]
     msg = text[5:]
     if pep8.ignore_code(code):
         return
     if code.startswith('E'):
         messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
     else:
         messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
Exemplo n.º 9
0
 def report_error(self, line_number, offset, text, check):
     """Collect errors."""
     code = text[:4]
     if not pep8.ignore_code(code):
         self.__results.append(
             dict(id=text.split()[0],
                  line=line_number,
                  column=offset + 1,
                  info=text))
Exemplo n.º 10
0
            def report_error(self, line_number, offset, text, check):
                code = text[:4]
                msg = text[5:]

                if pep8.ignore_code(code):
                    return
                elif code.startswith('E'):
                    messages.append(Pep8Error(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
                else:
                    messages.append(Pep8Warning(filename, Dict2Obj(lineno=line_number, col_offset=offset), code, msg))
Exemplo n.º 11
0
            def report_error(self, line_number, offset, text, check):
                code = text[:4]
                msg = text[5:]

                if pep8.ignore_code(code) or (select and code not in select):
                    return
                elif code.startswith('E'):
                    messages.append(Pep8Error(filename, line_number, offset, code, msg))
                else:
                    messages.append(Pep8Warning(filename, line_number, offset, code, msg))
Exemplo n.º 12
0
def checkPep8(currentDocument=None, refresh=True):
    if not commons.canCheckDocument(currentDocument):
        return
    if refresh:
        checkAll(currentDocument, ['checkPep8'],
                 exclude_all=not currentDocument)
    move_cursor = not currentDocument
    currentDocument = currentDocument or kate.activeDocument()
    if currentDocument.isModified():
        kate.gui.popup('You must save the file first', 3,
                        icon='dialog-warning', minTextWidth=200)
        return
    path = unicode(currentDocument.url().path())
    mark_key = '%s-pep8' % unicode(currentDocument.url().path())
    # Check the file for errors with PEP8
    sys.argv = [path]
    pep8.process_options([path])
    checker = StoreErrorsChecker(path)
    checker.check_all()
    errors = checker.get_errors()

    if len(errors) == 0:
        commons.showOk('Pep8 Ok')
        return

    errors_to_show = []
    if IGNORE_PEP8_ERRORS:
        pep8.options.ignore.extend(IGNORE_PEP8_ERRORS)
        pep8.options.ignore = list(set(pep8.options.ignore))
    # Paint errors found
    for error in errors:
        if pep8.ignore_code(error[2]):
            continue
        errors_to_show.append({
            "line": error[0],
            "column": error[1] + 1,
            "filename": path,
            "message": error[3],
            })
    if errors_to_show:
        commons.showErrors('Pep8 Errors:', errors_to_show,
                            mark_key, currentDocument,
                            move_cursor=move_cursor)
    else:
        commons.showOk('Pep8 Ok')
Exemplo n.º 13
0
 def report_error(self, line_number, offset, text, check):
     #XXX: pep8 is a retarded module!
     if pep8.ignore_code(text[:4]):
         self.ignored_errors += 1
     pep8.Checker.report_error(self, line_number, offset, text, check)
Exemplo n.º 14
0
 def report_error(instance, line_number, offset, text, check):
     code = text[:4]
     if pep8.ignore_code(code):
         return
     sourceline = instance.line_offset + line_number
     self.output.write('%s:%s:%s: %s\n' % (instance.filename, sourceline, offset+1, text))