cdms2.database:LDAPSearchResult

LDAPSearchResult.searchPredicate(predicate, tag=None)[source]

Method

searchPredicate(predicate, tag=None)

Description

Refine a search result, with a predicate search.

Arguments

predicate: Function name or lambda function. The function takes a single CDMS object, and returns true (1) if the object satisfies the predicate, 0 if not. tag: Restrict the search to objects in one class.

Returns
SearchResult instance. Entries can be accessed sequentially. For each entry, entry.name is the
name of the entry, entry.attributes is a dictionary of the attributes returned by the search,
entry.getObject() returns the CDMS object associated with the entry:
for entry in result:

print entry.name, entry.attributes[“id”]

Entries can be refined with searchPredicate().
Example
  1. Find all variables on a 73x96 grid

newresult = result.searchPredicate(lambda obj: obj.getGrid().shape==(73,96),”variable”)