예제 #1
0
파일: checker.py 프로젝트: dlfurse/pants
  def check_file(self, filename):
    """Process python file looking for indications of problems.

    :param filename: (str) Python source filename
    :return: (bool) flag indicating failure
    """
    try:
      python_file = PythonFile.parse(filename)
    except SyntaxError as e:
      print('{filename}:SyntaxError: {error}'.format(filename=filename, error=e))
      return True

    # If the user specifies an invalid severity use comment.
    severity = Nit.SEVERITY.get(self.options.severity, Nit.COMMENT)

    should_fail = False
    fail_threshold = Nit.WARNING if self.options.strict else Nit.ERROR

    for i, nit in enumerate(self.get_nits(python_file)):
      if i == 0:
        print()  # Add an extra newline to clean up the output only if we have nits.
      if nit.severity >= severity:
        print('{nit}\n'.format(nit=nit))
      should_fail |= (nit.severity >= fail_threshold)
    return should_fail
예제 #2
0
    def check_file(self, filename):
        """Process python file looking for indications of problems.
    :param filename: (str) Python source filename
    :return: (bool) flag indicating failure
    """
        try:
            python_file = PythonFile.parse(filename)
        except SyntaxError as e:
            print('{filename}:SyntaxError: {error}'.format(filename=filename,
                                                           error=e))
            return True

        # If the user specifies an invalid severity use comment
        severity = Nit.SEVERITY.get(self.options.severity, Nit.COMMENT)

        should_fail = False
        fail_threshold = Nit.WARNING if self.options.strict else Nit.ERROR

        for i, nit in enumerate(self.get_nits(python_file)):
            if i == 0:
                print(
                )  # add an extra newline to clean up the output only if we have nits
            if nit.severity >= severity:
                print('{nit}\n'.format(nit=nit))
            should_fail |= (nit.severity >= fail_threshold)
        return should_fail
예제 #3
0
파일: pep8.py 프로젝트: Gabriel439/pants
 def init_file(self, filename, lines, expected, line_offset):
   super(PantsReporter, self).init_file(filename, lines, expected, line_offset)
   self._python_file = PythonFile.parse(filename)
   self._twitter_errors = []
예제 #4
0
 def init_file(self, filename, lines, expected, line_offset):
     super(PantsReporter, self).init_file(filename, lines, expected,
                                          line_offset)
     self._python_file = PythonFile.parse(filename)
     self._twitter_errors = []