diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/librarian b/librarian index 7f0f8ca..7758d45 100755 --- a/librarian +++ b/librarian @@ -32,7 +32,7 @@ def menutest(s, l): w = curses.newwin(15,40,(rows-10)//2, (cols-40)//2) menu(w, l) - + curses.curs_set(1) # item is a list of (string, callable) tuples @@ -157,7 +157,7 @@ def return_menu(): def catMenu(): (my,mx)=stdscr.getmaxyx() w=curses.newwin(3,5) - cat = browser.categoryBrowser(w,hb, 10,40) + cat = browser.categoryBrowser(w,hb) (r,c) = w.getmaxyx() w.mvwin((my-r)//2 -2, (mx-c)//2) cat.refreshCategories() diff --git a/librarian_tests/test_db_layer.py b/librarian_tests/test_db_layer.py index 50a0302..d74b046 100644 --- a/librarian_tests/test_db_layer.py +++ b/librarian_tests/test_db_layer.py @@ -178,7 +178,7 @@ INSERT INTO book_categories (id, cat_id) VALUES (?, ?), (?, ?), (?, ?), (?, ?); def test_addBook(self): db_layer.addBook({'isbn': 8888888888888, 'title': 'New book'}) - + conn = sqlite3.connect(db_layer.dbFile) with contextlib.closing(conn.cursor()) as c: @@ -186,7 +186,7 @@ INSERT INTO book_categories (id, cat_id) VALUES (?, ?), (?, ?), (?, ?), (?, ?); SELECT title FROM books WHERE isbn = '8888888888888'; ''') rows = list(c) - + self.assertEqual(['New book'], [row[0] for row in rows]) def test_updateBook(self): @@ -200,7 +200,7 @@ SELECT title FROM books WHERE isbn = '8888888888888'; SELECT title FROM books WHERE id = ?; ''', (self.book0_id,)) rows = list(c) - + self.assertEqual(['Attack of the questionable code'], [row[0] for row in rows]) @@ -360,7 +360,7 @@ SELECT deleted FROM books WHERE id = ? OR id = ?; 'My second special category'] self.assertEqual(frozenset(expected_categories), frozenset(row[0] for row in rows)) - + db_layer.addCategory('My third special category') with contextlib.closing(conn.cursor()) as c: diff --git a/library/book_data.py b/library/book_data.py index 6a4f4ca..8c1ee0d 100644 --- a/library/book_data.py +++ b/library/book_data.py @@ -24,7 +24,7 @@ Keys: publish year - int (this kind of thing will have to be confirmed by cataloguer) publish month - int publish location - like publisher - + pages - integer - just the number of pages pagination - string eg. "xviii, 1327-1850" weight - string (purely for interest's sake eg. "3lb." or "3 pounds" @@ -134,4 +134,3 @@ def openLibrary_lccn(LCCN): if "subtitle" in openBook: book["subtitle"]=openBook["subtitle"] return book - diff --git a/library/interface/browser.py b/library/interface/browser.py index 149bcc4..2e521b4 100644 --- a/library/interface/browser.py +++ b/library/interface/browser.py @@ -123,7 +123,7 @@ class browserWindow: self.unHighlight() self.hl = new self.highlight() - + def scroll(self,delta): self.unHighlight() self.topline += delta @@ -262,10 +262,10 @@ class trashBrowser(browserWindow): ('ISBN',0,13), ('Authors',30,None), ('Title',60,None)] - + cs = [(' r', 'restore selected'), (' d', 'delete selected')] - + # redefinable functions def viewSelection(self,book): bookid = book['id'] @@ -327,14 +327,14 @@ class bookBrowser(browserWindow): ('ISBN',0,13), ('Authors',30,None), ('Title',60,None)] - + cs = [(' u', 'update'), (' d', 'delete selected')] - + # redefinable functions def updateSelection(self,book): bookid = book['id'] - + w=curses.newwin(1,1) bf = BookForm(w,self.hb,book, width=self.mx-20) self.centreChild(w) @@ -363,7 +363,7 @@ class bookBrowser(browserWindow): cs.refreshCategories() cs.eventLoop() cs.clear() - + def delSelected(self): books = [] for sel,book in zip(self.selected, self.entries): @@ -551,7 +551,7 @@ class columnSelector(browserWindow): self.w.refresh() ch = self.w.getch() self.hb.refresh() - + def handleInput(self,ch): browserWindow.handleInput(self,ch) return ch diff --git a/library/interface/checkout.py b/library/interface/checkout.py index 59ef6a4..10f6560 100644 --- a/library/interface/checkout.py +++ b/library/interface/checkout.py @@ -95,4 +95,3 @@ def return_procedure(w, hb, cy, cx, mx): step1.clear() if book_id: db.return_book(book_id) - diff --git a/library/interface/form.py b/library/interface/form.py index 839a41b..619f3ae 100644 --- a/library/interface/form.py +++ b/library/interface/form.py @@ -6,7 +6,7 @@ class TextEntry: """A part of a window that handles text entry. Properties: value holds the string that was entered - + Public Methods: set_geom(row,column,width) Sets the geometry in the window set_value(string) Set the value and redraw @@ -53,7 +53,7 @@ class TextEntry: self.cursor = 0 self.start = 0 self.redraw() - + def handle_input(self,ch): if ch==curses.KEY_LEFT: self._mv_cursor(-1) @@ -79,7 +79,7 @@ class TextEntry: # Private functions def _mv_cursor(self,delta): self._set_cursor(self.cursor + delta) - + def _set_cursor(self, new_c): self.cursor = max(0, min(len(self.value), new_c)) self.start = max(0,self.cursor-self.width+1) @@ -109,7 +109,7 @@ class TextEntry: class FormWindow: """General class for a Form Window. - + To use, make the window for it, call the constructor, then call event_loop. """ @@ -270,8 +270,8 @@ class FormWindow: if self.bt==-1: self.entries[self.hl].handle_input(ch) - - + + class BookForm(FormWindow): caption = "Add a Book" @@ -279,13 +279,13 @@ class BookForm(FormWindow): labels = ["ISBN", "LCCN", "Title", "Subtitle", "Authors", "Edition", "Publisher", "Publish Date", "Publish Year", "Publish Month", "Publish location", "Pages", "Pagination", "Weight"] - + # redefineable functions lookup is called when 'enter' is pressed on ISBN # and returns the looked-up book. Default returns nothing def lookup_isbn(self,isbn): return {'isbn':isbn} - + def lookup_lccn(self,lccn): return {'lccn':lccn}