diff --git a/cli/google_interface.py b/cli/google_interface.py index a01f612..f4a1625 100644 --- a/cli/google_interface.py +++ b/cli/google_interface.py @@ -14,13 +14,7 @@ from util import * exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q'] encoding = 'utf8' -# midlertidig -connection = pgdb.connect(database='oysteini_pbb2', - user='oysteini_pbb', - password='lio5Aide', - host='postgres.pvv.ntnu.no'); - -def suggest_book(dbconnection, tmp_file=False): +def google_suggest_book_data(dbconnection, tmp_file=False): service = BookService(source='Programvareverkstedet - Worblehat - 0.1a ') action_list = [] authors_added = {} @@ -33,7 +27,8 @@ def suggest_book(dbconnection, tmp_file=False): print("aborted") break elif book_in_db(dbconnection, ISBN): - action_list.append("Book with ISBN: " + str(ISBN) + " is already in DB, skipped") + comment = "Book with ISBN: " + str(ISBN) + " is already in DB, skipped" + action_list.append(comment) else: # First print a long comment line to separate books new_book = filler + "Book: " + ISBN.strip() + filler @@ -245,6 +240,3 @@ def unescape(s): if want_unicode: es = u"" return es.join(list) - -# remove me -suggest_book(connection, tmp_file=True) diff --git a/cli/worblehat.py b/cli/worblehat.py index cb0ef3f..305eaff 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -5,6 +5,7 @@ import sys import getopt import pgdb from fileformat import read_actionlist, write_actionlist +from google_interface import google_suggest_book_data from util import * # connection = pgdb.connect(database='oysteini_pbb2', @@ -343,6 +344,9 @@ def edit(connection, ids): def map_cmd(connection, shelfname=None, category=None): pass +def suggest_book_data(connection, tmp_file=False): + google_suggest_book_data(connection, tmp_file) + commands = { 'show': { 'args': [('ids', (1,None))], 'options': ['commit_format', 'tmp_file'], @@ -377,6 +381,11 @@ commands = { 'show': { 'args': [('shelfname', (0,1)), ('category', (0,1))], 'options': [], 'fun': map_cmd, + 'use_db': True }, + 'suggest-book-data': + { 'args': [], + 'options': ['tmp_file'], + 'fun': suggest_book_data, 'use_db': True } }