在 Jython(和 Gephi)中查找
我尝试在 Jython 中使用 Gephi Toolkit,但遇到问题。代码如下:
import sys
sys.path.append('gephi-toolkit.jar')
from org.openide.util import Lookup
import org.gephi.project.api.ProjectController as ProjectController
pc = Lookup.getDefault().lookup(ProjectController)
workspace = pc.newProject()
print "done."
它永远不会到达最后一行。相反,会出现以下错误:
Traceback (most recent call last):
File "standalone.py", line 9, in <module>
workspace = pc.newProject()
AttributeError: 'NoneType' object has no attribute 'newProject'
显然,“Lookup.getDefault().lookup(ProjectController)”返回 None 。谁能告诉我为什么?我发现以下解决方法有效(绕过查找):
...
import org.gephi.project.impl.ProjectControllerImpl as ProjectControllerImpl
pc = ProjectControllerImpl()
workspace = pc.newProject()
我想了解有关此问题的更多信息。谢谢。
I'm trying to use Gephi Toolkit in Jython, but having problems with it. The code is below:
import sys
sys.path.append('gephi-toolkit.jar')
from org.openide.util import Lookup
import org.gephi.project.api.ProjectController as ProjectController
pc = Lookup.getDefault().lookup(ProjectController)
workspace = pc.newProject()
print "done."
It never reaches the last line. Instead gives the following error:
Traceback (most recent call last):
File "standalone.py", line 9, in <module>
workspace = pc.newProject()
AttributeError: 'NoneType' object has no attribute 'newProject'
Apparently, "Lookup.getDefault().lookup(ProjectController)" is returning None. Can anyone tell me why? I found that the following workaround works (which bypasses Lookup):
...
import org.gephi.project.impl.ProjectControllerImpl as ProjectControllerImpl
pc = ProjectControllerImpl()
workspace = pc.newProject()
I'd like to know more about this issue. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是因为查找需要引用 java 类,而不是 jython 包装器
尝试这个,看看它是否适合你,至少对我来说它返回 org.gephi.project.impl.ProjectControllerImpl 的实例
您应该看到类似
C 的 内容:\jython2.5.2>jython.bat gephi_test.jy
org.gephi.project.impl.ProjectControllerImpl@8ddb93
i think it's because the lookup needs a reference to the java class, not the jython wrapper
try this and see if it works for you,for me at least it returns an instance of org.gephi.project.impl.ProjectControllerImpl
you should see something like
C:\jython2.5.2>jython.bat gephi_test.jy
org.gephi.project.impl.ProjectControllerImpl@8ddb93