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

Unified Diff: grit/format/policy_templates/writers/adm_writer.py

Issue 702793003: Fix duplicated strings in ADMX templates. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | grit/format/policy_templates/writers/adm_writer_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/policy_templates/writers/adm_writer.py
===================================================================
--- grit/format/policy_templates/writers/adm_writer.py (revision 180)
+++ grit/format/policy_templates/writers/adm_writer.py (working copy)
@@ -75,7 +75,12 @@
'dict': 'EDITTEXT'
}
+ def _Escape(self, string):
+ return string.replace('.', '_')
+
def _AddGuiString(self, name, value):
+ # The |name| must be escaped.
+ assert name == self._Escape(name)
# Escape newlines in the value.
value = value.replace('\n', '\\n')
if name in self.strings_seen:
@@ -100,7 +105,7 @@
key_name: The registry key backing the policy.
builder: Builder to append lines to.
'''
- policy_part_name = policy['name'] + '_Part'
+ policy_part_name = self._Escape(policy['name'] + '_Part')
self._AddGuiString(policy_part_name, policy['label'])
# Print the PART ... END PART section:
@@ -124,9 +129,9 @@
value_text = 'NUMERIC ' + str(item['value'])
else:
value_text = '"' + item['value'] + '"'
- builder.AddLine('NAME !!%s_DropDown VALUE %s' %
- (item['name'], value_text))
- self._AddGuiString(item['name'] + '_DropDown', item['caption'])
+ string_id = self._Escape(item['name'] + '_DropDown')
+ builder.AddLine('NAME !!%s VALUE %s' % (string_id, value_text))
+ self._AddGuiString(string_id, item['caption'])
builder.AddLine('END ITEMLIST', -1)
builder.AddLine('END PART', -1)
@@ -135,10 +140,11 @@
# This type can only be set through cloud policy.
return
- self._AddGuiString(policy['name'] + '_Policy', policy['caption'])
- builder.AddLine('POLICY !!%s_Policy' % policy['name'], 1)
+ policy_name = self._Escape(policy['name'] + '_Policy')
+ self._AddGuiString(policy_name, policy['caption'])
+ builder.AddLine('POLICY !!%s' % policy_name, 1)
self._WriteSupported(builder)
- policy_explain_name = policy['name'] + '_Explain'
+ policy_explain_name = self._Escape(policy['name'] + '_Explain')
self._AddGuiString(policy_explain_name, policy['desc'])
builder.AddLine('EXPLAIN !!' + policy_explain_name)
@@ -167,7 +173,7 @@
self.recommended_policies)
def BeginPolicyGroup(self, group):
- category_name = group['name'] + '_Category'
+ category_name = self._Escape(group['name'] + '_Category')
self._AddGuiString(category_name, group['caption'])
self.policies.AddLine('CATEGORY !!' + category_name, 1)
@@ -176,7 +182,7 @@
self.policies.AddLine('')
def BeginRecommendedPolicyGroup(self, group):
- category_name = group['name'] + '_Category'
+ category_name = self._Escape(group['name'] + '_Category')
self._AddGuiString(category_name, group['caption'])
self.recommended_policies.AddLine('CATEGORY !!' + category_name, 1)
« no previous file with comments | « no previous file | grit/format/policy_templates/writers/adm_writer_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698