Projects/worblehat-old
Projects
/
worblehat-old
Archived
12
0
Fork 0
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

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()