def mkCompoundFilter(parts):
 transformers = []
 filters = []
 for subfilter in parts:
  try:
   subfilter = list(subfilter)
  except TypeError:
   if hasattr(subfilter, 'getServiceEndpoints'):
    filters.append(subfilter)
   elif hasattr(subfilter, 'fromBasicServiceEndpoint'):
    transformers.append(subfilter.fromBasicServiceEndpoint)
   elif callable(subfilter):
    transformers.append(subfilter)
   else:
    raise filter_type_error
  else:
   filters.append(mkCompoundFilter(subfilter))
 if transformers:
  filters.append(TransformFilterMaker(transformers))
 if (len(filters) == 1):
  return filters[0]
 else:
  return CompoundFilter(filters)

def mkCompoundFilter ( parts ) : transformers = [ ] filters = [ ] for subfilter in parts : try : subfilter = list ( subfilter ) except TypeError : if hasattr ( subfilter , 'getServiceEndpoints' ) : filters . append ( subfilter ) elif hasattr ( subfilter , 'fromBasicServiceEndpoint' ) : transformers . append ( subfilter . fromBasicServiceEndpoint ) elif callable ( subfilter ) : transformers . append ( subfilter ) else : raise filter_type_error else : filters . append ( mkCompoundFilter ( subfilter ) ) if transformers : filters . append ( TransformFilterMaker ( transformers ) ) if ( len ( filters ) == 1 ) : return filters [ 0 ] else : return CompoundFilter ( filters )
create a filter out of a list of filter-like things used by mkfilter .