Example #1
0
 def main(cls, args):
     """ generated source for method main """
     if not args[0].endsWith(".kif") or len(args):
         print "Please enter the path of a .kif file as an argument."
         return
     filename = args[0]
     theGame = Game.createEphemeralGame(Game.preprocessRulesheet(FileUtils.readFileAsString(File(filename))))
     if theGame.getRules() == None or theGame.getRules().size() == 0:
         System.err.println("Problem reading the file " + filename + " or parsing the GDL.")
         return
     try:
         StaticValidator().checkValidity(theGame)
     except ValidatorException as e:
         System.err.println("GDL validation error: " + e.__str__())
         return
     transformedDescription = DeORer.run(theGame.getRules())
     newFilename = filename.substring(0, filename.lastIndexOf(".kif")) + "_DEORED.kif"
     try:
         for gdl in transformedDescription:
             out.write(gdl.__str__())
             out.newLine()
         out.close()
     except IOException as e:
         System.err.println("There was an error writing the translated GDL file " + newFilename + ".")
         e.printStackTrace()
Example #2
0
 def getUncachedGame(self, theKey):
     """ generated source for method getUncachedGame """
     try:
         return Game.createEphemeralGame(Game.preprocessRulesheet(FileUtils.readFileAsString(File("games/test/" + theKey + ".kif"))))
     except Exception as e:
         raise RuntimeException(e)