~ubuntu-branches/ubuntu/lucid/gyp/lucid-proposed

« back to all changes in this revision

Viewing changes to tools/pretty_vcproj.py

  • Committer: Bazaar Package Importer
  • Author(s): Fabien Tassin
  • Date: 2010-02-17 22:00:38 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100217220038-hmfvpu3zapmihgeo
Tags: 0.1~svn785-0ubuntu1

New upstream snapshot, needed to support --no-circular-check

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/python2.5
2
 
# Copyright 2009 Google Inc.
3
 
# All Rights Reserved.
 
2
 
 
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
7
"""Make the format of a vcproj really pretty.
6
8
 
7
9
   This script normalize and sort an xml. It also fetches all the properties
8
10
   inside linked vsprops and include them explicitly in the vcproj.
9
 
   
 
11
 
10
12
   It outputs the resulting xml to stdout.
11
13
"""
12
14
 
146
148
        sub_node.data = sub_node.data.replace("\r", "")
147
149
        sub_node.data = sub_node.data.replace("\n", "")
148
150
        sub_node.data = sub_node.data.rstrip()
149
 
        
 
151
 
150
152
  # Fix all the semicolon separated attributes to be sorted, and we also
151
153
  # remove the dups.
152
154
  if node.attributes:
153
155
    for (name, value) in node.attributes.items():
154
156
      sorted_list = sorted(value.split(';'))
155
 
      unique_list = [] 
 
157
      unique_list = []
156
158
      [unique_list.append(i) for i in sorted_list if not unique_list.count(i)]
157
159
      node.setAttribute(name, ';'.join(unique_list))
158
160
      if not value:
160
162
 
161
163
  if node.childNodes:
162
164
    node.normalize()
163
 
    
 
165
 
164
166
  # For each node, take a copy, and remove it from the list.
165
167
  node_array = []
166
168
  while node.childNodes and node.childNodes[0]:
175
177
    else:
176
178
      node_array.append(current)
177
179
 
178
 
    
 
180
 
179
181
  # Sort the list.
180
182
  node_array.sort(CmpNode())
181
183
 
309
311
  # user.
310
312
  #print dom.toprettyxml(newl="\n")
311
313
  PrettyPrintNode(dom.documentElement)
312
 
  
 
314
 
313
315
if __name__ == '__main__':
314
 
  main(sys.argv)
 
 
b'\\ No newline at end of file'
 
316
  main(sys.argv)