unicode in yaml & better term output
This commit is contained in:
parent
7d6340b7e8
commit
b8e72b2f38
@ -32,7 +32,7 @@ class metadata:
|
|||||||
self.microblog = article.microblog # Probably unused
|
self.microblog = article.microblog # Probably unused
|
||||||
|
|
||||||
def get_slug(self):
|
def get_slug(self):
|
||||||
return slugify("{}-{}".format(self.id, self.title))
|
return slugify(f"{self.id}-{self.title}")
|
||||||
|
|
||||||
def get_frontmatter(self):
|
def get_frontmatter(self):
|
||||||
return "---\n{}---".format(
|
return "---\n{}---".format(
|
||||||
@ -45,7 +45,8 @@ class metadata:
|
|||||||
"date": self.publicationDate,
|
"date": self.publicationDate,
|
||||||
"update": self.update,
|
"update": self.update,
|
||||||
"status": self.status,
|
"status": self.status,
|
||||||
}
|
},
|
||||||
|
allow_unicode=True,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
from datetime import date, datetime, time
|
# from datetime import date, datetime, time
|
||||||
|
|
||||||
# Modules
|
# Modules
|
||||||
from config import CONFIG
|
from config import CONFIG
|
||||||
@ -27,14 +27,12 @@ if len(sys.argv) > 1:
|
|||||||
if int(sys.argv[1]) > 0:
|
if int(sys.argv[1]) > 0:
|
||||||
nbToExport = int(sys.argv[1])
|
nbToExport = int(sys.argv[1])
|
||||||
else:
|
else:
|
||||||
nbToExport = 0
|
nbToExport = len(articles)
|
||||||
else:
|
else:
|
||||||
nbToExport = CONFIG["nbToExport"]
|
nbToExport = CONFIG["nbToExport"]
|
||||||
|
|
||||||
print(
|
print(
|
||||||
"--- Conversion of {} articles to Markdown files + YAML metadata ---\n".format(
|
f"--- {nbToExport} SPIP articles -> Markdown & YAML files ---\n"
|
||||||
nbToExport
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Loop among every articles & export them in Markdown files
|
# Loop among every articles & export them in Markdown files
|
||||||
@ -54,11 +52,15 @@ for article in articles:
|
|||||||
)
|
)
|
||||||
# End export if no more to export
|
# End export if no more to export
|
||||||
nbToExport -= 1
|
nbToExport -= 1
|
||||||
|
print(f"Exported {meta.title}")
|
||||||
|
print(f" in {meta.get_slug()}/index.md")
|
||||||
if nbToExport <= 0:
|
if nbToExport <= 0:
|
||||||
break
|
break
|
||||||
|
elif nbToExport % 5 == 0:
|
||||||
|
print(f"--- {nbToExport} articles remaining")
|
||||||
|
|
||||||
# Close the database connection
|
# Close the database connection
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
# Announce the end of the script
|
# Announce the end of the script
|
||||||
print("\n--- End of script ---")
|
print(f"\n--- Finished converting SPIP articles ---")
|
||||||
|
Loading…
Reference in New Issue
Block a user