Added suggest-book-data command

This commit is contained in:
Andreas Lindahl Flåten 2011-10-09 15:02:59 +00:00
parent c614e4b06a
commit 73b4c4f2e2
2 changed files with 12 additions and 11 deletions

View File

@ -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)

View File

@ -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 }
}