summaryrefslogtreecommitdiffstats
path: root/tools/grit
diff options
context:
space:
mode:
authorgfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 10:16:47 +0000
committergfeher@chromium.org <gfeher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-04 10:16:47 +0000
commit94828c90ab0bb8e120287f4265ca106eae34c8ce (patch)
treec36e7fec3ffe737e21f1f81aea2c8c39274923d9 /tools/grit
parent91877582059da9a959439b7fb35c285705248922 (diff)
downloadchromium_src-94828c90ab0bb8e120287f4265ca106eae34c8ce.zip
chromium_src-94828c90ab0bb8e120287f4265ca106eae34c8ce.tar.gz
chromium_src-94828c90ab0bb8e120287f4265ca106eae34c8ce.tar.bz2
Replace spaces with underscores in keys of Mac stringtables of policies
BUG=61054 TEST=PListWriterUnittest.*,PListStringsWriterUnittest.* Review URL: http://codereview.chromium.org/4318001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65039 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/grit')
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_helper.py14
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py4
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py50
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_writer.py4
-rw-r--r--tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py20
5 files changed, 54 insertions, 38 deletions
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_helper.py b/tools/grit/grit/format/policy_templates/writers/plist_helper.py
new file mode 100644
index 0000000..16a5803
--- /dev/null
+++ b/tools/grit/grit/format/policy_templates/writers/plist_helper.py
@@ -0,0 +1,14 @@
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+'''Common functions for plist_writer and plist_strings_writer.
+'''
+
+
+def GetPlistFriendlyName(name):
+ '''Transforms a string so that it will be suitable for use as
+ a pfm_name in the plist manifest file.
+ '''
+ return name.replace(' ', '_') \ No newline at end of file
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py
index e85d85e..965c900 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer.py
@@ -3,6 +3,7 @@
# found in the LICENSE file.
+from grit.format.policy_templates.writers import plist_helper
from grit.format.policy_templates.writers import template_writer
@@ -54,8 +55,9 @@ class PListStringsWriter(template_writer.TemplateWriter):
self._AddToStringTable(policy['name'], policy['label'], desc)
def BeginTemplate(self):
+ app_name = plist_helper.GetPlistFriendlyName(self.config['app_name'])
self._AddToStringTable(
- self.config['app_name'],
+ app_name,
self.config['app_name'],
self.messages['IDS_POLICY_MAC_CHROME_PREFERENCES'])
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py
index e8e8463..6df8f84 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_strings_writer_unittest.py
@@ -41,10 +41,9 @@ class PListStringsWriterUnittest(writer_unittest_common.WriterUnittestCommon):
{'_chromium': '1', 'mac_bundle_id': 'com.example.Test'},
'plist_strings',
'en')
- expected_output = \
-'''Chromium.pfm_title = "Chromium";
-Chromium.pfm_description = "Chromium preferen\\"ces";
-'''
+ expected_output = (
+ 'Chromium.pfm_title = "Chromium";\n'
+ 'Chromium.pfm_description = "Chromium preferen\\"ces";')
self.assertEquals(output.strip(), expected_output.strip())
def testMainPolicy(self):
@@ -78,12 +77,11 @@ Chromium.pfm_description = "Chromium preferen\\"ces";
{'_google_chrome' : '1', 'mac_bundle_id': 'com.example.Test'},
'plist_strings',
'en')
- expected_output = \
-'''Google Chrome.pfm_title = "Google Chrome";
-Google Chrome.pfm_description = "Preferences of Google Chrome";
-MainPolicy.pfm_title = "Caption of main policy.";
-MainPolicy.pfm_description = "Title of main policy.";
-'''
+ expected_output = (
+ 'Google_Chrome.pfm_title = "Google Chrome";\n'
+ 'Google_Chrome.pfm_description = "Preferences of Google Chrome";\n'
+ 'MainPolicy.pfm_title = "Caption of main policy.";\n'
+ 'MainPolicy.pfm_description = "Title of main policy.";')
self.assertEquals(output.strip(), expected_output.strip())
def testStringPolicy(self):
@@ -120,12 +118,12 @@ With a newline.</message>
{'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
'plist_strings',
'en')
- expected_output = \
-'''Chromium.pfm_title = "Chromium";
-Chromium.pfm_description = "Preferences Of Chromium";
-StringPolicy.pfm_title = "Caption of policy.";
-StringPolicy.pfm_description = "Description of policy.\\nWith a newline.";
- '''
+ expected_output = (
+ 'Chromium.pfm_title = "Chromium";\n'
+ 'Chromium.pfm_description = "Preferences Of Chromium";\n'
+ 'StringPolicy.pfm_title = "Caption of policy.";\n'
+ 'StringPolicy.pfm_description = '
+ '"Description of policy.\\nWith a newline.";')
self.assertEquals(output.strip(), expected_output.strip())
def testEnumPolicy(self):
@@ -165,12 +163,13 @@ StringPolicy.pfm_description = "Description of policy.\\nWith a newline.";
{'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'},
'plist_strings',
'en')
- expected_output = \
-'''Google Chrome.pfm_title = "Google Chrome";
-Google Chrome.pfm_description = "Google Chrome preferences";
-EnumPolicy.pfm_title = "Caption of policy.";
-EnumPolicy.pfm_description = "0 - Option1\\n1 - Option2\\nDescription of policy.";
- '''
+ expected_output = (
+ 'Google_Chrome.pfm_title = "Google Chrome";\n'
+ 'Google_Chrome.pfm_description = "Google Chrome preferences";\n'
+ 'EnumPolicy.pfm_title = "Caption of policy.";\n'
+ 'EnumPolicy.pfm_description = '
+ '"0 - Option1\\n1 - Option2\\nDescription of policy.";\n')
+
self.assertEquals(output.strip(), expected_output.strip())
def testNonSupportedPolicy(self):
@@ -205,10 +204,9 @@ EnumPolicy.pfm_description = "0 - Option1\\n1 - Option2\\nDescription of policy.
{'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'},
'plist_strings',
'en')
- expected_output = \
-'''Google Chrome.pfm_title = "Google Chrome";
-Google Chrome.pfm_description = "Google Chrome preferences";
- '''
+ expected_output = (
+ 'Google_Chrome.pfm_title = "Google Chrome";\n'
+ 'Google_Chrome.pfm_description = "Google Chrome preferences";')
self.assertEquals(output.strip(), expected_output.strip())
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_writer.py b/tools/grit/grit/format/policy_templates/writers/plist_writer.py
index 790e21a..87e9db9 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_writer.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_writer.py
@@ -4,6 +4,7 @@
from xml.dom import minidom
+from grit.format.policy_templates.writers import plist_helper
from grit.format.policy_templates.writers import xml_formatted_writer
@@ -93,7 +94,8 @@ class PListWriter(xml_formatted_writer.XMLFormattedWriter):
self._plist.attributes['version'] = '1'
dict = self.AddElement(self._plist, 'dict')
- self._AddStringKeyValuePair(dict, 'pfm_name', self.config['app_name'])
+ app_name = plist_helper.GetPlistFriendlyName(self.config['app_name'])
+ self._AddStringKeyValuePair(dict, 'pfm_name', app_name)
self._AddStringKeyValuePair(dict, 'pfm_description', '')
self._AddStringKeyValuePair(dict, 'pfm_title', '')
self._AddStringKeyValuePair(dict, 'pfm_version', '1')
diff --git a/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py
index 4b21ec4..bcebcaa 100644
--- a/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py
+++ b/tools/grit/grit/format/policy_templates/writers/plist_writer_unittest.py
@@ -73,8 +73,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
{'_chromium': '1', 'mac_bundle_id': 'com.example.Test'},
'plist',
'en')
- expected_output = \
- self._GetExpectedOutputs('Chromium', 'com.example.Test', '<array/>')
+ expected_output = self._GetExpectedOutputs(
+ 'Chromium', 'com.example.Test', '<array/>')
self.assertEquals(output.strip(), expected_output.strip())
def testMainPolicy(self):
@@ -107,8 +107,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
{'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
'plist',
'en')
- expected_output = \
- self._GetExpectedOutputs('Chromium', 'com.example.Test', '''<array>
+ expected_output = self._GetExpectedOutputs(
+ 'Chromium', 'com.example.Test', '''<array>
<dict>
<key>pfm_name</key>
<string>MainPolicy</string>
@@ -156,8 +156,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
{'_chromium' : '1', 'mac_bundle_id': 'com.example.Test'},
'plist',
'en')
- expected_output = \
- self._GetExpectedOutputs('Chromium', 'com.example.Test', '''<array>
+ expected_output = self._GetExpectedOutputs(
+ 'Chromium', 'com.example.Test', '''<array>
<dict>
<key>pfm_name</key>
<string>StringPolicy</string>
@@ -211,8 +211,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
{'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'},
'plist',
'en')
- expected_output = \
- self._GetExpectedOutputs('Google Chrome', 'com.example.Test2', '''<array>
+ expected_output = self._GetExpectedOutputs(
+ 'Google_Chrome', 'com.example.Test2', '''<array>
<dict>
<key>pfm_name</key>
<string>EnumPolicy</string>
@@ -266,8 +266,8 @@ class PListWriterUnittest(writer_unittest_common.WriterUnittestCommon):
{'_google_chrome': '1', 'mac_bundle_id': 'com.example.Test2'},
'plist',
'en')
- expected_output = \
- self._GetExpectedOutputs('Google Chrome', 'com.example.Test2', '''<array/>''')
+ expected_output = self._GetExpectedOutputs(
+ 'Google_Chrome', 'com.example.Test2', '''<array/>''')
self.assertEquals(output.strip(), expected_output.strip())