Ejemplo n.º 1
0
 def getOptions(self, inputfile):
     """Set options based on the input file"""
     self.log.debug('Parsing %s' % inputfile)
     #
     # Get the XML
     try:
         tree = ET.parse(inputfile)
     except Exception, err:
         raise common.ParsingFailed("Could not parse XML file '%s': %s" %
                                    (inputfile, err))
Ejemplo n.º 2
0
 def createBuilders(self):
     """Create the builders"""
     #
     # Go through all the builders
     for builder in self.root.find('builders').findall('builder'):
         self.log.debug('Processing builder "%s"' % builder.attrib['name'])
         module = importlib.import_module(builder.attrib['module'])
         #
         # Create the builder
         try:
             cls = self.resolveName(module, builder.attrib['class'])
             builder_item = cls(builder)
         except Exception, err:
             raise common.ParsingFailed(
                 'Failed when trying to create builder: %s' % err)
         #
         self.builders[builder_item.name] = builder_item
         builder_item.order = len(self.builders)
Ejemplo n.º 3
0
                builder_item.order = len(self.builders)

    def getOptions(self, inputfile):
        """Set options based on the input file"""
        self.log.debug('Parsing %s' % inputfile)
        #
        # Get the XML
        try:
            tree = ET.parse(inputfile)
        except Exception, err:
            raise common.ParsingFailed("Could not parse XML file '%s': %s" %
                                       (inputfile, err))
        root = tree.getroot()
        if root.tag != 'generator':
            raise common.ParsingFailed(
                "Input file '%s' doesn't start with a generator tag" %
                inputfile)
        #
        # Get size
        self.width = common.getInt(root, 'width')
        self.height = common.getInt(root, 'height')
        #
        world_class_name = common.getString(root, 'worldClass')
        world_class = getattr(world, world_class_name)
        self.world = world_class(self.width, self.height)
        #
        return root

    def getSortedBuilders(self):
        """Return a list of the builders in the order they are defined"""
        sorted_builders = self.builders.values()