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
radiopanik
panikdb
Commits
96d94674
Commit
96d94674
authored
Aug 25, 2013
by
fred
Browse files
also load 'events' rubrique of spip, to create more news
parent
5f1e9840
Changes
1
Hide whitespace changes
Inline
Side-by-side
panikdb/emissions/management/commands/load-from-spip.py
View file @
96d94674
...
...
@@ -108,13 +108,29 @@ class Command(BaseCommand):
emission_rubric_ids
.
append
(
subrubric
.
id_rubrique
)
for
article_xml
in
root
.
iter
(
'spip_articles'
):
if
not
article_xml
.
find
(
'id_rubrique'
).
text
in
emission_rubric_ids
:
if
article_xml
.
find
(
'id_rubrique'
).
text
==
'65'
:
pass
# rubric for events, handle with care
elif
not
article_xml
.
find
(
'id_rubrique'
).
text
in
emission_rubric_ids
:
continue
article
=
Article
()
for
attr
in
(
'id_rubrique'
,
'id_article'
,
'titre'
,
'surtitre'
,
'soustitre'
,
'descriptif'
,
'chapo'
,
'texte'
,
'date_redac'
,
'statut'
):
'date_redac'
,
'statut'
,
'date'
):
setattr
(
article
,
attr
,
article_xml
.
find
(
attr
).
text
)
if
article
.
id_rubrique
==
'65'
:
# this is an event, they get a special handling, to be
# merged with newsitems
if
article
.
statut
not
in
(
'publie'
,
'prop'
):
continue
breve
=
Breve
()
breve
.
id_breve
=
'0%s'
%
article
.
id_article
breve
.
titre
=
article
.
titre
breve
.
texte
=
article
.
texte
breve
.
date_heure
=
article
.
date
breves
[
breve
.
id_breve
]
=
breve
continue
if
article
.
statut
!=
'publie'
:
continue
article
.
mots_cles
=
[]
...
...
@@ -139,14 +155,17 @@ class Command(BaseCommand):
for
spip_url_xml
in
root
.
iter
(
'spip_urls'
):
id_objet
=
spip_url_xml
.
find
(
'id_objet'
).
text
url
=
spip_url_xml
.
find
(
'url'
).
text
if
spip_url_xml
.
find
(
'type'
).
text
==
'article'
and
id_objet
in
articles
:
articles
[
spip_url_xml
.
find
(
'id_objet'
).
text
].
url
=
spip_url_xml
.
find
(
'url'
).
text
articles
[
id_objet
].
url
=
url
elif
spip_url_xml
.
find
(
'type'
).
text
==
'article'
and
(
'0%s'
%
id_objet
)
in
breves
:
breves
[
'0'
+
id_objet
].
url
=
url
elif
spip_url_xml
.
find
(
'type'
).
text
==
'rubrique'
and
id_objet
in
rubrics
:
rubrics
[
spip_url_xml
.
find
(
'id_objet'
).
text
].
url
=
spip_url_xml
.
find
(
'url'
).
text
rubrics
[
id_objet
].
url
=
url
elif
spip_url_xml
.
find
(
'type'
).
text
==
'mot'
and
id_objet
in
keywords
:
keywords
[
spip_url_xml
.
find
(
'id_objet'
).
text
].
url
=
spip_url_xml
.
find
(
'url'
).
text
keywords
[
id_objet
].
url
=
url
elif
spip_url_xml
.
find
(
'type'
).
text
==
'breve'
and
id_objet
in
breves
:
breves
[
spip_url_xml
.
find
(
'id_objet'
).
text
].
url
=
spip_url_xml
.
find
(
'url'
).
text
breves
[
id_objet
].
url
=
url
for
spip_doc_xml
in
root
.
iter
(
'spip_documents'
):
id_document
=
spip_doc_xml
.
find
(
'id_document'
).
text
...
...
Write
Preview
Markdown
is supported
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