示例#1
0
 def startElement(self, name, attrs):
     if self.depth:
         self.parent.startElement(name, attrs)
     else:
         if name != 'grit-part':
             raise exception.MissingElement("root tag must be <grit-part>")
         if attrs:
             raise exception.UnexpectedAttribute(
                 "<grit-part> tag must not have attributes")
     self.depth += 1
示例#2
0
文件: structure.py 项目: sz21/WTL-DUI
 def GetLineEnd(self):
   '''Returns the end-of-line character or characters for files output because
   of this node ('\r\n', '\n', or '\r' depending on the 'line_end' attribute).
   '''
   if self.attrs['line_end'] == 'unix':
     return '\n'
   elif self.attrs['line_end'] == 'windows':
     return '\r\n'
   elif self.attrs['line_end'] == 'mac':
     return '\r'
   else:
     raise exception.UnexpectedAttribute(
       "Attribute 'line_end' must be one of 'linux' (default), 'windows' or 'mac'")
示例#3
0
    def HandleAttribute(self, attrib, value):
        '''Informs the node of an attribute that was parsed out of the GRD file
    for it.

    Args:
      attrib: 'name'
      value: 'fooblat'

    Return:
      None
    '''
        assert isinstance(attrib, types.StringTypes)
        assert isinstance(value, types.StringTypes)
        if self._IsValidAttribute(attrib, value):
            self.attrs[attrib] = value
        else:
            raise exception.UnexpectedAttribute(attrib)