Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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'] | |
|
flackr
2015/06/19 19:42:13
I'd convert this to a bool at this point to avoid
tdanderson
2015/06/22 23:33:20
Done. Note I added .lower() in next patch set.
| |
| 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 |
| OLD | NEW |