From 8b425a26ef6894fc4fa64fff000650e420d523f9 Mon Sep 17 00:00:00 2001 From: jabirali Date: Sat, 5 Mar 2011 22:57:27 +0000 Subject: [PATCH] =?UTF-8?q?Oppdaterte=20placement-funksjonene=20for=20?= =?UTF-8?q?=C3=A5=20utheve=20en=20kategori=20dersom=20to=20argumenter=20bl?= =?UTF-8?q?ir=20gitt=20(hylle=20og=20kategori).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/placement.py | 9 ++++++--- python/worblehat.py | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/python/placement.py b/python/placement.py index 8b03194..282c654 100644 --- a/python/placement.py +++ b/python/placement.py @@ -1,6 +1,6 @@ from web.library.models import Placement -def print_shelf(shelf, title=None): +def print_shelf(shelf, category=None, title=None): # Discover the dimensions of the shelves cols = len(shelf) rows, cell_height, cell_width = 0,0,0 @@ -37,6 +37,9 @@ def print_shelf(shelf, title=None): except: content = "" + + if category and content.upper() == category.upper(): + content = "\x1B[31;1m" + content.upper() + "\x1B[0m" spacing = " "*(cell_width-len(content)) output.append( format_cell %(content, spacing) ) @@ -55,9 +58,9 @@ def print_all_shelves(): print_shelf(Placement.shelf_as_list(shelfname), title=shelfname) -def print_shelf_cmd(shelfname): +def print_shelf_cmd(shelfname, category): if shelfname: - print_shelf(Placement.shelf_as_list(shelfname), title=shelfname) + print_shelf(Placement.shelf_as_list(shelfname), category=category, title=shelfname) else: print_all_shelves() diff --git a/python/worblehat.py b/python/worblehat.py index ccf507c..5bc4694 100755 --- a/python/worblehat.py +++ b/python/worblehat.py @@ -89,7 +89,7 @@ commands = { 'show': 'options': [], 'fun': edit_book_or_person }, 'map': - { 'args': [('shelfname', (0,1))], + { 'args': [('shelfname', (0,1)), ('category', (0,1))], 'options': [], 'fun': placement.print_shelf_cmd } }