Skip to content
Snippets Groups Projects
Commit a5ae3de6 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Skip articles that belongs to an obsolete rubrique

parent 3d723918
Branches
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@ from yaml_cleaner import strip_invalid, remove_date
AUTHORS = "Groupe Calcul"
CATEGORIES = {4: "journees", 39: "formations", 6: "paysage", 10: "paysage", 14: "paysage", 2: "groupe",
CATEGORIES = {4: "journees", 39: "formations", 6: "paysage", 10: "paysage", 14: "paysage", 2: "groupe", 49: "skip",
-1: "spip_divers"}
ATTACHMENTS_PREFIX = "attachments/spip/"
yaml = YAML(typ='safe')
......@@ -21,7 +21,6 @@ yaml = YAML(typ='safe')
# TODO: handle mix of italic and bold : { {{Marc Poinot}} (ONERA)}
# TODO: convert <img…|…> images
# TODO: Remove articles that belong to rubrique 49 ("Formations organisées par les méso-centres")
def header(s):
"""
......@@ -92,6 +91,15 @@ def link(s):
if rub_url:
# [text->rub#]
id_rub = int(rub_url.group(1))
category = categories_table[id_rub]
if category == 'skip':
msg = f" WARNING: link to a skipped rubrique {id_rub}\n"
msg += f" text: {text}\n"
msg += f" url: {url}\n"
msg += " -> nullify URL"
print(msg)
new_url = ""
else:
new_url = os.path.join(f"{categories_table[id_rub]}.html")
else:
# [text->path_to_file]
......@@ -177,7 +185,10 @@ def spip_to_pelican(spip, categories):
This is the content of my super blog post.
"""
if not spip['texte']:
category = categories[spip['id_rubrique']]
if category == 'skip':
skip_reason = "it belongs to a skipped rubrique"
elif not spip['texte']:
skip_reason = "empty content"
elif spip['statut'] != 'publie':
skip_reason = "not published"
......@@ -194,7 +205,6 @@ def spip_to_pelican(spip, categories):
title = spip_to_markdown(spip['titre'])
date = spip['date']
modified = spip['date_modif']
category = categories[spip['id_rubrique']]
tags = []
summary = spip['descriptif']
authors = AUTHORS
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment