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

Side by Side Diff: chrome/tools/build/win/sort_sln.py

Issue 8680018: Fix python scripts in src/chrome/ (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: copyright Created 9 years 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 | Annotate | Revision Log
« no previous file with comments | « chrome/tools/build/win/sln_deps.py ('k') | chrome/tools/check_grd_for_unused_strings.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2006-2008 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
6 import sys
7
8 if len(sys.argv) != 2:
9 print """Usage: sort_sln.py <SOLUTIONNAME>.sln
10 to sort the solution file to a normalized scheme. Do this before checking in
11 changes to a solution file to avoid having a lot of unnecessary diffs."""
12 sys.exit(1)
13
14 filename = sys.argv[1]
15 print "Sorting " + filename;
16
17 try:
18 sln = open(filename, "r");
19 except IOError:
20 print "Unable to open " + filename + " for reading."
21 sys.exit(1)
22
23 output = ""
24 seclines = None
25 while 1:
26 line = sln.readline()
27 if not line:
28 break
29
30 if seclines is not None:
31 # Process the end of a section, dump the sorted lines
32 if line.lstrip().startswith('End'):
33 output = output + ''.join(sorted(seclines))
34 seclines = None
35 # Process within a section
36 else:
37 seclines.append(line)
38 continue
39
40 # Process the start of a section
41 if (line.lstrip().startswith('GlobalSection') or
42 line.lstrip().startswith('ProjectSection')):
43 if seclines: raise Exception('Already in a section')
44 seclines = []
45
46 output = output + line
47
48 sln.close()
49 try:
50 sln = open(filename, "w")
51 sln.write(output)
52 except IOError:
53 print "Unable to write to " + filename
54 sys.exit(1);
55 print "Done."
56
OLDNEW
« no previous file with comments | « chrome/tools/build/win/sln_deps.py ('k') | chrome/tools/check_grd_for_unused_strings.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698