def FilterCollection(collection, offset, count=0, filter_value=None):
 if (offset < 0):
  raise ValueError('Offset needs to be greater than or equal to zero')
 if (count < 0):
  raise ValueError('Count needs to be greater than or equal to zero')
 count = (count or sys.maxint)
 if filter_value:
  index = 0
  items = []
  for item in collection.GenerateItems():
   serialized_item = item.SerializeToString()
   if re.search(re.escape(filter_value), serialized_item, re.I):
    if (index >= offset):
     items.append(item)
    index += 1
    if (len(items) >= count):
     break
 else:
  items = list(itertools.islice(collection.GenerateItems(offset), count))
 return items

def FilterCollection ( collection , offset , count = 0 , filter_value = None ) : if ( offset < 0 ) : raise ValueError ( 'Offset needs to be greater than or equal to zero' ) if ( count < 0 ) : raise ValueError ( 'Count needs to be greater than or equal to zero' ) count = ( count or sys . maxint ) if filter_value : index = 0 items = [ ] for item in collection . GenerateItems ( ) : serialized_item = item . SerializeToString ( ) if re . search ( re . escape ( filter_value ) , serialized_item , re . I ) : if ( index >= offset ) : items . append ( item ) index += 1 if ( len ( items ) >= count ) : break else : items = list ( itertools . islice ( collection . GenerateItems ( offset ) , count ) ) return items
filters an aff4 collection .