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

Side by Side Diff: components/policy/tools/generate_policy_source.py

Issue 1371073003: Display material design policies grouped by tags. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Extracting PolicyUi + Renaming. Created 5 years, 2 months 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
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 '''python %prog [options] platform chromium_os_flag template 6 '''python %prog [options] platform chromium_os_flag template
7 7
8 platform specifies which platform source is being generated for 8 platform specifies which platform source is being generated for
9 and can be one of (win, mac, linux) 9 and can be one of (win, mac, linux)
10 chromium_os_flag should be 1 if this is a Chromium OS build 10 chromium_os_flag should be 1 if this is a Chromium OS build
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 class RiskTags(object): 802 class RiskTags(object):
803 '''Generates files and strings to translate the parsed risk tags.''' 803 '''Generates files and strings to translate the parsed risk tags.'''
804 804
805 def __init__(self, template_file_contents): 805 def __init__(self, template_file_contents):
806 self.max_tags = None 806 self.max_tags = None
807 self.enum_for_tag = OrderedDict() # Ordered by severity. 807 self.enum_for_tag = OrderedDict() # Ordered by severity.
808 self._ReadRiskTagMetaData(template_file_contents) 808 self._ReadRiskTagMetaData(template_file_contents)
809 809
810 def GenerateEnum(self): 810 def GenerateEnum(self):
811 values = [' ' + self.enum_for_tag[tag] for tag in self.enum_for_tag] 811 values = [' ' + self.enum_for_tag[tag] for tag in self.enum_for_tag]
812 values.append(' RISK_TAG_COUNT')
812 values.append(' RISK_TAG_NONE') 813 values.append(' RISK_TAG_NONE')
813 enum_text = 'enum RiskTag {\n' 814 enum_text = 'enum RiskTag {\n'
814 enum_text +=',\n'.join(values) + '\n};\n' 815 enum_text +=',\n'.join(values) + '\n};\n'
815 return enum_text 816 return enum_text
816 817
817 def GetMaxTags(self): 818 def GetMaxTags(self):
818 return str(self.max_tags) 819 return str(self.max_tags)
819 820
820 def GetValidTags(self): 821 def GetValidTags(self):
821 return [tag for tag in self.enum_for_tag] 822 return [tag for tag in self.enum_for_tag]
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 # _WriteAppRestrictions body 1162 # _WriteAppRestrictions body
1162 f.write('<restrictions xmlns:android="' 1163 f.write('<restrictions xmlns:android="'
1163 'http://schemas.android.com/apk/res/android">\n\n') 1164 'http://schemas.android.com/apk/res/android">\n\n')
1164 for policy in policies: 1165 for policy in policies:
1165 if policy.is_supported and policy.restriction_type != 'invalid': 1166 if policy.is_supported and policy.restriction_type != 'invalid':
1166 WriteAppRestriction(policy) 1167 WriteAppRestriction(policy)
1167 f.write('</restrictions>') 1168 f.write('</restrictions>')
1168 1169
1169 if __name__ == '__main__': 1170 if __name__ == '__main__':
1170 sys.exit(main()) 1171 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698