[pylucene-dev] more test cases

Ofer Nave ofer at smarter.com
Thu Mar 29 23:12:09 PST 2007


Sorry, had a bit of a backlog in my To Do list - was waiting for python 
2.5 so I could eliminate that as a cause before posting.

PyLucene works fine like this:

store = FSDirectory.getDirectory('/tmp/foo', True)

But the Java Lucene 2.1 docs say:

|static FSDirectory <cid:part1.01050404.00080908 at smarter.com>| 
|*getDirectory <cid:part2.02050002.00070209 at smarter.com>*(String 
<http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html> path, 
boolean create)|
          *Deprecated.* /Use IndexWriter's create flag, instead, to 
create a new index.

/So I decided to switch to the alternative signature without the create 
boolean:

|static FSDirectory <cid:part1.01050404.00080908 at smarter.com>| 
|*getDirectory <cid:part4.01060806.08020608 at smarter.com>*(String 
<http://java.sun.com/j2se/1.4/docs/api/java/lang/String.html> path)|
          Returns the directory instance for the named location.

But PyLucene didn't like that:

---
[ofer at rnd01 ~/proj/search/trunk]$ ~/bin/foo.py
PyLucene 2.1.0-1 Lucene 2.1.0-509013
Traceback (most recent call last):
  File "/home/ofer/bin/foo.py", line 14, in <module>
    store = PyLucene.FSDirectory.getDirectory(directory)
PyLucene.InvalidArgsError: (<type 'PyLucene.FSDirectory'>, 
'getDirectory', ('/tmp/foo',))
---

Here's the script:

---
#!/bin/env python2.5
import PyLucene
print 'PyLucene', PyLucene.VERSION, 'Lucene', PyLucene.LUCENE_VERSION
directory = '/tmp/foo'
store = PyLucene.FSDirectory.getDirectory(directory)
#store = PyLucene.FSDirectory.getDirectory(directory, True)
store.close()
---

-ofer

PS-Just checked one last thing - apparently, just importing PyLucene is 
enough to have the process reported as multi-threaded in the STAT column 
of 'ps'.


More information about the pylucene-dev mailing list