Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
spip2pelican
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
groupe-calcul
spip2pelican
Commits
a5ae3de6
Commit
a5ae3de6
authored
7 years ago
by
Matthieu Boileau
Browse files
Options
Downloads
Patches
Plain Diff
Skip articles that belongs to an obsolete rubrique
parent
3d723918
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
spip2pelican.py
+19
-9
19 additions, 9 deletions
spip2pelican.py
with
19 additions
and
9 deletions
spip2pelican.py
+
19
−
9
View file @
a5ae3de6
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment