X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/d91551345b68c2bc7d96f2098691fab28276d6b8..d69fc5f16ed739c02685e7d695abf6de59c2bf5e:/apps/catalogue/management/commands/pack.py diff --git a/apps/catalogue/management/commands/pack.py b/apps/catalogue/management/commands/pack.py index 80f612ad3..ba06341b8 100755 --- a/apps/catalogue/management/commands/pack.py +++ b/apps/catalogue/management/commands/pack.py @@ -2,9 +2,6 @@ # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later. # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # -import re -import sys -from cPickle import load, dump from optparse import make_option from django.core.management.base import BaseCommand @@ -23,9 +20,8 @@ class Command(BaseCommand): make_option('-e', '--exclude', dest='exclude', metavar='SLUG,...', help='Exclude specific books by slug') ) - help = 'Prepare data for Lesmianator.' - ftypes = ['xml', 'txt', 'html', 'epub', 'pdf'] - args = '[%s] output_path.zip' % '|'.join(ftypes) + help = 'Prepare ZIP package with files of given type.' + args = '[%s] output_path.zip' % '|'.join(Book.formats) def handle(self, ftype, path, **options): self.style = color_style() @@ -34,7 +30,7 @@ class Command(BaseCommand): include = options.get('include') exclude = options.get('exclude') - if ftype in self.ftypes: + if ftype in Book.formats: field = "%s_file" % ftype else: print self.style.ERROR('Unknown file type.') @@ -53,7 +49,7 @@ class Command(BaseCommand): if exclude: books = [book for book in books if book.slug not in exclude.split(',')] - archive = zipfile.ZipFile(path, 'w') + archive = zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED) processed = skipped = 0 for book in books: