Skip to content

Instantly share code, notes, and snippets.

@c99koder
Last active December 10, 2020 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c99koder/9b4c2031d956e3875b30a2b3a611ab75 to your computer and use it in GitHub Desktop.
Save c99koder/9b4c2031d956e3875b30a2b3a611ab75 to your computer and use it in GitHub Desktop.
Convert recipes exported from SousChef in VRECIPE format to Meal-Master format so they can be imported into Paprika
import vobject
out = open("SousChef.mmf", "w")
def write_recipe(recipe):
out.write("MMMMM-----Meal-Master recipe exported from SousChef-----\n")
out.write(" Title: " + recipe.contents['name'][0].value + "\n")
category = recipe.contents['category'][0].value;
if(category == "(null)"):
category = ""
out.write(" Categories: " + category + "\n")
servings = recipe.contents['yield'][0].value;
if(servings == "(null)"):
servings = ""
out.write(" Servings: " + servings + "\n")
out.write("\n")
lines = [None] * 100
for line in recipe.contents['ing']:
s = line.value.split(";")
lines[int(s[0].split(":")[0])] = s[4]
for line in lines:
if(line != None):
out.write(" " + line + "\n")
out.write("\n")
lines = [None] * 100
for line in recipe.contents['dir']:
s = line.value.split(":")
lines[int(s[0])] = s[1]
for line in lines:
if(line != None):
out.write(line + "\n\n")
out.write("\n")
lines = [None] * 100
for line in recipe.contents['note']:
s = line.value.split(":")
lines[int(s[0])] = s[1]
for line in lines:
if(line != None and line != '(null)'):
out.write("NOTE: " + line + "\n\n")
out.write("\n")
out.write("MMMMM\n\n")
with open(r'recipes.vrc') as source_file:
for vrecipe in vobject.readComponents(source_file):
write_recipe(vrecipe)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment