def convert(mapFile): try: mapName = os.path.splitext(os.path.basename(mapFile).lower())[0] print("converting %s (%s)..." % (mapName, mapFile)) fomap.exportMap("data", mapFile, outFile="maps2/" + mapName + ".json", verbose=False) except Exception as e: print("couldn't convert %s: %s" % (mapFile, str(e)))
def export_maps(): # Export MAPs info("Converting map files, please wait while this runs.") if not os.path.exists("maps"): os.mkdir("maps") for mapFile in glob.glob(os.path.join("data", "maps", "*.map")): mapName = os.path.basename(mapFile).lower() outFile = os.path.join("maps", os.path.splitext(mapName)[0] + ".json") try: info("Converting map %s ..." % mapFile) fomap.exportMap("data", mapFile, outFile) except Exception: traceback.print_exc() warn("Error converting map %s (see traceback above). Will continue converting the rest." % mapFile) return True