Added suggest-book-data command
This commit is contained in:
parent
c614e4b06a
commit
73b4c4f2e2
|
@ -14,13 +14,7 @@ from util import *
|
||||||
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
|
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
|
||||||
encoding = 'utf8'
|
encoding = 'utf8'
|
||||||
|
|
||||||
# midlertidig
|
def google_suggest_book_data(dbconnection, tmp_file=False):
|
||||||
connection = pgdb.connect(database='oysteini_pbb2',
|
|
||||||
user='oysteini_pbb',
|
|
||||||
password='lio5Aide',
|
|
||||||
host='postgres.pvv.ntnu.no');
|
|
||||||
|
|
||||||
def suggest_book(dbconnection, tmp_file=False):
|
|
||||||
service = BookService(source='Programvareverkstedet - Worblehat - 0.1a ')
|
service = BookService(source='Programvareverkstedet - Worblehat - 0.1a ')
|
||||||
action_list = []
|
action_list = []
|
||||||
authors_added = {}
|
authors_added = {}
|
||||||
|
@ -33,7 +27,8 @@ def suggest_book(dbconnection, tmp_file=False):
|
||||||
print("aborted")
|
print("aborted")
|
||||||
break
|
break
|
||||||
elif book_in_db(dbconnection, ISBN):
|
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:
|
else:
|
||||||
# First print a long comment line to separate books
|
# First print a long comment line to separate books
|
||||||
new_book = filler + "Book: " + ISBN.strip() + filler
|
new_book = filler + "Book: " + ISBN.strip() + filler
|
||||||
|
@ -245,6 +240,3 @@ def unescape(s):
|
||||||
if want_unicode:
|
if want_unicode:
|
||||||
es = u""
|
es = u""
|
||||||
return es.join(list)
|
return es.join(list)
|
||||||
|
|
||||||
# remove me
|
|
||||||
suggest_book(connection, tmp_file=True)
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import sys
|
||||||
import getopt
|
import getopt
|
||||||
import pgdb
|
import pgdb
|
||||||
from fileformat import read_actionlist, write_actionlist
|
from fileformat import read_actionlist, write_actionlist
|
||||||
|
from google_interface import google_suggest_book_data
|
||||||
from util import *
|
from util import *
|
||||||
|
|
||||||
# connection = pgdb.connect(database='oysteini_pbb2',
|
# connection = pgdb.connect(database='oysteini_pbb2',
|
||||||
|
@ -343,6 +344,9 @@ def edit(connection, ids):
|
||||||
def map_cmd(connection, shelfname=None, category=None):
|
def map_cmd(connection, shelfname=None, category=None):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def suggest_book_data(connection, tmp_file=False):
|
||||||
|
google_suggest_book_data(connection, tmp_file)
|
||||||
|
|
||||||
commands = { 'show':
|
commands = { 'show':
|
||||||
{ 'args': [('ids', (1,None))],
|
{ 'args': [('ids', (1,None))],
|
||||||
'options': ['commit_format', 'tmp_file'],
|
'options': ['commit_format', 'tmp_file'],
|
||||||
|
@ -377,6 +381,11 @@ commands = { 'show':
|
||||||
{ 'args': [('shelfname', (0,1)), ('category', (0,1))],
|
{ 'args': [('shelfname', (0,1)), ('category', (0,1))],
|
||||||
'options': [],
|
'options': [],
|
||||||
'fun': map_cmd,
|
'fun': map_cmd,
|
||||||
|
'use_db': True },
|
||||||
|
'suggest-book-data':
|
||||||
|
{ 'args': [],
|
||||||
|
'options': ['tmp_file'],
|
||||||
|
'fun': suggest_book_data,
|
||||||
'use_db': True }
|
'use_db': True }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue