Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0

Endret litt på show-kommandoen.

This commit is contained in:
Øystein Ingmar Skartsæterhagen 2011-03-06 12:21:50 +00:00
parent 392870af5a
commit df5c6c5a88
1 changed files with 19 additions and 5 deletions

View File

@ -4,20 +4,34 @@
import os
os.environ['DJANGO_SETTINGS_MODULE']='web.settings'
from web.library.models import *
from web.library.fileformat import read_actionlist, write_actionlist
from django.db.models import Q
from util import *
import getopt
import sys
import types
import search
import placement
def show_book_or_person(ids, commit_format=False, tmp_file=False):
for id in ids:
object = get_book_or_person(id)
if object:
print object.to_string()
objects = map(get_book_or_person, ids)
for i in range(len(ids)):
if not objects[i]:
objects[i] = 'No book or person with id %s.' % id
elif commit_format:
objects[i] = objects[i].to_dict()
else:
print 'No book or person with id %s.' % id
objects[i] = objects[i].to_string()
if commit_format:
output = write_actionlist(objects)
else:
output = '\n'.join(objects)
if tmp_file:
# TODO
#return write_tmpfile('-'.join(ids), output)
pass
else:
print output
def get_book_or_person(id):
books = Book.objects.filter(Q(isbn=id)|Q(id__id=id)).all()