From 469c4a4b41225b6558362a7d31890510be65dee3 Mon Sep 17 00:00:00 2001 From: gombos Date: Sun, 9 Oct 2011 13:18:36 +0000 Subject: [PATCH] added search-description to book search --- cli/google_interface.py | 5 ++--- cli/worblehat.py | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/cli/google_interface.py b/cli/google_interface.py index 7733d3b..45453e8 100644 --- a/cli/google_interface.py +++ b/cli/google_interface.py @@ -29,8 +29,7 @@ def suggest_book(dbconnection, tmp_file=False): authors_added = {} file_prefix = "suggestion" filler = ' -------------------------------------------------- ' - if not tmp_file: - print("# Enter ISBN number(s), end with eof ") + print("# Enter ISBN number(s), end with eof ") for ISBN in sys.stdin: if ISBN.strip() in exit_commands: print("aborted") @@ -292,4 +291,4 @@ def unescape(s): return es.join(list) -suggest_book(connection, tmp_file=False) +suggest_book(connection, tmp_file=True) diff --git a/cli/worblehat.py b/cli/worblehat.py index 5a95e2d..dd0681c 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -263,11 +263,19 @@ def list_cmd(connection, what): def search_book(connection, search_strings, search_description=False): c = connection.cursor() - where_clauses = ['book.title ILIKE %s OR book.subtitle ILIKE %s OR book.series ILIKE %s OR person.lastname ILIKE %s OR person.firstname ILIKE %s']*len(search_strings) + if search_description: + where_clauses = ['book.title ILIKE %s OR book.subtitle ILIKE %s OR book.series ILIKE %s OR person.lastname ILIKE %s OR person.firstname ILIKE %s OR book.description ILIKE %s']*len(search_strings) + else: + where_clauses = ['book.title ILIKE %s OR book.subtitle ILIKE %s OR book.series ILIKE %s OR person.lastname ILIKE %s OR person.firstname ILIKE %s']*len(search_strings) + result_list = [] for s in search_strings: - for i in range(5): - result_list.append(s) + if search_description: + for i in range(6): + result_list.append(s) + else: + for i in range(5): + result_list.append(s) c.execute('SELECT * FROM book LEFT JOIN bookperson ON book.isbn=bookperson.book LEFT JOIN person ON person.id=bookperson.person WHERE ' + ' OR '.join(where_clauses), map(lambda s:'%' + s + '%',result_list)) for i in xrange(c.rowcount): book = fetchone_dict(c)