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

Side by Side Diff: tools/pretty_vcproj.py

Issue 523164: License cleanup for http://code.google.com/p/gyp/issues/detail?id=133... (Closed) Base URL: http://gyp.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 11 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 | Annotate | Revision Log
« test/toolsets/toolsets.cc ('K') | « tools/pretty_sln.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python2.5 1 #!/usr/bin/python2.5
2 # Copyright 2009 Google Inc. 2
3 # All Rights Reserved. 3 # Copyright (c) 2009 Google Inc. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
4 6
5 """Make the format of a vcproj really pretty. 7 """Make the format of a vcproj really pretty.
6 8
7 This script normalize and sort an xml. It also fetches all the properties 9 This script normalize and sort an xml. It also fetches all the properties
8 inside linked vsprops and include them explicitly in the vcproj. 10 inside linked vsprops and include them explicitly in the vcproj.
9 11
10 It outputs the resulting xml to stdout. 12 It outputs the resulting xml to stdout.
11 """ 13 """
12 14
13 __author__ = 'nsylvain (Nicolas Sylvain)' 15 __author__ = 'nsylvain (Nicolas Sylvain)'
14 16
15 import os 17 import os
16 import sys 18 import sys
17 19
18 from xml.dom.minidom import parse 20 from xml.dom.minidom import parse
19 from xml.dom.minidom import Node 21 from xml.dom.minidom import Node
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 for sub_node in node.childNodes: 141 for sub_node in node.childNodes:
140 AbsoluteNode(sub_node) 142 AbsoluteNode(sub_node)
141 CleanupVcproj(sub_node) 143 CleanupVcproj(sub_node)
142 144
143 # Normalize the node, and remove all extranous whitespaces. 145 # Normalize the node, and remove all extranous whitespaces.
144 for sub_node in node.childNodes: 146 for sub_node in node.childNodes:
145 if sub_node.nodeType == Node.TEXT_NODE: 147 if sub_node.nodeType == Node.TEXT_NODE:
146 sub_node.data = sub_node.data.replace("\r", "") 148 sub_node.data = sub_node.data.replace("\r", "")
147 sub_node.data = sub_node.data.replace("\n", "") 149 sub_node.data = sub_node.data.replace("\n", "")
148 sub_node.data = sub_node.data.rstrip() 150 sub_node.data = sub_node.data.rstrip()
149 151
150 # Fix all the semicolon separated attributes to be sorted, and we also 152 # Fix all the semicolon separated attributes to be sorted, and we also
151 # remove the dups. 153 # remove the dups.
152 if node.attributes: 154 if node.attributes:
153 for (name, value) in node.attributes.items(): 155 for (name, value) in node.attributes.items():
154 sorted_list = sorted(value.split(';')) 156 sorted_list = sorted(value.split(';'))
155 unique_list = [] 157 unique_list = []
156 [unique_list.append(i) for i in sorted_list if not unique_list.count(i)] 158 [unique_list.append(i) for i in sorted_list if not unique_list.count(i)]
157 node.setAttribute(name, ';'.join(unique_list)) 159 node.setAttribute(name, ';'.join(unique_list))
158 if not value: 160 if not value:
159 node.removeAttribute(name) 161 node.removeAttribute(name)
160 162
161 if node.childNodes: 163 if node.childNodes:
162 node.normalize() 164 node.normalize()
163 165
164 # For each node, take a copy, and remove it from the list. 166 # For each node, take a copy, and remove it from the list.
165 node_array = [] 167 node_array = []
166 while node.childNodes and node.childNodes[0]: 168 while node.childNodes and node.childNodes[0]:
167 # Take a copy of the node and remove it from the list. 169 # Take a copy of the node and remove it from the list.
168 current = node.childNodes[0] 170 current = node.childNodes[0]
169 node.removeChild(current) 171 node.removeChild(current)
170 172
171 # If the child is a filter, we want to append all its children 173 # If the child is a filter, we want to append all its children
172 # to this same list. 174 # to this same list.
173 if current.nodeName == 'Filter': 175 if current.nodeName == 'Filter':
174 node_array.extend(FlattenFilter(current)) 176 node_array.extend(FlattenFilter(current))
175 else: 177 else:
176 node_array.append(current) 178 node_array.append(current)
177 179
178 180
179 # Sort the list. 181 # Sort the list.
180 node_array.sort(CmpNode()) 182 node_array.sort(CmpNode())
181 183
182 # Insert the nodes in the correct order. 184 # Insert the nodes in the correct order.
183 for new_node in node_array: 185 for new_node in node_array:
184 # But don't append empty tool node. 186 # But don't append empty tool node.
185 if new_node.nodeName == 'Tool': 187 if new_node.nodeName == 'Tool':
186 if new_node.attributes and new_node.attributes.length == 1: 188 if new_node.attributes and new_node.attributes.length == 1:
187 # This one was empty. 189 # This one was empty.
188 continue 190 continue
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 MergeProperties(configuration_node, 304 MergeProperties(configuration_node,
303 parse(current_vsprops).documentElement) 305 parse(current_vsprops).documentElement)
304 306
305 # Now that everything is merged, we need to cleanup the xml. 307 # Now that everything is merged, we need to cleanup the xml.
306 CleanupVcproj(dom.documentElement) 308 CleanupVcproj(dom.documentElement)
307 309
308 # Finally, we use the prett xml function to print the vcproj back to the 310 # Finally, we use the prett xml function to print the vcproj back to the
309 # user. 311 # user.
310 #print dom.toprettyxml(newl="\n") 312 #print dom.toprettyxml(newl="\n")
311 PrettyPrintNode(dom.documentElement) 313 PrettyPrintNode(dom.documentElement)
312 314
313 if __name__ == '__main__': 315 if __name__ == '__main__':
314 main(sys.argv) 316 main(sys.argv)
OLDNEW
« test/toolsets/toolsets.cc ('K') | « tools/pretty_sln.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698