Chromium Code Reviews| Index: grit/format/resource_map.py |
| =================================================================== |
| --- grit/format/resource_map.py (revision 171) |
| +++ grit/format/resource_map.py (working copy) |
| @@ -110,17 +110,25 @@ |
| seen = set() |
| active_descendants = [item for item in root.ActiveDescendants()] |
| for item in root: |
| - if isinstance(item, (include.IncludeNode, |
| - structure.StructureNode, |
| - message.MessageNode)): |
| - key = get_key(item) |
| - tid = item.attrs['name'] |
| - if tid in tids and key not in seen: |
| - seen.add(key) |
| - # For messages, only include the active ones |
| - if not isinstance(item, message.MessageNode) \ |
| - or item in active_descendants: |
| - yield ' {"%s", %s},\n' % (key, tid) |
| + if not isinstance(item, (include.IncludeNode, |
| + structure.StructureNode, |
| + message.MessageNode)): |
|
tony
2014/08/06 21:13:31
This code and the isinstance checks below are a li
Lei Zhang
2014/08/06 21:41:08
Done.
|
| + continue |
| + key = get_key(item) |
| + tid = item.attrs['name'] |
| + if tid not in tids or key in seen: |
| + continue |
| + seen.add(key) |
| + should_yield = True |
| + if isinstance(item, message.MessageNode): |
| + # For messages, only include the active ones. |
| + should_yield = item in active_descendants |
| + elif isinstance(item, structure.StructureNode): |
| + # For structures, it depends... |
| + if not root.ShouldOutputAllResourceDefines(): |
| + should_yield = item in active_descendants |
| + if should_yield: |
| + yield ' {"%s", %s},\n' % (key, tid) |
| yield _FormatSourceFooter(root) |