From eab7b3e180b32ddfd25db49fc00070cb8084c714 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Mon, 22 May 2017 16:31:17 +0200 Subject: [PATCH 1/1] skip books with isbn metadata --- apps/catalogue/management/commands/insert_isbn.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/catalogue/management/commands/insert_isbn.py b/apps/catalogue/management/commands/insert_isbn.py index e9727daa..7548cb1f 100644 --- a/apps/catalogue/management/commands/insert_isbn.py +++ b/apps/catalogue/management/commands/insert_isbn.py @@ -69,6 +69,7 @@ class Command(BaseCommand): csvfile.close() for slug, isbn_list in isbn_lists.iteritems(): + print 'processing %s' % slug book = Book.objects.get(dc_slug=slug) chunk = book.chunk_set.first() old_head = chunk.head @@ -76,7 +77,8 @@ class Command(BaseCommand): tree = etree.fromstring(src) isbn_node = tree.find('.//' + DCNS("relation.hasFormat")) if isbn_node is not None: - raise Exception('%s already contains ISBN metadata!' % slug) + print '%s already contains ISBN metadata, skipping' % slug + continue desc = tree.find(".//" + RDFNS("Description")) for format, isbn in isbn_list: for template in ISBN_TEMPLATES: -- 2.20.1