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

Side by Side Diff: visual_studio/NativeClientVSAddIn/InstallerResources/xml_patch.py

Issue 14122017: [VS Addin] Add visual studio 2012 support (Closed) Base URL: https://nativeclient-sdk.googlecode.com/svn/trunk/src
Patch Set: Created 7 years, 7 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """ This module is a utility for applying an xml patch to an xml file. 6 """ This module is a utility for applying an xml patch to an xml file.
7 7
8 The format of the patch is described in the documentation for 8 The format of the patch is described in the documentation for
9 the patch_xml() function. 9 the patch_xml() function.
10 """ 10 """
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 find_target = None 132 find_target = None
133 133
134 # Otherwise this source element doesn't match any patch operations, add it. 134 # Otherwise this source element doesn't match any patch operations, add it.
135 else: 135 else:
136 new_element.append(copy.deepcopy(source_child)) 136 new_element.append(copy.deepcopy(source_child))
137 137
138 # Raise exceptions if find/remove didn't finish before the end of the source. 138 # Raise exceptions if find/remove didn't finish before the end of the source.
139 if find_target is not None: 139 if find_target is not None:
140 raise Exception('Find operation never matched:' + find_target.tag) 140 raise Exception('Find operation never matched:' + find_target.tag)
141 elif len(remove_targets) != 0: 141 elif len(remove_targets) != 0:
142 raise Exception('Remove operation never matched: ' + remove_targets) 142 raise Exception('Remove operation never matched: ' + str(remove_targets))
143 143
144 # We may have more add operations after source has run empty: 144 # We may have more add operations after source has run empty:
145 while patch_index < len(patch_children): 145 while patch_index < len(patch_children):
146 if IsPatchAddTag(patch_children[patch_index].tag): 146 if IsPatchAddTag(patch_children[patch_index].tag):
147 for addition in patch_children[patch_index]: 147 for addition in patch_children[patch_index]:
148 new_element.append(copy.deepcopy(addition)) 148 new_element.append(copy.deepcopy(addition))
149 patch_index += 1 149 patch_index += 1
150 else: 150 else:
151 raise Exception('Non-add operation attempted after source end. ' + 151 raise Exception('Non-add operation attempted after source end. ' +
152 'Tag: %s, Children %s' % 152 'Tag: %s, Children %s' %
(...skipping 12 matching lines...) Expand all
165 # Because the tag can be a sub-element of arbitrary elements it could inherit 165 # Because the tag can be a sub-element of arbitrary elements it could inherit
166 # any default namespace. 166 # any default namespace.
167 return tag.endswith('PatchAdd') 167 return tag.endswith('PatchAdd')
168 168
169 169
170 def IsPatchRemoveTag(tag): 170 def IsPatchRemoveTag(tag):
171 # We look at the end of the tag because we need to ignore the namespace. 171 # We look at the end of the tag because we need to ignore the namespace.
172 # Because the tag can be a sub-element of arbitrary elements it could inherit 172 # Because the tag can be a sub-element of arbitrary elements it could inherit
173 # any default namespace. 173 # any default namespace.
174 return tag.endswith('PatchRemove') 174 return tag.endswith('PatchRemove')
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698