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

Side by Side Diff: grit/format/resource_map.py

Issue 444053003: Respect output_all_resource_defines when generating resource maps. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: refactor Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | grit/format/resource_map_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '''This file contains item formatters for resource_map_header and 6 '''This file contains item formatters for resource_map_header and
7 resource_map_source files. A resource map is a mapping between resource names 7 resource_map_source files. A resource map is a mapping between resource names
8 (string) and the internal resource ID.''' 8 (string) and the internal resource ID.'''
9 9
10 import os 10 import os
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 ''' % { 'map_name': GetMapName(root) } 102 ''' % { 'map_name': GetMapName(root) }
103 103
104 104
105 def _FormatSource(get_key, root, lang, output_dir): 105 def _FormatSource(get_key, root, lang, output_dir):
106 from grit.format import rc_header 106 from grit.format import rc_header
107 from grit.node import include, structure, message 107 from grit.node import include, structure, message
108 yield _FormatSourceHeader(root) 108 yield _FormatSourceHeader(root)
109 tids = rc_header.GetIds(root) 109 tids = rc_header.GetIds(root)
110 seen = set() 110 seen = set()
111 active_descendants = [item for item in root.ActiveDescendants()] 111 active_descendants = [item for item in root.ActiveDescendants()]
112 output_all_resource_defines = root.ShouldOutputAllResourceDefines()
112 for item in root: 113 for item in root:
113 if isinstance(item, (include.IncludeNode, 114 if not item.IsResourceMapSource():
114 structure.StructureNode, 115 continue
115 message.MessageNode)): 116 key = get_key(item)
116 key = get_key(item) 117 tid = item.attrs['name']
117 tid = item.attrs['name'] 118 if tid not in tids or key in seen:
118 if tid in tids and key not in seen: 119 continue
119 seen.add(key) 120 seen.add(key)
120 # For messages, only include the active ones 121 if item.GeneratesResourceMapEntry(output_all_resource_defines,
121 if not isinstance(item, message.MessageNode) \ 122 item in active_descendants):
122 or item in active_descendants: 123 yield ' {"%s", %s},\n' % (key, tid)
123 yield ' {"%s", %s},\n' % (key, tid)
124 yield _FormatSourceFooter(root) 124 yield _FormatSourceFooter(root)
125 125
126 126
127 def _GetItemName(item): 127 def _GetItemName(item):
128 return item.attrs['name'] 128 return item.attrs['name']
129 129
130 130
131 def _GetItemPath(item): 131 def _GetItemPath(item):
132 return item.GetInputPath().replace("\\", "/") 132 return item.GetInputPath().replace("\\", "/")
OLDNEW
« no previous file with comments | « no previous file | grit/format/resource_map_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698