def _comp_match(item, filter_, scope='collection'):
 filter_length = len(filter_)
 if (scope == 'collection'):
  tag = item.collection.get_meta('tag')
 else:
  for component in item.components():
   if (component.name in ('VTODO', 'VEVENT', 'VJOURNAL')):
    tag = component.name
    break
  else:
   return False
 if (filter_length == 0):
  return (filter_.get('name') == tag)
 else:
  if (filter_length == 1):
   if (filter_[0].tag == _tag('C', 'is-not-defined')):
    return (filter_.get('name') != tag)
  if (filter_[0].tag == _tag('C', 'time-range')):
   if (not _time_range_match(item.item, filter_[0], tag)):
    return False
   filter_ = filter_[1:]
  return all(((_prop_match(item, child) if (child.tag == _tag('C', 'prop-filter')) else _comp_match(item, child, scope='component')) for child in filter_))

def _comp_match ( item , filter_ , scope = 'collection' ) : filter_length = len ( filter_ ) if ( scope == 'collection' ) : tag = item . collection . get_meta ( 'tag' ) else : for component in item . components ( ) : if ( component . name in ( 'VTODO' , 'VEVENT' , 'VJOURNAL' ) ) : tag = component . name break else : return False if ( filter_length == 0 ) : return ( filter_ . get ( 'name' ) == tag ) else : if ( filter_length == 1 ) : if ( filter_ [ 0 ] . tag == _tag ( 'C' , 'is-not-defined' ) ) : return ( filter_ . get ( 'name' ) != tag ) if ( filter_ [ 0 ] . tag == _tag ( 'C' , 'time-range' ) ) : if ( not _time_range_match ( item . item , filter_ [ 0 ] , tag ) ) : return False filter_ = filter_ [ 1 : ] return all ( ( ( _prop_match ( item , child ) if ( child . tag == _tag ( 'C' , 'prop-filter' ) ) else _comp_match ( item , child , scope = 'component' ) ) for child in filter_ ) )
check whether the item matches the comp filter_ .