🎨 make output directories a config option
This commit is contained in:
parent
955790b788
commit
55483e4897
27 changed files with 8 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
||||||
__pycache__
|
__pycache__
|
||||||
|
config.py
|
||||||
|
|
|
@ -2,17 +2,17 @@ import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
|
from config import *
|
||||||
input_dir = "recipes-md"
|
input_dir = "recipes-md"
|
||||||
output_dir = "recipes-mediawiki"
|
|
||||||
|
|
||||||
os.makedirs(output_dir, exist_ok=True)
|
os.makedirs(OUTDIR_MEDIAWIKI, exist_ok=True)
|
||||||
|
|
||||||
# Process each markdown file in the input directory
|
# Process each markdown file in the input directory
|
||||||
for filename in tqdm(os.listdir(input_dir)):
|
for filename in tqdm(os.listdir(input_dir)):
|
||||||
if filename.endswith(".md"):
|
if filename.endswith(".md"):
|
||||||
input_path = os.path.join(input_dir, filename)
|
input_path = os.path.join(input_dir, filename)
|
||||||
output_filename = os.path.splitext(filename)[0] + ".mediawiki"
|
output_filename = os.path.splitext(filename)[0] + ".mediawiki"
|
||||||
output_path = os.path.join(output_dir, output_filename)
|
output_path = os.path.join(OUTDIR_MEDIAWIKI, output_filename)
|
||||||
|
|
||||||
# Run pandoc command
|
# Run pandoc command
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -14,9 +14,9 @@ site = mwclient.Site(WIKI_HOST, path=WIKI_PATH)
|
||||||
site.login(WIKI_USERNAME, WIKI_PASSWORD)
|
site.login(WIKI_USERNAME, WIKI_PASSWORD)
|
||||||
|
|
||||||
# Process and upload each .mediawiki file
|
# Process and upload each .mediawiki file
|
||||||
for filename in tqdm(os.listdir(DIRECTORY)):
|
for filename in tqdm(os.listdir(OUTDIR_MEDIAWIKI)):
|
||||||
if filename.endswith('.mediawiki'):
|
if filename.endswith('.mediawiki'):
|
||||||
filepath = os.path.join(DIRECTORY, filename)
|
filepath = os.path.join(OUTDIR_MEDIAWIKI, filename)
|
||||||
article_name = WIKI_ARTICLE_PREFIX + filename.replace('.mediawiki', '')
|
article_name = WIKI_ARTICLE_PREFIX + filename.replace('.mediawiki', '')
|
||||||
|
|
||||||
with open(filepath, 'r', encoding='utf-8') as f:
|
with open(filepath, 'r', encoding='utf-8') as f:
|
||||||
|
|
|
@ -6,4 +6,5 @@ WIKI_PASSWORD = 's3cr3t'
|
||||||
WIKI_ARTICLE_PREFIX = 'GPN23:'
|
WIKI_ARTICLE_PREFIX = 'GPN23:'
|
||||||
WIKI_CATEGORY_LIST = ['GPN23', 'Rezepte', 'Gulaschkueche', 'GPN23:Rezepte']
|
WIKI_CATEGORY_LIST = ['GPN23', 'Rezepte', 'Gulaschkueche', 'GPN23:Rezepte']
|
||||||
|
|
||||||
DIRECTORY = 'recipes-mediawiki'
|
OUTDIR = 'out'
|
||||||
|
OUTDIR_MEDIAWIKI = OUTDIR + '/mediawiki'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue