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 import os
os.environ['DJANGO_SETTINGS_MODULE']='web.settings' os.environ['DJANGO_SETTINGS_MODULE']='web.settings'
from web.library.models import * from web.library.models import *
from web.library.fileformat import read_actionlist, write_actionlist
from django.db.models import Q from django.db.models import Q
from util import * from util import *
import getopt import getopt
import sys import sys
import types
import search import search
import placement import placement
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: objects = map(get_book_or_person, ids)
object = get_book_or_person(id) for i in range(len(ids)):
if object: if not objects[i]:
print object.to_string() objects[i] = 'No book or person with id %s.' % id
elif commit_format:
objects[i] = objects[i].to_dict()
else: 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): def get_book_or_person(id):
books = Book.objects.filter(Q(isbn=id)|Q(id__id=id)).all() books = Book.objects.filter(Q(isbn=id)|Q(id__id=id)).all()