2011-09-07 09:34:03 +00:00
|
|
|
from django.core.management.base import BaseCommand
|
|
|
|
|
|
|
|
from regluit.core import books
|
|
|
|
|
|
|
|
class Command(BaseCommand):
|
|
|
|
help = "load books based on a text file of ISBNs"
|
|
|
|
args = "<filename>"
|
|
|
|
|
|
|
|
def handle(self, filename, **options):
|
|
|
|
for isbn in open(filename):
|
|
|
|
isbn = isbn.strip()
|
2011-09-09 05:38:28 +00:00
|
|
|
edition = books.add_book(isbn)
|
2011-09-09 18:27:29 +00:00
|
|
|
if edition:
|
|
|
|
print edition
|
|
|
|
else:
|
|
|
|
print "failed to load book for %s" % isbn
|