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

Side by Side Diff: grit/node/include.py

Issue 1194063002: grit: Add fallback_to_default_layout attribute to <output> (Closed) Base URL: https://chromium.googlesource.com/external/grit-i18n.git@master
Patch Set: proof of concept test Created 5 years, 6 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
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 """Handling of the <include> element. 6 """Handling of the <include> element.
7 """ 7 """
8 8
9 import os 9 import os
10 10
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 # the path to be relative against our basedir. 61 # the path to be relative against our basedir.
62 if self.attrs.get('use_base_dir', 'true') != 'true': 62 if self.attrs.get('use_base_dir', 'true') != 'true':
63 return os.path.relpath(self.attrs['file'], self.GetRoot().GetBaseDir()) 63 return os.path.relpath(self.attrs['file'], self.GetRoot().GetBaseDir())
64 64
65 return self.attrs['file'] 65 return self.attrs['file']
66 66
67 def FileForLanguage(self, lang, output_dir): 67 def FileForLanguage(self, lang, output_dir):
68 """Returns the file for the specified language. This allows us to return 68 """Returns the file for the specified language. This allows us to return
69 different files for different language variants of the include file. 69 different files for different language variants of the include file.
70 """ 70 """
71 return self.ToRealPath(self.GetInputPath()) 71 input_path = self.GetInputPath()
72 if input_path is None:
73 return None
74
75 return self.ToRealPath(input_path)
72 76
73 def GetDataPackPair(self, lang, encoding): 77 def GetDataPackPair(self, lang, encoding):
74 """Returns a (id, string) pair that represents the resource id and raw 78 """Returns a (id, string) pair that represents the resource id and raw
75 bytes of the data. This is used to generate the data pack data file. 79 bytes of the data. This is used to generate the data pack data file.
76 """ 80 """
77 # TODO(benrg/joi): Move this and other implementations of GetDataPackPair 81 # TODO(benrg/joi): Move this and other implementations of GetDataPackPair
78 # to grit.format.data_pack? 82 # to grit.format.data_pack?
79 from grit.format import rc_header 83 from grit.format import rc_header
80 id_map = rc_header.GetIds(self.GetRoot()) 84 id_map = rc_header.GetIds(self.GetRoot())
81 id = id_map[self.GetTextualIds()[0]] 85 id = id_map[self.GetTextualIds()[0]]
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 node.StartParsing('include', parent) 143 node.StartParsing('include', parent)
140 node.HandleAttribute('name', name) 144 node.HandleAttribute('name', name)
141 node.HandleAttribute('type', type) 145 node.HandleAttribute('type', type)
142 node.HandleAttribute('file', file) 146 node.HandleAttribute('file', file)
143 node.HandleAttribute('translateable', translateable) 147 node.HandleAttribute('translateable', translateable)
144 node.HandleAttribute('filenameonly', filenameonly) 148 node.HandleAttribute('filenameonly', filenameonly)
145 node.HandleAttribute('mkoutput', mkoutput) 149 node.HandleAttribute('mkoutput', mkoutput)
146 node.HandleAttribute('relativepath', relativepath) 150 node.HandleAttribute('relativepath', relativepath)
147 node.EndParsing() 151 node.EndParsing()
148 return node 152 return node
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698