| OLD | NEW |
| 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 xml.dom import minidom | 7 from xml.dom import minidom |
| 8 from writers import plist_helper | 8 from writers import plist_helper |
| 9 from writers import xml_formatted_writer | 9 from writers import xml_formatted_writer |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 STRING_TABLE = 'Localizable.strings' | 29 STRING_TABLE = 'Localizable.strings' |
| 30 TYPE_TO_INPUT = { | 30 TYPE_TO_INPUT = { |
| 31 'string': 'string', | 31 'string': 'string', |
| 32 'int': 'integer', | 32 'int': 'integer', |
| 33 'int-enum': 'integer', | 33 'int-enum': 'integer', |
| 34 'string-enum': 'string', | 34 'string-enum': 'string', |
| 35 'string-enum-list': 'array', | 35 'string-enum-list': 'array', |
| 36 'main': 'boolean', | 36 'main': 'boolean', |
| 37 'list': 'array', | 37 'list': 'array', |
| 38 'dict': 'dictionary', | 38 'dict': 'dictionary', |
| 39 'external': 'dictionary', |
| 39 } | 40 } |
| 40 | 41 |
| 41 def _AddKeyValuePair(self, parent, key_string, value_tag): | 42 def _AddKeyValuePair(self, parent, key_string, value_tag): |
| 42 '''Adds a plist key-value pair to a parent XML element. | 43 '''Adds a plist key-value pair to a parent XML element. |
| 43 | 44 |
| 44 A key-value pair in plist consists of two XML elements next two each other: | 45 A key-value pair in plist consists of two XML elements next two each other: |
| 45 <key>key_string</key> | 46 <key>key_string</key> |
| 46 <value_tag>...</value_tag> | 47 <value_tag>...</value_tag> |
| 47 | 48 |
| 48 Args: | 49 Args: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 self.AddElement(array, 'string', {}, 'user') | 95 self.AddElement(array, 'string', {}, 'user') |
| 95 if self.CanBeMandatory(policy): | 96 if self.CanBeMandatory(policy): |
| 96 self.AddElement(array, 'string', {}, 'user-managed') | 97 self.AddElement(array, 'string', {}, 'user-managed') |
| 97 | 98 |
| 98 def PreprocessPolicies(self, policy_list): | 99 def PreprocessPolicies(self, policy_list): |
| 99 return self.FlattenGroupsAndSortPolicies(policy_list) | 100 return self.FlattenGroupsAndSortPolicies(policy_list) |
| 100 | 101 |
| 101 def WritePolicy(self, policy): | 102 def WritePolicy(self, policy): |
| 102 policy_name = policy['name'] | 103 policy_name = policy['name'] |
| 103 policy_type = policy['type'] | 104 policy_type = policy['type'] |
| 104 if policy_type == 'external': | |
| 105 # This type can only be set through cloud policy. | |
| 106 return | |
| 107 | 105 |
| 108 dict = self.AddElement(self._array, 'dict') | 106 dict = self.AddElement(self._array, 'dict') |
| 109 self._AddStringKeyValuePair(dict, 'pfm_name', policy_name) | 107 self._AddStringKeyValuePair(dict, 'pfm_name', policy_name) |
| 110 # Set empty strings for title and description. They will be taken by the | 108 # Set empty strings for title and description. They will be taken by the |
| 111 # OSX Workgroup Manager from the string table in a Localizable.strings file. | 109 # OSX Workgroup Manager from the string table in a Localizable.strings file. |
| 112 # Those files are generated by plist_strings_writer. | 110 # Those files are generated by plist_strings_writer. |
| 113 self._AddStringKeyValuePair(dict, 'pfm_description', '') | 111 self._AddStringKeyValuePair(dict, 'pfm_description', '') |
| 114 self._AddStringKeyValuePair(dict, 'pfm_title', '') | 112 self._AddStringKeyValuePair(dict, 'pfm_title', '') |
| 115 self._AddTargets(dict, policy) | 113 self._AddTargets(dict, policy) |
| 116 self._AddStringKeyValuePair(dict, 'pfm_type', | 114 self._AddStringKeyValuePair(dict, 'pfm_type', |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 '-//Apple//DTD PLIST 1.0//EN', | 150 '-//Apple//DTD PLIST 1.0//EN', |
| 153 'http://www.apple.com/DTDs/PropertyList-1.0.dtd') | 151 'http://www.apple.com/DTDs/PropertyList-1.0.dtd') |
| 154 return dom_impl.createDocument(None, 'plist', doctype) | 152 return dom_impl.createDocument(None, 'plist', doctype) |
| 155 | 153 |
| 156 def Init(self): | 154 def Init(self): |
| 157 self._doc = self.CreatePlistDocument() | 155 self._doc = self.CreatePlistDocument() |
| 158 self._plist = self._doc.documentElement | 156 self._plist = self._doc.documentElement |
| 159 | 157 |
| 160 def GetTemplateText(self): | 158 def GetTemplateText(self): |
| 161 return self.ToPrettyXml(self._doc) | 159 return self.ToPrettyXml(self._doc) |
| OLD | NEW |