Commit 3095e2b8 authored by fred's avatar fred

load-from-spip: add possibility to get a report of skipped articles

parent c7425dcb
# -*- coding: utf-8 -*-
from datetime import datetime
import time
import gzip
......@@ -78,6 +80,11 @@ class Command(BaseCommand):
dest='dont_update',
default=False,
help='Only create new objects, do not update existing ones'),
make_option('--stats-skipped',
dest='stats_skipped_file',
metavar='FILE',
default=None,
help='Create a CSV file ith skipped articles'),
make_option('--rewritemap',
dest='rewritemap_file',
metavar='FILE',
......@@ -85,10 +92,14 @@ class Command(BaseCommand):
help='Create a Apache RewriteMap'),
)
def handle(self, filename, dont_update, rewritemap_file, **options):
def handle(self, filename, dont_update, rewritemap_file, stats_skipped_file, **options):
self.do_updates = (not dont_update)
if rewritemap_file:
self.rewritemap = []
if stats_skipped_file:
self.stats_skipped_file = file(stats_skipped_file, 'w')
else:
self.stats_skipped_file = None
with open(filename) as fd:
content = fd.read()
# the spip_courriers parts of the spip export are not properly
......@@ -145,6 +156,9 @@ class Command(BaseCommand):
if rewritemap_file:
self.write_rewritemap(rewritemap_file)
if self.stats_skipped_file:
self.stats_skipped_file.close()
def load_keyword_groups(self):
self.keyword_groups = {}
for keywordgroup_xml in self.root.iter('spip_groupes_mots'):
......@@ -373,6 +387,16 @@ class Command(BaseCommand):
if article.date_redac == '0000-00-00 00:00:00':
# date_redac was used for the diffusion date, if it's
# not set it's probably not really an episode
if self.stats_skipped_file:
episode_files = self.attached_documents.get(article.id_article)
if episode_files:
has_sound = u'♫'
else:
has_sound = '-'
base_spip_edit_url = 'http://www.radiopanik.org/spip/ecrire/?exec=articles_edit&id_article='
print >> self.stats_skipped_file, unicode('%s\t%s\t%s\t%s%s' % (
emission.title, article.titre, has_sound,
base_spip_edit_url, article.id_article)).encode('utf-8')
return None
possible_slugs = [article.url.lower()]
......
Markdown is supported
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