-
-
Save skyjay1/5cd9924271366f1af0862733415fb2e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"type": "nomadictents:tent_size", | |
"pattern": [ | |
"WWW", | |
"WTW"], | |
"key": { | |
"W": { "item": "nomadictents:{type}_section" }, | |
"T": { "item": "nomadictents:{size_from}_{type}" } | |
}, | |
"result": { | |
"item": "nomadictents:{size_to}_{type}", | |
"count": 1 | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
sizes = ["tiny", "small", "medium", "large", "giant", "mega"] | |
tent = "bedouin" | |
if len(sys.argv) > 1: | |
tent = sys.argv[1] | |
with open("recipe_template.json", "r") as tent_template: | |
# read template file | |
tent_template_contents = tent_template.read() | |
# iterate over all size values | |
for i in range(len(sizes) - 1): | |
# determine sizes | |
size_from = sizes[i] | |
size_to = sizes[i + 1] | |
# create recipe output string | |
output = str(tent_template_contents)\ | |
.replace("{size_from}", size_from)\ | |
.replace("{size_to}", size_to)\ | |
.replace("{type}", tent) | |
# create recipe file | |
with open(size_to + "_" + tent + ".json", "w") as f_output: | |
f_output.write(output) | |
f_output.close() | |
# determine number of layers | |
# for now, this the tent size tier + 1 | |
# change this to | |
layer_count = i + 1 | |
for j in range(layer_count): | |
# open template files | |
with open("layer_template" + str(j + 1) + ".json", "r") as layer_template: | |
# read template files | |
layer_template_contents = layer_template.read() | |
# create recipe output string | |
output = str(layer_template_contents)\ | |
.replace("{size}", size_to)\ | |
.replace("{type}", tent) | |
# create recipe file | |
with open(size_to + "_" + tent + "_layer" + str(j + 1) + ".json", "w") as f_output: | |
f_output.write(output) | |
f_output.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment