create output dir if not exist

This commit is contained in:
PossiblyAxolotl 2024-08-13 12:07:47 -06:00
parent 8b919284f3
commit a7352f7c9d

View file

@ -12,6 +12,10 @@ output_dir = 'output/'
tree = ET.parse(source=dump_file)
root = tree.getroot()
# Create output folder if needed
if not os.path.exists(output_dir):
os.mkdir(output_dir)
# Iterate through the pages and save them
for page in root.findall('./{http://www.mediawiki.org/xml/export-0.11/}page'):
title = page.find('./{http://www.mediawiki.org/xml/export-0.11/}title').text
@ -19,6 +23,7 @@ for page in root.findall('./{http://www.mediawiki.org/xml/export-0.11/}page'):
print(title)
# Check for and process files differently
if ":" in title:
splitName = title.split(":")