Closed GoogleCodeExporter closed 9 years ago
This approach of setting the target platform on the root node earlier seems to
make things work:
Index: grit/grd_reader.py
===================================================================
--- grit/grd_reader.py (revision 140)
+++ grit/grd_reader.py (working copy)
@@ -24,7 +24,8 @@
class GrdContentHandler(xml.sax.handler.ContentHandler):
- def __init__(self, stop_after, debug, dir, defines, tags_to_ignore):
+ def __init__(self, stop_after, debug, dir, defines, tags_to_ignore,
+ target_platform):
# Invariant of data:
# 'root' is the root of the parse tree being created, or None if we haven't
# parsed out any elements.
@@ -39,6 +40,7 @@
self.defines = defines
self.tags_to_ignore = tags_to_ignore or set()
self.ignore_depth = 0
+ self.target_platform = target_platform
def startElement(self, name, attrs):
if self.ignore_depth or name in self.tags_to_ignore:
@@ -61,6 +63,9 @@
else:
assert self.root is None
self.root = node
+ if isinstance(self.root, misc.GritNode):
+ if self.target_platform:
+ self.root.SetTargetPlatform(self.target_platform)
node.StartParsing(name, None)
if self.defines:
node.SetDefines(self.defines)
@@ -175,7 +180,8 @@
dir = util.dirname(filename_or_stream)
handler = GrdContentHandler(stop_after=stop_after, debug=debug, dir=dir,
- defines=defines, tags_to_ignore=tags_to_ignore)
+ defines=defines, tags_to_ignore=tags_to_ignore,
+ target_platform=target_platform)
try:
xml.sax.parse(filename_or_stream, handler)
except StopParsingException:
@@ -195,8 +201,6 @@
handler.root.SetOwnDir(dir)
if isinstance(handler.root, misc.GritNode):
- if target_platform:
- handler.root.SetTargetPlatform(target_platform)
if first_ids_file:
# Make the path to the first_ids_file relative to the grd file,
# unless it begins with GRIT_DIR.
Original comment by thakis@chromium.org
on 26 Dec 2013 at 3:55
Original comment by thakis@chromium.org
on 26 Dec 2013 at 3:58
Original comment by joi@chromium.org
on 27 Dec 2013 at 2:33
Fixed by r141.
Original comment by joi@chromium.org
on 27 Dec 2013 at 2:42
Original issue reported on code.google.com by
thakis@chromium.org
on 26 Dec 2013 at 3:35