create output dir if not exist
This commit is contained in:
parent
8b919284f3
commit
a7352f7c9d
1 changed files with 5 additions and 0 deletions
|
@ -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(":")
|
||||
|
||||
|
|
Loading…
Reference in a new issue