diff options
author | jkummerow@chromium.org <jkummerow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-18 08:43:48 +0000 |
---|---|---|
committer | jkummerow@chromium.org <jkummerow@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-01-18 08:43:48 +0000 |
commit | 42c50aba03e59e0fdd60cd4a2f8c141a09406a93 (patch) | |
tree | b2e1f8babb001a8feb3762c417092e9f5b2c6f5f /tools/grit | |
parent | 54097492f68c8ccfaeb168487dcad00d698d30ec (diff) | |
download | chromium_src-42c50aba03e59e0fdd60cd4a2f8c141a09406a93.zip chromium_src-42c50aba03e59e0fdd60cd4a2f8c141a09406a93.tar.gz chromium_src-42c50aba03e59e0fdd60cd4a2f8c141a09406a93.tar.bz2 |
Remove 'annotations' dictionary in policy_definitions.json.
The former members of the dict are now included directly in the policy definitions.
BUG=64898
TEST=existing unit tests in tools/grit/grit/format/policy_templates/
Review URL: http://codereview.chromium.org/6360002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/grit')
8 files changed, 47 insertions, 106 deletions
diff --git a/tools/grit/grit/format/policy_templates/writers/doc_writer.py b/tools/grit/grit/format/policy_templates/writers/doc_writer.py index 1d3b7ef..34f111e 100644 --- a/tools/grit/grit/format/policy_templates/writers/doc_writer.py +++ b/tools/grit/grit/format/policy_templates/writers/doc_writer.py @@ -136,7 +136,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): policy: The data structure of a policy. ''' features = [] - for key, value in policy['annotations']['features'].iteritems(): + for key, value in policy['features'].iteritems(): key_name = self._FEATURE_MAP[key] if value == 0: value_name = self._GetLocalizedMessage('not_supported') @@ -153,7 +153,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): policy: A policy of type 'list', for which the Mac example value is generated. ''' - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] self.AddElement(parent, 'dt', {}, 'Mac:') mac = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) @@ -171,7 +171,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): policy: A policy of type 'list', for which the Windows example value is generated. ''' - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] self.AddElement(parent, 'dt', {}, 'Windows:') win = self._AddStyledElement(parent, 'dd', ['.monospace', '.pre']) win_text = [] @@ -191,7 +191,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): policy: A policy of type 'list', for which the Linux example value is generated. ''' - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] self.AddElement(parent, 'dt', {}, 'Linux:') linux = self._AddStyledElement(parent, 'dd', ['.monospace']) linux_text = [] @@ -223,7 +223,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): parent: The DOM node for which the example will be added. policy: The data structure of a policy. ''' - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] examples = self._AddStyledElement(parent, 'dl', ['dd dl']) self._AddListExampleWindows(examples, policy) self._AddListExampleLinux(examples, policy) @@ -244,7 +244,7 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): Exception: If the type of the policy is unknown or the example value of the policy is out of its expected range. ''' - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] policy_type = policy['type'] if policy_type == 'main': if example_value == True: @@ -330,7 +330,6 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): parent: A DOM element for which the list will be added. policy: The data structure of the policy. ''' - annotations = policy['annotations'] dl = self.AddElement(parent, 'dl') self._AddPolicyAttribute( @@ -363,9 +362,9 @@ class DocWriter(xml_formatted_writer.XMLFormattedWriter): Args: policy: The data structure of the policy. ''' - if 'problem_href' not in policy['annotations']: + if 'problem_href' not in policy: return - problem_href = policy['annotations']['problem_href'] + problem_href = policy['problem_href'] div = self._AddStyledElement(parent, 'div', ['div.note']) note = self._GetLocalizedMessage('note').replace('$6', problem_href) self._AddTextWithLinks(div, note) diff --git a/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py index 56f02f3..6186500 100644 --- a/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py +++ b/tools/grit/grit/format/policy_templates/writers/doc_writer_unittest.py @@ -196,9 +196,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex def testAddFeatures(self): # Test if the list of features of a policy is handled correctly. policy = { - 'annotations': { - 'features': {'spaceship_docking': 0, 'dynamic_refresh': 1} - } + 'features': {'spaceship_docking': 0, 'dynamic_refresh': 1} } self.writer._FEATURE_MAP = { 'spaceship_docking': 'Spaceship Docking', @@ -215,9 +213,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex def testAddListExample(self): policy = { 'name': 'PolicyName', - 'annotations': { - 'example_value': ['Foo', 'Bar'] - } + 'example_value': ['Foo', 'Bar'] } self.writer._AddListExample(self.doc_root, policy) self.assertEquals( @@ -248,9 +244,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex policy = { 'name': 'PolicyName', 'type': 'main', - 'annotations': { - 'example_value': True - } + 'example_value': True } e1 = self.writer.AddElement(self.doc_root, 'e1') self.writer._AddExample(e1, policy) @@ -261,9 +255,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex policy = { 'name': 'PolicyName', 'type': 'main', - 'annotations': { - 'example_value': False - } + 'example_value': False } e2 = self.writer.AddElement(self.doc_root, 'e2') self.writer._AddExample(e2, policy) @@ -276,9 +268,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex policy = { 'name': 'PolicyName', 'type': 'int-enum', - 'annotations': { - 'example_value': 16 - } + 'example_value': 16 } self.writer._AddExample(self.doc_root, policy) self.assertEquals( @@ -290,9 +280,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex policy = { 'name': 'PolicyName', 'type': 'string-enum', - 'annotations': { - 'example_value': "wacky" - } + 'example_value': "wacky" } self.writer._AddExample(self.doc_root, policy) self.assertEquals( @@ -304,9 +292,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex policy = { 'name': 'PolicyName', 'type': 'string', - 'annotations': { - 'example_value': 'awesome-example' - } + 'example_value': 'awesome-example' } self.writer._AddExample(self.doc_root, policy) self.assertEquals( @@ -318,9 +304,7 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex policy = { 'name': 'PolicyName', 'type': 'int', - 'annotations': { - 'example_value': 26 - } + 'example_value': 26 } self.writer._AddExample(self.doc_root, policy) self.assertEquals( @@ -351,10 +335,8 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex 'since_version': '8', 'until_version': '', }], - 'annotations': { - 'features': {'dynamic_refresh': 0}, - 'example_value': False - } + 'features': {'dynamic_refresh': 0}, + 'example_value': False } self.writer.messages['doc_since_version'] = {'text': '...$6...'} self.writer._AddPolicyDetails(self.doc_root, policy) @@ -380,11 +362,11 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex '</dl></root>') def testAddPolicyNote(self): + # TODO(jkummerow): The functionality tested by this test is currently not + # used for anything and will probably soon be removed. # Test if nodes are correctly added to policies. policy = { - 'annotations': { - 'problem_href': 'http://www.example.com/5' - } + 'problem_href': 'http://www.example.com/5' } self.writer.messages['doc_note'] = {'text': '...$6...'} self.writer._AddPolicyNote(self.doc_root, policy) @@ -440,10 +422,8 @@ See <a href="http://policy-explanation.example.com">http://policy-explanation.ex 'since_version': '7', 'until_version': '', }], - 'annotations': { - 'features': {'dynamic_refresh': 0}, - 'example_value': False - } + 'features': {'dynamic_refresh': 0}, + 'example_value': False } self.writer.messages['doc_since_version'] = {'text': '..$6..'} self.writer._AddPolicySection(self.doc_root, policy) diff --git a/tools/grit/grit/format/policy_templates/writers/json_writer.py b/tools/grit/grit/format/policy_templates/writers/json_writer.py index a754305..de7ec27 100644 --- a/tools/grit/grit/format/policy_templates/writers/json_writer.py +++ b/tools/grit/grit/format/policy_templates/writers/json_writer.py @@ -26,7 +26,7 @@ class JsonWriter(template_writer.TemplateWriter): return self.FlattenGroupsAndSortPolicies(policy_list) def WritePolicy(self, policy): - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] if policy['type'] == 'string': example_value_str = '"' + example_value + '"' elif policy['type'] == 'int': diff --git a/tools/grit/grit/format/policy_templates/writers/json_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/json_writer_unittest.py index 0d86634..a3fc3a2 100644 --- a/tools/grit/grit/format/policy_templates/writers/json_writer_unittest.py +++ b/tools/grit/grit/format/policy_templates/writers/json_writer_unittest.py @@ -56,9 +56,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": True' - ' }' + ' "example_value": True' ' },' ' ],' ' "placeholders": [],' @@ -82,9 +80,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": "hello, world!"' - ' }' + ' "example_value": "hello, world!"' ' },' ' ],' ' "placeholders": [],' @@ -108,9 +104,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": 15' - ' }' + ' "example_value": 15' ' },' ' ],' ' "placeholders": [],' @@ -138,9 +132,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' {"name": "ProxyServerAutoDetect", "value": 1, "caption": ""},' ' ],' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": 1' - ' }' + ' "example_value": 1' ' },' ' ],' ' "placeholders": [],' @@ -170,9 +162,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": ""},' ' ],' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": "one"' - ' }' + ' "example_value": "one"' ' },' ' ],' ' "placeholders": [],' @@ -196,9 +186,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": ["foo", "bar"]' - ' }' + ' "example_value": ["foo", "bar"]' ' },' ' ],' ' "placeholders": [],' @@ -223,9 +211,7 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.mac:8-"],' - ' "annotations": {' - ' "example_value": ["a"]' - ' }' + ' "example_value": ["a"]' ' },' ' ],' ' "placeholders": [],' @@ -251,18 +237,14 @@ class JsonWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": ["a", "b"]' - ' }' + ' "example_value": ["a", "b"]' ' },{' ' "name": "Policy2",' ' "type": "string",' ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": "c"' - ' }' + ' "example_value": "c"' ' }],' ' },' ' ],' diff --git a/tools/grit/grit/format/policy_templates/writers/reg_writer.py b/tools/grit/grit/format/policy_templates/writers/reg_writer.py index 4ff5508..dc6a08d 100644 --- a/tools/grit/grit/format/policy_templates/writers/reg_writer.py +++ b/tools/grit/grit/format/policy_templates/writers/reg_writer.py @@ -50,7 +50,7 @@ class RegWriter(template_writer.TemplateWriter): return (is_list, policy['name']) def WritePolicy(self, policy): - example_value = policy['annotations']['example_value'] + example_value = policy['example_value'] if policy['type'] == 'list': self._StartBlock(policy['name']) diff --git a/tools/grit/grit/format/policy_templates/writers/reg_writer_unittest.py b/tools/grit/grit/format/policy_templates/writers/reg_writer_unittest.py index 62d1ac7..58e8226 100644 --- a/tools/grit/grit/format/policy_templates/writers/reg_writer_unittest.py +++ b/tools/grit/grit/format/policy_templates/writers/reg_writer_unittest.py @@ -44,7 +44,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "placeholders": [],' ' "messages": {}' '}') - output = self.GetOutput(grd, 'fr', {'_chromium': '1',}, 'reg', 'en') + output = self.GetOutput(grd, 'fr', {'_chromium': '1', }, 'reg', 'en') expected_output = 'Windows Registry Editor Version 5.00' self.CompareOutputs(output, expected_output) @@ -59,9 +59,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": True' - ' }' + ' "example_value": True' ' },' ' ],' ' "placeholders": [],' @@ -86,9 +84,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": "hello, world! \\\" \\\\"' - ' }' + ' "example_value": "hello, world! \\\" \\\\"' ' },' ' ],' ' "placeholders": [],' @@ -113,9 +109,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": 26' - ' }' + ' "example_value": 26' ' },' ' ],' ' "placeholders": [],' @@ -144,9 +138,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' {"name": "ProxyServerAutoDetect", "value": 1, "caption": ""},' ' ],' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": 1' - ' }' + ' "example_value": 1' ' },' ' ],' ' "placeholders": [],' @@ -177,9 +169,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": ""},' ' ],' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": "two"' - ' }' + ' "example_value": "two"' ' },' ' ],' ' "placeholders": [],' @@ -204,9 +194,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.linux:8-"],' - ' "annotations": {' - ' "example_value": ["foo", "bar"]' - ' }' + ' "example_value": ["foo", "bar"]' ' },' ' ],' ' "placeholders": [],' @@ -232,9 +220,7 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.mac:8-"],' - ' "annotations": {' - ' "example_value": ["a"]' - ' }' + ' "example_value": ["a"]' ' },' ' ],' ' "placeholders": [],' @@ -261,18 +247,14 @@ class RegWriterUnittest(writer_unittest_common.WriterUnittestCommon): ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": ["a", "b"]' - ' }' + ' "example_value": ["a", "b"]' ' },{' ' "name": "Policy2",' ' "type": "string",' ' "caption": "",' ' "desc": "",' ' "supported_on": ["chrome.win:8-"],' - ' "annotations": {' - ' "example_value": "c"' - ' }' + ' "example_value": "c"' ' }],' ' },' ' ],' diff --git a/tools/grit/grit/gather/policy_json.py b/tools/grit/grit/gather/policy_json.py index cd7875f..c4545088 100644 --- a/tools/grit/grit/gather/policy_json.py +++ b/tools/grit/grit/gather/policy_json.py @@ -178,7 +178,7 @@ class PolicyJson(skeleton_gatherer.SkeletonGatherer): else: str_val = item[key] if type(str_val) == types.StringType: - str_val = "'%s'" % str_val + str_val = "'%s'" % self.Escape(str_val) else: str_val = str(str_val) self._AddNontranslateableChunk(str_val + ',\n') diff --git a/tools/grit/grit/gather/policy_json_unittest.py b/tools/grit/grit/gather/policy_json_unittest.py index 3df43a0..f443e43 100644 --- a/tools/grit/grit/gather/policy_json_unittest.py +++ b/tools/grit/grit/gather/policy_json_unittest.py @@ -39,10 +39,8 @@ class PolicyJsonUnittest(unittest.TestCase): " 'name': 'HomepageLocation'," " 'type': 'string'," " 'supported_on': ['chrome.*:8-']," - " 'annotations': {" - " 'features': {'dynamic_refresh': 1}," - " 'example_value': 'http://chromium.org'," - " }," + " 'features': {'dynamic_refresh': 1}," + " 'example_value': 'http://chromium.org'," " 'caption': 'nothing special 1'," " 'desc': 'nothing special 2'," " 'label': 'nothing special 3'," |