From ae8dd0ba023f8c671bf075fb67ed28fe1659db9b Mon Sep 17 00:00:00 2001 From: oysteini Date: Sat, 5 Mar 2011 18:08:14 +0000 Subject: [PATCH] Fjernet duplikatkode. --- python/worblehat.py | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/python/worblehat.py b/python/worblehat.py index 010678d..7884fed 100755 --- a/python/worblehat.py +++ b/python/worblehat.py @@ -31,28 +31,6 @@ def get_in_order(list, id): pass return None -def search_book_cmd(search_strings, search_description=False): - books = search_book(search_strings, search_description) - format = '%-13s %-10s %-40s %-30s' - for book in books: - b_id = book.getid() or '' - title = cut_str(book.title, 40) - authors = map(lambda p: p.first_name+' '+p.last_name, - book.get_authors()) - authors_str = cut_str(', '.join(authors), 30) - print format % (book.isbn, b_id, title, authors_str) - -def search_book(search_strings, search_description=False): - basic_query = Book.objects.select_related('persons__person','id','alt_titles') - for word in search_strings: - basic_query=basic_query.filter(Q(title__icontains=word) | - Q(subtitle__icontains=word) | - Q(alt_titles__alt_title__icontains=word) | - Q(id__id__icontains=word) | - Q(persons__person__first_name__icontains=word) | - Q(persons__person__last_name__icontains=word)) - return remove_duplicates(basic_query.all()) - def remove_duplicates(list): d = {} for i in list: