| OLD | NEW |
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 | 5 |
| 6 """Results object and results formatters for checkdeps tool.""" | 6 """Results object and results formatters for checkdeps tool.""" |
| 7 | 7 |
| 8 | 8 |
| 9 class DependencyViolation(object): | 9 class DependencyViolation(object): |
| 10 """A single dependency violation.""" | 10 """A single dependency violation.""" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 lines = [] | 75 lines = [] |
| 76 lines.append('\nERROR in %s' % dependee_status.dependee_path) | 76 lines.append('\nERROR in %s' % dependee_status.dependee_path) |
| 77 for violation in dependee_status.violations: | 77 for violation in dependee_status.violations: |
| 78 lines.append(self.FormatViolation(violation, self.verbose)) | 78 lines.append(self.FormatViolation(violation, self.verbose)) |
| 79 self.results.append('\n'.join(lines)) | 79 self.results.append('\n'.join(lines)) |
| 80 | 80 |
| 81 @staticmethod | 81 @staticmethod |
| 82 def FormatViolation(violation, verbose=False): | 82 def FormatViolation(violation, verbose=False): |
| 83 lines = [] | 83 lines = [] |
| 84 if verbose: | 84 if verbose: |
| 85 lines.append('For %s' % violation.rules) | 85 lines.append(' For %s' % violation.rules) |
| 86 lines.append( | 86 lines.append( |
| 87 ' Illegal include: "%s"\n Because of %s' % | 87 ' Illegal include: "%s"\n Because of %s' % |
| 88 (violation.include_path, str(violation.violated_rule))) | 88 (violation.include_path, str(violation.violated_rule))) |
| 89 return '\n'.join(lines) | 89 return '\n'.join(lines) |
| 90 | 90 |
| 91 def GetResults(self): | 91 def GetResults(self): |
| 92 return self.results | 92 return self.results |
| 93 | 93 |
| 94 def PrintResults(self): | 94 def PrintResults(self): |
| 95 for result in self.results: | 95 for result in self.results: |
| (...skipping 14 matching lines...) Expand all Loading... |
| 110 def AddError(self, dependee_status): | 110 def AddError(self, dependee_status): |
| 111 for violation in dependee_status.violations: | 111 for violation in dependee_status.violations: |
| 112 self.violations.add(violation.include_path) | 112 self.violations.add(violation.include_path) |
| 113 | 113 |
| 114 def GetResults(self): | 114 def GetResults(self): |
| 115 return [' "!%s",' % path for path in sorted(self.violations)] | 115 return [' "!%s",' % path for path in sorted(self.violations)] |
| 116 | 116 |
| 117 def PrintResults(self): | 117 def PrintResults(self): |
| 118 for result in self.GetResults(): | 118 for result in self.GetResults(): |
| 119 print result | 119 print result |
| OLD | NEW |