begynt på worblehat show, må nå skrive printfunksjoner for forfattere og bøker
This commit is contained in:
parent
72ef23de26
commit
e9e508d1eb
|
@ -11,7 +11,24 @@ import sys
|
||||||
import search
|
import search
|
||||||
|
|
||||||
def show_book_or_person(ids, commit_format=False, tmp_file=False):
|
def show_book_or_person(ids, commit_format=False, tmp_file=False):
|
||||||
|
for id in ids:
|
||||||
|
object = get_book_or_person(id)
|
||||||
|
print object
|
||||||
|
|
||||||
|
def get_book_or_person(id):
|
||||||
|
if id.isdigit():
|
||||||
|
return get_in_order([Book,Person],id)
|
||||||
|
else:
|
||||||
|
return get_in_order([Person,Book],id)
|
||||||
|
|
||||||
|
def get_in_order(list, id):
|
||||||
|
for object in list:
|
||||||
|
try:
|
||||||
|
b = object.objects.get(pk=id)
|
||||||
|
return b
|
||||||
|
except object.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
return None
|
||||||
|
|
||||||
def search_book_cmd(search_strings, search_description=False):
|
def search_book_cmd(search_strings, search_description=False):
|
||||||
books = search_book(search_strings, search_description)
|
books = search_book(search_strings, search_description)
|
||||||
|
|
Reference in New Issue