Quote:
Originally Posted by derrell
I do want to be able to use something like impfind --author Ringo and have it spew out a list of titles and paths to all of the files. I'm thinking it would be uesful to search on all the fields execpt the id. Shouldn't be too hard for me to do now that I can extract the info from the files. All that is left is just moving through the directory tree and generating the list on the right key.
|
Look at the first two functions I have written for impserve -- they'll do the job.
Code:
def get_ebook_info(name):
""" get the details of the IMP book as a tuple """
if not isfile(name):
return None
info = [name, getsize(name), getmtime(name)]
f = open(name, 'rb')
if f.read(10) != '\x00\x02BOOKDOUG':
return None
def cString(skip=0):
result = ''
while 1:
data = f.read(1)
if data == '\x00':
if not skip: return result
skip -= 1
result, data = '', ''
result += data
f.read(38)
info += [cString(), cString(), cString(1), cString(2)]
f.close()
return tuple(info)