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

Side by Side Diff: tools/clang/scripts/extract_edits.py

Issue 2599193002: Split run_tool.py into run_tool.py, extract_edits.py and apply_edits.py (Closed)
Patch Set: --similarity=15 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 (c) 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5 """Script to extract edits from clang tool output.
6
7 Clang tools are expected to emit edits like this:
dcheng 2016/12/27 07:30:14 Not all clang tools, just rewriter tools, right?
Łukasz Anforowicz 2016/12/27 22:33:26 If a clang tool emits edits, then it is a rewriter
8 ...
9 ==== BEGIN EDITS ====
10 <edit1>
11 <edit2>
12 ...
13 ==== END EDITS ====
14 ...
15 ...
16 ==== BEGIN EDITS ====
17 <yet another edit1>
18 <yet another edit2>
19 ...
20 ==== END EDITS ====
21 ...
22
23 This python script extracts and dedupes lines between the begin/end marker
24 lines.
25
26 This python script is mainly needed on Windows.
27 On unix this script can be replaced with running sed as follows:
28
29 $ cat run_tool.out \
30 | sed '/^==== BEGIN EDITS ====$/,/^==== END EDITS ====$/{//!b};d'
31 | sort | uniq
32 """
33
34
35 import sys
36
37
38 def main():
39 unique_lines = set()
40 inside_marker_lines = False
41 for line in sys.stdin:
42 line = line.rstrip("\n\r")
43 if line == '==== BEGIN EDITS ====':
44 inside_marker_lines = True
45 continue
46 if line == '==== END EDITS ====':
47 inside_marker_lines = False
48 continue
49 if inside_marker_lines and line not in unique_lines:
50 unique_lines.add(line)
danakj 2016/12/23 15:45:06 jw why bother with this, it will make this tool sl
dcheng 2016/12/27 07:30:14 The apply script reads all the edits before dedupi
Łukasz Anforowicz 2016/12/27 22:33:26 I haven't made a change here, but I am open to rem
dcheng 2016/12/28 19:01:36 I don't feel strongly about this, but one easy way
Łukasz Anforowicz 2016/12/28 19:33:07 I am sure that this is lots and lots of lines. I
51 print(line)
dcheng 2016/12/27 07:30:14 For consistency, no ()
Łukasz Anforowicz 2016/12/27 22:33:26 Done.
52 return 0
53
54
55 if __name__ == '__main__':
56 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698