OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. |
| 5 |
| 6 '''Container nodes that don't have any logic. |
| 7 ''' |
| 8 |
| 9 |
| 10 from grit.node import base |
| 11 from grit.node import include |
| 12 from grit.node import structure |
| 13 from grit.node import message |
| 14 from grit.node import io |
| 15 from grit.node import misc |
| 16 |
| 17 |
| 18 class GroupingNode(base.Node): |
| 19 '''Base class for all the grouping elements (<structures>, <includes>, |
| 20 <messages> and <identifiers>).''' |
| 21 def DefaultAttributes(self): |
| 22 return { |
| 23 'first_id' : '', |
| 24 'comment' : '', |
| 25 'fallback_to_english' : 'false', |
| 26 } |
| 27 |
| 28 |
| 29 class IncludesNode(GroupingNode): |
| 30 '''The <includes> element.''' |
| 31 def _IsValidChild(self, child): |
| 32 return isinstance(child, (include.IncludeNode, misc.IfNode)) |
| 33 |
| 34 |
| 35 class MessagesNode(GroupingNode): |
| 36 '''The <messages> element.''' |
| 37 def _IsValidChild(self, child): |
| 38 return isinstance(child, (message.MessageNode, misc.IfNode)) |
| 39 |
| 40 def ItemFormatter(self, t): |
| 41 '''Return the stringtable itemformatter if an RC is being formatted.''' |
| 42 if t in ['rc_all', 'rc_translateable', 'rc_nontranslateable']: |
| 43 from grit.format import rc # avoid circular dep by importing here |
| 44 return rc.StringTable() |
| 45 elif t == 'js_map_format': |
| 46 from grit.format import js_map_format |
| 47 return js_map_format.StringTable() |
| 48 |
| 49 |
| 50 class StructuresNode(GroupingNode): |
| 51 '''The <structures> element.''' |
| 52 def _IsValidChild(self, child): |
| 53 return isinstance(child, (structure.StructureNode, misc.IfNode)) |
| 54 |
| 55 |
| 56 class TranslationsNode(base.Node): |
| 57 '''The <translations> element.''' |
| 58 def _IsValidChild(self, child): |
| 59 return isinstance(child, (io.FileNode, misc.IfNode)) |
| 60 |
| 61 |
| 62 class OutputsNode(base.Node): |
| 63 '''The <outputs> element.''' |
| 64 def _IsValidChild(self, child): |
| 65 return isinstance(child, (io.OutputNode, misc.IfNode)) |
| 66 |
| 67 |
| 68 class IdentifiersNode(GroupingNode): |
| 69 '''The <identifiers> element.''' |
| 70 def _IsValidChild(self, child): |
| 71 from grit.node import misc |
| 72 return isinstance(child, misc.IdentifierNode) |
OLD | NEW |