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

Side by Side Diff: tools/grit/grit/format/policy_templates/writers/xml_formatted_writer.py

Issue 2532483003: Replace the term 'poor man' with another phrase (gender-neutral fixit). (Closed)
Patch Set: Respond to review comments. Created 4 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
« no previous file with comments | « third_party/WebKit/Source/core/frame/SmartClip.h ('k') | ui/gfx/x/x11_error_tracker.cc » ('j') | 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/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 6
7 from grit.format.policy_templates.writers import template_writer 7 from grit.format.policy_templates.writers import template_writer
8 8
9 9
10 class XMLFormattedWriter(template_writer.TemplateWriter): 10 class XMLFormattedWriter(template_writer.TemplateWriter):
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 def ToPrettyXml(self, doc, **kwargs): 60 def ToPrettyXml(self, doc, **kwargs):
61 # return doc.toprettyxml(indent=' ') 61 # return doc.toprettyxml(indent=' ')
62 # The above pretty-printer does not print the doctype and adds spaces 62 # The above pretty-printer does not print the doctype and adds spaces
63 # around texts, e.g.: 63 # around texts, e.g.:
64 # <string> 64 # <string>
65 # value of the string 65 # value of the string
66 # </string> 66 # </string>
67 # This is problematic both for the OSX Workgroup Manager (plist files) and 67 # This is problematic both for the OSX Workgroup Manager (plist files) and
68 # the Windows Group Policy Editor (admx files). What they need instead: 68 # the Windows Group Policy Editor (admx files). What they need instead:
69 # <string>value of string</string> 69 # <string>value of string</string>
70 # So we use the poor man's pretty printer here. It assumes that there are 70 # So we use a hacky pretty printer here. It assumes that there are no
71 # no mixed-content nodes. 71 # mixed-content nodes.
72 # Get all the XML content in a one-line string. 72 # Get all the XML content in a one-line string.
73 xml = doc.toxml(**kwargs) 73 xml = doc.toxml(**kwargs)
74 # Determine where the line breaks will be. (They will only be between tags.) 74 # Determine where the line breaks will be. (They will only be between tags.)
75 lines = xml[1:len(xml) - 1].split('><') 75 lines = xml[1:len(xml) - 1].split('><')
76 indent = '' 76 indent = ''
77 res = '' 77 res = ''
78 # Determine indent for each line. 78 # Determine indent for each line.
79 for i, line in enumerate(lines): 79 for i, line in enumerate(lines):
80 if line[0] == '/': 80 if line[0] == '/':
81 # If the current line starts with a closing tag, decrease indent before 81 # If the current line starts with a closing tag, decrease indent before
82 # printing. 82 # printing.
83 indent = indent[2:] 83 indent = indent[2:]
84 lines[i] = indent + '<' + line + '>' 84 lines[i] = indent + '<' + line + '>'
85 if (line[0] not in ['/', '?', '!'] and '</' not in line and 85 if (line[0] not in ['/', '?', '!'] and '</' not in line and
86 line[len(line) - 1] != '/'): 86 line[len(line) - 1] != '/'):
87 # If the current line starts with an opening tag and does not conatin a 87 # If the current line starts with an opening tag and does not conatin a
88 # closing tag, increase indent after the line is printed. 88 # closing tag, increase indent after the line is printed.
89 indent += ' ' 89 indent += ' '
90 # Reconstruct XML text from the lines. 90 # Reconstruct XML text from the lines.
91 return '\n'.join(lines) 91 return '\n'.join(lines)
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/SmartClip.h ('k') | ui/gfx/x/x11_error_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698