| 1 |
ninoborges |
8 |
"""
|
| 2 |
|
|
|
| 3 |
|
|
ConcordanceCaseLevelQuery
|
| 4 |
|
|
|
| 5 |
|
|
Created by
|
| 6 |
|
|
Emanuel Borges
|
| 7 |
|
|
02.04.10
|
| 8 |
|
|
|
| 9 |
|
|
|
| 10 |
|
|
This program will start at a top level directory (a case) and look for actual concordance databases, skipping notes
|
| 11 |
|
|
and redlines databases. Once finding them, it will query them by the criteria below. At first I'll use this to
|
| 12 |
|
|
find out how many documents are in X tag, across databases, but it could be used for other queries.
|
| 13 |
|
|
|
| 14 |
|
|
|
| 15 |
|
|
"""
|
| 16 |
|
|
|
| 17 |
|
|
from ConcordanceHelperTools import EnumerateConcordanceDatabases
|
| 18 |
|
|
from ConcordanceCOMLib import ConcordanceConnection
|
| 19 |
|
|
import os, NinoGenTools
|
| 20 |
|
|
|
| 21 |
|
|
def QueryByTag(databasePath, tag):
|
| 22 |
|
|
print "Now Processing %s"% databasePath
|
| 23 |
|
|
db = ConcordanceConnection(databasePath)
|
| 24 |
|
|
db.pyQueryByTag(tag)
|
| 25 |
|
|
newCount = db.pyReturnRecordCount()
|
| 26 |
|
|
db.ConcordObj.Close(db.DBHandle)
|
| 27 |
|
|
return newCount
|
| 28 |
|
|
|
| 29 |
|
|
|
| 30 |
|
|
if __name__ == '__main__':
|
| 31 |
|
|
caseDir = r"\\lisdisdss01\ercdis06\E\Data\Concordance\03\039\39323292"
|
| 32 |
|
|
tagNameList = ["Privilege Question"]
|
| 33 |
|
|
#tagNameList = ["Privileged","Privilege"]
|
| 34 |
|
|
productionDatabase = ["\\lisdisdss01\ercdis06\E\Data\Concordance\03\039\39323292\39323292_Davita_Georgia_Production.Dcb"]
|
| 35 |
|
|
countObj = NinoGenTools.Counter(0)
|
| 36 |
|
|
for dirPath, dirNames, fileNames in os.walk(caseDir):
|
| 37 |
|
|
concordanceDatabaseList = EnumerateConcordanceDatabases(dirPath,fileNames)
|
| 38 |
|
|
for databasepath in concordanceDatabaseList:
|
| 39 |
|
|
if databasepath in productionDatabase:
|
| 40 |
|
|
print "%s is a prod db, skipping"% database
|
| 41 |
|
|
else:
|
| 42 |
|
|
for tagName in tagNameList:
|
| 43 |
|
|
results = QueryByTag(os.path.join(dirPath,databasepath), tagName)
|
| 44 |
|
|
countObj.inc(results)
|
| 45 |
|
|
print "There are %d records tagged with the following tags:"% countObj.count
|
| 46 |
|
|
print tagNameList |