🎨 make output directories a config option
This commit is contained in:
parent
55483e4897
commit
f89a9683e0
26 changed files with 8 additions and 6 deletions
|
@ -7,8 +7,10 @@ from pathvalidate import validate_filename
|
|||
import os
|
||||
from tqdm import tqdm
|
||||
|
||||
from config import *
|
||||
|
||||
|
||||
include_title = False
|
||||
output_dir = "recipes-md"
|
||||
|
||||
|
||||
def valid_duration(duration):
|
||||
|
@ -114,8 +116,8 @@ def main(json_file):
|
|||
markdown_fn = f"{recipe.get('name', 'Untitled Recipe')}.md"
|
||||
validate_filename(markdown_fn) # XXX does this check directory traversal?
|
||||
markdown = format_recipe_to_markdown(recipe)
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
with open(os.path.join(output_dir, markdown_fn), "w") as f:
|
||||
os.makedirs(OUTDIR_MARKDOWN, exist_ok=True)
|
||||
with open(os.path.join(OUTDIR_MARKDOWN, markdown_fn), "w") as f:
|
||||
f.write(markdown)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
@ -3,14 +3,13 @@ import subprocess
|
|||
from tqdm import tqdm
|
||||
|
||||
from config import *
|
||||
input_dir = "recipes-md"
|
||||
|
||||
os.makedirs(OUTDIR_MEDIAWIKI, exist_ok=True)
|
||||
|
||||
# Process each markdown file in the input directory
|
||||
for filename in tqdm(os.listdir(input_dir)):
|
||||
for filename in tqdm(os.listdir(OUTDIR_MARKDOWN)):
|
||||
if filename.endswith(".md"):
|
||||
input_path = os.path.join(input_dir, filename)
|
||||
input_path = os.path.join(OUTDIR_MARKDOWN, filename)
|
||||
output_filename = os.path.splitext(filename)[0] + ".mediawiki"
|
||||
output_path = os.path.join(OUTDIR_MEDIAWIKI, output_filename)
|
||||
|
||||
|
|
|
@ -7,4 +7,5 @@ WIKI_ARTICLE_PREFIX = 'GPN23:'
|
|||
WIKI_CATEGORY_LIST = ['GPN23', 'Rezepte', 'Gulaschkueche', 'GPN23:Rezepte']
|
||||
|
||||
OUTDIR = 'out'
|
||||
OUTDIR_MARKDOWN = OUTDIR + '/markdown'
|
||||
OUTDIR_MEDIAWIKI = OUTDIR + '/mediawiki'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue