diff --git a/spip2md/metadata.py b/spip2md/metadata.py index 4338bfc..c1d75de 100644 --- a/spip2md/metadata.py +++ b/spip2md/metadata.py @@ -32,7 +32,7 @@ class metadata: self.microblog = article.microblog # Probably unused def get_slug(self): - return slugify("{}-{}".format(self.id, self.title)) + return slugify(f"{self.id}-{self.title}") def get_frontmatter(self): return "---\n{}---".format( @@ -45,7 +45,8 @@ class metadata: "date": self.publicationDate, "update": self.update, "status": self.status, - } + }, + allow_unicode=True, ) ) diff --git a/spip2md/spip2md.py b/spip2md/spip2md.py index 49009af..1b1285a 100755 --- a/spip2md/spip2md.py +++ b/spip2md/spip2md.py @@ -2,7 +2,7 @@ import os import shutil import sys -from datetime import date, datetime, time +# from datetime import date, datetime, time # Modules from config import CONFIG @@ -27,14 +27,12 @@ if len(sys.argv) > 1: if int(sys.argv[1]) > 0: nbToExport = int(sys.argv[1]) else: - nbToExport = 0 + nbToExport = len(articles) else: nbToExport = CONFIG["nbToExport"] print( - "--- Conversion of {} articles to Markdown files + YAML metadata ---\n".format( - nbToExport - ) + f"--- {nbToExport} SPIP articles -> Markdown & YAML files ---\n" ) # Loop among every articles & export them in Markdown files @@ -54,11 +52,15 @@ 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: break + elif nbToExport % 5 == 0: + print(f"--- {nbToExport} articles remaining") # Close the database connection db.close() # Announce the end of the script -print("\n--- End of script ---") +print(f"\n--- Finished converting SPIP articles ---")