def test_genMethods111(): assemble.SETTING_LIB, assemble.SETTING_REG, assemble.SETTING_MAIN = "True", "True", "True" assemble.genMethods() assert ( fileIO.fileToString(assemble.DATA_OUTPUT_FILE + "/src/main/java/com/testAuthor/thisIsA/main.java") == fileIO.fileToString( assemble.DATA_INPUT_FILE + "/src/main/java/com/example/examplemod/main.java").replace( "com.example.examplemod", "com." + assemble.DATA_AUTHOR + "." + assemble.DATA_MODNAME))
def test_genResFiles(): assemble.genResFiles( assemble.DATA_INPUT_FILE + "/src/main/resources/assets/examplemod/models/item/", "secondTestItem") assert (fileIO.fileToString( assemble.DATA_OUTPUT_FILE + "/src/main/resources/assets/thisIsA/models/item/secondTestItem.json" ) == fileIO.fileToString( assemble.DATA_INPUT_FILE + "/src/main/resources/assets/examplemod/models/item/aquamarine.json"). replace("anothergemsmod", assemble.DATA_MODNAME).replace("aquamarine", "secondTestItem"))
def assembleRecipe(recipeType, outRecipe, outResult, outIngredients): craftingRecipe = fileIO.fileToString(RESDIR + recipeType + ".json") craftingRecipe = craftingRecipe.replace( "outRecipe", str(outRecipe[recipeType]).replace("\'", "\""), 1) craftingRecipe = craftingRecipe.replace("outResult", "\"" + outResult + "\"", 1) craftingRecipe = craftingRecipe.replace( "outGroup", "\"" + getNamespacedIngredient(outRecipe["group"]) + "\"", 1) craftingRecipe = craftingRecipe.replace("outCount", str(outRecipe["count"]), 1) ingredientsJson = "" pointer = 65 for index in outIngredients: if (recipeType == "pattern"): ingredientsJson += "\"" + chr( pointer) + "\": { \"item\": \"" + index + "\" }, " if (recipeType == "shapeless"): ingredientsJson += "{ \"item\": \"" + index + "\" }, " pointer += 1 ingredientsJson = ingredientsJson[:-2] craftingRecipe = craftingRecipe.replace("outIngredients", ingredientsJson, 1) fileIO.stringToFile( OUTDIR + stripNamespace(outResult) + "_from_" + stripNamespace(outIngredients[NAME_FROM_INGREDIENT]) + ".json", craftingRecipe)
def genMethods(): print(SETTING_REG) LIB_FILES, REG_FILES, MAIN_FILES = list(), list(), list() if (SETTING_LIB == "True"): LIB_FILES = fileIO.getListOfFiles( DATA_INPUT_FILE + "/src/main/java/com/example/examplemod/lib", False) if (SETTING_REG == "True"): REG_FILES = fileIO.getListOfFiles( DATA_INPUT_FILE + "/src/main/java/com/example/examplemod/registers", False) if (SETTING_MAIN == "True"): MAIN_FILES = fileIO.getListOfFiles( DATA_INPUT_FILE + "/src/main/java/com/example/examplemod", True) ALL_JAVA_FILES = LIB_FILES + REG_FILES + MAIN_FILES for file in ALL_JAVA_FILES: print(file) fileContentsStr = fileIO.fileToString(file) fileContentsStr = fileContentsStr.replace( "com.example.examplemod", "com." + DATA_AUTHOR + "." + DATA_MODNAME) fileIO.stringToFile( file.replace("com/example/examplemod", "com/" + DATA_AUTHOR + "/" + DATA_MODNAME, 1).replace(DATA_INPUT_FILE, DATA_OUTPUT_FILE), fileContentsStr)
def genResFile(file, name): print(file) fileContentsStr = fileIO.fileToString(file.replace(name, "aquamarine", 1)) fileContentsStr = fileContentsStr.replace("aquamarine", name).replace( "anothergemsmod", DATA_MODNAME) fileIO.stringToFile( file.replace("examplemod", DATA_MODNAME, 1).replace(DATA_INPUT_FILE, DATA_OUTPUT_FILE, 1), fileContentsStr)
def test_fileToString(): testString = "this\nis\na\ntest" assert (fileIO.fileToString(THISDIR + "/testFileIO.txt") == testString)
def test_stringToFile(): testString = "this is a test" testFile = THISDIR + "/stringToFile.txt" fileIO.stringToFile(testFile, testString) assert (fileIO.fileToString(testFile) == testString)