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

Side by Side Diff: pylib/gyp/xml_fix.py

Issue 1454433002: Python 3 compatibility Base URL: https://chromium.googlesource.com/external/gyp.git@master
Patch Set: Rebase with master (4ec6c4e3a94bd04a6da2858163d40b2429b8aad1) Created 4 years, 8 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
1 # Copyright (c) 2011 Google Inc. All rights reserved. 1 # Copyright (c) 2011 Google Inc. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Applies a fix to CR LF TAB handling in xml.dom. 5 """Applies a fix to CR LF TAB handling in xml.dom.
6 6
7 Fixes this: http://code.google.com/p/chromium/issues/detail?id=76293 7 Fixes this: http://code.google.com/p/chromium/issues/detail?id=76293
8 Working around this: http://bugs.python.org/issue5752 8 Working around this: http://bugs.python.org/issue5752
9 TODO(bradnelson): Consider dropping this when we drop XP support. 9 TODO(bradnelson): Consider dropping this when we drop XP support.
10 """ 10 """
(...skipping 14 matching lines...) Expand all
25 writer.write(data) 25 writer.write(data)
26 26
27 27
28 def _Replacement_writexml(self, writer, indent="", addindent="", newl=""): 28 def _Replacement_writexml(self, writer, indent="", addindent="", newl=""):
29 # indent = current indentation 29 # indent = current indentation
30 # addindent = indentation to add to higher levels 30 # addindent = indentation to add to higher levels
31 # newl = newline string 31 # newl = newline string
32 writer.write(indent+"<" + self.tagName) 32 writer.write(indent+"<" + self.tagName)
33 33
34 attrs = self._get_attributes() 34 attrs = self._get_attributes()
35 a_names = attrs.keys() 35 a_names = sorted(attrs.keys())
36 a_names.sort()
37 36
38 for a_name in a_names: 37 for a_name in a_names:
39 writer.write(" %s=\"" % a_name) 38 writer.write(" %s=\"" % a_name)
40 _Replacement_write_data(writer, attrs[a_name].value, is_attrib=True) 39 _Replacement_write_data(writer, attrs[a_name].value, is_attrib=True)
41 writer.write("\"") 40 writer.write("\"")
42 if self.childNodes: 41 if self.childNodes:
43 writer.write(">%s" % newl) 42 writer.write(">%s" % newl)
44 for node in self.childNodes: 43 for node in self.childNodes:
45 node.writexml(writer, indent + addindent, addindent, newl) 44 node.writexml(writer, indent + addindent, addindent, newl)
46 writer.write("%s</%s>%s" % (indent, self.tagName, newl)) 45 writer.write("%s</%s>%s" % (indent, self.tagName, newl))
(...skipping 13 matching lines...) Expand all
60 xml.dom.minidom.Element.writexml = _Replacement_writexml 59 xml.dom.minidom.Element.writexml = _Replacement_writexml
61 60
62 def Cleanup(self): 61 def Cleanup(self):
63 if self.write_data: 62 if self.write_data:
64 xml.dom.minidom._write_data = self.write_data 63 xml.dom.minidom._write_data = self.write_data
65 xml.dom.minidom.Element.writexml = self.writexml 64 xml.dom.minidom.Element.writexml = self.writexml
66 self.write_data = None 65 self.write_data = None
67 66
68 def __del__(self): 67 def __del__(self):
69 self.Cleanup() 68 self.Cleanup()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698