Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
groupe-calcul
spip2pelican
Commits
c960a883
Commit
c960a883
authored
Jun 26, 2018
by
Matthieu Boileau
Browse files
List articles from rubrique id
parent
2461c141
Changes
1
Show whitespace changes
Inline
Side-by-side
spip2pelican.py
View file @
c960a883
...
...
@@ -509,6 +509,14 @@ class Website:
for
pre
,
fill
,
rubrique_node
in
anytree
.
RenderTree
(
self
.
rubrique_nodes
[
'0: root'
]):
print
(
f
"
{
pre
}{
rubrique_node
.
name
}
[
{
rubrique_node
.
count
}
]"
)
def
print_articles
(
self
,
id_rubrique
):
"""Print the rubrique structure as a tree using anytree"""
logger
.
info
(
f
"Spip articles that belong to rubrique
{
id_rubrique
}
:
{
self
.
labels
[
id_rubrique
]
}
"
)
for
article
in
self
.
articles
:
if
article
.
rubrique
==
id_rubrique
and
article
.
type
!=
"rubrique"
:
print
(
f
"-
{
article
.
short_id
}
#
{
article
.
title
}
"
)
def
_build_doc_index
(
self
):
"""Build the index dictionary: {id_doc: file_path}"""
...
...
@@ -589,6 +597,8 @@ def parse_cl_args():
"""Parse command line arguments"""
parser
=
argparse
.
ArgumentParser
(
description
=
"Convert Spip website as YAML data to Pelican format"
)
parser
.
add_argument
(
'-r'
,
'--rubriques'
,
action
=
'store_true'
,
help
=
"Show Spip rubriques structure as a tree"
)
parser
.
add_argument
(
'-a'
,
'--articles'
,
metavar
=
"id_rubrique"
,
nargs
=
1
,
help
=
"List Spip articles corresponding to given rubrique id"
)
parser
.
add_argument
(
'-c'
,
'--convert'
,
action
=
'store_true'
,
default
=
True
,
help
=
"Convert to Pelican"
)
return
parser
.
parse_args
()
...
...
@@ -600,5 +610,7 @@ if __name__ == '__main__':
if
args
.
rubriques
:
# Show only Spip rubrique structure
website
.
print_rubrique_tree
()
elif
args
.
articles
:
website
.
print_articles
(
int
(
args
.
articles
[
0
]))
else
:
website
.
export_to_pelican
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment