1#!/usr/bin/env python 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 4# found in the LICENSE file. 5 6'''Container nodes that don't have any logic. 7''' 8 9 10from grit.node import base 11from grit.node import include 12from grit.node import structure 13from grit.node import message 14from grit.node import io 15from grit.node import misc 16 17 18class 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 'fallback_to_low_resolution' : 'false', 27 } 28 29 30class IncludesNode(GroupingNode): 31 '''The <includes> element.''' 32 def _IsValidChild(self, child): 33 return isinstance(child, (include.IncludeNode, misc.IfNode, misc.PartNode)) 34 35 36class MessagesNode(GroupingNode): 37 '''The <messages> element.''' 38 def _IsValidChild(self, child): 39 return isinstance(child, (message.MessageNode, misc.IfNode, misc.PartNode)) 40 41 42class StructuresNode(GroupingNode): 43 '''The <structures> element.''' 44 def _IsValidChild(self, child): 45 return isinstance(child, (structure.StructureNode, 46 misc.IfNode, misc.PartNode)) 47 48 49class TranslationsNode(base.Node): 50 '''The <translations> element.''' 51 def _IsValidChild(self, child): 52 return isinstance(child, (io.FileNode, misc.IfNode, misc.PartNode)) 53 54 55class OutputsNode(base.Node): 56 '''The <outputs> element.''' 57 def _IsValidChild(self, child): 58 return isinstance(child, (io.OutputNode, misc.IfNode, misc.PartNode)) 59 60 61class IdentifiersNode(GroupingNode): 62 '''The <identifiers> element.''' 63 def _IsValidChild(self, child): 64 return isinstance(child, misc.IdentifierNode) 65