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

Side by Side Diff: grit/tool/build.py

Issue 669763002: Apply whitelist file to structure elements. (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: fix indent Created 6 years, 1 month 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
« no previous file with comments | « grit/testdata/whitelist_strings.grd ('k') | grit/tool/build_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 '''The 'grit build' tool along with integration for this tool with the 6 '''The 'grit build' tool along with integration for this tool with the
7 SCons build system. 7 SCons build system.
8 ''' 8 '''
9 9
10 import filecmp 10 import filecmp
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 # The set of names that are whitelisted to actually be included in the 217 # The set of names that are whitelisted to actually be included in the
218 # output. 218 # output.
219 self.whitelist_names = None 219 self.whitelist_names = None
220 220
221 @staticmethod 221 @staticmethod
222 def AddWhitelistTags(start_node, whitelist_names): 222 def AddWhitelistTags(start_node, whitelist_names):
223 # Walk the tree of nodes added attributes for the nodes that shouldn't 223 # Walk the tree of nodes added attributes for the nodes that shouldn't
224 # be written into the target files (skip markers). 224 # be written into the target files (skip markers).
225 from grit.node import include 225 from grit.node import include
226 from grit.node import message 226 from grit.node import message
227 from grit.node import structure
227 for node in start_node: 228 for node in start_node:
228 # Same trick data_pack.py uses to see what nodes actually result in 229 # Same trick data_pack.py uses to see what nodes actually result in
229 # real items. 230 # real items.
230 if (isinstance(node, include.IncludeNode) or 231 if (isinstance(node, include.IncludeNode) or
231 isinstance(node, message.MessageNode)): 232 isinstance(node, message.MessageNode) or
233 isinstance(node, structure.StructureNode)):
232 text_ids = node.GetTextualIds() 234 text_ids = node.GetTextualIds()
233 # Mark the item to be skipped if it wasn't in the whitelist. 235 # Mark the item to be skipped if it wasn't in the whitelist.
234 if text_ids and text_ids[0] not in whitelist_names: 236 if text_ids and text_ids[0] not in whitelist_names:
235 node.SetWhitelistMarkedAsSkip(True) 237 node.SetWhitelistMarkedAsSkip(True)
236 238
237 @staticmethod 239 @staticmethod
238 def ProcessNode(node, output_node, outfile): 240 def ProcessNode(node, output_node, outfile):
239 '''Processes a node in-order, calling its formatter before and after 241 '''Processes a node in-order, calling its formatter before and after
240 recursing to its children. 242 recursing to its children.
241 243
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 self.MakeDirectoriesTo(depfile) 418 self.MakeDirectoriesTo(depfile)
417 outfile = self.fo_create(depfile, 'wb') 419 outfile = self.fo_create(depfile, 'wb')
418 outfile.writelines(depfile_contents) 420 outfile.writelines(depfile_contents)
419 421
420 @staticmethod 422 @staticmethod
421 def MakeDirectoriesTo(file): 423 def MakeDirectoriesTo(file):
422 '''Creates directories necessary to contain |file|.''' 424 '''Creates directories necessary to contain |file|.'''
423 dir = os.path.split(file)[0] 425 dir = os.path.split(file)[0]
424 if not os.path.exists(dir): 426 if not os.path.exists(dir):
425 os.makedirs(dir) 427 os.makedirs(dir)
OLDNEW
« no previous file with comments | « grit/testdata/whitelist_strings.grd ('k') | grit/tool/build_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698