Example #1
0
 def getAgentImportFiles(self):
     """Searches the agents directory for import files """
     filepaths = locateFiles("*.xml", self.objects_directory)
     for filepath in filepaths:
         try:
             xml_file = vfs.VFS.open(filepath)
             root = ElementTree.parse(xml_file).getroot()
             if root.tag == "object":
                 self.agent_import_files[root.attrib["id"]] = filepath
         except SyntaxError as error:
             logging.error("Error parsing file {0}: {1}".format(filepath,
                                                                error))
 def getAgentImportFiles(self):
     """Searches the agents directory for import files """
     files = locateFiles("*.xml", self.agents_directory)
     for xml_file in files:
         xml_file = os.path.relpath(xml_file).replace("\\", "/")
         try:
             root = ElementTree.parse(xml_file).getroot()
             if root.tag == "object":
                 self.agent_import_files[root.attrib["id"]] = xml_file
         except SyntaxError as error:
             assert(isinstance(error, SyntaxError))
             print "Error parsing file " + xml_file + ": " + error.msg
Example #3
0
    def getDialogues(self):
        """Searches the dialogue directory for dialogues """
        files = locateFiles("*.yaml", self.dialogue_directory)
        dialogue_parser = YamlDialogueParser()
        for dialogue_filepath in files:
            # Note Technomage 2010-11-13: the new DialogueEngine uses its own
            #     parser now, YamlDialogueParser.
#            dialogues = yaml.load_all(file(dialogue_file, "r"))
            dialogue_file = vfs.VFS.open(dialogue_filepath)
            try:
                dialogue = dialogue_parser.load(dialogue_file)
            except DialogueFormatError as error:
                logging.error('unable to load dialogue file {0}: {1}'
                              .format(dialogue_filepath, error))
            else:
                self.dialogues[dialogue.npc_name] = dialogue
    def getDialogues(self):
        """Searches the dialogue directory for dialogues """
        files = locateFiles("*.yaml", self.dialogues_directory)
        dialogue_parser = YamlDialogueParser()
        for dialogue_filepath in files:
            dialogue_filepath = os.path.relpath(dialogue_filepath) \
                                .replace("\\", "/")
            # Note Technomage 2010-11-13: the new DialogueEngine uses its own
            #     parser now, YamlDialogueParser.
#            dialogues = yaml.load_all(file(dialogue_file, "r"))
            with file(dialogue_filepath, 'r') as dialogue_file:
                try:
                    dialogue = dialogue_parser.load(dialogue_file)
                except (DialogueFormatError,) as error:
                    logging.error('unable to load dialogue file {0}: {1}'
                                  .format(dialogue_filepath, error))
                else:
                    self.dialogues[dialogue.npc_name] = dialogue