-
大小: 77.75MB文件类型: .zip金币: 1下载: 0 次发布日期: 2023-06-21
- 语言: 其他
- 标签: 文件搜索 搜索 DocFetcher 简体中文
资源简介
个人自用,花了几个小时翻译得来。全为精校版的简体中文。谢谢下载~
代码片段和文件信息
#!/usr/bin/env python
# -*- coding: utf-8 -*-
“““
This script sends the given command-line arguments as a query to the running
DocFetcher instance. The results returned by the latter are printed as filename-
filepath pairs on the standard output.
For more advanced processing of the results call the search function below
directly. In principle you can also reuse the code in the search function for
arbitrarily scripting the DocFetcher instance.
By default DocFetcher‘s scripting support is disabled due to security reasons
and must be enabled by setting the variable “PythonApiEnabled“ in the advanced
settings file (program-conf.txt) to “true“.
Running this script requires Py4J (https://www.py4j.org/). DocFetcher already
ships with a Py4J distribution but it only works if the py4j folder is in the
same folder as this script. To script DocFetcher from a different location move
the py4j folder there or install Py4J separately.
Note that only the main DocFetcher program instance supports scripting not the
DocFetcher daemon.
“““
def main():
import sys
if len(sys.argv) <= 1:
print(“No query specified.“)
return
query = “ “.join(sys.argv[1:])
try:
result_docs = search(query 28834)
for doc in result_docs:
print(doc.getFilename() + “\t“ + doc.getPathStr())
except:
print(“ERROR: “ + str(sys.exc_info()[1]))
# string int -> [ResultDocument]
def search(query port):
“““Sends the given query string to the running DocFetcher instance at the
given port and returns a list of result objects.
The result objects provide the following getter methods for accessing their
attributes:
- getAuthors
- getDateStr - e-mail send date
- getFilename
- getLastModifiedStr - last-modified date on files
- getPathStr - file path
- getScore - result score as int
- getSender - e-mail sender
- getSizeInKB - file size as int
- gettitle
- getType
- isEmail - boolean indicating whether result object is e-mail or file
This method will throw an error if communication with the DocFetcher
instance fails.
“““
from py4j.java_gateway import JavaGateway GatewayParameters
from py4j.java_gateway import java_import
gateway = JavaGateway(gateway_parameters=GatewayParameters(port=port))
java_import(gateway.jvm “net.sourceforge.docfetcher.gui.Application“)
application = gateway.jvm.net.sourceforge.docfetcher.gui.Application
indexRegistry = application.getIndexRegistry()
searcher = indexRegistry.getSearcher()
results = searcher.search(query)
return results
if __name__ == “__main__“:
main()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-08-15 08:15 conf\
文件 7362 2018-07-30 15:32 conf\program-conf.txt
文件 2688 2018-08-15 15:48 conf\settings-conf.txt
文件 366089 2018-07-30 15:32 docfetcher-daemon-linux
文件 563621 2018-07-30 15:32 docfetcher-daemon-windows.exe
文件 310 2018-07-30 15:32 DocFetcher-GTK2.sh
文件 291 2018-07-30 15:32 DocFetcher-GTK3.sh
目录 0 2018-08-15 08:15 DocFetcher.app\
目录 0 2018-08-15 08:15 DocFetcher.app\Contents\
文件 902 2018-07-30 15:32 DocFetcher.app\Contents\Info.plist
目录 0 2018-08-15 08:15 DocFetcher.app\Contents\MacOS\
文件 503 2018-07-30 15:32 DocFetcher.app\Contents\MacOS\DocFetcher
目录 0 2018-08-15 08:15 DocFetcher.app\Contents\Resources\
文件 183618 2018-07-30 15:32 DocFetcher.app\Contents\Resources\DocFetcher.icns
文件 39424 2018-07-30 15:32 DocFetcher.exe
目录 0 2018-08-15 08:15 help\
目录 0 2018-08-15 08:15 help\Chinese\
文件 13370 2018-07-30 15:32 help\Chinese\DocFetcher_Manual.html
目录 0 2018-08-15 08:15 help\Chinese\DocFetcher_Manual_files\
文件 167 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\bullet.png
文件 5944 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Indexing_Options.html
文件 3109 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Memory_Limit.html
文件 4245 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Portable_Repositories.html
文件 2900 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Preferences.html
文件 8822 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Query_Syntax.html
文件 5137 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Regular_ex
文件 2022 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Release_Notification.html
文件 1162 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\st
文件 1301 2018-07-30 15:32 help\Chinese\DocFetcher_Manual_files\Watch_Limit.html
目录 0 2018-08-15 08:15 help\English\
文件 15508 2018-07-30 15:32 help\English\DocFetcher_Manual.html
............此处省略222个文件信息
评论
共有 条评论