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']
+ help = 'Prepare ZIP package with files of given type.'
args = '[%s] output_path.zip' % '|'.join(ftypes)
def handle(self, ftype, path, **options):
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.')
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: