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

Unified Diff: grit/format/resource_map.py

Issue 22739002: Make grit resource maps work also for strings (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: Add unittest for string resource maps Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | grit/format/resource_map_unittest.py » ('j') | grit/format/resource_map_unittest.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/format/resource_map.py
diff --git a/grit/format/resource_map.py b/grit/format/resource_map.py
index 90370aa20eb09b0e894294172cadd90a824a6575..b5a7b453855ab5e57c210fb0628f7574c65936da 100644
--- a/grit/format/resource_map.py
+++ b/grit/format/resource_map.py
@@ -104,17 +104,23 @@ const size_t %(map_name)sSize = arraysize(%(map_name)s);
def _FormatSource(get_key, root, lang, output_dir):
from grit.format import rc_header
- from grit.node import include, structure
+ from grit.node import include, structure, message
yield _FormatSourceHeader(root)
tids = rc_header.GetIds(root)
seen = set()
+ active_descendants = [item for item in root.ActiveDescendants()]
for item in root:
- if isinstance(item, (include.IncludeNode, structure.StructureNode)):
+ 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)
- yield ' {"%s", %s},\n' % (key, tid)
+ # For messages, only include the active ones
+ if not isinstance(item, message.MessageNode) \
+ or item in active_descendants:
+ yield ' {"%s", %s},\n' % (key, tid)
yield _FormatSourceFooter(root)
« no previous file with comments | « no previous file | grit/format/resource_map_unittest.py » ('j') | grit/format/resource_map_unittest.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698