This repository has been archived on 2024-07-04. You can view files and clone it, but cannot push or open issues or pull requests.
worblehat-old/python/interface.py
almelid b9804b39ee Restrukturert trunk.
Lispkoden ligger nå i trunk/lisp

Lagt til trunk/python, som inneholder interface.py, en 
sped begynnelse på et brukerinterfjas mot bibsys/databasen.

Lagt til modifisert PyZ3950-bibliotek

(\ /)
(O.o)
(> <) Bunny approves these changes.
2010-09-10 21:54:45 +00:00

35 lines
711 B
Python

from xml.dom import minidom
from PyZ3950 import zoom
exit_commands = ['exit', 'abort', 'quit', 'bye', 'eat flaming death', 'q']
class Bibsys():
def __init__(self):
self.conn = zoom.Connection ('z3950.bibsys.no', 2100)
self.conn.databaseName = 'BIBSYS'
self.conn.preferredRecordSyntax = 'XML'
def isbn_search(self, isbn):
query = zoom.Query('CCL', 'ISBN='+isbn)
result = self.conn.search(query)
return result
def close(self):
self.conn.close()
#class Menu():
def get_book_loop():
bib = Bibsys()
while True:
input = raw_input('Enter ISBN number> ')
if input in exit_commands:
break
else:
r = bib.isbn_search(input)
if len(r) > 0:
print r[0]
bib.close()
get_book_loop()