update django-allauth
[wolnelektury.git] / scripts / make-xml-zip.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 #
6 import sys
7 sys.path.insert(0, '../apps')
8 sys.path.insert(0, '../lib')
9 sys.path.insert(0, '../lib/librarian')
10 sys.path.insert(0, '..')
11
12 from django.core.management import setup_environ
13 from wolnelektury import settings
14 import sys
15 import zipfile
16
17 setup_environ(settings)
18
19 from catalogue.models import Book
20
21
22 if len(sys.argv) < 2:
23     print "Provide a zip name as first argument"
24     sys.exit(-1)
25
26 zip = zipfile.ZipFile(sys.argv[1], 'w')
27 for book in Book.objects.all():
28     zip.write(book.xml_file.path, "%s.xml" % book.slug)
29 zip.close()
30