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'''The <skeleton> element.
7'''
8
9
10from grit.node import base
11
12
13class SkeletonNode(base.Node):
14  '''A <skeleton> element.'''
15
16  # TODO(joi) Support inline skeleton variants as CDATA instead of requiring
17  # a 'file' attribute.
18
19  def MandatoryAttributes(self):
20    return ['expr', 'variant_of_revision', 'file']
21
22  def DefaultAttributes(self):
23    '''If not specified, 'encoding' will actually default to the parent node's
24    encoding.
25    '''
26    return {'encoding' : ''}
27
28  def _ContentType(self):
29    if self.attrs.has_key('file'):
30      return self._CONTENT_TYPE_NONE
31    else:
32      return self._CONTENT_TYPE_CDATA
33
34  def GetEncodingToUse(self):
35    if self.attrs['encoding'] == '':
36      return self.parent.attrs['encoding']
37    else:
38      return self.attrs['encoding']
39
40  def GetInputPath(self):
41    return self.attrs['file']
42
43