Commit 1161dd0d authored by Julian Pastarmov's avatar Julian Pastarmov Committed by Commit Bot

Add owners to the description field of TC exports.

This first change only adds the owners verbatim. This in most cases is
enough but some policies refer to OWNERS file in the code tree. Since
the people involved with translation are not Chromium engineers it will
be beneficial to also dereference OWNERS files to their contents.

BUG=1005850
TEST=grit unit tests

Change-Id: I21630b74ea34af6697b90402566358191a1a717c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1814693Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Commit-Queue: Julian Pastarmov <pastarmovj@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707834}
parent e6c55b35
......@@ -45,6 +45,7 @@ class PolicyTemplatesJsonUnittest(unittest.TestCase):
{
'name': 'MainPolicy',
'type': 'main',
'owners': ['foo@bar.com'],
'schema': {
'properties': {
'default_launch_container': {
......@@ -155,6 +156,7 @@ class PolicyTemplatesJsonUnittest(unittest.TestCase):
"example_value": true,
"features": {"can_be_recommended": true, "dynamic_refresh": true},
"name": "MainPolicy",
"owners": ["foo@bar.com"],
"schema": {
"properties": {
"default_launch_container": {
......
......@@ -164,12 +164,14 @@ class PolicyJson(skeleton_gatherer.SkeletonGatherer):
'arc_support': 'Information about the effect on Android apps'
}
if item_type == 'policy':
return '%s of the policy named %s' % (key_map[key], item['name'])
elif item_type == 'enum_item':
return ('%s of the option named %s in policy %s' %
(key_map[key], item['name'], parent_item['name']))
else:
raise Exception('Unexpected type %s' % item_type)
return ('%s of the policy named %s [owner(s): %s]' %
(key_map[key], item['name'],
','.join(item['owners'] if 'owners' in item else 'unknown')))
if item_type == 'enum_item':
return ('%s of the option named %s in policy %s [owner(s): %s]' %
(key_map[key], item['name'], parent_item['name'],
','.join(parent_item['owners'] if 'owners' in parent_item else 'unknown')))
raise Exception('Unexpected type %s' % item_type)
def _AddSchemaKeys(self, obj, depth):
obj_type = type(obj)
......
......@@ -46,6 +46,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" {"
" 'name': 'HomepageLocation',"
" 'type': 'string',"
" 'owners': ['foo@bar.com'],"
" 'supported_on': ['chrome.*:8-'],"
" 'features': {'dynamic_refresh': 1},"
" 'example_value': 'http://chromium.org',"
......@@ -74,6 +75,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" 'policy_definitions': ["
" {"
" 'name': 'Policy1',"
" 'owners': ['a@b'],"
" 'items': ["
" {"
" 'name': 'Item1',"
......@@ -116,6 +118,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" },"
" },"
" 'caption': 'nothing special',"
" 'owners': ['a@b']"
" },"
" ],"
" 'policy_atomic_group_definitions': [],"
......@@ -132,6 +135,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" 'policy_definitions': ["
" {"
" 'name': 'Policy1',"
" 'owners': ['a@b'],"
" 'validation_schema': {"
" 'type': 'object',"
" 'properties': {"
......@@ -155,6 +159,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" 'policy_definitions': ["
" {"
" 'name': 'Policy1',"
" 'owners': ['a@b'],"
" 'description_schema': {"
" 'type': 'object',"
" 'properties': {"
......@@ -184,6 +189,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" {"
" 'name': 'Policy1',"
" 'caption': 'nothing special',"
" 'owners': ['a@b']"
" }"
" ]"
" }"
......@@ -208,6 +214,7 @@ class PolicyJsonUnittest(unittest.TestCase):
" {"
" 'name': 'Policy1',"
" 'caption': 'nothing special',"
" 'owners': ['a@b']"
" }"
" ],"
" 'policy_atomic_group_definitions': [],"
......@@ -268,7 +275,8 @@ with a newline?''',
"policy_definitions": [
{
"name": "Policy1",
"caption": "Please install\\n<ph name=\\"PRODUCT_NAME\\">$1<ex>Google Chrome</ex></ph>."
"caption": "Please install\\n<ph name=\\"PRODUCT_NAME\\">$1<ex>Google Chrome</ex></ph>.",
"owners": "a@b"
}
],
"policy_atomic_group_definitions": [],
......@@ -293,7 +301,8 @@ with a newline?''',
"policy_definitions": [
{
"name": "Policy1",
"caption": "Please install\\n<ph name=\\"PRODUCT_NAME\\">$1<ex>Google Chrome</ex></ph>."
"caption": "Please install\\n<ph name=\\"PRODUCT_NAME\\">$1<ex>Google Chrome</ex></ph>.",
"owners": "a@b"
}
],
"policy_atomic_group_definitions": [],
......@@ -317,18 +326,21 @@ with a newline?''',
gatherer = policy_json.PolicyJson({})
gatherer.SetDefines({'_google_chrome': True})
self.assertEquals(
gatherer._GetDescription({'name': 'Policy1'}, 'policy', None, 'desc'),
'Description of the policy named Policy1')
gatherer._GetDescription({'name': 'Policy1', 'owners': ['a@b']},
'policy', None, 'desc'),
'Description of the policy named Policy1 [owner(s): a@b]')
self.assertEquals(
gatherer._GetDescription({'name': 'Plcy2'}, 'policy', None, 'caption'),
'Caption of the policy named Plcy2')
gatherer._GetDescription({'name': 'Plcy2', 'owners': ['a@b', 'c@d']},
'policy', None, 'caption'),
'Caption of the policy named Plcy2 [owner(s): a@b,c@d]')
self.assertEquals(
gatherer._GetDescription({'name': 'Plcy3'}, 'policy', None, 'label'),
'Label of the policy named Plcy3')
gatherer._GetDescription({'name': 'Plcy3', 'owners': ['a@b']},
'policy', None, 'label'),
'Label of the policy named Plcy3 [owner(s): a@b]')
self.assertEquals(
gatherer._GetDescription({'name': 'Item'}, 'enum_item',
{'name': 'Policy'}, 'caption'),
'Caption of the option named Item in policy Policy')
{'name': 'Plcy', 'owners': ['a@b']}, 'caption'),
'Caption of the option named Item in policy Plcy [owner(s): a@b]')
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment