[Tutor] about indexing program
Thu Apr 10 13:14:25 2003
Abdirizak abdi wrote:
> when I try to run it gives an error which is as follows:
> Shelf.__init__(self, anydbm.open(filename, flag))
> File "C:\Python22\lib\anydbm.py", line 86, in open
> return mod.open(file, flag, mode)
> File "C:\Python22\lib\dbhash.py", line 16, in open
> return bsddb.hashopen(file, flag, mode)
> error: (2, 'No such file or directory')
Well, you've cut out the part of the exception traceback that tells
where exactly this is coming from in the recipe's code, but at a guess,
you're feeding it a filename that doesn't exist. The shelf is trying to
open a file (presumably the index file) but can't find it. This could
conceivably also be caused by running the script from a directory other
than the one in which the previously-created index file is located -- I
haven't looked at it closely enough to determine whether it's allowing
for different directories or not.
> it is also compalaining about this import statement:
> from TextSplitter import TextSplitter
> is there any module for this "TextSplitter" ?
Well, it looks like this TextSplitter is not actually used anywhere
within this recipe. How odd. My guess here is that the recipe's author
cut this code out of an existing module of his, and forgot to remove
this line. I bet that you can delete this line without any problems.
> I am runing the program by passing to it an XML file as argument.
Ah -- look at the usage notes in the script.
"xmlIndexer -c filename "
" to create an index of all xml files in current directory in 'filename'"
"xmlIndexer -f filename -s searchPattern"
" to search the current index 'filename' for 'searchPattern'"
You wouldn't ever need to pass this an XML file. When you're creating an
index, you pass it a filename (presumably nonexistent) to use for the
index file, and it will build an index of all the XML files in your
current directory. When you're trying to access that index, you pass it
the name of that same index file. That index file is a special shelve,
not an XML file