Menu

[8f66b6]: / CodeBeagleAutomation.py  Maximize  Restore  History

Download this file

49 lines (34 with data), 2.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
import AppConfig
from tools import FileTools
from fulltextindex import IndexConfiguration, FullTextIndex
# TODO: installations pfad aus _reg_clsid_\PythonCOMPath lesen und als Pfad für config.txt verwenden
# bei installation pythoncom33.dll ins windows verzeichnis kopieren
# als moegliche Server Typen nur inprocess angeben? Oder testen ob es mit der cx_freeze exe funktioniert
class CodeBeagleAutomation:
_public_methods_ = ['search']
_reg_clsid_ = "{DB31CA26-655B-4C5E-BE82-0D5D78A604F7}"
_reg_desc_ = "CodeBeagle COM Automation"
_reg_progid_ = "CodeBeagle.Search"
# indexName = Name of configuration from global or user local config
# The rest of the parameters are similar to the UI parameters.
def search(self, indexName, searchPhrase, filterDirectories, filterExtensions, caseSensitive):
indexName = indexName.lower()
# Switch to application directory to be able to load the configuration even if we are
# executed from a different working directory.
FileTools.switchToAppDir()
conf = AppConfig.appConfig()
indexes = IndexConfiguration.readConfig(conf)
# Build a map from index name to index database for those configuration which actually generate an index
indexMap = dict((conf.indexName.lower(), conf.indexdb) for conf in indexes if conf.isContentIndexed())
if not indexName in indexMap:
return []
query = FullTextIndex.ContentQuery(searchPhrase, filterDirectories, filterExtensions, caseSensitive)
fti = FullTextIndex.FullTextIndex(indexMap[indexName])
return fti.searchContent(query)
if __name__== '__main__':
import win32com.server.register
win32com.server.register.UseCommandLine(CodeBeagleAutomation)
#import pythoncom
#print (pythoncom.CreateGuid())
#o = win32com.client.Dispatch("Python.ComServerTest")
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.