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

Side by Side Diff: grit/node/io.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: for landing 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
« no previous file with comments | « grit/node/include.py ('k') | grit/node/misc.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 <output> and <file> elements. 6 '''The <output> and <file> elements.
7 ''' 7 '''
8 8
9 import os 9 import os
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 '''An <output> element.''' 70 '''An <output> element.'''
71 71
72 def MandatoryAttributes(self): 72 def MandatoryAttributes(self):
73 return ['filename', 'type'] 73 return ['filename', 'type']
74 74
75 def DefaultAttributes(self): 75 def DefaultAttributes(self):
76 return { 76 return {
77 'lang' : '', # empty lang indicates all languages 77 'lang' : '', # empty lang indicates all languages
78 'language_section' : 'neutral', # defines a language neutral section 78 'language_section' : 'neutral', # defines a language neutral section
79 'context' : '', 79 'context' : '',
80 'fallback_to_default_layout' : 'true',
80 } 81 }
81 82
82 def GetType(self): 83 def GetType(self):
83 return self.attrs['type'] 84 return self.attrs['type']
84 85
85 def GetLanguage(self): 86 def GetLanguage(self):
86 '''Returns the language ID, default 'en'.''' 87 '''Returns the language ID, default 'en'.'''
87 return self.attrs['lang'] 88 return self.attrs['lang']
88 89
89 def GetContext(self): 90 def GetContext(self):
90 return self.attrs['context'] 91 return self.attrs['context']
91 92
92 def GetFilename(self): 93 def GetFilename(self):
93 return self.attrs['filename'] 94 return self.attrs['filename']
94 95
95 def GetOutputFilename(self): 96 def GetOutputFilename(self):
96 path = None 97 path = None
97 if hasattr(self, 'output_filename'): 98 if hasattr(self, 'output_filename'):
98 path = self.output_filename 99 path = self.output_filename
99 else: 100 else:
100 path = self.attrs['filename'] 101 path = self.attrs['filename']
101 return os.path.expandvars(path) 102 return os.path.expandvars(path)
102 103
104 def GetFallbackToDefaultLayout(self):
105 return self.attrs['fallback_to_default_layout'].lower() == 'true'
106
103 def _IsValidChild(self, child): 107 def _IsValidChild(self, child):
104 return isinstance(child, EmitNode) 108 return isinstance(child, EmitNode)
105 109
106 class EmitNode(base.ContentNode): 110 class EmitNode(base.ContentNode):
107 ''' An <emit> element.''' 111 ''' An <emit> element.'''
108 112
109 def DefaultAttributes(self): 113 def DefaultAttributes(self):
110 return { 'emit_type' : 'prepend'} 114 return { 'emit_type' : 'prepend'}
111 115
112 def GetEmitType(self): 116 def GetEmitType(self):
113 '''Returns the emit_type for this node. Default is 'append'.''' 117 '''Returns the emit_type for this node. Default is 'append'.'''
114 return self.attrs['emit_type'] 118 return self.attrs['emit_type']
115 119
OLDNEW
« no previous file with comments | « grit/node/include.py ('k') | grit/node/misc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698