folderPath = "[default]"
browseFilter = {
'dataType': 'Boolean',
'recursive': True
}
browseResults = system.tag.browse(path=folderPath, filter=browseFilter)
tagPaths = [
str(result['fullPath'])
for result in browseResults
if isinstance(result, dict) and 'fullPath' in result and result.get('tagType') != 'Folder'
]
if tagPaths:
qualifiedValues = system.tag.readBlocking(tagPaths)
trueCount = sum(1 for qv in qualifiedValues if qv.value == True and qv.quality.isGood())
print "Found " + str(trueCount) + " TRUE boolean tags in " + folderPath
This is the alternative to use system.tag.query. You could stop and just do do len(pyResults) but then you’d also get tags with bad quality which depends on if you want to include those.
folderPath = "[default]"
searchPath = folderPath + "/**"
query_obj = {
"condition": {
"properties":{
"op": "And",
"conditions": [
{
"prop": "dataType",
"comp": "Like",
"value": "Boolean"
},
{
"prop": "value",
"comp": "Like",
"value": "True"
},
]
}
},
"returnProperties": [
"value",
"quality"
]
}
results = system.tag.query(query=query_obj)
pyResults = results.getResults()
trueCount = 0
for tag in pyResults:
if 'value' in tag and 'quality' in tag:
isValueTrue = (tag['value'].getValue() == True)
isQualityGood = tag['quality'].isGood()
if isValueTrue and isQualityGood:
trueCount += 1
print "Found " + str(trueCount) + " TRUE boolean tags in " + folderPath