Commit 6c75dbff authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Add summary (fix #9)

parent 842037ca
......@@ -24,6 +24,10 @@ ATTACHMENTS_PREFIX = "attachments/spip/"
yaml = YAML(typ='safe')
SKIP_REASON = {"skip_rub": "belonging to a skipped rubrique",
"empty": "empty content",
"unpub": "not published"}
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
......@@ -275,11 +279,11 @@ class Article:
self.title = spip_article['titre']
if self.category == 'skip':
self.skip_reason = "belongs to a skipped rubrique"
self.skip_reason = SKIP_REASON["skip_rub"]
elif not spip_article['texte']:
self.skip_reason = "empty content"
self.skip_reason = SKIP_REASON["empty"]
elif spip_article['statut'] != 'publie':
self.skip_reason = "not published"
self.skip_reason = SKIP_REASON["unpub"]
else:
self.skip_reason = ''
......@@ -340,6 +344,8 @@ summary: {self.summary}
f.write(markdown)
logger.debug(f" --> {export_path}")
return self.skip_reason
def reset_output_directories():
"""Erase existing output files and create empty output directories"""
......@@ -421,8 +427,19 @@ class Website:
def export_to_pelican(self):
"""Loop on Spip articles to convert them into Pelican format"""
processed = []
for article in self.articles:
article.export_to_pelican()
skip_reason = article.export_to_pelican()
processed.append(skip_reason)
logger.info("-------")
logger.info("Summary")
logger.info(f" {len(processed)} processed articles:")
logger.info(f" {processed.count('')} converted articles")
for k in SKIP_REASON:
logger.warning(f" {processed.count(SKIP_REASON[k])} skipped articles because {SKIP_REASON[k]}")
logger.info("-------")
logger.debug("See output in ouput.log")
if __name__ == '__main__':
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment