Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: third_party/closure_linter/closure_linter/errorrecord.py

Issue 2592193002: Remove closure_linter from Chrome (Closed)
Patch Set: Created 3 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2012 The Closure Linter Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS-IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16
17 """A simple, pickle-serializable class to represent a lint error."""
18
19 __author__ = 'nnaze@google.com (Nathan Naze)'
20
21 import gflags as flags
22
23 from closure_linter import errors
24 from closure_linter.common import erroroutput
25
26 FLAGS = flags.FLAGS
27
28
29 class ErrorRecord(object):
30 """Record-keeping struct that can be serialized back from a process.
31
32 Attributes:
33 path: Path to the file.
34 error_string: Error string for the user.
35 new_error: Whether this is a "new error" (see errors.NEW_ERRORS).
36 """
37
38 def __init__(self, path, error_string, new_error):
39 self.path = path
40 self.error_string = error_string
41 self.new_error = new_error
42
43
44 def MakeErrorRecord(path, error):
45 """Make an error record with correctly formatted error string.
46
47 Errors are not able to be serialized (pickled) over processes because of
48 their pointers to the complex token/context graph. We use an intermediary
49 serializable class to pass back just the relevant information.
50
51 Args:
52 path: Path of file the error was found in.
53 error: An error.Error instance.
54
55 Returns:
56 _ErrorRecord instance.
57 """
58 new_error = error.code in errors.NEW_ERRORS
59
60 if FLAGS.unix_mode:
61 error_string = erroroutput.GetUnixErrorOutput(
62 path, error, new_error=new_error)
63 else:
64 error_string = erroroutput.GetErrorOutput(error, new_error=new_error)
65
66 return ErrorRecord(path, error_string, new_error)
OLDNEW
« no previous file with comments | « third_party/closure_linter/closure_linter/error_fixer_test.py ('k') | third_party/closure_linter/closure_linter/errorrules.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698