increased default export limit to 1000 articles & better term output

This commit is contained in:
Guilhem Fauré 2023-04-24 16:15:11 +02:00
parent 69d713dca5
commit 5c78a896ec
2 changed files with 15 additions and 11 deletions

View File

@ -1 +1 @@
CONFIG = {"outputDir": "output", "nbToExport": 3}
CONFIG = {"outputDir": "output", "maxExportNb": 1000}

View File

@ -3,7 +3,6 @@ import os
import shutil
import sys
# from datetime import date, datetime, time
# Modules
from config import CONFIG
from content import content
@ -29,15 +28,22 @@ if len(sys.argv) > 1:
else:
nbToExport = len(articles)
else:
nbToExport = CONFIG["nbToExport"]
if len(articles) > CONFIG["maxExportNb"]:
nbToExport = CONFIG["maxExportNb"]
else:
nbToExport = len(articles)
print(
f"--- {nbToExport} SPIP articles -> Markdown & YAML files ---\n"
f"--- Export of {nbToExport} SPIP articles to Markdown & YAML files ---\n"
)
exported = 1
# Loop among every articles & export them in Markdown files
for article in articles:
meta = metadata(article)
print(f"{exported}. Exporting {meta.title}")
print(f" in {meta.get_slug()}/index.md")
body = content(article.texte)
articleDir = "{}/{}".format(CONFIG["outputDir"], meta.get_slug())
os.mkdir(articleDir)
@ -51,16 +57,14 @@ for article in articles:
)
)
# End export if no more to export
nbToExport -= 1
print(f"Exported {meta.title}")
print(f" in {meta.get_slug()}/index.md")
if nbToExport <= 0:
if exported > nbToExport:
break
elif nbToExport % 5 == 0:
print(f"--- {nbToExport} articles remaining")
elif exported % 10 == 0:
print(f"\n--- {nbToExport - exported} articles remaining ---\n")
exported += 1
# Close the database connection
db.close()
# Announce the end of the script
print(f"\n--- Finished converting SPIP articles ---")
print(f"\n--- Finished exporting {nbToExport} SPIP articles to md & YAML ---")