From 09e2bc414d11c26cb75cc27aae87b9f5f8f2e3fc Mon Sep 17 00:00:00 2001 From: andrfla Date: Sun, 9 Oct 2011 16:13:20 +0000 Subject: [PATCH] Added 'register books' and made a list of book categories --- cli/categories.txt | 26 ++++++++++++++++++++++++++ cli/google_interface.py | 4 ++-- cli/worblehat.py | 17 +++++++++++++++-- 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 cli/categories.txt diff --git a/cli/categories.txt b/cli/categories.txt new file mode 100644 index 0000000..de4053a --- /dev/null +++ b/cli/categories.txt @@ -0,0 +1,26 @@ +Mathematics +Physics +Science +Linux +Unix +BSD +Operating Systems +Networking +X Window System +Algorithms +RTFM +TeX +Computer Graphics +Computer Science +Computer History +Computer Nonsense +Programming +Programming Languages +C/C++ +Java +Lisp +Python +Perl +PVV +Religion +TODO: Comics/fiction diff --git a/cli/google_interface.py b/cli/google_interface.py index f4a1625..28276ef 100644 --- a/cli/google_interface.py +++ b/cli/google_interface.py @@ -19,7 +19,7 @@ def google_suggest_book_data(dbconnection, tmp_file=False): action_list = [] authors_added = {} file_prefix = "suggestion" - filler = ' -------------------------------------------------- ' + filler = ' -------------------------------- ' print("# Enter ISBN number(s), end with eof ") for ISBN in sys.stdin: ISBN = ISBN.strip() @@ -60,7 +60,7 @@ def google_suggest_book_data(dbconnection, tmp_file=False): print("No items found") if tmp_file: - write_tmpfile(file_prefix, write_actionlist(action_list)) + return write_tmpfile(file_prefix, write_actionlist(action_list)) else: print(write_actionlist(action_list)) diff --git a/cli/worblehat.py b/cli/worblehat.py index 5f44318..6058a06 100755 --- a/cli/worblehat.py +++ b/cli/worblehat.py @@ -365,11 +365,19 @@ def map_cmd(connection, shelfname=None, category=None): pass def suggest_book_data(connection, tmp_file=False): - google_suggest_book_data(connection, tmp_file) + return google_suggest_book_data(connection, tmp_file) +<<<<<<< .mine +def register_books(connection): + filename = suggest_book_data(connection, tmp_file=True) + run_editor(filename) + commit(connection, filename) + +======= def give_bananas(): print "Om nom nom... Thanks!" +>>>>>>> .r164 commands = { 'show': { 'args': [('ids', (1,None))], 'options': ['commit_format', 'tmp_file'], @@ -410,11 +418,16 @@ commands = { 'show': 'options': ['tmp_file'], 'fun': suggest_book_data, 'use_db': True }, + 'register-books': + { 'args': [], + 'options': [], + 'fun': register_books, + 'use_db': True }, 'give-bananas': { 'args': [], 'options': [], 'fun': give_bananas, - 'use_db': False }, + 'use_db': False } } flags = { 'commit_format':