Exemple #1
0
    def digest(self):
        """ Returns true/false depending on if the resource pack can be loaded or not """
        data = CKeyValues.load(self.configPath)
        EnvironmentConfiguration.processData(self, data)

        for key in data:
            if not isinstance(data[key],
                              dict) and key in self.ConfigModifiers.keys():
                entry = self.ConfigModifiers.get(key)
                modifier = entry[0]

                returnedData = modifier.digest(data[key])

                if key == 'author':
                    self.authors.append(returnedData)
                else:
                    setattr(self, entry[1], returnedData)
            elif key != 'environment':
                self.notify.warning('Unexpected key %s was found.' % key)

        if not self.name or not self.version:
            self.notify.warning(
                'Must have a name and a version defined in its descriptor file.'
            )
            return False
        return True
Exemple #2
0
    def open(self, filename = None):
        # if filename is none, this is a new document/map
        if not filename:
            self.__newMap()
            return

        # opening a map from disk, read through the keyvalues and
        # generate the objects
        self.idGenerator.reset()
        root = CKeyValues.load(filename)
        for i in range(root.getNumChildren()):
            self.r_open(root.getChild(i))
        self.unsaved = False
        self.filename = filename
        self.isOpen = True
        self.toolMgr.switchToSelectTool()
        self.updateTabText()