Ejemplo n.º 1
0
def __doProcess(file=None, strdata=None, xmldata=None):
    if xmldata != None:
        m = xmldata
    else:
        # FIXME: validity checking
        try:
            if file != None:
                m = xmlparser.parseFile(file)
            else:
                m = xmlparser.parseString(strdata)
        except xmlparser.ParsingError:
            raise ReaderError(None, "file '%s' is invalid" % file)

    def processNodes(list):
        for e in list:
            if e.name == 'if':
                if evalWeakCondition(e):
                    processNodes(e.children)
            else:
                try:
                    h=HANDLERS[e.name]
                except(KeyError):
                    raise ReaderError(e, "unknown tag '%s'" % e.name)
                h(e)
    
    try:
        processNodes(m.children)
    except ReaderError:
        reraise()
Ejemplo n.º 2
0
def __doProcess(file=None, strdata=None, xmldata=None):
    if xmldata != None:
        m = xmldata
    else:
        # FIXME: validity checking
        try:
            if file != None:
                m = xmlparser.parseFile(file)
            else:
                m = xmlparser.parseString(strdata)
        except xmlparser.ParsingError:
            raise ReaderError(None, "file '%s' is invalid" % file)

    def processNodes(list):
        for e in list:
            if e.name == 'if':
                if evalWeakCondition(e):
                    processNodes(e.children)
            else:
                try:
                    h = HANDLERS[e.name]
                except (KeyError):
                    raise ReaderError(e, "unknown tag '%s'" % e.name)
                h(e)

    try:
        processNodes(m.children)
    except ReaderError:
        reraise()
Ejemplo n.º 3
0
def loadManifestFile(filename):
    """Loads manifest from file 'filename'."""
    manifest = xmlparser.parseFile(filename, xmlparser.NS_FORMATS_MANIFEST)
    if manifest.name != 'bakefile-manifest':
        raise errors.ReaderError(manifest, 'invalid manifest file')
    for fmt in manifest.children:
        if fmt.name != 'format':
            raise errors.ReaderError(fmt, 'invalid manifest file')
        info = FormatInfo()
        info.name = fmt.props['id']        
        for node in fmt.children:
            if node.name == 'description':
                info.desc = node.value
            elif node.name == 'default-filename':
                info.defaultFile = node.value
            else:
                raise errors.ReaderError(node, 'invalid format description')
        if info.name == None or info.desc == None or info.defaultFile == None:
            raise errors.ReaderError(fmt, 'format not fully described')
        formats[info.name] = info
Ejemplo n.º 4
0
def loadManifestFile(filename):
    """Loads manifest from file 'filename'."""
    manifest = xmlparser.parseFile(filename, xmlparser.NS_FORMATS_MANIFEST)
    if manifest.name != 'bakefile-manifest':
        raise errors.ReaderError(manifest, 'invalid manifest file')
    for fmt in manifest.children:
        if fmt.name != 'format':
            raise errors.ReaderError(fmt, 'invalid manifest file')
        info = FormatInfo()
        info.name = fmt.props['id']
        for node in fmt.children:
            if node.name == 'description':
                info.desc = node.value
            elif node.name == 'default-filename':
                info.defaultFile = node.value
            else:
                raise errors.ReaderError(node, 'invalid format description')
        if info.name == None or info.desc == None or info.defaultFile == None:
            raise errors.ReaderError(fmt, 'format not fully described')
        formats[info.name] = info
Ejemplo n.º 5
0
 def _loadFile(filename):
     if verbose:
         print 'loading task description from %s...' % filename
     try:
         root = xmlparser.parseFile(filename, xmlparser.NS_BAKEFILE_GEN)
     except xmlparser.ParsingError:
         raise errors.Error("can't load file '%s'" % filename)
     ret = []
     for cmd in root.children:
         if cmd.name == 'include':
             inc = os.path.join(os.path.dirname(filename), cmd.props['file'])
             if os.path.isfile(inc):
                 r2 = _loadFile(inc)
                 ret += r2.children
             else:
                 if ('ignore_missing' not in cmd.props) or \
                    (cmd.props['ignore_missing'] == '0'):
                        raise ReaderError(cmd, "file '%s' doesn't exist" % inc)
         else:
             ret.append(cmd)
     root.children = ret
     return root
Ejemplo n.º 6
0
 def _loadFile(filename):
     if verbose:
         print 'loading task description from %s...' % filename
     try:
         root = xmlparser.parseFile(filename, xmlparser.NS_BAKEFILE_GEN)
     except xmlparser.ParsingError:
         raise errors.Error("can't load file '%s'" % filename)
     ret = []
     for cmd in root.children:
         if cmd.name == 'include':
             inc = os.path.join(os.path.dirname(filename),
                                cmd.props['file'])
             if os.path.isfile(inc):
                 r2 = _loadFile(inc)
                 ret += r2.children
             else:
                 if ('ignore_missing' not in cmd.props) or \
                    (cmd.props['ignore_missing'] == '0'):
                     raise ReaderError(cmd, "file '%s' doesn't exist" % inc)
         else:
             ret.append(cmd)
     root.children = ret
     return root